修改
This commit is contained in:
parent
1dd56d4690
commit
c33a03e29d
@ -40,11 +40,11 @@ public class UserController {
|
|||||||
* @return {@link BaseResponse}
|
* @return {@link BaseResponse}
|
||||||
*/
|
*/
|
||||||
@PutMapping("/user/delete")
|
@PutMapping("/user/delete")
|
||||||
public BaseResponse userDelete(@RequestParam Long id) {
|
public BaseResponse userDelete(HttpServletRequest request,@RequestParam Long id) {
|
||||||
// 判断是否有参数错误
|
// 判断是否有参数错误
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
|
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
|
||||||
} else return userService.userDelete(id);
|
} else return userService.userDelete(request,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,12 +54,12 @@ public class UserController {
|
|||||||
* @return {@link BaseResponse}
|
* @return {@link BaseResponse}
|
||||||
*/
|
*/
|
||||||
@PutMapping("/user/lock")
|
@PutMapping("/user/lock")
|
||||||
public BaseResponse userLock(@RequestParam Long id) {
|
public BaseResponse userLock(HttpServletRequest request,@RequestParam Long id) {
|
||||||
// 判断是否有参数错误
|
// 判断是否有参数错误
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
|
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
|
||||||
}
|
}
|
||||||
return userService.userLock(id);
|
return userService.userLock(request,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,6 @@ public class UserEditProfileVO {
|
|||||||
private Long id;
|
private Long id;
|
||||||
@Pattern(regexp = "^[0-9A-Za-z_]{3,40}$", message = "用户名只能为字母、数字或下划线")
|
@Pattern(regexp = "^[0-9A-Za-z_]{3,40}$", message = "用户名只能为字母、数字或下划线")
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
|
||||||
private String address;
|
private String address;
|
||||||
private String phone;
|
private String phone;
|
||||||
private String email;
|
private String email;
|
||||||
|
@ -34,7 +34,7 @@ public interface UserService {
|
|||||||
* @param id 用户id
|
* @param id 用户id
|
||||||
* @return {@link BaseResponse}
|
* @return {@link BaseResponse}
|
||||||
*/
|
*/
|
||||||
BaseResponse userDelete(Long id);
|
BaseResponse userDelete(HttpServletRequest request,Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>账号锁定</h2>
|
* <h2>账号锁定</h2>
|
||||||
@ -44,7 +44,7 @@ public interface UserService {
|
|||||||
* @param id 用户id
|
* @param id 用户id
|
||||||
* @return {@link BaseResponse}
|
* @return {@link BaseResponse}
|
||||||
*/
|
*/
|
||||||
BaseResponse userLock(Long id);
|
BaseResponse userLock(HttpServletRequest request,Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>用户编辑自己的信息</h2>
|
* <h2>用户编辑自己的信息</h2>
|
||||||
|
@ -34,18 +34,24 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseResponse userDelete(Long id) {
|
public BaseResponse userDelete(HttpServletRequest request,Long id) {
|
||||||
//判断用户是否存在
|
//判断用户是否存在
|
||||||
if (userDAO.isExistUser(id)) {
|
if (userDAO.isExistUser(id)) {
|
||||||
|
if(!Processing.checkUserIsAdmin(request,roleMapper)){
|
||||||
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
|
}
|
||||||
userDAO.userDelete(id);
|
userDAO.userDelete(id);
|
||||||
return ResultUtil.success("删除成功");
|
return ResultUtil.success("删除成功");
|
||||||
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseResponse userLock(Long id) {
|
public BaseResponse userLock(HttpServletRequest request,Long id) {
|
||||||
//判断用户是否存在
|
//判断用户是否存在
|
||||||
if (userDAO.isExistUser(id)) {
|
if (userDAO.isExistUser(id)) {
|
||||||
|
if (!Processing.checkUserIsAdmin(request,roleMapper)){
|
||||||
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
|
}
|
||||||
userDAO.userLock(id);
|
userDAO.userLock(id);
|
||||||
return ResultUtil.success("锁定成功");
|
return ResultUtil.success("锁定成功");
|
||||||
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||||
@ -54,9 +60,6 @@ public class UserServiceImpl implements UserService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseResponse userEditProfile(@NotNull UserEditProfileVO userEditProfileVO) {
|
public BaseResponse userEditProfile(@NotNull UserEditProfileVO userEditProfileVO) {
|
||||||
if (userDAO.isExistUser(userEditProfileVO.getId())) {
|
if (userDAO.isExistUser(userEditProfileVO.getId())) {
|
||||||
if (userEditProfileVO.getPassword() != null) {
|
|
||||||
userEditProfileVO.setPassword(BCrypt.hashpw(userEditProfileVO.getPassword(), BCrypt.gensalt()));
|
|
||||||
}
|
|
||||||
userDAO.userEditProfile(userEditProfileVO);
|
userDAO.userEditProfile(userEditProfileVO);
|
||||||
return ResultUtil.success("修改成功");
|
return ResultUtil.success("修改成功");
|
||||||
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<if test="username != null and username != ''">
|
<if test="username != null and username != ''">
|
||||||
username = #{username},
|
username = #{username},
|
||||||
</if>
|
</if>
|
||||||
<if test="password != null and password != ''">
|
|
||||||
password = #{password},
|
|
||||||
</if>
|
|
||||||
<if test="address != null and address != ''">
|
<if test="address != null and address != ''">
|
||||||
address = #{address},
|
address = #{address},
|
||||||
</if>
|
</if>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user