diff --git a/src/main/java/com/yupi/springbootinit/config/SaTokenConfigure.java b/src/main/java/com/yupi/springbootinit/config/SaTokenConfigure.java index 3928c8e..9ec57ba 100644 --- a/src/main/java/com/yupi/springbootinit/config/SaTokenConfigure.java +++ b/src/main/java/com/yupi/springbootinit/config/SaTokenConfigure.java @@ -45,7 +45,8 @@ public class SaTokenConfigure implements WebMvcConfigurer { // 你的其他放行路径,例如登录接口 "/user/doLogin", "/tenant/get-id-by-name", - "/user/bigbrother-doLogin" + "/user/bigbrother-doLogin", + "/user/aiChat-doLogin" }; } diff --git a/src/main/java/com/yupi/springbootinit/controller/UserController.java b/src/main/java/com/yupi/springbootinit/controller/UserController.java index 915a757..3aff4af 100644 --- a/src/main/java/com/yupi/springbootinit/controller/UserController.java +++ b/src/main/java/com/yupi/springbootinit/controller/UserController.java @@ -88,6 +88,38 @@ public class UserController { BeanUtil.copyProperties(user, systemUsersVO); // 赋予用户 Id StpUtil.login(user.getId(),"bigbrother"); +// 设置 token 有效期为当前日期和套餐有效期的差值 + StpUtil.renewTimeout(second); + systemUsersVO.setTokenName(StpUtil.getTokenName()); + systemUsersVO.setTokenValue(StpUtil.getTokenValue()); + return ResultUtils.success(systemUsersVO); + } + + // 用户登陆接口 + @PostMapping("aiChat-doLogin") + public BaseResponse aiChatDoLogin(@RequestBody SystemUsersDTO usersDTO) { + SystemUsers user = usersService.getUserByUserName(usersDTO.getUsername(),usersDTO.getTenantId()); + if (user == null) { + throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR); + } + if (!usersService.isPasswordMatch(usersDTO.getPassword(), user.getPassword())) { + throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR); + } + + if (CommonStatusEnum.isDisable(Integer.valueOf(user.getStatus()))) { + throw new BusinessException(ErrorCode.USER_DISABLE); + } + if (usersService.isExpired(usersDTO.getTenantId())){ + throw new BusinessException(ErrorCode.PACKAGE_EXPIRED); + } + if (!usersService.checkAiCHatLoginRole(user.getId())){ + throw new BusinessException(ErrorCode.LOGIN_NOW_ALLOWED); + } + Long second = usersService.getTenantExpiredTime(usersDTO.getTenantId()); + SystemUsersVO systemUsersVO = new SystemUsersVO(); + BeanUtil.copyProperties(user, systemUsersVO); +// 赋予用户 Id + StpUtil.login(user.getId(),"aiChat"); // 设置 token 有效期为当前日期和套餐有效期的差值 StpUtil.renewTimeout(second); systemUsersVO.setTokenName(StpUtil.getTokenName()); diff --git a/src/main/java/com/yupi/springbootinit/model/entity/SystemUsers.java b/src/main/java/com/yupi/springbootinit/model/entity/SystemUsers.java index a5d61ce..efd59f5 100644 --- a/src/main/java/com/yupi/springbootinit/model/entity/SystemUsers.java +++ b/src/main/java/com/yupi/springbootinit/model/entity/SystemUsers.java @@ -174,4 +174,11 @@ public class SystemUsers { @TableField(value = "big_brother") @ApiModelProperty(value = "能否登录大哥爬虫客户端") private Byte bigBrother; + + /** + * 能否登录大哥爬虫客户端 + */ + @TableField(value = "ai_chat") + @ApiModelProperty(value = "能否登录大哥爬虫客户端") + private Byte aiChat; } \ No newline at end of file diff --git a/src/main/java/com/yupi/springbootinit/service/SystemUsersService.java b/src/main/java/com/yupi/springbootinit/service/SystemUsersService.java index b342c9f..85e27ee 100644 --- a/src/main/java/com/yupi/springbootinit/service/SystemUsersService.java +++ b/src/main/java/com/yupi/springbootinit/service/SystemUsersService.java @@ -23,4 +23,5 @@ public interface SystemUsersService extends IService { boolean checkbigBrotherlRole(Long userId); + boolean checkAiCHatLoginRole(Long userId); } diff --git a/src/main/java/com/yupi/springbootinit/service/impl/SystemUsersServiceImpl.java b/src/main/java/com/yupi/springbootinit/service/impl/SystemUsersServiceImpl.java index cf570d9..b15498e 100644 --- a/src/main/java/com/yupi/springbootinit/service/impl/SystemUsersServiceImpl.java +++ b/src/main/java/com/yupi/springbootinit/service/impl/SystemUsersServiceImpl.java @@ -76,5 +76,11 @@ public class SystemUsersServiceImpl extends ServiceImpl - + and ns.hosts_coins >=#{hostInfoDTO.hostsCoinsMin,jdbcType=INTEGER} - + and ns.hosts_coins <=#{hostInfoDTO.hostsCoinsMax,jdbcType=INTEGER} and ns.hosts_coins between #{hostInfoDTO.hostsCoinsMin,jdbcType=INTEGER} and #{hostInfoDTO.hostsCoinsMax,jdbcType=INTEGER} - + and ns.yesterday_coins >=#{hostInfoDTO.yesterdayCoinsMin,jdbcType=INTEGER} - + and ns.yesterday_coins <=#{hostInfoDTO.yesterdayCoinsMax,jdbcType=INTEGER} and ns.yesterday_coins between #{hostInfoDTO.yesterdayCoinsMin,jdbcType=INTEGER} and #{hostInfoDTO.yesterdayCoinsMax,jdbcType=INTEGER} - + and ns.fans >=#{hostInfoDTO.fansMin,jdbcType=INTEGER} - + and ns.fans <=#{hostInfoDTO.fansMax,jdbcType=INTEGER} and ns.fans between #{hostInfoDTO.fansMin,jdbcType=INTEGER} and #{hostInfoDTO.fansMax,jdbcType=INTEGER} - + and ns.fllowernum >=#{hostInfoDTO.fllowernumMin,jdbcType=INTEGER} - + and ns.fllowernum <=#{hostInfoDTO.fllowernumMax,jdbcType=INTEGER} and ns.fllowernum between #{hostInfoDTO.fllowernumMin,jdbcType=INTEGER} and #{hostInfoDTO.fllowernumMax,jdbcType=INTEGER} - + and ns.online_fans >=#{hostInfoDTO.onlineFansMin,jdbcType=INTEGER} - + and ns.online_fans <= #{hostInfoDTO.onlineFansMax,jdbcType=INTEGER}