bug修改
This commit is contained in:
1 parent
5daac1640c
commit
2c10db5b24
6 files changed
+54
No files matched your search
+8
@@ -56,6 +56,14 @@ public class AppAuthController {
|
||||
return success(authService.airlineLogin(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/airline-check")
|
||||
@Operation(summary = "航空账号会话校验(禁用/过期/设备不匹配则失败)")
|
||||
@Parameter(name = "deviceId", description = "设备唯一识别号", required = true)
|
||||
public CommonResult<Boolean> airlineCheck(@RequestParam("deviceId") String deviceId) {
|
||||
authService.airlineCheck(getLoginUserId(), deviceId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
@Operation(summary = "登出系统")
|
||||
@PermitAll
|
||||
|
||||
+4
@@ -27,4 +27,8 @@ public interface MemberAirlineAccountMapper extends BaseMapperX<MemberAirlineAcc
|
||||
return selectOne(MemberAirlineAccountDO::getDeviceId, deviceId);
|
||||
}
|
||||
|
||||
default MemberAirlineAccountDO selectByUserId(Long userId) {
|
||||
return selectOne(MemberAirlineAccountDO::getUserId, userId);
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -35,4 +35,9 @@ public interface MemberAirlineAccountService {
|
||||
*/
|
||||
MemberAirlineAccountDO authenticateAndBindDevice(String mobile, String password, String deviceId);
|
||||
|
||||
/**
|
||||
* 会话校验:已登录用户打开 App 时检查账号是否禁用/过期/设备不匹配。
|
||||
*/
|
||||
void validateAirlineSession(Long userId, String deviceId);
|
||||
|
||||
}
|
||||
+26
@@ -130,6 +130,32 @@ public class MemberAirlineAccountServiceImpl implements MemberAirlineAccountServ
|
||||
return account;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateAirlineSession(Long userId, String deviceId) {
|
||||
if (userId == null) {
|
||||
throw exception(AIRLINE_ACCOUNT_NOT_EXISTS);
|
||||
}
|
||||
MemberAirlineAccountDO account = airlineAccountMapper.selectByUserId(userId);
|
||||
if (account == null) {
|
||||
throw exception(AIRLINE_ACCOUNT_NOT_EXISTS);
|
||||
}
|
||||
if (CommonStatusEnum.isDisable(account.getStatus())) {
|
||||
throw exception(AIRLINE_ACCOUNT_DISABLED);
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (account.getStartTime() != null && now.isBefore(account.getStartTime())) {
|
||||
throw exception(AIRLINE_ACCOUNT_NOT_STARTED);
|
||||
}
|
||||
if (account.getEndTime() != null && now.isAfter(account.getEndTime())) {
|
||||
throw exception(AIRLINE_ACCOUNT_EXPIRED);
|
||||
}
|
||||
String boundDeviceId = account.getDeviceId();
|
||||
if (StrUtil.isNotBlank(boundDeviceId) && StrUtil.isNotBlank(deviceId)
|
||||
&& !StrUtil.equals(boundDeviceId, deviceId)) {
|
||||
throw exception(AIRLINE_ACCOUNT_DEVICE_BOUND);
|
||||
}
|
||||
}
|
||||
|
||||
private MemberAirlineAccountDO validateExists(Long id) {
|
||||
MemberAirlineAccountDO account = airlineAccountMapper.selectById(id);
|
||||
if (account == null) {
|
||||
|
||||
+6
@@ -114,4 +114,10 @@ public interface MemberAuthService {
|
||||
* 航空账号登录:校验密码、有效期、设备唯一绑定,并签发会员 Token
|
||||
*/
|
||||
AppAuthLoginRespVO airlineLogin(@Valid AppAuthAirlineLoginReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 航空账号会话校验(已登录):禁用/过期/设备不匹配时抛业务异常
|
||||
*/
|
||||
void airlineCheck(Long userId, String deviceId);
|
||||
|
||||
}
|
||||
+5
@@ -432,6 +432,11 @@ public class MemberAuthServiceImpl implements MemberAuthService {
|
||||
return createTokenAfterLoginSuccess(user, reqVO.getMobile(), LoginLogTypeEnum.LOGIN_MOBILE, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void airlineCheck(Long userId, String deviceId) {
|
||||
airlineAccountService.validateAirlineSession(userId, deviceId);
|
||||
}
|
||||
|
||||
private void createLogoutLog(Long userId) {
|
||||
LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO();
|
||||
reqDTO.setLogType(LoginLogTypeEnum.LOGOUT_SELF.getType());
|
||||
|
||||
Reference in new issue
Block a user