内容补丁
This commit is contained in:
parent
c6af36829b
commit
a4a95d66b3
@ -175,7 +175,7 @@ public class UserController {
|
||||
|
||||
|
||||
@GetMapping("/user/profile/get")
|
||||
public BaseResponse userProflieGet(@RequestParam Long id){
|
||||
return userService.userProflieGet(id);
|
||||
public BaseResponse userProfileGet(HttpServletRequest request){
|
||||
return userService.userProfileGet(request);
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ public class UserDAO {
|
||||
* 根据用户名获取用户信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @author 筱锋xiao_lfeng
|
||||
* @return {@link UserDO}
|
||||
* @author 筱锋xiao_lfeng
|
||||
*/
|
||||
public UserDO getUserInfoByUsername(String username) {
|
||||
UserDO userDO = null;
|
||||
@ -45,16 +45,19 @@ public class UserDAO {
|
||||
|
||||
/**
|
||||
* 根据id判断用户是否存在
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Boolean isExistUser(Long id){
|
||||
if(userMapper.getUserById(id)==null) {
|
||||
public Boolean isExistUser(Long id) {
|
||||
if (userMapper.getUserById(id) == null) {
|
||||
return false;
|
||||
}else return true;
|
||||
} else return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户账号删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void userDelete(Long id) {
|
||||
@ -63,6 +66,7 @@ public class UserDAO {
|
||||
|
||||
/**
|
||||
* 用户账号锁定
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void userLock(Long id) {
|
||||
@ -159,25 +163,26 @@ public class UserDAO {
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @Description: TODO 用户添加
|
||||
* @Description 用户添加
|
||||
* @Date: 2024/1/16
|
||||
* @Param userDO: user 数据库表实体类
|
||||
*/
|
||||
public boolean userAdd(UserDO userDO){
|
||||
public boolean userAdd(UserDO userDO) {
|
||||
return userMapper.insertUser(userDO);
|
||||
}
|
||||
|
||||
public void userEdit(UserDO userDO){ userMapper.updateUser(userDO); }
|
||||
|
||||
public void userEdit(UserDO userDO) {
|
||||
userMapper.updateUser(userDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: TODO 根据username检测用户是否重复
|
||||
* @Description 根据username检测用户是否重复
|
||||
* @Date: 2024/1/16
|
||||
* @Param username: 用户名
|
||||
**/
|
||||
public Boolean isRepeatUser(String username){
|
||||
if(userMapper.getUserInfoByUsername(username)==null){
|
||||
public Boolean isRepeatUser(String username) {
|
||||
if (userMapper.getUserInfoByUsername(username) == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -185,48 +190,48 @@ public class UserDAO {
|
||||
|
||||
|
||||
/**
|
||||
* @Description: TODO 检测用户工号是否重复
|
||||
* @Date: 2024/1/18
|
||||
* @Description 检测用户工号是否重复
|
||||
* @Date 2024/1/18
|
||||
* @Param userNum:
|
||||
**/
|
||||
public Boolean isRepeatUserNum(String userNum){
|
||||
if(userMapper.getUserByUserNum(userNum) != null){
|
||||
public Boolean isRepeatUserNum(String userNum) {
|
||||
if (userMapper.getUserByUserNum(userNum) != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: TODO 根据用户id获取用户数据
|
||||
* @Date: 2024/1/17
|
||||
* @Param userId:
|
||||
* @Description 根据用户id获取用户数据
|
||||
* @Date 2024/1/17
|
||||
* @Param userId
|
||||
**/
|
||||
public UserDO getUserById(Long userId){
|
||||
public UserDO getUserById(Long userId) {
|
||||
return userMapper.getUserById(userId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: TODO 根据用户id查询对应用户权限
|
||||
* @Date: 2024/1/18
|
||||
* @Description 根据用户id查询对应用户权限
|
||||
* @Date 2024/1/18
|
||||
* @Param uid:用户id
|
||||
**/
|
||||
public RoleUserDO getRoleFromUser(Long uid){
|
||||
public RoleUserDO getRoleFromUser(Long uid) {
|
||||
return userMapper.getRoleIdByUserId(uid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: TODO 检验用户权限是否为管理员
|
||||
* @Date: 2024/1/18
|
||||
* @Description 检验用户权限是否为管理员
|
||||
* @Date 2024/1/18
|
||||
* @Param null:用户id
|
||||
**/
|
||||
public Boolean isManagerByRoleId(Long roleId){
|
||||
public Boolean isManagerByRoleId(Long roleId) {
|
||||
RoleDO role = userMapper.getRoleById(roleId);
|
||||
if(role == null){
|
||||
if (role == null) {
|
||||
return false;
|
||||
}
|
||||
if(role.getRoleName().equals("管理员")){
|
||||
if (role.getRoleName().equals("admin")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -30,7 +30,7 @@ public interface UserMapper {
|
||||
@Update("UPDATE organize_oa.oa_user SET enabled = 0 ,updated_at = CURRENT_TIMESTAMP WHERE id = #{id} ")
|
||||
void userDelete(Long id);
|
||||
|
||||
@Update("UPDATE organize_oa.oa_user SET account_no_locked = 1 ,updated_at = CURRENT_TIMESTAMP WHERE id = #{id} ")
|
||||
@Update("UPDATE organize_oa.oa_user SET account_no_locked = 0 ,updated_at = CURRENT_TIMESTAMP WHERE id = #{id} ")
|
||||
void userLock(Long id);
|
||||
|
||||
@Select("SELECT * FROM organize_oa.oa_user WHERE id = #{id}")
|
||||
|
@ -89,7 +89,7 @@ public interface UserService {
|
||||
BaseResponse userEdit(UserEditVo userEditVo, HttpServletRequest request);
|
||||
|
||||
|
||||
BaseResponse userProflieGet(Long id);
|
||||
BaseResponse userProfileGet(HttpServletRequest request);
|
||||
|
||||
|
||||
}
|
||||
|
@ -93,12 +93,16 @@ public class AuthServiceImpl implements AuthService {
|
||||
if (userDO != null) {
|
||||
// 账户是否有效
|
||||
if (userDO.getEnabled()) {
|
||||
if (userDO.getAccountNoLocked()) {
|
||||
// 获取用户并登陆
|
||||
if (BCrypt.checkpw(userLoginVO.getPassword(), userDO.getPassword())) {
|
||||
return this.encapsulateDisplayContent(userDO);
|
||||
} else {
|
||||
return ResultUtil.error(ErrorCode.WRONG_PASSWORD);
|
||||
}
|
||||
} else {
|
||||
return ResultUtil.error(ErrorCode.USER_IS_LOCKED);
|
||||
}
|
||||
} else {
|
||||
return ResultUtil.error(ErrorCode.USER_IS_DEACTIVATED);
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
public BaseResponse userLock(HttpServletRequest request, Long id) {
|
||||
//判断用户是否存在
|
||||
if (userDAO.isExistUser(id)) {
|
||||
if (!Processing.checkUserIsAdmin(request, roleMapper)) {
|
||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||
}
|
||||
//判断用户是否存在
|
||||
if (userDAO.isExistUser(id)) {
|
||||
userDAO.userLock(id);
|
||||
return ResultUtil.success("锁定成功");
|
||||
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||
@ -152,8 +152,7 @@ public class UserServiceImpl implements UserService {
|
||||
.setPhone(userAddVo.getPhone())
|
||||
.setEmail(userAddVo.getEmail())
|
||||
.setAge(userAddVo.getAge())
|
||||
.setSex(userAddVo.getSex())
|
||||
.setAccountNoLocked(false);
|
||||
.setSex(userAddVo.getSex());
|
||||
// 插入数据
|
||||
if (userDAO.userAdd(userDO)) {
|
||||
userDO.setPassword(null);
|
||||
@ -172,6 +171,7 @@ public class UserServiceImpl implements UserService {
|
||||
if (checkManagerResult.getCode() != 200) {
|
||||
return checkManagerResult;
|
||||
}
|
||||
|
||||
//根据id获取用户信息
|
||||
UserDO userDO = userDAO.getUserById(userEditVo.getId());
|
||||
if (userDO == null) {
|
||||
@ -192,12 +192,9 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse userProflieGet(Long id) {
|
||||
|
||||
UserDO userDO = userDAO.getUserById(id);
|
||||
if (userDO == null) {
|
||||
return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||
}
|
||||
public BaseResponse userProfileGet(HttpServletRequest request) {
|
||||
// 获取用户Id
|
||||
UserDO userDO = userDAO.getUserById(Processing.getAuthHeaderToUserId(request));
|
||||
UserProfile userProfile = new UserProfile();
|
||||
try {
|
||||
Processing.copyProperties(userDO, userProfile);
|
||||
|
@ -16,6 +16,7 @@ public enum ErrorCode {
|
||||
TOKEN_EXPIRED("TokenExpired", 40101, "Token已过期"),
|
||||
VERIFICATION_INVALID("VerificationInvalid", 40102, "验证码无效"),
|
||||
TOKEN_NOT_EXIST("TokenNotExist", 40103, "Token不存在"),
|
||||
USER_IS_LOCKED("UserIsLocked", 40300, "用户已被锁定"),
|
||||
USER_IS_DEACTIVATED("UserIsDeactivated", 40300, "用户已被禁用"),
|
||||
NOT_ADMIN("NotAdmin", 40300, "不是管理员"),
|
||||
EMAIL_LOGIN_NOT_SUPPORT("EmailLoginNotSupport", 40300, "请使用邮箱登陆"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user