123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- import Http from './http'
- import Apis from './api'
- //获取用户信息
- export const getCurrentUser = () => {
- // 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)
- }
- //
- 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 = () => {
- Http.post(Apis)
- }
- //上传企业认证信息
- export const uploadEnterpriseAuthenticationInfo = () => {
- }
- //上传机构认证信息
- export const uploadAgencyAuthenticationInfo = () => {
- }
- //获取所有认证消息
- export const getAllAuthentications = () => {
- return [{
- userVO: {},
- type: '',
- status: '',
- authenticationDetail: {}
- }]
- }
- 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 getCurrentAuthenInfo = () => {
- const individualData = {
- type: '个人',//企业、机构、个人
- //共有
- id: 1,
- userId: 3,
- bankAccount: '621000999000999000',
- address: '江苏科技大厦',
- status: '认证失败',
- rejectReason: '太强',
- createTime: '2019.13.12',
- //个人
- realName: '李白',
- IDCard: '32092111111111',
- IDCardPhoto: '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) => {
- // const data = {}
- // return new Promise((resolve) => {
- // resolve(data)
- // })
- return Http.put(Apis.USER.UPDATE_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo)
- }
- export const updateEnterpriseAuthInfo = (userId, authInfo) => {
- // const data = {}
- // return new Promise((resolve) => {
- // resolve(data)
- // })
- return Http.put(Apis.USER.UPDATE_ENTERPRISE_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo)
- }
|