huliguo
2025-05-12 c151ec18d4d302a6359a8ef4144835c254c842bc
src/main/java/com/cl/controller/UserController.java
@@ -9,10 +9,7 @@
import com.cl.common.exception.user.LoginErrorException;
import com.cl.common.exception.user.UserException;
import com.cl.common.result.Result;
import com.cl.pojo.dto.AddUserDTO;
import com.cl.pojo.dto.EditUserDTO;
import com.cl.pojo.dto.LoginDTO;
import com.cl.pojo.dto.PasswordDTO;
import com.cl.pojo.dto.*;
import com.cl.pojo.entity.User;
import com.cl.pojo.vo.UserVO;
@@ -72,7 +69,7 @@
        }
        if (!Objects.equals(user.getStatus(), StatusConstant.ENABLE)){
            throw new LoginErrorException("该账号已被冻结");
            throw new LoginErrorException("登录失败,当前账号已被冻结");
        }
        //校验密码是否正确
        if (!BCryptPasswordEncoder.matches(dto.getPassword(), user.getPassword())) {
@@ -91,6 +88,9 @@
        Map<String,String> map=new HashMap<>();
        map.put("token", token);
        map.put("is_first",user.getIsFirst().toString());
        map.put("name",user.getName());
        map.put("phone",user.getPhone());
        map.put("id", String.valueOf(user.getId()));
        if (1==user.getIsFirst()){
            User user1 = new User();
            user1.setId(user.getId());
@@ -120,6 +120,17 @@
        return Result.success("修改成功");
    }
    /**
     * 修改密码
     */
    @PutMapping("/passwordBeforeLogin")
    @ApiOperation("修改密码(登录前)")
    public Result<String> passwordBeforeLogin(@RequestBody @Valid PasswordBeforeLoginDTO passwordDTO) {
        if (passwordDTO.getPhone().equals("admin")) {
            return Result.error("管理员账号,不可操作");
        }
        return userService.passwordBeforeLogin(passwordDTO);
    }
    /**
     * 添加
     */
    @PostMapping("/addUser")