diff --git a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java index 0bbc7e05..e2bef18a 100644 --- a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java +++ b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java @@ -132,7 +132,6 @@ public class MyTaskScheduler { @Resource private CollectionSortMapper collectionSortMapper; - @Lazy @Resource private DesignService designService; @@ -151,7 +150,6 @@ public class MyTaskScheduler { private ProjectMapper projectMapper; @Resource private WorkspaceMapper workspaceMapper; - @Lazy @Resource private WorkspaceService workspaceService; @Resource 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 219cea74..31d65b0a 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -95,11 +95,6 @@ public class AccountServiceImpl extends ServiceImpl impl @Resource private AccountLoginLogService accountLoginLogService; - @Lazy - @Resource - private ConvenientInquiryService convenientInquiryService; - - @Lazy @Resource private LibraryService libraryService; @@ -118,10 +113,6 @@ public class AccountServiceImpl extends ServiceImpl impl @Resource private QuestionnaireMapper questionnaireMapper; - @Lazy - @Resource - private CreditsService creditsService; - @Resource private MinioUtil minioUtil; @@ -141,14 +132,6 @@ public class AccountServiceImpl extends ServiceImpl impl @Resource private RedisUtil redisUtil; - @Lazy - @Resource - private StripeService stripeService; - - @Lazy - @Resource - private AffiliateService affiliateService; - @Resource private UserFollowService userFollowService; @@ -207,10 +190,6 @@ public class AccountServiceImpl extends ServiceImpl impl return new AccountPreLoginVO(account.getId()); } - @Lazy - @Resource - private PortfolioService portfolioService; - @Transactional(rollbackFor = Exception.class) @Override public AccountLoginVO login(AccountLoginDTO accountLoginDTO, HttpServletRequest request) { @@ -1641,6 +1620,7 @@ public class AccountServiceImpl extends ServiceImpl impl log.warn("当前用户 {} 在AiDA中没有账号", email); throw new BusinessException("user.has.no.account", ResultEnum.PROMPT.getCode()); } + CreditsService creditsService = SpringUtils.getBean(CreditsService.class); // 2、先判断当前用户是否已经填写过问卷 CreditsDetail record = creditsService.getByAccountIdAndChangeEvent(account.getId(), "Fill out the questionnaire", "+100"); if (!Objects.isNull(record)) { @@ -2059,7 +2039,7 @@ public class AccountServiceImpl extends ServiceImpl impl String avatar = StringUtil.isNullOrEmpty(account.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : account.getAvatar(); personalHomepageVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); - personalHomepageVO.setPortfolioCount(portfolioService.getPortfolioCount(accountId)); + personalHomepageVO.setPortfolioCount(SpringUtils.getBean(PortfolioService.class).getPortfolioCount(accountId)); personalHomepageVO.setFolloweeCount(userFollowService.getFolloweeCount(accountId)); personalHomepageVO.setFollowerCount(userFollowService.getFollowerCount(accountId)); personalHomepageVO.setHomepageViewCount(viewPersonalHomepageCount(0L)); @@ -3142,7 +3122,7 @@ public class AccountServiceImpl extends ServiceImpl impl response.setAccountExtendList(accountExtends); } response.setLanguage(Language.valueOf(account.getLanguage()).name()); - SubscriptionInfo subscriptionInfo = stripeService.getLatestSubscriptionInfoByAccountId(accountId); + SubscriptionInfo subscriptionInfo = SpringUtils.getBean(StripeService.class).getLatestSubscriptionInfoByAccountId(accountId); if (!Objects.isNull(subscriptionInfo)) { response.setSubscriptionId(subscriptionInfo.getSubscriptionId()); response.setSubscriptionType(subscriptionInfo.getType()); @@ -3151,7 +3131,7 @@ public class AccountServiceImpl extends ServiceImpl impl response.setAutoRenewal(subscriptionInfo.getStatus().equals("active")); } - Affiliate affiliate = affiliateService.getByAccountId(accountId); + Affiliate affiliate = SpringUtils.getBean(AffiliateService.class).getByAccountId(accountId); if (!Objects.isNull(affiliate) && affiliate.getStatus().equals("Active")) { response.setAffiliate(true); } @@ -3371,6 +3351,7 @@ public class AccountServiceImpl extends ServiceImpl impl } accountMapper.updateById(account); + CreditsService creditsService = SpringUtils.getBean(CreditsService.class); // 先判断是否已添加添加积分变更记录 CreditsDetail creditsDetail = creditsService.queryDetailByTaskId(orderNo); if (Objects.isNull(creditsDetail)) { @@ -3663,14 +3644,19 @@ public class AccountServiceImpl extends ServiceImpl impl // todo 机构管理员再次订阅时,需要同步机构的激活状态 private void setOrganizationStatus(Account adminAcc, boolean isActive) { Organization organization; + ConvenientInquiryService convenientInquiryService = null; if (Objects.nonNull(adminAcc.getOrganizationId())) { organization = organizationMapper.selectById(adminAcc.getOrganizationId()); } else if (!StringUtil.isNullOrEmpty(adminAcc.getOrganizationName())) { + convenientInquiryService = SpringUtils.getBean(ConvenientInquiryService.class); organization = convenientInquiryService.checkOrganization(adminAcc.getSystemUser(), adminAcc.getOrganizationName()); } else { return; } if (Objects.isNull(organization)) { + if (Objects.isNull(convenientInquiryService)) { + convenientInquiryService = SpringUtils.getBean(ConvenientInquiryService.class); + } organization = convenientInquiryService.addOrganization(adminAcc.getOrganizationName(), getOrganizationTypeByRole(adminAcc.getSystemUser())); } if (isActive) { diff --git a/src/main/java/com/ai/da/service/impl/AffiliateServiceImpl.java b/src/main/java/com/ai/da/service/impl/AffiliateServiceImpl.java index b189e11e..3449becf 100644 --- a/src/main/java/com/ai/da/service/impl/AffiliateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AffiliateServiceImpl.java @@ -53,9 +53,6 @@ public class AffiliateServiceImpl extends ServiceImpl implements CloudTaskService { - @Lazy @Resource private CreditsService creditsService; diff --git a/src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java b/src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java index b24eaec1..80b28aa9 100644 --- a/src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java @@ -61,7 +61,6 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl mailTo, JSONObject jsonObject, String templateName, String title, String fileName, InputStreamSource inputStreamSource) { if (mailTo.size() == 1){ String receiver = mailTo.get(0); - Account account = accountService.getBaseMapper().selectOne(new QueryWrapper().eq("user_email", receiver)); + Account account = accountMapper.selectOne(new QueryWrapper().eq("user_email", receiver)); if (Objects.nonNull(account)){ boolean b = redisUtil.allowSend(account.getId()); if (!b){throw new BusinessException("email.count.limit", ResultEnum.PROMPT.getCode());} diff --git a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java index 2cf1e194..f3fb058e 100644 --- a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java @@ -89,7 +89,6 @@ import static com.ai.da.common.enums.WangXiangTaskStatusEnum.UNKNOWN_W; @RequiredArgsConstructor public class GenerateServiceImpl extends ServiceImpl implements GenerateService { - private final AccountService accountService; private final APIGenerateService apiGenerateService; private final CollectionElementMapper collectionElementMapper; private final CollectionElementService collectionElementService; @@ -828,7 +827,7 @@ public class GenerateServiceImpl extends ServiceImpl i if (finishMessage != null && finishMessage.contains("Try rephrasing the prompt")) { finishMessage = "Try rephrasing the prompt or modifying the model image. If you think this was an error, send feedback."; LambdaQueryWrapper select = new LambdaQueryWrapper().eq(Account::getId, userId).select(Account::getLanguage); - Account account = accountService.getOne(select); + Account account = getAccountService().getOne(select); if ("CHINESE_SIMPLIFIED".equals(account.getLanguage())) { finishMessage = "请尝试重新表述提示词,或修改模特图。若您认为这是误判,可提交反馈。"; } @@ -1096,7 +1095,7 @@ public class GenerateServiceImpl extends ServiceImpl i if (finishMessage != null && finishMessage.contains("Try rephrasing the prompt")) { finishMessage = "Try rephrasing the prompt or replacing the image. If you think this was an error, send feedback."; LambdaQueryWrapper select = new LambdaQueryWrapper().eq(Account::getId, userId).select(Account::getLanguage); - Account account = accountService.getOne(select); + Account account = getAccountService().getOne(select); if ("CHINESE_SIMPLIFIED".equals(account.getLanguage())) { finishMessage = "请尝试重新表述提示词,或更换图片。若您认为这是误判,可提交反馈。"; } @@ -1117,7 +1116,7 @@ public class GenerateServiceImpl extends ServiceImpl i if (raiFilteredReason != null && raiFilteredReason.contains("Try rephrasing the prompt")) { raiFilteredReason = "Input data may contain inappropriate content."; LambdaQueryWrapper select = new LambdaQueryWrapper().eq(Account::getId, userId).select(Account::getLanguage); - Account account = accountService.getOne(select); + Account account = getAccountService().getOne(select); if ("CHINESE_SIMPLIFIED".equals(account.getLanguage())) { raiFilteredReason = "输入数据可能包含不当内容。"; } @@ -1381,7 +1380,7 @@ public class GenerateServiceImpl extends ServiceImpl i exceptionMessage = jsonObj.getStr("message"); if ("Input data may contain inappropriate content.".equals(exceptionMessage)) { LambdaQueryWrapper select = new LambdaQueryWrapper().eq(Account::getId, userId).select(Account::getLanguage); - Account account = accountService.getOne(select); + Account account = getAccountService().getOne(select); if ("CHINESE_SIMPLIFIED".equals(account.getLanguage())) { exceptionMessage = "输入数据可能包含不当内容。"; } @@ -1478,7 +1477,7 @@ public class GenerateServiceImpl extends ServiceImpl i } catch (Exception e) { log.error("Doubao image generation failed for taskId: {}", taskId, e); LambdaQueryWrapper select = new LambdaQueryWrapper().eq(Account::getId, userId).select(Account::getLanguage); - Account account = accountService.getOne(select); + Account account = getAccountService().getOne(select); // 根据用户语言设置默认错误信息 String errorMessage = "图像生成失败,请稍后重试"; // 默认中文 @@ -2204,7 +2203,7 @@ public class GenerateServiceImpl extends ServiceImpl i } public void doCreditsSubtract(Long accountId, CreditsEventsEnum event) { - Account account = accountService.getById(accountId); + Account account = getAccountService().getById(accountId); BigDecimal existingCredits = account.getCredits(); BigDecimal subtract = existingCredits.subtract(new BigDecimal(event.getValue())); BigDecimal creditsUsage = null; @@ -2212,10 +2211,14 @@ public class GenerateServiceImpl extends ServiceImpl i creditsUsage = Objects.isNull(account.getCreditsUsage()) ? BigDecimal.ZERO : account.getCreditsUsage(); creditsUsage = creditsUsage.add(new BigDecimal(event.getValue())); } - accountService.updateCreditsAndEndTime(account, subtract.toString(), null, creditsUsage); + getAccountService().updateCreditsAndEndTime(account, subtract.toString(), null, creditsUsage); creditsService.preInsert(accountId, event.getName(), null, Boolean.FALSE, event.getValue()); } + private AccountService getAccountService() { + return SpringUtils.getBean(AccountService.class); + } + // 注入线程池(可在配置类中定义) @Resource private Executor asyncTaskExecutor; diff --git a/src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java b/src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java index 7d82fcb4..0c3aabd5 100644 --- a/src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java @@ -83,8 +83,7 @@ public class LibraryServiceImpl extends ServiceImpl impl private final PythonTAllInfoService pythonTAllInfoService; private final SysFileMapper sysFileMapper; private final SysFileExtraMapper sysFileExtraMapper; - @Lazy - private final WorkspaceService workspaceService; + private final WorkspaceMapper workspaceMapper; @Value("${minio.bucketName.users}") private String users; @@ -730,7 +729,7 @@ public class LibraryServiceImpl extends ServiceImpl impl } // TODO:isDeleted设置 qw.lambda().eq(Workspace::getIsDeleted, 0L); - List workspaceList = workspaceService.list(qw); + List workspaceList = workspaceMapper.selectList(qw); if (CollectionUtil.isNotEmpty(workspaceList)) { if (deleteModelConfirm.equals(0)) { throw new BusinessException("the.model.has.been.referenced.by.the.workspace", ResultEnum.WARNING.getCode()); @@ -744,8 +743,8 @@ public class LibraryServiceImpl extends ServiceImpl impl for (Workspace workspace : workspaceList) { workspace.setMannequinFemaleId(sysFemaleFiles.get(0).getId()); workspace.setMannequinFemaleType(MannequinType.SYSTEM.getValue()); + workspaceMapper.updateById(workspace); } - workspaceService.updateBatchById(workspaceList); } } if (value.equals(Sex.MALE.getValue())) { @@ -757,8 +756,8 @@ public class LibraryServiceImpl extends ServiceImpl impl for (Workspace workspace : workspaceList) { workspace.setMannequinMaleId(sysMaleFiles.get(0).getId()); workspace.setMannequinMaleType(MannequinType.SYSTEM.getValue()); + workspaceMapper.updateById(workspace); } - workspaceService.updateBatchById(workspaceList); } } } diff --git a/src/main/java/com/ai/da/service/impl/PayPalCheckoutServiceImpl.java b/src/main/java/com/ai/da/service/impl/PayPalCheckoutServiceImpl.java index dfecc877..caa31202 100644 --- a/src/main/java/com/ai/da/service/impl/PayPalCheckoutServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/PayPalCheckoutServiceImpl.java @@ -72,7 +72,6 @@ public class PayPalCheckoutServiceImpl implements PayPalCheckoutService { private PayPalClient payPalClient; @Resource private OrderInfoService orderInfoService; - @Lazy @Resource private PaymentInfoService paymentInfoService; @Resource diff --git a/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java b/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java index 44edfc40..7d11ecaf 100644 --- a/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java @@ -3,6 +3,7 @@ package com.ai.da.service.impl; import com.ai.da.common.context.UserContext; import com.ai.da.common.enums.PayTypeEnum; import com.ai.da.common.response.PageBaseResponse; +import com.ai.da.common.utils.SpringUtils; import com.ai.da.mapper.primary.PaymentInfoMapper; import com.ai.da.mapper.primary.entity.OrderInfo; import com.ai.da.mapper.primary.entity.PaymentInfo; @@ -45,10 +46,6 @@ import java.util.Objects; @Slf4j public class PaymentInfoServiceImpl extends ServiceImpl implements PaymentInfoService { - @Lazy - @Resource - private StripeService stripeService; - @Resource private OrderInfoService orderInfoService; @@ -230,6 +227,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl(uuid, "SR", name.substring(name.lastIndexOf("/") + 1), superResolutionDTO, "Waiting", LocalDateTime.now().format(dateTimeFormatter))); + SpringUtils.getBean(TaskListService.class).addToTaskListRedis(new TaskDTO<>(uuid, "SR", name.substring(name.lastIndexOf("/") + 1), superResolutionDTO, "Waiting", LocalDateTime.now().format(dateTimeFormatter))); // 7、将消息发布到MQ消息队列 log.info("发送消息到SR_QUEUE,参数 :{}", jsonString); diff --git a/src/main/java/com/ai/da/service/impl/TaskListServiceImpl.java b/src/main/java/com/ai/da/service/impl/TaskListServiceImpl.java index 709c92c8..b7131b1d 100644 --- a/src/main/java/com/ai/da/service/impl/TaskListServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/TaskListServiceImpl.java @@ -42,7 +42,6 @@ public class TaskListServiceImpl extends ServiceImpl i @Resource private MinioUtil minioUtil; - @Lazy @Resource private SuperResolutionService superResolutionService; diff --git a/src/main/java/com/ai/da/service/impl/TrialOrderServiceImpl.java b/src/main/java/com/ai/da/service/impl/TrialOrderServiceImpl.java index d7ade57b..cacce405 100644 --- a/src/main/java/com/ai/da/service/impl/TrialOrderServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/TrialOrderServiceImpl.java @@ -7,6 +7,7 @@ import com.ai.da.common.response.ResultEnum; import com.ai.da.common.utils.CopyUtil; import com.ai.da.common.utils.RequestInfoUtil; import com.ai.da.common.utils.SendEmailUtil; +import com.ai.da.common.utils.SpringUtils; import com.ai.da.mapper.primary.AccountMapper; import com.ai.da.mapper.primary.TrialOrderMapper; import com.ai.da.mapper.primary.entity.Account; @@ -40,12 +41,8 @@ public class TrialOrderServiceImpl extends ServiceImpl implements UserLikeGroupService { private final UserLikeGroupMapper userLikeGroupMapper; - private final AccountService accountService; + private final AccountMapper accountMapper; private final CollectionService collectionService; private final UserLikeService userLikeService; private final WorkspaceService workspaceService; @@ -1963,7 +1963,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl> finalGroupDetailMap = groupDetailMap; IPage convert = page.convert((Function) project -> { if (project != null) { @@ -1991,7 +1991,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl