SysUserController.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.gyee.table.controller;
  2. import com.alibaba.fastjson2.JSONObject;
  3. import com.gyee.table.entity.SysUser;
  4. import com.gyee.table.result.Result;
  5. import com.gyee.table.service.ISysUserService;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.web.bind.annotation.PostMapping;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestParam;
  10. import org.springframework.web.bind.annotation.RestController;
  11. import javax.annotation.Resource;
  12. /**
  13. * @author hlf
  14. * @date 2023/3/29 15:58
  15. * 文件说明:用户管理操作接口
  16. */
  17. @Slf4j
  18. @RestController
  19. @RequestMapping("/suc")
  20. public class SysUserController {
  21. @Resource
  22. private ISysUserService userService;
  23. /**
  24. * 修改密码
  25. *
  26. * @param id 用户ID
  27. * @param originalPassword 旧密码
  28. * @param newPassword 新密码
  29. * @return
  30. */
  31. @PostMapping("/changePassword")
  32. public JSONObject changePassword(@RequestParam(value = "id") String id,
  33. @RequestParam(value = "originalPassword") String originalPassword,
  34. @RequestParam(value = "newPassword") String newPassword) {
  35. SysUser user = userService.getById(id);
  36. if (!originalPassword.equals(user.getPassword())){
  37. return Result.error();
  38. }
  39. user.setPassword(newPassword);
  40. userService.updateById(user);
  41. return Result.success();
  42. }
  43. }