From 4e334dca7d69cccb66fd035dfd7c3582cf26c92f Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Tue, 9 Jan 2024 17:31:14 +0800 Subject: [PATCH 01/10] =?UTF-8?q?TASK:python=E6=9C=8D=E5=8A=A1=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-prod.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 0d9913ab..ff77a4e2 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -42,7 +42,7 @@ spring.servlet.multipart.max-request-size= 5MB #access.python.ip=http://43.198.80.117 access.python.ip=http://18.167.251.121 #access.python.ip=http://18.167.251.121:9991/ -access.python.port=9991 +access.python.port=9990 minio.endpoint=https://www.minio.aida.com.hk:9000 minio.accessKey=admin From ae49f3f3a78002f32f6ec5b57d3d0d40d276ce85 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 15:25:30 +0800 Subject: [PATCH 02/10] =?UTF-8?q?TASK:docker=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c1843a76..b9bca48c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ version: "3" services: aida_back: - container_name: stable-version-aida-back + container_name: develop-version-aida-back build: . volumes: # 数据挂载 - /workspace/home/aida/file/:/workspace/home/aida/file/ ports: - - "10086:5567" \ No newline at end of file + - "10090:5567" \ No newline at end of file From 660ee9d4379588ea7ba9b81accab185ad2652d3f Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 15:41:48 +0800 Subject: [PATCH 03/10] =?UTF-8?q?TASK:=E5=85=8D=E5=AF=86=E7=99=BB=E5=BD=95?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/controller/AccountController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/ai/da/controller/AccountController.java b/src/main/java/com/ai/da/controller/AccountController.java index 4e5c54e2..d62d7335 100644 --- a/src/main/java/com/ai/da/controller/AccountController.java +++ b/src/main/java/com/ai/da/controller/AccountController.java @@ -146,7 +146,7 @@ public class AccountController { @ApiOperation(value = "查询账号到期时间") @PostMapping("/noLoginRequired") - public Response noLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO){ + public Response noLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO){ return Response.success(accountService.noLoginRequired(noLoginRequiredDTO)); } } From 324966b1c65b82c33800d2f13917cb7a1865c322 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 15:50:48 +0800 Subject: [PATCH 04/10] =?UTF-8?q?TASK:=E5=85=8D=E5=AF=86=E7=99=BB=E5=BD=95?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/controller/AccountController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/ai/da/controller/AccountController.java b/src/main/java/com/ai/da/controller/AccountController.java index 4e5c54e2..d62d7335 100644 --- a/src/main/java/com/ai/da/controller/AccountController.java +++ b/src/main/java/com/ai/da/controller/AccountController.java @@ -146,7 +146,7 @@ public class AccountController { @ApiOperation(value = "查询账号到期时间") @PostMapping("/noLoginRequired") - public Response noLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO){ + public Response noLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO){ return Response.success(accountService.noLoginRequired(noLoginRequiredDTO)); } } From ca2ed7a69cc701db7654cafbd122361840622628 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 15:59:12 +0800 Subject: [PATCH 05/10] =?UTF-8?q?TASK:=E5=85=8D=E5=AF=86=E7=99=BB=E5=BD=95?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/service/impl/AccountServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index c26aa6bf..7673fbfa 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -590,6 +590,7 @@ public class AccountServiceImpl extends ServiceImpl impl account.setIsBeginner(1); account.setIsTrial(0); account.setBrowserIdentifiers(noLoginRequiredDTO.getBrowserIdentifiers()); + account.setLanguage(Language.ENGLISH.name()); accountMapper.insert(account); return Boolean.TRUE; } From 8737350002ccb3e4e5a7861374da624dff584847 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 16:33:23 +0800 Subject: [PATCH 06/10] =?UTF-8?q?TASK:=E5=85=8D=E5=AF=86=E7=99=BB=E5=BD=95?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/security/filter/AuthenticationFilter.java | 1 + .../com/ai/da/controller/ThirdPartyController.java | 7 +++++++ src/main/java/com/ai/da/service/AccountService.java | 2 ++ .../com/ai/da/service/impl/AccountServiceImpl.java | 11 +++++++++++ 4 files changed, 21 insertions(+) diff --git a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java index 1103242c..7974a487 100644 --- a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java +++ b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java @@ -46,6 +46,7 @@ public class AuthenticationFilter extends OncePerRequestFilter { "/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId", "/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile", "/api/third/party/addNoLoginRequired","/api/third/party/deleteNoLoginRequired", + "/api/third/party/existNoLoginRequired", "/api/python/chatStream", "/api/python/flush", "/api/account/healthy" diff --git a/src/main/java/com/ai/da/controller/ThirdPartyController.java b/src/main/java/com/ai/da/controller/ThirdPartyController.java index a9db8b2a..72167882 100644 --- a/src/main/java/com/ai/da/controller/ThirdPartyController.java +++ b/src/main/java/com/ai/da/controller/ThirdPartyController.java @@ -55,4 +55,11 @@ public class ThirdPartyController { public Response deleteNoLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO) { return Response.success(accountService.deleteNoLoginRequired(noLoginRequiredDTO)); } + + @CrossOrigin + @ApiOperation(value = "add No Login Required") + @PostMapping("/existNoLoginRequired") + public Response existNoLoginRequired(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO) { + return Response.success(accountService.existNoLoginRequired(noLoginRequiredDTO)); + } } diff --git a/src/main/java/com/ai/da/service/AccountService.java b/src/main/java/com/ai/da/service/AccountService.java index b9089c54..d6c7aede 100644 --- a/src/main/java/com/ai/da/service/AccountService.java +++ b/src/main/java/com/ai/da/service/AccountService.java @@ -121,4 +121,6 @@ public interface AccountService extends IService { Boolean deleteNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO); AccountLoginVO noLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO); + + Boolean existNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO); } diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 7673fbfa..b91f406e 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -623,4 +623,15 @@ public class AccountServiceImpl extends ServiceImpl impl response.setUserId(account.getId()); return response; } + + @Override + public Boolean existNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO) { + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(Account::getBrowserIdentifiers, noLoginRequiredDTO.getBrowserIdentifiers()); + List accountList = accountMapper.selectList(qw); + if (CollectionUtil.isEmpty(accountList)) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } } From 11e231992a6f454ab7ce57be9aa3849900e1f8dc Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 16:54:20 +0800 Subject: [PATCH 07/10] =?UTF-8?q?TASK:=E5=85=8D=E5=AF=86=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=B9=B6=E5=8F=91=E4=BC=98=E5=8C=96;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/service/impl/AccountServiceImpl.java | 78 ++++++++++++++----- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index b91f406e..cf8274dc 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -569,40 +569,76 @@ public class AccountServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = Exception.class) public Boolean addNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO) { - QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().isNotNull(Account::getBrowserIdentifiers); - qw.lambda().like(Account::getUserName, "PolyU-SFT-"); - List accountList = accountMapper.selectList(qw); - if (accountList.size() >= 100) { + // 构建查询条件,查找已注册的账户数量 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().isNotNull(Account::getBrowserIdentifiers); + queryWrapper.lambda().like(Account::getUserName, "PolyU-SFT-"); + List existingAccounts = accountMapper.selectList(queryWrapper); + + // 检查注册账户数量是否超过限制 + if (existingAccounts.size() >= 100) { throw new BusinessException("The number of registered accounts exceeds the limit"); } - qw.lambda().eq(Account::getBrowserIdentifiers, noLoginRequiredDTO.getBrowserIdentifiers()); - if (!accountMapper.selectList(qw).isEmpty()) { + + // 检查浏览器标识是否已经被注册 + queryWrapper.clear(); + queryWrapper.lambda().eq(Account::getBrowserIdentifiers, noLoginRequiredDTO.getBrowserIdentifiers()); + if (!accountMapper.selectList(queryWrapper).isEmpty()) { throw new BusinessException("This browser has already been registered"); } - Account account = new Account(); - account.setUserName("PolyU-SFT-" + String.format("%03d", accountList.size() + 1)); - account.setUserPassword("Third-000000"); - account.setValidStartTime(System.currentTimeMillis()); - account.setValidEndTime(System.currentTimeMillis() + 365L * 24 * 60 * 60 * 1000); - account.setCreateDate(new Date()); - account.setIsBeginner(1); - account.setIsTrial(0); - account.setBrowserIdentifiers(noLoginRequiredDTO.getBrowserIdentifiers()); - account.setLanguage(Language.ENGLISH.name()); - accountMapper.insert(account); + + // 创建新账户 + Account newAccount = new Account(); + newAccount.setUserName("PolyU-SFT-" + String.format("%03d", existingAccounts.size() + 1)); + newAccount.setUserPassword("Third-000000"); + newAccount.setValidStartTime(System.currentTimeMillis()); + newAccount.setValidEndTime(System.currentTimeMillis() + 365L * 24 * 60 * 60 * 1000); + newAccount.setCreateDate(new Date()); + newAccount.setIsBeginner(1); + newAccount.setIsTrial(0); + newAccount.setBrowserIdentifiers(noLoginRequiredDTO.getBrowserIdentifiers()); + newAccount.setLanguage(Language.ENGLISH.name()); + + // 插入新账户 + accountMapper.insert(newAccount); + return Boolean.TRUE; } + @Override + @Transactional(rollbackFor = Exception.class) public Boolean deleteNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO) { - QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(Account::getBrowserIdentifiers, noLoginRequiredDTO.getBrowserIdentifiers()); - accountMapper.delete(qw); + // 删除将被注销的用户 + QueryWrapper queryWrapperDelete = new QueryWrapper<>(); + queryWrapperDelete.lambda().eq(Account::getBrowserIdentifiers, noLoginRequiredDTO.getBrowserIdentifiers()); + List accountList = accountMapper.selectList(queryWrapperDelete); + if (CollectionUtil.isNotEmpty(accountList)) { + Account accountDelete = accountList.get(0); + String userName = accountDelete.getUserName(); + // 查询当前浏览器标识下的所有用户,并按照用户名编号降序排序 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().isNotNull(Account::getBrowserIdentifiers); + queryWrapper.lambda().orderByDesc(Account::getUserName); + List accounts = accountMapper.selectList(queryWrapper); + + // 如果存在用户,将将被注销的用户的浏览器标识更新为用户名编号最大的用户的浏览器标识 + if (!accounts.isEmpty()) { + Account userToBeUpdate = accounts.get(0); + if (!userName.equals(userToBeUpdate.getUserName())) { + accountMapper.deleteById(accountDelete); + userToBeUpdate.setUserName(userName); + accountMapper.updateById(userToBeUpdate); + } + } + } + return Boolean.TRUE; } + @Override public AccountLoginVO noLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO) { QueryWrapper qw = new QueryWrapper<>(); From 27974e5e7c5a08d5176f98dbfa87dedef9d6a6ef Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 16:56:49 +0800 Subject: [PATCH 08/10] =?UTF-8?q?TASK:docker=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=9B=9E=E9=80=80;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b9bca48c..c1843a76 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ version: "3" services: aida_back: - container_name: develop-version-aida-back + container_name: stable-version-aida-back build: . volumes: # 数据挂载 - /workspace/home/aida/file/:/workspace/home/aida/file/ ports: - - "10090:5567" \ No newline at end of file + - "10086:5567" \ No newline at end of file From 2d73f0c4148f19f5f9cabcca1fed9563e4c07b83 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 17:27:34 +0800 Subject: [PATCH 09/10] =?UTF-8?q?TASK:=E5=85=8D=E7=99=BB=E5=BD=95;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/service/impl/AccountServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index cf8274dc..82ae2449 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -631,6 +631,8 @@ public class AccountServiceImpl extends ServiceImpl impl accountMapper.deleteById(accountDelete); userToBeUpdate.setUserName(userName); accountMapper.updateById(userToBeUpdate); + }else { + accountMapper.deleteById(accountDelete); } } } From 1c3692d03453c10853cf8f24435001be2169d696 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 15 Jan 2024 17:45:11 +0800 Subject: [PATCH 10/10] =?UTF-8?q?TASK:=E5=85=8D=E7=99=BB=E5=BD=95;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/service/impl/AccountServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 82ae2449..f66a9369 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -627,6 +627,11 @@ public class AccountServiceImpl extends ServiceImpl impl // 如果存在用户,将将被注销的用户的浏览器标识更新为用户名编号最大的用户的浏览器标识 if (!accounts.isEmpty()) { Account userToBeUpdate = accounts.get(0); + //jwt本身失效比较难做 统一用缓存实现 删除缓存就失效 + String token = LocalCacheUtils.getTokenCache(String.valueOf(accountDelete.getId())); + if (StringUtils.isNotBlank(token)) { + LocalCacheUtils.delTokenCache(String.valueOf(accountDelete.getId())); + } if (!userName.equals(userToBeUpdate.getUserName())) { accountMapper.deleteById(accountDelete); userToBeUpdate.setUserName(userName);