From 472f5e65b4f2da8566e3729b8ec8d5afe2899d6f Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 13 Sep 2024 11:13:23 +0800 Subject: [PATCH 1/8] =?UTF-8?q?TASK:=E5=87=AD=E8=AF=81=E6=9B=B4=E6=96=B0;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/controller/ThirdPartyController.java | 7 +++ .../com/ai/da/service/AccountService.java | 2 + .../da/service/impl/AccountServiceImpl.java | 51 +++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/src/main/java/com/ai/da/controller/ThirdPartyController.java b/src/main/java/com/ai/da/controller/ThirdPartyController.java index 1f4f64c3..4b89d32b 100644 --- a/src/main/java/com/ai/da/controller/ThirdPartyController.java +++ b/src/main/java/com/ai/da/controller/ThirdPartyController.java @@ -107,4 +107,11 @@ public class ThirdPartyController { public Response getRedirectUrl() { return Response.success(REDIRECT_URL); } + + @CrossOrigin + @ApiOperation(value = "add No Login Required") + @PostMapping("/updateNoLoginRequiredNew") + public Response updateNoLoginRequiredNew(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request) { + return Response.success(accountService.updateNoLoginRequiredNew(noLoginRequiredDTO, request)); + } } diff --git a/src/main/java/com/ai/da/service/AccountService.java b/src/main/java/com/ai/da/service/AccountService.java index a6a39011..40cd6a74 100644 --- a/src/main/java/com/ai/da/service/AccountService.java +++ b/src/main/java/com/ai/da/service/AccountService.java @@ -157,4 +157,6 @@ public interface AccountService extends IService { IPage getPageByIds(List ids, int pageNum, int size); List getByIds(List ids); + + String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request); } 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 ac8e0071..dd135b14 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -875,6 +875,57 @@ public class AccountServiceImpl extends ServiceImpl impl "                        "; } + @Override + @Transactional(rollbackFor = Exception.class) + public String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request) { + // 验证机房注册序列号(001-100) + String id = noLoginRequiredDTO.getId(); + if (!isStringInRange(id)) { + throw new BusinessException("Illegal serial number."); + } + // 获取真实 IP 地址,考虑了经过代理的情况 + String ipAddress = request.getHeader("X-Forwarded-For"); + if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("WL-Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getRemoteAddr(); + } + String browserIdentifiers = ipAddress + "," + id; + // 构建查询条件,查找已注册的账户数量 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(Account::getUserName, "PolyU-SFT-" + id); +// queryWrapper.lambda().eq(Account::getBrowserIdentifiers, browserIdentifiers); + List existingAccounts = accountMapper.selectList(queryWrapper); + + // 检查序列号是否被注册 + if (!CollectionUtil.isNotEmpty(existingAccounts)) { + throw new BusinessException("Updated serial number not found."); + } + + Account account = existingAccounts.get(0); + account.setBrowserIdentifiers(browserIdentifiers); + accountMapper.updateById(account); + + return "\n" + + "                        \n" + + "                        \n" + + "                            \n" + + "                            \n" + + "                            Document\n" + + " \n" + + "                        \n" + + "                        \n" + + "                        \n" + + "                            \n" + + "                        "; + } + public static boolean isStringInRange(String input) { // 去除字符串两端的空格 input = input.trim(); From 32975d9900371cce9c5cae6b0eb07a6a20602923 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 13 Sep 2024 11:16:17 +0800 Subject: [PATCH 2/8] =?UTF-8?q?TASK:=E9=93=BE=E6=8E=A5=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E8=AF=95=E7=94=A8;?= 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 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 dd135b14..2e876f98 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -546,7 +546,7 @@ public class AccountServiceImpl extends ServiceImpl impl account.setSystemUser(3); account.setValidStartTime(System.currentTimeMillis()); if (link) { - account.setValidEndTime(toDayEnd(Instant.now().plus(14, ChronoUnit.DAYS).toEpochMilli())); + account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli())); } else { account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli())); } @@ -558,7 +558,7 @@ public class AccountServiceImpl extends ServiceImpl impl account.setLanguage(Language.ENGLISH.name()); account.setValidStartTime(System.currentTimeMillis()); if (link) { - account.setValidEndTime(toDayEnd(Instant.now().plus(14, ChronoUnit.DAYS).toEpochMilli())); + account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli())); } else { account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli())); } From 40f5705e7aef9b61530649b81ca79276a571e190 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 13 Sep 2024 11:24:14 +0800 Subject: [PATCH 3/8] =?UTF-8?q?TASK:=E5=87=AD=E8=AF=81=E6=9B=B4=E6=96=B0;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/da/common/security/filter/AuthenticationFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0f61d591..8d10a58a 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,7 +46,7 @@ public class AuthenticationFilter extends OncePerRequestFilter { "/webjars/", "/swagger-resources", "/v2/api-docs", "api/account/resetPwd", "/api/python/saveGeneratePicture", "/api/python/getLibraryByUserId", "/api/third/party/addUser","/api/third/party/addTrialUser", "/api/third/party/editUser", "/api/element/initDefaultSysFile", - "/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew", + "/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew","/api/third/party/updateNoLoginRequiredNew", "/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl", "/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify", "/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease", From c5e9941adb6cdb5cd5eb207493962acc2360e450 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 20 Sep 2024 11:31:48 +0800 Subject: [PATCH 4/8] =?UTF-8?q?BUGFIX:design=20colorboard=E5=85=83?= =?UTF-8?q?=E7=B4=A0=E6=B7=B7=E5=85=A5sketchboard;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/CollectionElementServiceImpl.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java index 521b4ab0..222fdbf5 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java @@ -78,6 +78,9 @@ public class CollectionElementServiceImpl extends ServiceImpl sketchBoards) { if (CollectionUtil.isNotEmpty(sketchBoards)) { - sketchBoards.forEach(sketchBoard -> { + List collect = sketchBoards.stream().filter(o -> o.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName())).collect(Collectors.toList()); + collect.forEach(sketchBoard -> { CollectionElement collectionElement = CopyUtil.copyObject(sketchBoard, CollectionElement.class); collectionElement.setHasPin(sketchBoard.getIsPin()); collectionElement.setId(sketchBoard.getSketchBoardId()); collectionElementMapper.updateById(collectionElement); }); - List sketchBoardIds = sketchBoards.stream().map(CollectionSketchDTO::getSketchBoardId).collect(Collectors.toList()); - List sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds); - elementVO.setSketchBoardElements(sketchBoardElements); + List sketchBoardIds = collect.stream().map(CollectionSketchDTO::getSketchBoardId).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(sketchBoardIds)) { + List sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds); + elementVO.setSketchBoardElements(sketchBoardElements); + }else { + elementVO.setSketchBoardElements(new ArrayList<>()); + } } } @Override public void editPrintBoardsElement(ValidateElementVO elementVO, List printBoards) { if (CollectionUtil.isNotEmpty(printBoards)) { - printBoards.forEach(printBoard -> { + List collect = printBoards.stream().filter(o -> o.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName())).collect(Collectors.toList()); + collect.forEach(printBoard -> { CollectionElement collectionElement = CopyUtil.copyObject(printBoard, CollectionElement.class); collectionElement.setHasPin(Objects.isNull(printBoard.getIsPin()) ? 0 : printBoard.getIsPin()); collectionElement.setId(printBoard.getId()); collectionElementMapper.updateById(collectionElement); }); - List printBoardIds = printBoards.stream().map(DesignCollectionPrintElementDTO::getId).collect(Collectors.toList()); - List printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds); - elementVO.setPrintBoardElements(printBoardElements); + List printBoardIds = collect.stream().map(DesignCollectionPrintElementDTO::getId).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(printBoardIds)) { + List printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds); + elementVO.setPrintBoardElements(printBoardElements); + }else { + elementVO.setPrintBoardElements(new ArrayList<>()); + } } } From 4304acbe6f95befbf8c3468f4be3455fd4152624 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Tue, 24 Sep 2024 14:37:22 +0800 Subject: [PATCH 5/8] =?UTF-8?q?BUGFIX:=E4=BD=9C=E5=93=81=E5=B9=BF=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/service/impl/PortfolioServiceImpl.java | 74 ++++++++++++++----- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java b/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java index 0fba4ddb..0ca763d2 100644 --- a/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java @@ -421,9 +421,13 @@ public class PortfolioServiceImpl extends ServiceImpl page(QueryPortfolioPageDTO query) { AuthPrincipalVo userHolder = UserContext.getUserHolder(); QueryWrapper qw = new QueryWrapper<>(); + + // 查询用户的作品集 if (query.getGetMyPortfolio() == 1) { qw.lambda().eq(Portfolio::getAccountId, userHolder.getId()); } + + // 查询用户喜欢的作品集 if (query.getGetLikePortfolio() == 1) { List likedPortfolioIdList = redisUtil.getLikedPortfolios(userHolder.getId()); if (!CollectionUtils.isEmpty(likedPortfolioIdList)) { @@ -432,31 +436,54 @@ public class PortfolioServiceImpl extends ServiceImpl()); } } - List topThree = new ArrayList<>(); - if (query.getPage() == 1 && - (query.getGetMyPortfolio() != 1 || query.getGetLikePortfolio() != 1)) { + List topThree = new ArrayList<>(); + List excludeIds = new ArrayList<>(); // 存放需要排除的 ID 列表 + + // 获取前三点赞和前三浏览的作品集,并将其排除在分页查询之外 + if (query.getPage() == 1 && (query.getGetMyPortfolio() != 1 || query.getGetLikePortfolio() != 1)) { + // 获取前三点赞的作品集 ID List topThreeLike = getTopThreeLikeFromRedis(RedisUtil.PORTFOLIO_LIKE_KEY); - log.info("top three like 的作品集的id : {}", topThreeLike); - List topThreeView = getTopThreeViewFromRedis(RedisUtil.PORTFOLIO_VIEW_KEY); - log.info("top three view 的作品集的id : {}", topThreeView); - QueryWrapper queryLike = new QueryWrapper<>(); - queryLike.in("id", topThreeLike); - QueryWrapper queryView = new QueryWrapper<>(); - queryView.in("id", topThreeView); - List topThreeLikePortfolio = baseMapper.selectList(queryLike); - List topThreeViewPortfolio = baseMapper.selectList(queryView); - topThree.addAll(topThreeLikePortfolio); - topThree.addAll(topThreeViewPortfolio); + List topThreeView = getTopThreeViewFromRedis(RedisUtil.PORTFOLIO_VIEW_KEY, topThreeLike); + + // 获取前三点赞的作品集 + if (!CollectionUtils.isEmpty(topThreeLike)) { + QueryWrapper queryLike = new QueryWrapper<>(); + queryLike.in("id", topThreeLike); + List topThreeLikePortfolio = baseMapper.selectList(queryLike); + topThree.addAll(topThreeLikePortfolio); + excludeIds.addAll(topThreeLike); // 添加到排除 ID 列表 + } + + // 获取前三浏览的作品集 + if (!CollectionUtils.isEmpty(topThreeView)) { + QueryWrapper queryView = new QueryWrapper<>(); + queryView.in("id", topThreeView); + List topThreeViewPortfolio = baseMapper.selectList(queryView); + topThree.addAll(topThreeViewPortfolio); + excludeIds.addAll(topThreeView); // 添加到排除 ID 列表 + } } + // 在正常分页查询中排除前三点赞和前三浏览的作品集 + if (!CollectionUtils.isEmpty(excludeIds)) { + qw.lambda().notIn(Portfolio::getId, excludeIds); + } + + // 按更新时间排序 qw.lambda().orderByDesc(Portfolio::getUpdateDate); + + // 执行分页查询 IPage page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw); + + // 如果前三点赞和浏览不为空,将它们添加到分页查询的结果最前面 if (!topThree.isEmpty()) { List records = page.getRecords(); - records.addAll(0, topThree); + records.addAll(0, topThree); // 添加到查询结果的开头 page.setRecords(records); } + + // 将 Portfolio 转换为 PortfolioVO 并进行相关处理 IPage convert = page.convert((Function) portfolio -> { if (portfolio != null) { PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class); @@ -473,9 +500,11 @@ public class PortfolioServiceImpl extends ServiceImpl getTopThreeViewFromRedis(String prefix) { + private List getTopThreeViewFromRedis(String prefix, List excludeIds) { // Step 1: Get all keys with the specific prefix Set keys = redisUtil.getKeysFromString(prefix + "*"); -// Step 2: Create a map to store portfolioId and its corresponding value + + // Step 2: Create a map to store portfolioId and its corresponding value Map portfolioViews = new HashMap<>(); if (keys != null) { for (String key : keys) { @@ -992,11 +1022,15 @@ public class PortfolioServiceImpl extends ServiceImpl top3PortfolioIds = portfolioViews.entrySet().stream() .sorted(Map.Entry.comparingByValue().reversed()) @@ -1004,7 +1038,7 @@ public class PortfolioServiceImpl extends ServiceImpl Date: Tue, 24 Sep 2024 15:20:24 +0800 Subject: [PATCH 6/8] =?UTF-8?q?TASK:=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/da/common/task/MoveDataScheduler.java | 216 ++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 src/main/java/com/ai/da/common/task/MoveDataScheduler.java diff --git a/src/main/java/com/ai/da/common/task/MoveDataScheduler.java b/src/main/java/com/ai/da/common/task/MoveDataScheduler.java new file mode 100644 index 00000000..759a9067 --- /dev/null +++ b/src/main/java/com/ai/da/common/task/MoveDataScheduler.java @@ -0,0 +1,216 @@ +//package com.ai.da.common.task; +// +//import com.ai.da.common.utils.CopyUtil; +//import com.ai.da.common.utils.ExcelReader; +//import com.ai.da.common.utils.MinioUtil; +//import com.ai.da.common.utils.SendEmailUtil; +//import com.ai.da.mapper.primary.*; +//import com.ai.da.mapper.primary.entity.*; +//import com.ai.da.mapper.secondary.AttributeRetrievalMapper; +//import com.ai.da.mapper.third.*; +//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +//import org.apache.commons.lang3.StringUtils; +//import org.apache.poi.ss.usermodel.Row; +//import org.apache.poi.ss.usermodel.Sheet; +//import org.apache.poi.ss.usermodel.Workbook; +//import org.apache.poi.xssf.usermodel.XSSFWorkbook; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import javax.annotation.PostConstruct; +//import javax.annotation.Resource; +//import java.io.FileOutputStream; +//import java.io.IOException; +//import java.nio.file.Files; +//import java.nio.file.Paths; +//import java.time.LocalDate; +//import java.time.format.DateTimeFormatter; +//import java.util.List; +//import java.util.concurrent.ExecutorService; +//import java.util.concurrent.Executors; +//import java.util.concurrent.TimeUnit; +//import java.util.stream.Collectors; +// +//@Component +//public class MoveDataScheduler { +// +// @PostConstruct +// public void test() { +// moveData(); +// } +// +// @Resource +// private UserLikeGroupMapper userLikeGroupMapper; +// @Resource +// private UserLikeGroupZSMapper userLikeGroupZSMapper; +// @Resource +// private UserLikeMapper userLikeMapper; +// @Resource +// private UserLikeZSMapper userLikeZSMapper; +// @Resource +// private CollectionElementMapper collectionElementMapper; +// @Resource +// private CollectionElementZSMapper collectionElementZSMapper; +// +// @Resource +// private CollectionMapper collectionMapper; +// +// @Resource +// private CollectionZSMapper collectionZSMapper; +// +// @Resource +// private DesignMapper designMapper; +// +// @Resource +// private DesignZSMapper designZSMapper; +// +// @Resource +// private DesignItemMapper designItemMapper; +// +// @Resource +// private DesignItemZSMapper designItemZSMapper; +// +// @Resource +// private TDesignPythonOutfitMapper designPythonOutfitMapper; +// +// @Resource +// private TDesignPythonOutfitZSMapper designPythonOutfitZSMapper; +// +// @Resource +// private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper; +// +// @Resource +// private TDesignPythonOutfitDetailZSMapper designPythonOutfitDetailZSMapper; +// +// @Resource +// private DesignItemDetailMapper designItemDetailMapper; +// @Resource +// private DesignItemZSDetailMapper designItemDetailZSMapper; +// +// @Resource +// private DesignItemDetailPrintMapper designItemDetailPrintMapper; +// +// @Resource +// private DesignItemDetailPrintZSMapper designItemDetailPrintZSMapper; +// +// +// private void moveData() { +// // 查询用户所有history记录 +// QueryWrapper userLikeGroupQueryWrapper = new QueryWrapper<>(); +// userLikeGroupQueryWrapper.lambda().eq(UserLikeGroup::getAccountId, 11411); +// List userLikeGroupList = userLikeGroupMapper.selectList(userLikeGroupQueryWrapper); +// +// for (UserLikeGroup userLikeGroup : userLikeGroupList) { +// +// com.ai.da.mapper.third.entity.UserLikeGroup userLikeGroupZS = CopyUtil.copyObject(userLikeGroup, com.ai.da.mapper.third.entity.UserLikeGroup.class); +// userLikeGroupZS.setAccountId(11420L); +// userLikeGroupZS.setId(null); +// Collection collection = collectionMapper.selectById(userLikeGroup.getCollectionId()); +// com.ai.da.mapper.third.entity.Collection collectionZS = CopyUtil.copyObject(collection, com.ai.da.mapper.third.entity.Collection.class); +// collectionZS.setAccountId(11420L); +// collectionZS.setId(null); +// +// if (collection.getMoodTemplateId() != null) { +// CollectionElement element = collectionElementMapper.selectById(collection.getMoodTemplateId()); +// com.ai.da.mapper.third.entity.CollectionElement collectionElementZS = CopyUtil.copyObject(element, com.ai.da.mapper.third.entity.CollectionElement.class); +// collectionElementZS.setAccountId(11420L); +// collectionElementZS.setId(null); +// collectionElementZSMapper.insert(collectionElementZS); +// collectionZS.setMoodTemplateId(String.valueOf(collectionElementZS.getId())); +// } +// collectionZSMapper.insert(collectionZS); +// userLikeGroupZS.setCollectionId(collectionZS.getId()); +// userLikeGroupZSMapper.insert(userLikeGroupZS); +// +// // 生成元素 +// QueryWrapper collectionElementQueryWrapper = new QueryWrapper<>(); +// collectionElementQueryWrapper.lambda().eq(CollectionElement::getCollectionId, userLikeGroup.getCollectionId()); +// List collectionElements = collectionElementMapper.selectList(collectionElementQueryWrapper); +// +// for (CollectionElement collectionElement : collectionElements) { +// com.ai.da.mapper.third.entity.CollectionElement collectionElementZS = CopyUtil.copyObject(collectionElement, com.ai.da.mapper.third.entity.CollectionElement.class); +// collectionElementZS.setId(null); +// collectionElementZS.setAccountId(11420L); +// collectionElementZS.setCollectionId(collectionZS.getId()); +// collectionElementZSMapper.insert(collectionElementZS); +// } +// +// // 查询记录关联 +// QueryWrapper userLikeQueryWrapper = new QueryWrapper<>(); +// userLikeQueryWrapper.lambda().eq(UserLike::getUserLikeGroupId, userLikeGroup.getId()); +// List userLikes = userLikeMapper.selectList(userLikeQueryWrapper); +// for (UserLike userLike : userLikes) { +// Design design = designMapper.selectById(userLike.getDesignId()); +// com.ai.da.mapper.third.entity.Design designZS = CopyUtil.copyObject(design, com.ai.da.mapper.third.entity.Design.class); +// designZS.setId(null); +// designZS.setAccountId(11420L); +// designZS.setCollectionId(collectionZS.getId()); +// designZSMapper.insert(designZS); +// +// com.ai.da.mapper.third.entity.UserLike userLikeZS = CopyUtil.copyObject(userLike, com.ai.da.mapper.third.entity.UserLike.class); +//// Design design = designMapper.selectById(userLike.getDesignId()); +// userLikeZS.setId(null); +// DesignItem designItem = designItemMapper.selectById(userLike.getDesignItemId()); +// com.ai.da.mapper.third.entity.DesignItem designItemZS = CopyUtil.copyObject(designItem, com.ai.da.mapper.third.entity.DesignItem.class); +// designItemZS.setId(null); +// designItemZS.setAccountId(11420L); +// designItemZS.setDesignId(designZS.getId()); +// designItemZSMapper.insert(designItemZS); +// +// QueryWrapper designItemDetailQueryWrapper = new QueryWrapper<>(); +// designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItem.getId()); +// List designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper); +// for (DesignItemDetail designItemDetail : designItemDetails) { +// com.ai.da.mapper.third.entity.DesignItemDetail designItemDetailZS = CopyUtil.copyObject(designItemDetail, com.ai.da.mapper.third.entity.DesignItemDetail.class); +// designItemDetailZS.setId(null); +// designItemDetailZS.setDesignItemId(designItemZS.getId()); +// designItemDetailZS.setAccountId(11420L); +// designItemDetailZS.setDesignId(designZS.getId()); +// designItemDetailZSMapper.insert(designItemDetailZS); +// +// QueryWrapper designItemDetailPrintQueryWrapper = new QueryWrapper<>(); +// designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetail.getId()); +// List designItemDetailPrintList = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper); +// if (!CollectionUtils.isEmpty(designItemDetailPrintList)) { +// for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) { +// com.ai.da.mapper.third.entity.DesignItemDetailPrint designItemDetailPrintZS = CopyUtil.copyObject(designItemDetailPrint, com.ai.da.mapper.third.entity.DesignItemDetailPrint.class); +// designItemDetailPrintZS.setId(null); +// designItemDetailPrintZS.setDesignItemDetailId(designItemDetailZS.getId()); +// designItemDetailPrintZSMapper.insert(designItemDetailPrintZS); +// } +// } +// } +// +// userLikeZS.setDesignItemId(designItemZS.getId()); +// TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId()); +// com.ai.da.mapper.third.entity.TDesignPythonOutfit tDesignPythonOutfitZS = CopyUtil.copyObject(tDesignPythonOutfit, com.ai.da.mapper.third.entity.TDesignPythonOutfit.class); +// tDesignPythonOutfitZS.setId(null); +// tDesignPythonOutfitZS.setDesignItemId(designItemZS.getId()); +// tDesignPythonOutfitZS.setCollectionId(collectionZS.getId()); +// tDesignPythonOutfitZS.setUserId(11420L); +// tDesignPythonOutfitZS.setDesignId(designZS.getId()); +// designPythonOutfitZSMapper.insert(tDesignPythonOutfitZS); +// +// userLikeZS.setUserLikeGroupId(userLikeGroupZS.getId()); +// userLikeZS.setDesignId(designZS.getId()); +// userLikeZS.setDesignOutfitId(tDesignPythonOutfitZS.getId()); +// userLikeZSMapper.insert(userLikeZS); +// +// QueryWrapper designPythonOutfitDetailQueryWrapper = new QueryWrapper<>(); +// designPythonOutfitDetailQueryWrapper.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, tDesignPythonOutfit.getId()); +// List tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(designPythonOutfitDetailQueryWrapper); +// for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) { +// com.ai.da.mapper.third.entity.TDesignPythonOutfitDetail tDesignPythonOutfitDetailZS = CopyUtil.copyObject(tDesignPythonOutfitDetail, com.ai.da.mapper.third.entity.TDesignPythonOutfitDetail.class); +// tDesignPythonOutfitDetailZS.setDesignPythonOutfitId(tDesignPythonOutfitZS.getId()); +// tDesignPythonOutfitDetailZS.setId(null); +// tDesignPythonOutfitDetailZS.setDesignId(designZS.getId()); +// designPythonOutfitDetailZSMapper.insert(tDesignPythonOutfitDetailZS); +// } +// } +// } +// +// +// } +// +// +//} From 41ffe335fcc6e317ea7844865c08ab5c3dceef5d Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Tue, 24 Sep 2024 15:43:37 +0800 Subject: [PATCH 7/8] =?UTF-8?q?TASK:mq=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/da/common/RabbitMQ/MQConfig.java | 66 ++++++++++++------- src/main/resources/application-dev.properties | 11 +++- .../resources/application-prod.properties | 11 +++- .../resources/application-test.properties | 11 +++- 4 files changed, 73 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java b/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java index 5442ae06..cc1076be 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java @@ -1,37 +1,57 @@ package com.ai.da.common.RabbitMQ; import org.springframework.amqp.core.Queue; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import javax.annotation.PostConstruct; + @Configuration public class MQConfig { - public static final String GENERATE_EXCHANGE_FANOUT = "generate-exchange"; - // public static final String GENERATE_QUEUE = "generate-queue-prod"; -// public static final String GENERATE_QUEUE = "generate-queue-test"; -// ================================================================== -// public static final String GENERATE_QUEUE = "generate-queue-local"; -// public static final String GENERATE_QUEUE = "generate-queue-dev"; - public static final String GENERATE_QUEUE = "generate-queue-prod"; -// -// public static final String SR_QUEUE = "SR-queue-local"; -// public static final String SR_QUEUE = "SR-queue-dev"; - public static final String SR_QUEUE = "SR-queue-prod"; -// -// public static final String SR_RESULT_QUEUE = "SuperResolution-local"; -// public static final String SR_RESULT_QUEUE = "SuperResolution-dev"; - public static final String SR_RESULT_QUEUE = "SuperResolution-prod"; -// -// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local"; -// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev"; - public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod"; + // 定义为非静态变量 + @Value("${generate.exchange}") + private String generateExchange; -// public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-dev"; - public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-prod"; + @Value("${generate.queue}") + private String generateQueue; -// public static final String RELIGHT_RESULT_QUEUE = "Relight-dev"; - public static final String RELIGHT_RESULT_QUEUE = "Relight-prod"; + @Value("${sr.queue}") + private String srQueue; + + @Value("${sr.result.queue}") + private String srResultQueue; + + @Value("${generate.result.queue}") + private String generateResultQueue; + + @Value("${to.product.image.result.queue}") + private String toProductImageResultQueue; + + @Value("${relight.result.queue}") + private String relightResultQueue; + + // 定义静态变量以供外部访问 + public static String GENERATE_EXCHANGE; + public static String GENERATE_QUEUE; + public static String SR_QUEUE; + public static String SR_RESULT_QUEUE; + public static String GENERATE_RESULT_QUEUE; + public static String TO_PRODUCT_IMAGE_RESULT_QUEUE; + public static String RELIGHT_RESULT_QUEUE; + + // 使用 @PostConstruct 在 bean 初始化之后,将实例变量值赋给静态变量 + @PostConstruct + public void init() { + GENERATE_EXCHANGE = this.generateExchange; + GENERATE_QUEUE = this.generateQueue; + SR_QUEUE = this.srQueue; + SR_RESULT_QUEUE = this.srResultQueue; + GENERATE_RESULT_QUEUE = this.generateResultQueue; + TO_PRODUCT_IMAGE_RESULT_QUEUE = this.toProductImageResultQueue; + RELIGHT_RESULT_QUEUE = this.relightResultQueue; + } public MQConfig() { } diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 5beb50fd..1ca92a3e 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -92,4 +92,13 @@ redis.key.relightResultKey=Relight:Result aws.s3.accessKeyId=AKIAVD3OJIMF6UJFLSHZ aws.s3.secretKey=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 -aws.s3.regionName=ap-east-1 \ No newline at end of file +aws.s3.regionName=ap-east-1 + +# RabbitMQ Exchange and Queue configurations +generate.exchange=generate-exchange +generate.queue=generate-queue-dev +sr.queue=SR-queue-dev +sr.result.queue=SuperResolution-dev +generate.result.queue=GenerateImage-dev +to.product.image.result.queue=ToProductImage-dev +relight.result.queue=Relight-dev \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 4cdf0386..7c9ee94c 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -93,4 +93,13 @@ redis.key.relightResultKey=Relight:Result aws.s3.accessKeyId=AKIAVD3OJIMF6UJFLSHZ aws.s3.secretKey=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 -aws.s3.regionName=ap-east-1 \ No newline at end of file +aws.s3.regionName=ap-east-1 + +# RabbitMQ Exchange and Queue configurations +generate.exchange=generate-exchange +generate.queue=generate-queue-prod +sr.queue=SR-queue-prod +sr.result.queue=SuperResolution-prod +generate.result.queue=GenerateImage-prod +to.product.image.result.queue=ToProductImage-prod +relight.result.queue=Relight-prod \ No newline at end of file diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties index 423031ff..31ccb6a6 100644 --- a/src/main/resources/application-test.properties +++ b/src/main/resources/application-test.properties @@ -85,4 +85,13 @@ redis.key.SRCancelSet=SRCancelSet redis.key.SRExceptionMap=SRExceptionMap redis.key.taskList=TaskList redis.key.credits.pre-deduction=Credits:PreDeduction -redis.key.generateResult=Generate:Result \ No newline at end of file +redis.key.generateResult=Generate:Result + +# RabbitMQ Exchange and Queue configurations +generate.exchange=generate-exchange +generate.queue=generate-queue-test +sr.queue=SR-queue-test +sr.result.queue=SuperResolution-test +generate.result.queue=GenerateImage-test +to.product.image.result.queue=ToProductImage-test +relight.result.queue=Relight-test \ No newline at end of file From deda511e325e0b6bd20e2ec65baa2307eebeb2f1 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 27 Sep 2024 16:43:02 +0800 Subject: [PATCH 8/8] TASK:aida; --- .../da/common/RabbitMQ/GenerateConsumer.java | 28 ++++--- .../com/ai/da/common/RabbitMQ/MQConfig.java | 84 +++++-------------- .../ai/da/common/RabbitMQ/MQPublisher.java | 15 ++-- .../common/RabbitMQ/RabbitMQProperties.java | 30 +++++++ .../com/ai/da/common/RabbitMQ/SRConsumer.java | 9 +- src/main/resources/application-dev.properties | 14 ++-- .../resources/application-prod.properties | 14 ++-- .../resources/application-test.properties | 18 ++-- 8 files changed, 104 insertions(+), 108 deletions(-) create mode 100644 src/main/java/com/ai/da/common/RabbitMQ/RabbitMQProperties.java diff --git a/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java b/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java index 0c5ea013..423c5892 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java @@ -14,6 +14,7 @@ import org.apache.tomcat.jni.Time; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -30,6 +31,9 @@ public class GenerateConsumer { @Resource private GenerateService generateService; + @Autowired + private RabbitMQProperties rabbitMQProperties; + @Resource private RedisUtil redisUtil; @@ -243,73 +247,73 @@ public class GenerateConsumer { log.info("============ProcessRelightResult End listening=========="); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer1(Message msg, Channel channel) { generate(msg, channel, "consumer 1"); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer2(Message msg, Channel channel) { generate(msg, channel, "consumer 2"); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer3(Message msg, Channel channel) { generate(msg, channel, "consumer 3"); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer4(Message msg, Channel channel) { generate(msg, channel, "consumer 4"); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer5(Message msg, Channel channel) { generate(msg, channel, "consumer 5"); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer6(Message msg, Channel channel) { generate(msg, channel, "consumer 6"); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer7(Message msg, Channel channel) { generate(msg, channel, "consumer 7"); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer8(Message msg, Channel channel) { generate(msg, channel, "consumer 8"); } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generate}") @RabbitHandler public void generateConsumer9(Message msg, Channel channel) { generate(msg, channel, "consumer 9"); } - @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.generateResult}") @RabbitHandler public void getGenerateResult(Message msg, Channel channel) { processGenerateResult(msg, channel); } - @RabbitListener(queues = MQConfig.TO_PRODUCT_IMAGE_RESULT_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.toProductImageResult}") @RabbitHandler public void getToProductImageResult(Message msg, Channel channel) { processToProductImageResult(msg, channel); } - @RabbitListener(queues = MQConfig.RELIGHT_RESULT_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.relightResult}") @RabbitHandler public void getRelightResult(Message msg, Channel channel) { processRelightResult(msg, channel); diff --git a/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java b/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java index cc1076be..493c5a61 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/MQConfig.java @@ -1,89 +1,43 @@ package com.ai.da.common.RabbitMQ; import org.springframework.amqp.core.Queue; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import javax.annotation.PostConstruct; - @Configuration public class MQConfig { - // 定义为非静态变量 - @Value("${generate.exchange}") - private String generateExchange; + @Autowired + private RabbitMQProperties rabbitMQProperties; - @Value("${generate.queue}") - private String generateQueue; - - @Value("${sr.queue}") - private String srQueue; - - @Value("${sr.result.queue}") - private String srResultQueue; - - @Value("${generate.result.queue}") - private String generateResultQueue; - - @Value("${to.product.image.result.queue}") - private String toProductImageResultQueue; - - @Value("${relight.result.queue}") - private String relightResultQueue; - - // 定义静态变量以供外部访问 - public static String GENERATE_EXCHANGE; - public static String GENERATE_QUEUE; - public static String SR_QUEUE; - public static String SR_RESULT_QUEUE; - public static String GENERATE_RESULT_QUEUE; - public static String TO_PRODUCT_IMAGE_RESULT_QUEUE; - public static String RELIGHT_RESULT_QUEUE; - - // 使用 @PostConstruct 在 bean 初始化之后,将实例变量值赋给静态变量 - @PostConstruct - public void init() { - GENERATE_EXCHANGE = this.generateExchange; - GENERATE_QUEUE = this.generateQueue; - SR_QUEUE = this.srQueue; - SR_RESULT_QUEUE = this.srResultQueue; - GENERATE_RESULT_QUEUE = this.generateResultQueue; - TO_PRODUCT_IMAGE_RESULT_QUEUE = this.toProductImageResultQueue; - RELIGHT_RESULT_QUEUE = this.relightResultQueue; - } - public MQConfig() { - } - -// @Bean -// FanoutExchange fanoutRasaExchange() { -// return new FanoutExchange(GENERATE_EXCHANGE_FANOUT); -// } - - /** - * 创建队列,使用工作模式,不用定义交换机 - */ @Bean public Queue generateQueue() { - return new Queue(GENERATE_QUEUE); + return new Queue(rabbitMQProperties.getQueues().getGenerate()); } @Bean public Queue SRQueue() { - return new Queue(SR_QUEUE); + return new Queue(rabbitMQProperties.getQueues().getSr()); } @Bean public Queue SRResultQueue() { - return new Queue(SR_RESULT_QUEUE); + return new Queue(rabbitMQProperties.getQueues().getSrResult()); } - /** - * 将队列绑定到交换机上【队列订阅交换机】 - */ -// @Bean -// Binding bindingExchangeRasa() { -// return BindingBuilder.bind(queueRasa()).to(fanoutRasaExchange()); -// } + @Bean + public Queue generateResultQueue() { + return new Queue(rabbitMQProperties.getQueues().getGenerateResult()); + } + @Bean + public Queue toProductImageResultQueue() { + return new Queue(rabbitMQProperties.getQueues().getToProductImageResult()); + } + + @Bean + public Queue relightResultQueue() { + return new Queue(rabbitMQProperties.getQueues().getRelightResult()); + } } diff --git a/src/main/java/com/ai/da/common/RabbitMQ/MQPublisher.java b/src/main/java/com/ai/da/common/RabbitMQ/MQPublisher.java index 5cffa019..56b4b724 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/MQPublisher.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/MQPublisher.java @@ -2,6 +2,7 @@ package com.ai.da.common.RabbitMQ; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.AmqpTemplate; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -10,19 +11,19 @@ import javax.annotation.Resource; @Component public class MQPublisher { -// private final String url = "http://localhost:15672/api/queues/%2f/generate-queue"; + @Autowired + private RabbitMQProperties rabbitMQProperties; - @Resource + @Autowired private AmqpTemplate amqpTemplate; public void sendGenerateMessage(String mm) { - log.info("send message:" + mm); - amqpTemplate.convertAndSend(MQConfig.GENERATE_QUEUE, mm); + log.info("send message: " + mm); + amqpTemplate.convertAndSend(rabbitMQProperties.getQueues().getGenerate(), mm); } public void sendSRMessage(String mm) { - log.info("send message:" + mm); - amqpTemplate.convertAndSend(MQConfig.SR_QUEUE, mm); + log.info("send message: " + mm); + amqpTemplate.convertAndSend(rabbitMQProperties.getQueues().getSr(), mm); } - } diff --git a/src/main/java/com/ai/da/common/RabbitMQ/RabbitMQProperties.java b/src/main/java/com/ai/da/common/RabbitMQ/RabbitMQProperties.java new file mode 100644 index 00000000..29a2e1de --- /dev/null +++ b/src/main/java/com/ai/da/common/RabbitMQ/RabbitMQProperties.java @@ -0,0 +1,30 @@ +package com.ai.da.common.RabbitMQ; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "rabbitmq") +@Data +public class RabbitMQProperties { + + private Queues queues; + private Exchange exchange; + + @Data + public static class Queues { + private String generate; + private String sr; + private String srResult; + private String generateResult; + private String toProductImageResult; + private String relightResult; + } + + @Data + public static class Exchange { + private String generate; + } +} + diff --git a/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java b/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java index 6ad261bd..0bd56344 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java @@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -27,6 +28,9 @@ import java.util.HashMap; @Component public class SRConsumer { + @Autowired + private RabbitMQProperties rabbitMQProperties; + @Resource private RedisUtil redisUtil; @@ -218,14 +222,13 @@ public class SRConsumer { taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null); } - @RabbitListener(queues = MQConfig.SR_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.sr}") @RabbitHandler public void SRConsumer1(Message msg, Channel channel) { superResolution(msg, channel, "consumer 1"); } - - @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE) + @RabbitListener(queues = "#{rabbitMQProperties.queues.srResult}") @RabbitHandler public void SRResultConsumer1(Message msg, Channel channel) { getSRResult(msg, channel, "consumer 1"); diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 1ca92a3e..90757816 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -95,10 +95,10 @@ aws.s3.secretKey=LNIwFFB27/QedtZ+Q/viVUoX9F5x1DbuM8N0DkD8 aws.s3.regionName=ap-east-1 # RabbitMQ Exchange and Queue configurations -generate.exchange=generate-exchange -generate.queue=generate-queue-dev -sr.queue=SR-queue-dev -sr.result.queue=SuperResolution-dev -generate.result.queue=GenerateImage-dev -to.product.image.result.queue=ToProductImage-dev -relight.result.queue=Relight-dev \ No newline at end of file +rabbitmq.queues.generate=generate-queue-dev +rabbitmq.queues.sr=SR-queue-dev +rabbitmq.queues.srResult=SuperResolution-dev +rabbitmq.queues.generateResult=GenerateImage-dev +rabbitmq.queues.toProductImageResult=ToProductImage-dev +rabbitmq.queues.relightResult=Relight-dev +rabbitmq.exchange.generate=generate-exchange \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 7c9ee94c..dd2c47ff 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -96,10 +96,10 @@ aws.s3.secretKey=LNIwFFB27/QedtZ+Q/viVUoX9F5x1DbuM8N0DkD8 aws.s3.regionName=ap-east-1 # RabbitMQ Exchange and Queue configurations -generate.exchange=generate-exchange -generate.queue=generate-queue-prod -sr.queue=SR-queue-prod -sr.result.queue=SuperResolution-prod -generate.result.queue=GenerateImage-prod -to.product.image.result.queue=ToProductImage-prod -relight.result.queue=Relight-prod \ No newline at end of file +rabbitmq.queues.generate=generate-queue-prod +rabbitmq.queues.sr=SR-queue-prod +rabbitmq.queues.srResult=SuperResolution-prod +rabbitmq.queues.generateResult=GenerateImage-prod +rabbitmq.queues.toProductImageResult=ToProductImage-prod +rabbitmq.queues.relightResult=Relight-prod +rabbitmq.exchange.generate=generate-exchange \ No newline at end of file diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties index 31ccb6a6..612e6b4c 100644 --- a/src/main/resources/application-test.properties +++ b/src/main/resources/application-test.properties @@ -87,11 +87,15 @@ redis.key.taskList=TaskList redis.key.credits.pre-deduction=Credits:PreDeduction redis.key.generateResult=Generate:Result +aws.s3.accessKeyId=AKIAVD3OJIMF6UJFLSHZ +aws.s3.secretKey=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 +aws.s3.regionName=ap-east-1 + # RabbitMQ Exchange and Queue configurations -generate.exchange=generate-exchange -generate.queue=generate-queue-test -sr.queue=SR-queue-test -sr.result.queue=SuperResolution-test -generate.result.queue=GenerateImage-test -to.product.image.result.queue=ToProductImage-test -relight.result.queue=Relight-test \ No newline at end of file +rabbitmq.queues.generate=generate-queue-test +rabbitmq.queues.sr=SR-queue-test +rabbitmq.queues.srResult=SuperResolution-test +rabbitmq.queues.generateResult=GenerateImage-test +rabbitmq.queues.toProductImageResult=ToProductImage-test +rabbitmq.queues.relightResult=Relight-test +rabbitmq.exchange.generate=generate-exchange \ No newline at end of file