userService.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import Http from './http'
  2. import Apis from './api'
  3. //获取用户信息
  4. export const getCurrentUser = () => {
  5. // const data = {
  6. // userVO: {
  7. // id: 3,
  8. // photo: 'http://www.mooctest.net/assets/img/mooctest.png',
  9. // name: '郭超',
  10. // roleList: ['区域管理员', '个人用户', '企业用户', '测评机构', '系统管理员'],
  11. // mobile: '110',
  12. // email: '12345@qq.com',
  13. // },
  14. // agency: '',
  15. // }
  16. // return new Promise((resolve) => {
  17. // resolve(data)
  18. // })
  19. return Http.get(Apis.USER.GET_CURRENT_USER)
  20. }
  21. //
  22. export const getRolesPermissions = (roleList) => {
  23. const roles = {
  24. regionManager: 'RegionalManager',
  25. individualUser: 'generalUser',
  26. enterpriseUser: 'enterpriseUser',
  27. agency: 'evaluationAgency',
  28. systemAdministrator: 'SystemAdministrator'
  29. }
  30. const permissions = {
  31. isRegionManager: false,
  32. isIndividualUser: false,
  33. isEnterpriseUser: false,
  34. isAgency: false,
  35. isSystemAdministrator: false
  36. }
  37. if (roleList.includes(roles.regionManager)) {
  38. permissions.isRegionManager = true
  39. permissions.isEnterpriseUser = true
  40. permissions.isIndividualUser = true
  41. }
  42. if (roleList.includes(roles.agency)) {
  43. permissions.isAgency = true
  44. permissions.isEnterpriseUser = true
  45. permissions.isIndividualUser = true
  46. }
  47. if (roleList.includes(roles.enterpriseUser)) {
  48. permissions.isEnterpriseUser = true
  49. }
  50. if (roleList.includes(roles.individualUser)) {
  51. permissions.isIndividualUser = true
  52. }
  53. if (roleList.includes(roles.systemAdministrator)) {
  54. permissions.isSystemAdministrator = true
  55. permissions.isRegionManager = true
  56. permissions.isAgency = true
  57. permissions.isEnterpriseUser = true
  58. permissions.isIndividualUser = true
  59. }
  60. return permissions
  61. }
  62. export const logout = () => {
  63. sessionStorage.removeItem('user')
  64. sessionStorage.removeItem('rolesPermissions')
  65. return Http.get(Apis.USER.LOGOUT)
  66. }
  67. //获取当前角色可访问的url
  68. export const getAuthUrls = () => {
  69. return [
  70. '/', '/home', '/square', '/mine', '/project/create',
  71. '/project/:projectId', '/project/:projectId/task/create',
  72. '/project/:projectId/task/:taskId', '/project/:projectId/analyse',
  73. '/report/create', '/report/:reportId', '/greenChannel/addProject', '/greenChannel/addAgency',
  74. '/authentication/individual', '/authentication/enterprise',
  75. '/authentication/agency', '/authentication/index'
  76. ]
  77. //return Http.get(Apis.USER.GET_AUTH_URLS)
  78. }
  79. //上传个人认证信息
  80. export const uploadIndividualAuthenticationInfo = () => {
  81. Http.post(Apis)
  82. }
  83. //上传企业认证信息
  84. export const uploadEnterpriseAuthenticationInfo = () => {
  85. }
  86. //上传机构认证信息
  87. export const uploadAgencyAuthenticationInfo = () => {
  88. }
  89. //获取所有认证消息
  90. export const getAllAuthentications = () => {
  91. return [{
  92. userVO: {},
  93. type: '',
  94. status: '',
  95. authenticationDetail: {}
  96. }]
  97. }
  98. export const getCurrentIndividualAuthenInfo = (userId, getCurrentIndividualAuthenInfoSuccess, getCurrentIndividualAuthenInfoFail) => {
  99. Http.get(Apis.USER.GET_INDIVIDUAL_AUTHENTICATION_INFO.replace('{userId}', userId)).then((res) => {
  100. getCurrentIndividualAuthenInfoSuccess(res)
  101. }).catch((error) => {
  102. getCurrentIndividualAuthenInfoFail(error)
  103. })
  104. }
  105. export const getCurrentAuthenInfo = () => {
  106. const individualData = {
  107. type: '个人',//企业、机构、个人
  108. //共有
  109. id: 1,
  110. userId: 3,
  111. bankAccount: '621000999000999000',
  112. address: '江苏科技大厦',
  113. status: '认证失败',
  114. rejectReason: '太强',
  115. createTime: '2019.13.12',
  116. //个人
  117. realName: '李白',
  118. IDCard: '32092111111111',
  119. IDCardPhoto: 'http://www.mooctest.net/assets/img/mooctest.png',
  120. }
  121. const enterpriseData = {
  122. type: '企业',//企业、机构、个人
  123. //共有
  124. id: 1,
  125. userId: 3,
  126. bankAccount: '621000999000999000',
  127. address: '江苏科技大厦1901',
  128. status: '',
  129. rejectReason: '',
  130. createTime: '',
  131. //企业
  132. companyName: '慕测呀',
  133. legalPersonName: '郭超啊',
  134. businessLicensePhoto: null,
  135. unifiedSocialCreditCode: '1900000000086',
  136. }
  137. const agencyData = {
  138. type: '机构',//企业、机构、个人
  139. //共有
  140. id: 1,
  141. userId: 3,
  142. bankAccount: '100000000086',
  143. address: '江苏科技大厦1901',
  144. status: '',
  145. rejectReason: '123123123',
  146. createTime: '',
  147. //机构
  148. evaluationAgencyName: '慕测科技',
  149. evaluationAgencyAbilityList: ['接口测试', '安全漏洞扫描', '风险评估服务', '源代码安全审计服务', '功能测试服务', '性能测试', '功能和易用性测试'],
  150. evaluationAgencyResourceList: [
  151. {
  152. id: 0,
  153. type: '人力资源',
  154. name: '专家',
  155. totalNum: 100,
  156. availableNum: 3,
  157. },
  158. {
  159. id: 1,
  160. type: '人力资源',
  161. name: '程序员',
  162. totalNum: 100,
  163. availableNum: 3,
  164. }
  165. ],
  166. agencyPhoto: 'http://www.mooctest.net/assets/img/mooctest.png',
  167. }
  168. return new Promise((resolve) => {
  169. resolve(enterpriseData)
  170. })
  171. }
  172. //放弃认证
  173. export const deleteAuthInfo = () => {
  174. const data = {}
  175. return new Promise((resolve) => {
  176. resolve(data)
  177. })
  178. //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES)
  179. }
  180. //
  181. export const updateIndividualAuthInfo = (userId, authInfo, updateIndividualAuthInfoSuccess, updateIndividualAuthInfoFail) => {
  182. // const data = {}
  183. // return new Promise((resolve) => {
  184. // resolve(data)
  185. // })
  186. Http.put(Apis.USER.UPDATE_INDIVIDUAL_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo).then((res) => {
  187. updateIndividualAuthInfoSuccess(res)
  188. }).catch((error) => {
  189. updateIndividualAuthInfoFail(error)
  190. })
  191. }
  192. export const updateAgencyAuthInfo = (userId, authInfo) => {
  193. // const data = {}
  194. // return new Promise((resolve) => {
  195. // resolve(data)
  196. // })
  197. return Http.put(Apis.USER.UPDATE_AGENCY_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo)
  198. }
  199. export const updateEnterpriseAuthInfo = (userId, authInfo) => {
  200. // const data = {}
  201. // return new Promise((resolve) => {
  202. // resolve(data)
  203. // })
  204. return Http.put(Apis.USER.UPDATE_ENTERPRISE_AUTHENTICATION_INFO.replace('{userId}', userId), authInfo)
  205. }