修改禅道bug
This commit is contained in:
@ -4,6 +4,7 @@ import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.greenorange.promotion.annotation.RequiresPermission;
|
||||
import com.greenorange.promotion.common.ErrorCode;
|
||||
import com.greenorange.promotion.exception.BusinessException;
|
||||
import com.greenorange.promotion.exception.ThrowUtils;
|
||||
import com.greenorange.promotion.model.entity.UserInfo;
|
||||
import com.greenorange.promotion.model.enums.UserRoleEnum;
|
||||
@ -57,9 +58,14 @@ public class PermissionCheck {
|
||||
ThrowUtils.throwIf(interfaceRoleEnum == null, ErrorCode.NO_AUTH_ERROR);
|
||||
// 获取用户权限
|
||||
String token = request.getHeader("Authorization");
|
||||
ThrowUtils.throwIf(StringUtils.isBlank(token), ErrorCode.NO_AUTH_ERROR, "JWT为空");
|
||||
ThrowUtils.throwIf(StringUtils.isBlank(token), ErrorCode.NO_AUTH_ERROR, "token为空");
|
||||
// 解析token
|
||||
DecodedJWT decodedJWT = jwtUtils.verify(token);
|
||||
DecodedJWT decodedJWT;
|
||||
try {
|
||||
decodedJWT = jwtUtils.verify(token);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(ErrorCode.NO_AUTH_ERROR, "token已过期");
|
||||
}
|
||||
String userAccount = decodedJWT.getClaim("userAccount").asString();
|
||||
String userPassword = decodedJWT.getClaim("userPassword").asString();
|
||||
String userRole = decodedJWT.getClaim("userRole").asString();
|
||||
|
@ -103,6 +103,17 @@ public class UserInfoController {
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户校验token
|
||||
* @return 是否校验成功
|
||||
*/
|
||||
@PostMapping("verify/token")
|
||||
@Operation(summary = "小程序端用户校验token", description = "参数:token, 权限:管理员(boss, admin),方法名:verifyToken")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
public BaseResponse<Boolean> verifyToken() {
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* web端修改员工申请须知
|
||||
@ -110,7 +121,7 @@ public class UserInfoController {
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@PostMapping("modify/applyNotice")
|
||||
@Operation(summary = "web端用户修改用户昵称", description = "参数:昵称,权限:管理员(boss, admin),方法名:modifyApplyNotice")
|
||||
@Operation(summary = "web端修改员工申请须知", description = "参数:昵称,权限:管理员(boss, admin),方法名:modifyApplyNotice")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Boolean> modifyApplyNotice(@Valid @RequestBody CommonStringRequest commonStringRequest) {
|
||||
String applyNotice = commonStringRequest.getTemplateString();
|
||||
@ -143,6 +154,11 @@ public class UserInfoController {
|
||||
public BaseResponse<Boolean> modifyNickname(@Valid @RequestBody CommonStringRequest commonStringRequest, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
String nickName = commonStringRequest.getTemplateString();
|
||||
LambdaQueryWrapper<UserInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(UserInfo::getNickName, nickName);
|
||||
queryWrapper.ne(UserInfo::getId, userId);
|
||||
ThrowUtils.throwIf(userInfoService.count(queryWrapper) > 0, ErrorCode.PARAMS_ERROR, "昵称已存在");
|
||||
|
||||
LambdaUpdateWrapper<UserInfo> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(UserInfo::getId, userId).set(UserInfo::getNickName, nickName);
|
||||
userInfoService.update(updateWrapper);
|
||||
|
@ -101,4 +101,6 @@ public interface UserInfoService extends IService<UserInfo> {
|
||||
* 查询当前用户的所有下级用户(包括间接)
|
||||
*/
|
||||
List<Long> findAllSubUser(Long userId);
|
||||
|
||||
|
||||
}
|
||||
|
@ -348,7 +348,13 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
|
||||
// 判断手机号是否已注册
|
||||
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(UserInfo::getPhoneNumber, phoneNumber).eq(UserInfo::getUserRole, userRole);
|
||||
UserRoleEnum userRoleEnum = UserRoleEnum.getEnumByValue(userRole);
|
||||
if (userRoleEnum == UserRoleEnum.USER) {
|
||||
lambdaQueryWrapper.eq(UserInfo::getUserRole, UserConstant.DEFAULT_ROLE);
|
||||
} else {
|
||||
lambdaQueryWrapper.in(UserInfo::getUserRole, UserConstant.STAFF_ROLE, UserConstant.SUPERVISOR_ROLE, UserConstant.MANAGER_ROLE);
|
||||
}
|
||||
lambdaQueryWrapper.eq(UserInfo::getPhoneNumber, phoneNumber);
|
||||
UserInfo userInfo = this.getOne(lambdaQueryWrapper);
|
||||
ThrowUtils.throwIf(userInfo != null, ErrorCode.OPERATION_ERROR, "手机号已注册");
|
||||
|
||||
@ -359,6 +365,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 校验用户手机号和验证码
|
||||
*/
|
||||
@ -408,6 +415,11 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
AdvancementApply advancementApply = advancementApplyService.getById(applyId);
|
||||
String phoneNumber = advancementApply.getPhone();
|
||||
ThrowUtils.throwIf(RegexUtils.isPhoneInvalid(phoneNumber), ErrorCode.PARAMS_ERROR, "手机号格式无效");
|
||||
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(UserInfo::getPhoneNumber, phoneNumber)
|
||||
.in(UserInfo::getUserRole, UserConstant.STAFF_ROLE, UserConstant.SUPERVISOR_ROLE, UserConstant.MANAGER_ROLE);
|
||||
UserInfo userInfo = this.getOne(lambdaQueryWrapper);
|
||||
ThrowUtils.throwIf(userInfo != null, ErrorCode.OPERATION_ERROR, "手机号已注册");
|
||||
|
||||
// 根据邀请码获得上级用户信息
|
||||
Long userId = advancementApplyApproveRequest.getUserId();
|
||||
@ -594,6 +606,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user