123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- 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)
- })
- }
- }
|