user.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { Result, deleteRequest, get, post, put } from "../base";
  2. /**
  3. * 分页查询
  4. * @param query .
  5. * @returns .
  6. */
  7. export function queryPage<T>(query?: any): Promise<Result<T>> {
  8. return get("/sys/user/query/page", query);
  9. }
  10. /**
  11. * 列表查询
  12. * @param query .
  13. * @returns .
  14. */
  15. export function queryList<T>(query?: any): Promise<Result<T>> {
  16. return get("/sys/user/query/list", query);
  17. }
  18. /**
  19. * 检查用户名是否存在
  20. * @param username .
  21. * @returns .
  22. */
  23. export function hashUsername(username: string): Promise<Result<Boolean>> {
  24. return get("/sys/user/check/username", { username: username });
  25. }
  26. /**
  27. * 新增
  28. * @param data .
  29. * @returns .
  30. */
  31. export function save<T>(data: any): Promise<Result<T>> {
  32. return post("/sys/user/save", data);
  33. }
  34. /**
  35. * 更新
  36. * @param id .
  37. * @param data .
  38. * @returns .
  39. */
  40. export function update<T>(id: string, data: any): Promise<Result<T>> {
  41. return put(`/sys/user/update/${id}`, {}, data);
  42. }
  43. /**
  44. * 获取用户角色ID
  45. * @param userId .
  46. * @returns .
  47. */
  48. export function queryRoleIds<T>(userId: string): Promise<Result<T>> {
  49. return get(`/sys/user/query/role/ids`, { id: userId });
  50. }
  51. /**
  52. * 删除用户
  53. * @param userIds .
  54. * @returns .
  55. */
  56. export function del<T>(userIds: string[]): Promise<Result<T>> {
  57. return deleteRequest(`/sys/user/delete`, {}, userIds);
  58. }
  59. /**
  60. * 重置密码
  61. * @param username .
  62. * @param data .
  63. * @returns .
  64. */
  65. export function resetPasswd<T>(
  66. username: string,
  67. data: any
  68. ): Promise<Result<T>> {
  69. return put(`/sys/user/reset/passwd/${username}`, {}, data);
  70. }
  71. /**
  72. * 更新密码
  73. * @param username .
  74. * @param data .
  75. * @returns .
  76. */
  77. export function changePasswd<T>(
  78. username: string,
  79. data: any
  80. ): Promise<Result<T>> {
  81. return put(`/sys/user/change/passwd/${username}`, {}, data);
  82. }