package com.gyee.table.controller; import com.alibaba.fastjson2.JSONObject; import com.gyee.table.entity.SysUser; import com.gyee.table.result.Result; import com.gyee.table.service.ISysUserService; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; /** * @author hlf * @date 2023/3/29 15:58 * 文件说明:用户管理操作接口 */ @Slf4j @RestController @RequestMapping("/suc") public class SysUserController { @Resource private ISysUserService userService; /** * 修改密码 * * @param id 用户ID * @param originalPassword 旧密码 * @param newPassword 新密码 * @return */ @PostMapping("/changePassword") public JSONObject changePassword(@RequestParam(value = "id") String id, @RequestParam(value = "originalPassword") String originalPassword, @RequestParam(value = "newPassword") String newPassword) { SysUser user = userService.getById(id); if (!originalPassword.equals(user.getPassword())){ return Result.error(); } user.setPassword(newPassword); userService.updateById(user); return Result.success(); } }