功能:后台登录增加店铺必选
This commit is contained in:
+35
@@ -523,6 +523,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
throw new RuntimeException("您没有后台管理权限");
|
||||
}
|
||||
|
||||
Long resolvedShopId = resolveAdminLoginShopId(userDO, loginRequestDTO.getShopId());
|
||||
if (!resolvedShopId.equals(userDO.getShopId())) {
|
||||
userDO.setShopId(resolvedShopId);
|
||||
userDO.setUpdateTime(LocalDateTime.now());
|
||||
userMapper.updateById(userDO);
|
||||
}
|
||||
|
||||
String accessToken = jwtUtil.generateAccessToken(userDO.getId(), userDO.getAccount());
|
||||
String refreshToken = jwtUtil.generateRefreshToken(userDO.getId(), userDO.getAccount());
|
||||
|
||||
@@ -542,6 +549,34 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
return responseVO;
|
||||
}
|
||||
|
||||
private Long resolveAdminLoginShopId(UserDO userDO, Long requestedShopId) {
|
||||
if (requestedShopId == null || requestedShopId <= 0) {
|
||||
throw new RuntimeException("请选择登录店铺");
|
||||
}
|
||||
|
||||
ShopVO shopVO = shopService.getShopById(requestedShopId);
|
||||
if (shopVO == null) {
|
||||
throw new RuntimeException("所选店铺不存在或已失效");
|
||||
}
|
||||
|
||||
if (Integer.valueOf(4).equals(userDO.getType())) {
|
||||
return requestedShopId;
|
||||
}
|
||||
|
||||
Long boundShopId = normalizeShopId(userDO.getShopId());
|
||||
if (boundShopId == null) {
|
||||
return requestedShopId;
|
||||
}
|
||||
if (!boundShopId.equals(requestedShopId)) {
|
||||
throw new RuntimeException("当前账号只能选择所属店铺登录");
|
||||
}
|
||||
return boundShopId;
|
||||
}
|
||||
|
||||
private Long normalizeShopId(Long shopId) {
|
||||
return shopId != null && shopId > 0 ? shopId : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean register(RegisterRequestDTO registerRequestDTO) {
|
||||
if (!verificationCodeService.verifyCode(registerRequestDTO.getPhone(), registerRequestDTO.getVerificationCode())) {
|
||||
|
||||
Reference in New Issue
Block a user