From 4f7e0e4576dfe5085929495e95abaf96fe80c1cb Mon Sep 17 00:00:00 2001 From: Ziin Date: Thu, 3 Jul 2025 15:25:33 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0AI=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=99=BB=E5=BD=95=E6=8E=A5=E5=8F=A3=202.?= =?UTF-8?q?=E5=88=A0=E9=99=A4=20xmlsql=20=E6=97=A0=E7=94=A8=E5=88=A4?= =?UTF-8?q?=E6=96=AD=203.=E4=BF=AE=E6=94=B9=20dev=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=BC=80=E5=90=AF=20swagger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/SaTokenConfigure.java | 3 +- .../controller/UserController.java | 32 +++++++++++++++++++ .../model/entity/SystemUsers.java | 7 ++++ .../service/SystemUsersService.java | 1 + .../service/impl/SystemUsersServiceImpl.java | 6 ++++ src/main/resources/application-dev.yml | 10 ++++++ src/main/resources/application.yml | 11 +------ src/main/resources/mapper/NewHostsMapper.xml | 20 ++++++------ 8 files changed, 69 insertions(+), 21 deletions(-) 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}