import Http from './http' import Apis from './api' //获取用户信息 export const getCurrentUser = (getCurrentUserSuccess, getCurrentUserFail) => { // const data = { // userVO: { // id: 3, // photo: 'http://www.mooctest.net/assets/img/mooctest.png', // name: '郭超', // roleList: ['区域管理员', '个人用户', '企业用户', '测评机构', '系统管理员'], // mobile: '110', // email: '12345@qq.com', // }, // agency: '', // } // return new Promise((resolve) => { // resolve(data) // }) return Http.get(Apis.USER.GET_CURRENT_USER) // Http.get(Apis.USER.GET_CURRENT_USER).then((res) => { // getCurrentUserSuccess(res) // }).catch((error) => { // getCurrentUserFail(error) // }) } // export const getRolesPermissions = (roleList) => { const roles = { regionManager: 'RegionalManager', individualUser: 'generalUser', enterpriseUser: 'enterpriseUser', agency: 'evaluationAgency', systemAdministrator: 'SystemAdministrator' } const permissions = { isRegionManager: false, isIndividualUser: false, isEnterpriseUser: false, isAgency: false, isSystemAdministrator: false } if (roleList.includes(roles.regionManager)) { permissions.isRegionManager = true permissions.isEnterpriseUser = true permissions.isIndividualUser = true } if (roleList.includes(roles.agency)) { permissions.isAgency = true permissions.isEnterpriseUser = true permissions.isIndividualUser = true } if (roleList.includes(roles.enterpriseUser)) { permissions.isEnterpriseUser = true } if (roleList.includes(roles.individualUser)) { permissions.isIndividualUser = true } if (roleList.includes(roles.systemAdministrator)) { permissions.isSystemAdministrator = true permissions.isRegionManager = true permissions.isAgency = true permissions.isEnterpriseUser = true permissions.isIndividualUser = true } return permissions } export const logout = () => { sessionStorage.removeItem('user') sessionStorage.removeItem('rolesPermissions') return Http.get(Apis.USER.LOGOUT) } //获取当前角色可访问的url export const getAuthUrls = () => { return [ '/', '/home', '/square', '/mine', '/project/create', '/project/:projectId', '/project/:projectId/task/create', '/project/:projectId/task/:taskId', '/project/:projectId/analyse', '/report/create', '/report/:reportId', '/greenChannel/addProject', '/greenChannel/addAgency', '/authentication/individual', '/authentication/enterprise', '/authentication/agency', '/authentication/index' ] //return Http.get(Apis.USER.GET_AUTH_URLS) } //上传个人认证信息 export const uploadIndividualAuthenticationInfo = (userId, userAuthInfo, uploadIndividualAuthenticationInfoSuccess, uploadIndividualAuthenticationInfoFail) => { Http.post(Apis.USER.SUBMIT_INDIVIDUAL_AUTHENTICATION_INFO.replace('{userId}', userId), userAuthInfo).then((res) => { uploadIndividualAuthenticationInfoSuccess(res) }).catch(error => { uploadIndividualAuthenticationInfoFail(error) }) } //上传企业认证信息 export const uploadEnterpriseAuthenticationInfo = (userId, userAuthInfo, uploadEnterpriseAuthenticationInfoSuccess, uploadEnterpriseAuthenticationInfoFail) => { Http.post(Apis.USER.SUBMIT_ENTERPRISE_AUTHENTICATION_INFO.replace('{userId}', userId), userAuthInfo).then((res) => { uploadEnterpriseAuthenticationInfoSuccess(res) }).catch(error => { uploadEnterpriseAuthenticationInfoFail(error) }) } //上传机构认证信息 export const uploadAgencyAuthenticationInfo = (userId, userAuthInfo, uploadAgencyAuthenticationInfoSuccess, uploadAgencyAuthenticationInfoFail) => { Http.post(Apis.USER.SUBMIT_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId), userAuthInfo).then((res) => { uploadAgencyAuthenticationInfoSuccess(res) }).catch(error => { uploadAgencyAuthenticationInfoFail(error) }) } //获取所有未处理认证消息 export const getAllHandlingAuthInfo = (getAllHandlingAuthInfoSuccess, getAllHandlingAuthInfoFail) => { Http.get(Apis.USER.GET_ALL_HANDLING_AUTH_INFO).then((res) => { getAllHandlingAuthInfoSuccess(res) }).catch((error) => { getAllHandlingAuthInfoFail(error) }) } //获取所有已处理认证消息 export const getAllHandledAuthInfo = (getAllHandledAuthInfoSuccess, getAllHandledAuthInfoFail) => { Http.get(Apis.USER.GET_ALL_HANDLED_AUTH_INFO).then((res) => { getAllHandledAuthInfoSuccess(res) }).catch((error) => { getAllHandledAuthInfoFail(error) }) } export const getCurrentIndividualAuthenInfo = (userId, getCurrentIndividualAuthenInfoSuccess, getCurrentIndividualAuthenInfoFail) => { Http.get(Apis.USER.GET_INDIVIDUAL_AUTHENTICATION_INFO.replace('{userId}', userId)).then((res) => { getCurrentIndividualAuthenInfoSuccess(res) }).catch((error) => { getCurrentIndividualAuthenInfoFail(error) }) } export const getCurrentEnterpriseAuthInfo = (userId, getCurrentEnterpriseAuthInfoSuccess, getCurrentEnterpriseAuthInfoFail) => { Http.get(Apis.USER.GET_ENTERPRISE_AUTHENTICATION_INFO.replace('{userId}', userId)).then((res) => { getCurrentEnterpriseAuthInfoSuccess(res) }).catch((error) => { getCurrentEnterpriseAuthInfoFail(error) }) } export const getCurrentAgencyAuthInfo = (userId, getCurrentEnterpriseAuthInfoSuccess, getCurrentEnterpriseAuthInfoFail) => { Http.get(Apis.USER.GET_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId)).then((res) => { getCurrentEnterpriseAuthInfoSuccess(res) }).catch((error) => { getCurrentEnterpriseAuthInfoFail(error) }) } export const getAgencyAuthInfoCommon = (userId, getCurrentEnterpriseAuthInfoSuccess, getCurrentEnterpriseAuthInfoFail) => { Http.get(Apis.USER.GET_AGENCY_AUTHENTICATION_INFO_COMMON.replace('{userId}', userId)).then((res) => { getCurrentEnterpriseAuthInfoSuccess(res) }).catch((error) => { getCurrentEnterpriseAuthInfoFail(error) }) } export const getCurrentAuthenInfo = () => { const individualData = { type: '个人',//企业、机构、个人 //共有 id: 1, userId: 3, bankAccount: '621000999000999000', address: '江苏科技大厦', status: '认证失败', rejectReason: '太强', createTime: '2019.13.12', //个人 realName: '李白', IDCard: '32092111111111', IDCardPositivePhoto: 'http://www.mooctest.net/assets/img/mooctest.png', } const enterpriseData = { type: '企业',//企业、机构、个人 //共有 id: 1, userId: 3, bankAccount: '621000999000999000', address: '江苏科技大厦1901', status: '', rejectReason: '', createTime: '', //企业 companyName: '慕测呀', legalPersonName: '郭超啊', businessLicensePhoto: null, unifiedSocialCreditCode: '1900000000086', } const agencyData = { type: '机构',//企业、机构、个人 //共有 id: 1, userId: 3, bankAccount: '100000000086', address: '江苏科技大厦1901', status: '', rejectReason: '123123123', createTime: '', //机构 evaluationAgencyName: '慕测科技', evaluationAgencyAbilityList: ['接口测试', '兼容性测试', '可靠性测试', '稳定性测试', '功能测试', '性能测试', '安全测试','易用性测试', '应用故障诊断', '应用漏洞扫描', '代码安全审计', '风险评估', '等保测评', '评估评价', '定制测试'], evaluationAgencyResourceList: [ { id: 0, type: '人力资源', name: '专家', totalNum: 100, availableNum: 3, }, { id: 1, type: '人力资源', name: '程序员', totalNum: 100, availableNum: 3, } ], agencyPhoto: 'http://www.mooctest.net/assets/img/mooctest.png', } return new Promise((resolve) => { resolve(enterpriseData) }) } //放弃认证 export const deleteAuthInfo = () => { const data = {} return new Promise((resolve) => { resolve(data) }) //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES) } // export const updateIndividualAuthInfo = (userId, authInfo, updateIndividualAuthInfoSuccess, updateIndividualAuthInfoFail) => { // const data = {} // return new Promise((resolve) => { // resolve(data) // }) Http.put(Apis.USER.UPDATE_INDIVIDUAL_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo).then((res) => { updateIndividualAuthInfoSuccess(res) }).catch((error) => { updateIndividualAuthInfoFail(error) }) } export const updateAgencyAuthInfo = (userId, authInfo, updateAgencyAuthInfoSuccess, updateAgencyAuthInfoFail) => { Http.put(Apis.USER.UPDATE_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo).then((res) => { updateAgencyAuthInfoSuccess(res) }).catch((error) => { updateAgencyAuthInfoFail(error) }) } export const updateAgencyResourceAndAbility = (userId, authInfo, updateAgencyResourceAndAbilitySuccess, updateAgencyResourceAndAbilityFail) => { Http.post(Apis.USER.UPDATE_AGENCY_RESOURCE_AND_ABILITY.replace('{userId}', userId), authInfo).then((res) => { updateAgencyResourceAndAbilitySuccess(res) }).catch((error) => { updateAgencyResourceAndAbilityFail(error) }) } export const updateEnterpriseAuthInfo = (userId, authInfo, updateEnterpriseAuthInfoSuccess, updateEnterpriseAuthInfoFail) => { // const data = {} // return new Promise((resolve) => { // resolve(data) // }) Http.put(Apis.USER.UPDATE_ENTERPRISE_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo).then((res) => { updateEnterpriseAuthInfoSuccess(res) }).catch((error) => { updateEnterpriseAuthInfoFail(error) }) } export const checkPassAuth = (type, userId, checkPassAuthSuccess, checkPassAuthFail) => { if (type == 'agency') { Http.put(Apis.USER.PASS_AGENCY_AUTH.replace('{userId}', userId), {}).then((res) => { checkPassAuthSuccess(res) }).catch((error) => { checkPassAuthFail(error) }) } if (type == 'personal') { Http.put(Apis.USER.PASS_INDIVIDUAL_AUTH.replace('{userId}', userId), {}).then((res) => { checkPassAuthSuccess(res) }).catch((error) => { checkPassAuthFail(error) }) } if (type == 'enterprise') { Http.put(Apis.USER.PASS_ENTERPRISE_AUTH.replace('{userId}', userId), {}).then((res) => { checkPassAuthSuccess(res) }).catch((error) => { checkPassAuthFail(error) }) } } export const checkRejectAuth = (type, userId, data, checkRejectAuthSuccess, checkRejectAuthFail) => { if (type == 'agency') { Http.put(Apis.USER.REJECT_AGENCY_AUTH.replace('{userId}', userId), data).then((res) => { checkRejectAuthSuccess(res) }).catch((error) => { checkRejectAuthFail(error) }) } if (type == 'personal') { Http.put(Apis.USER.REJECT_INDIVIDUAL_AUTH.replace('{userId}', userId), data).then((res) => { checkRejectAuthSuccess(res) }).catch((error) => { checkRejectAuthFail(error) }) } if (type == 'enterprise') { Http.put(Apis.USER.REJECT_ENTERPRISE_AUTH.replace('{userId}', userId), data).then((res) => { checkRejectAuthSuccess(res) }).catch((error) => { checkRejectAuthFail(error) }) } }