user.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import {httpApi} from "../request/httpApi";
  2. import website from "~src/config/index";
  3. import md5 from 'js-md5'
  4. export const userLogin = ({tenantId, deptId, roleId, username, password, type, key, code}, msg = true) => httpApi({
  5. url: '/api/blade-auth/oauth/token',
  6. method: 'post',
  7. headers: {
  8. 'Tenant-Id': tenantId,
  9. 'Dept-Id': (website.switchMode ? deptId : ''),
  10. 'Role-Id': (website.switchMode ? roleId : ''),
  11. 'Captcha-Key': key,
  12. 'Captcha-Code': code,
  13. },
  14. params: {
  15. tenantId,
  16. username,
  17. password: md5(password),
  18. grant_type: (website.captchaMode ? "captcha" : "password"),
  19. scope: "all",
  20. type
  21. }
  22. }, msg);
  23. export const refreshToken = (refresh_token, tenantId, deptId, roleId, msg = true) => httpApi({
  24. url: '/api/blade-auth/oauth/token',
  25. method: 'post',
  26. headers: {
  27. 'Tenant-Id': tenantId,
  28. 'Dept-Id': (website.switchMode ? deptId : ''),
  29. 'Role-Id': (website.switchMode ? roleId : '')
  30. },
  31. params: {
  32. tenantId,
  33. refresh_token,
  34. grant_type: "refresh_token",
  35. scope: "all",
  36. }
  37. }, msg);
  38. export const logout = (msg = true) => httpApi({
  39. url: '/api/blade-auth/oauth/logout',
  40. method: 'get'
  41. }, msg);
  42. export const registerGuest = (form, oauthId, msg = true) => httpApi({
  43. url: '/api/blade-user/register-guest',
  44. method: 'post',
  45. params: {
  46. tenantId: form.tenantId,
  47. name: form.name,
  48. account: form.account,
  49. password: form.password,
  50. oauthId
  51. }
  52. }, msg);
  53. export const getProjectAndContract = (msg = true) => httpApi({
  54. url: '/api/blade-business/userViewProjectContract/queryUserViewProjectAndContract',
  55. method: 'get'
  56. }, msg);
  57. export const getCaptcha = (msg = true) => httpApi({
  58. url: '/api/blade-auth/oauth/captcha',
  59. method: 'get'
  60. }, msg);
  61. export const getUserInfo = (msg = true) => httpApi({
  62. url: '/api/blade-auth/oauth/user-info',
  63. method: 'get'
  64. }, msg);
  65. export const sendLogs = (list, msg = true) => httpApi({
  66. url: '/api/blade-auth/oauth/logout',
  67. method: 'post',
  68. data: list
  69. }, msg);
  70. export const clearCache = (msg = true) => httpApi({
  71. url: '/api/blade-auth/oauth/clear-cache',
  72. method: 'get'
  73. }, msg);
  74. export const loginByToken = (form, msg = true) => httpApi({
  75. url: '/api/blade-user/loginByToken',
  76. method: 'post',
  77. params: form
  78. }, msg);
  79. //获取租户ID
  80. export const getTenantID = (domain, msg = true) => httpApi({
  81. url: '/api/blade-system/tenant/info',
  82. method: 'get',
  83. params: {
  84. domain
  85. }
  86. }, msg);