UserApi.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import FetchRequest from "@/api/FetchRequest";
  2. import type User from "@/mode/User";
  3. import type setUser from "@/mode/setUser";
  4. /**
  5. * 用户接口
  6. */
  7. class UserApi {
  8. static url = "/api/sys/users";
  9. static getUser(id: string): Promise<any> {
  10. return FetchRequest.get(`${this.url}/${id}`, true);
  11. }
  12. static currentUser(): Promise<any> {
  13. return FetchRequest.get(`${this.url}/my`, true);
  14. }
  15. static update(id: string, user: User): Promise<any> {
  16. user.id = id;
  17. return FetchRequest.put(`${this.url}/update` , JSON.stringify(user), true);
  18. }
  19. //system/user/setUser
  20. //"registrationId":"11234'"userId": 49,
  21. static setUser(data:string): Promise<any> {
  22. return FetchRequest.post('/system/user/setUser' ,data, false);
  23. }
  24. /**
  25. * search好友
  26. * @param mobile mobile
  27. */
  28. static search(mobile: string): Promise<any> {
  29. return FetchRequest.get(`${this.url}/search?mobile=${mobile}`, true);
  30. }
  31. /**
  32. * 刷新用户密钥
  33. * @param oldPassword
  34. * @param newPassword
  35. */
  36. static updateUserPwd(oldPassword: string, newPassword: string): Promise<any> {
  37. const data = {
  38. oldPassword: oldPassword,
  39. newPassword: newPassword,
  40. };
  41. return FetchRequest.put(
  42. `${this.url}/updatePwd`,
  43. JSON.stringify(data),
  44. true
  45. );
  46. }
  47. }
  48. export default UserApi;