user.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import request from '@/utils/request'
  2. import { praseStrEmpty } from "@/utils/ruoyi";
  3. // 查询用户列表
  4. export function listUser(query) {
  5. return request({
  6. url: '/system/user/page',
  7. method: 'get',
  8. params: query
  9. })
  10. }
  11. // 查询用户详细
  12. export function getUser(userId) {
  13. return request({
  14. url: '/system/user/get?id=' + praseStrEmpty(userId),
  15. method: 'get'
  16. })
  17. }
  18. // 新增用户
  19. export function addUser(data) {
  20. return request({
  21. url: '/system/user/create',
  22. method: 'post',
  23. data: data
  24. })
  25. }
  26. // 修改用户
  27. export function updateUser(data) {
  28. return request({
  29. url: '/system/user/update',
  30. method: 'post',
  31. data: data
  32. })
  33. }
  34. // 删除用户
  35. export function delUser(userId) {
  36. return request({
  37. url: '/system/user/delete?id=' + userId,
  38. method: 'delete'
  39. })
  40. }
  41. // 导出用户
  42. export function exportUser(query) {
  43. return request({
  44. url: '/system/user/export',
  45. method: 'get',
  46. params: query,
  47. responseType: 'blob'
  48. })
  49. }
  50. // 用户密码重置
  51. export function resetUserPwd(id, password) {
  52. const data = {
  53. id,
  54. password
  55. }
  56. return request({
  57. url: '/system/user/update-password',
  58. method: 'post',
  59. data: data
  60. })
  61. }
  62. // 用户状态修改
  63. export function changeUserStatus(id, status) {
  64. const data = {
  65. id,
  66. status
  67. }
  68. return request({
  69. url: '/system/user/update-status',
  70. method: 'post',
  71. data: data
  72. })
  73. }
  74. // 查询用户个人信息
  75. export function getUserProfile() {
  76. return request({
  77. url: '/system/user/profile',
  78. method: 'get'
  79. })
  80. }
  81. // 修改用户个人信息
  82. export function updateUserProfile(data) {
  83. return request({
  84. url: '/system/user/profile',
  85. method: 'put',
  86. data: data
  87. })
  88. }
  89. // 用户密码重置
  90. export function updateUserPwd(oldPassword, newPassword) {
  91. const data = {
  92. oldPassword,
  93. newPassword
  94. }
  95. return request({
  96. url: '/system/user/profile/updatePwd',
  97. method: 'put',
  98. params: data
  99. })
  100. }
  101. // 用户头像上传
  102. export function uploadAvatar(data) {
  103. return request({
  104. url: '/system/user/profile/avatar',
  105. method: 'post',
  106. data: data
  107. })
  108. }
  109. // 下载用户导入模板
  110. export function importTemplate() {
  111. return request({
  112. url: '/system/user/get-import-template',
  113. method: 'get',
  114. responseType: 'blob'
  115. })
  116. }