diff --git a/pom.xml b/pom.xml index 2c6dacea..21b1264b 100644 --- a/pom.xml +++ b/pom.xml @@ -202,6 +202,31 @@ 20230618 + + org.apache.poi + poi + 5.2.1 + + + + org.apache.poi + poi-ooxml + 5.2.1 + + + + commons-io + commons-io + 2.11.0 + + + + org.apache.logging.log4j + log4j-api + 2.17.1 + + + 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 f193a16a..f505796e 100644 --- a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java +++ b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java @@ -2,12 +2,25 @@ package com.ai.da.common.config; import com.ai.da.common.utils.SendEmailUtil; import com.ai.da.mapper.primary.AccountMapper; +import com.ai.da.mapper.primary.TrialOrderMapper; import com.ai.da.mapper.primary.entity.Account; +import com.ai.da.mapper.primary.entity.TrialOrder; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +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.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +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; @Component @@ -16,6 +29,9 @@ public class MyTaskScheduler { @Resource private AccountMapper accountMapper; + @Resource + private TrialOrderMapper trialOrderMapper; + // 定时任务,每十五天执行一次 // @Scheduled(cron = "0 0 0 ? * MON") @Scheduled(cron = "0 0 0 */15 * ?") @@ -36,7 +52,7 @@ public class MyTaskScheduler { Long currentTimestamp = System.currentTimeMillis(); // 计算时间差(毫秒) - long timeDifference = timestamp - currentTimestamp; + long timeDifference = currentTimestamp - timestamp; if (timeDifference < 0) { continue; @@ -52,4 +68,65 @@ public class MyTaskScheduler { } } } + @Scheduled(cron = "0 0 8 * * ?") + public void sendTrialOrderExcelToManagements() { + // 获取前一天日期 + LocalDate yesterday = LocalDate.now().minusDays(1); + + // 查询前一天的试用订单 + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().between(TrialOrder::getCreateTime, yesterday.atStartOfDay(), yesterday.atTime(23, 59, 59)); + List trialOrders = trialOrderMapper.selectList(qw); + + if (!trialOrders.isEmpty()) { + // 创建Excel工作簿 + try (Workbook workbook = new XSSFWorkbook()) { + // 创建工作表 + Sheet sheet = workbook.createSheet("Trial Orders"); + // 创建标题行 + Row headerRow = sheet.createRow(0); + headerRow.createCell(0).setCellValue("ID"); + headerRow.createCell(1).setCellValue("Title"); + headerRow.createCell(2).setCellValue("Surname"); + headerRow.createCell(3).setCellValue("Given Name"); + headerRow.createCell(4).setCellValue("Username"); + headerRow.createCell(5).setCellValue("Email"); + headerRow.createCell(6).setCellValue("Country"); + headerRow.createCell(7).setCellValue("Occupation"); + headerRow.createCell(8).setCellValue("Create Time"); + headerRow.createCell(9).setCellValue("Update Time"); + headerRow.createCell(10).setCellValue("Status"); + + // 填充数据 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + int rowNum = 1; + for (TrialOrder trialOrder : trialOrders) { + Row row = sheet.createRow(rowNum++); + row.createCell(0).setCellValue(trialOrder.getId()); + row.createCell(1).setCellValue(trialOrder.getTitle()); + row.createCell(2).setCellValue(trialOrder.getSurname()); + row.createCell(3).setCellValue(trialOrder.getGivenName()); + row.createCell(4).setCellValue(trialOrder.getUserName()); + row.createCell(5).setCellValue(trialOrder.getEmail()); + row.createCell(6).setCellValue(trialOrder.getCountry()); + row.createCell(7).setCellValue(trialOrder.getOccupation()); + row.createCell(8).setCellValue(trialOrder.getCreateTime().format(formatter)); + row.createCell(9).setCellValue(trialOrder.getUpdateTime().format(formatter)); + row.createCell(10).setCellValue(trialOrder.getStatus()); + } + + // 保存Excel文件 + String fileName = "trialOrder-" + yesterday.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx"; + try (FileOutputStream fileOut = new FileOutputStream(fileName)) { + workbook.write(fileOut); + SendEmailUtil.sendExcelEmail("1023316923@qq.com", null, Files.readAllBytes(Paths.get(fileName)), fileName); + SendEmailUtil.sendExcelEmail("calvinwong@aidlab.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); + SendEmailUtil.sendExcelEmail("kaicpang.pang@connect.polyu.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); + SendEmailUtil.sendExcelEmail("kimwong@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } } diff --git a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java index 7b3f3d3e..6653c7da 100644 --- a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java +++ b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java @@ -9,12 +9,14 @@ import com.tencentcloudapi.common.exception.TencentCloudSDKException; import com.tencentcloudapi.common.profile.ClientProfile; import com.tencentcloudapi.common.profile.HttpProfile; import com.tencentcloudapi.ses.v20201002.SesClient; +import com.tencentcloudapi.ses.v20201002.models.Attachment; import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest; import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse; import com.tencentcloudapi.ses.v20201002.models.Template; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; +import java.util.Base64; import java.util.Date; /** @@ -130,7 +132,9 @@ public class SendEmailUtil { private final static Long YOUR_TRIAL_TEMPLATE_ID = 117214L; private final static Long APPROVAL_TEMPLATE_ID = 117215L; private final static Long NOTIFICATION_TEMPLATE_ID = 117216L; - public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType) { + private final static Long NOTIFICATION_CHINESE_TEMPLATE_ID = 122229L; + private final static Long TRIAL_ORDER_LIST_ID = 122273L; + public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country) { try { // 实例化一个认证对象 Credential cred = new Credential(SECRET_ID, SECRET_KEy); @@ -162,7 +166,11 @@ public class SendEmailUtil { break; case 3: subject = "Approval Confirmation for AiDA System Trial Access"; - template.setTemplateID(NOTIFICATION_TEMPLATE_ID); + if (country.equals("China")) { + template.setTemplateID(NOTIFICATION_CHINESE_TEMPLATE_ID); + }else { + template.setTemplateID(NOTIFICATION_TEMPLATE_ID); + } template.setTemplateData(buildNotificationData(trialOrder)); break; default: @@ -180,6 +188,45 @@ public class SendEmailUtil { throw new BusinessException("failed.to.send.mail"); } } + + public static void sendExcelEmail(String receiverAddress, String senderAddress, byte[] fileContent, String fileName) { + try { + // 实例化一个认证对象 + Credential cred = new Credential(SECRET_ID, SECRET_KEy); + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("ses.tencentcloudapi.com"); + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + SesClient client = new SesClient(cred, "ap-hongkong", clientProfile); + SendEmailRequest req = new SendEmailRequest(); + if (StringUtils.isEmpty(senderAddress)) { + senderAddress = SEND_ADDRESS; + } + req.setFromEmailAddress(senderAddress); + req.setDestination(new String[]{receiverAddress}); + + // 根据邮件类型设置不同的主题和模板 + String subject = ""; + Template template = new Template(); + subject = "昨日试用订单数据"; + template.setTemplateID(TRIAL_ORDER_LIST_ID); + + req.setSubject(subject); + req.setTemplate(template); + + Attachment attachment = new Attachment(); + attachment.setFileName(fileName); // 设置附件文件名 + // 设置附件内容 + attachment.setContent(Base64.getEncoder().encodeToString(fileContent)); + req.setAttachments(new Attachment[] {attachment}); + // 发送邮件 + SendEmailResponse resp = client.SendEmail(req); + log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp)); + } catch (TencentCloudSDKException e) { + log.info("邮件发送失败###{}", e.toString()); + throw new BusinessException("failed.to.send.mail"); + } + } private final static Long WILLBEEXPIRED_TEMPLATE_ID = 118178L; public static void sendWillBeExpiredEmail(Account account, String senderAddress) { try { @@ -293,7 +340,7 @@ public class SendEmailUtil { // 根据邮件类型设置不同的主题和模板 String subject = ""; Template template = new Template(); - subject = "Notice: AiDA 3.0 Website Maintenance Downtime"; + subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance"; template.setTemplateID(UPGRADE_NOTIFICATION_ID); template.setTemplateData(buildAccountData(account)); diff --git a/src/main/java/com/ai/da/mapper/primary/entity/Workspace.java b/src/main/java/com/ai/da/mapper/primary/entity/Workspace.java index 5fcc49cc..2fe6fe9e 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/Workspace.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/Workspace.java @@ -35,10 +35,15 @@ public class Workspace implements Serializable { @ApiModelProperty(value = "工作空间名称") private String workSpaceName; /** - * 用户ID + * 用户名 */ @ApiModelProperty(value = "用户名") private String userName; + /** + * 用户ID + */ + @ApiModelProperty(value = "用户ID") + private Long accountId; /** * 性别 */ diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index ddabb8c2..eaa1c786 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -228,19 +228,28 @@ public class PythonService { long noPrintNum = 8 - pinPrintNum - noPinPrintNum; elementVO.setNoPinPrintNum(noPinPrintNum); - int pinSketchNum = 0; - int sysSketchNum = 0; - int noPinSketchNum = 0; + int[] sketchNumbers = new int[3]; for (int i = 0; i < 8; i++) { - CurrentDesignPictureTypeEnum designPictureType = calculateCurrentDesignPictureTypeNew(elementVO, pinSketchNum, sysSketchNum, noPinSketchNum, systemScale); + CurrentDesignPictureTypeEnum designPictureType = calculateCurrentDesignPictureTypeNew(elementVO, sketchNumbers, systemScale); if (designPictureType == null) break; CurrentDesignPrintPictureTypeEnum designPrintPictureType = calculateCurrentDesignPintPictureType(pinPrintNum, noPinPrintNum, noPrintNum); if (designPrintPictureType == null) break; - updateSketchNumbers(designPictureType, pinSketchNum, sysSketchNum, noPinSketchNum); - updatePrintNumbers(designPrintPictureType, pinPrintNum, noPinPrintNum, noPrintNum); + updateSketchNumbers(designPictureType, sketchNumbers); + switch (designPrintPictureType) { + case PIN: + pinPrintNum--; + break; + case NO_PIN: + noPinPrintNum--; + break; + case NO: + noPrintNum--; + break; + } +// updatePrintNumbers(designPrintPictureType, pinPrintNum, noPinPrintNum, noPrintNum); DesignPythonItemPrint designPythonItemPrint = getRandomPrint(elementVO, designPrintPictureType); elementVO.setDesignPythonItemPrint(designPythonItemPrint); @@ -252,16 +261,16 @@ public class PythonService { return designPythonObjects; } - private void updateSketchNumbers(CurrentDesignPictureTypeEnum designPictureType, int pinSketchNum, int sysSketchNum, int noPinSketchNum) { + private void updateSketchNumbers(CurrentDesignPictureTypeEnum designPictureType, int[] sketchNumbers) { switch (designPictureType) { case PIN: - pinSketchNum++; + sketchNumbers[0] ++; break; case NO_PIN: - noPinSketchNum--; + sketchNumbers[2] --; break; case SYS_FILE: - sysSketchNum--; + sketchNumbers[1] --; break; } } @@ -288,16 +297,24 @@ public class PythonService { } - private CurrentDesignPictureTypeEnum calculateCurrentDesignPictureTypeNew(ValidateElementVO elementVO, int pinSketchNum, int sysSketchNum, int noPinSketchNum, BigDecimal systemScale) { + private CurrentDesignPictureTypeEnum calculateCurrentDesignPictureTypeNew(ValidateElementVO elementVO, int[] sketchNumbers, BigDecimal systemScale) { List pinData = getPinData(elementVO); if (CollectionUtil.isNotEmpty(pinData)) { return CurrentDesignPictureTypeEnum.PIN; } else { - if (sysSketchNum == 0 && noPinSketchNum == 0) { - sysSketchNum = systemScale.multiply(BigDecimal.valueOf(8 - pinSketchNum)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); - noPinSketchNum = 8 - pinSketchNum - sysSketchNum; + if (sketchNumbers[1] == 0 && sketchNumbers[2] == 0) { + sketchNumbers[1] = systemScale.multiply(BigDecimal.valueOf(8 - sketchNumbers[0])).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); + sketchNumbers[2] = 8 - sketchNumbers[0] - sketchNumbers[1]; } - if (noPinSketchNum > 0) { + if (sketchNumbers[2] > 0 && sketchNumbers[1] > 0) { + Long l = RandomsUtil.randomSysFile(0l, 2l); + if (l == 0l) { + return CurrentDesignPictureTypeEnum.NO_PIN; + }else { + return CurrentDesignPictureTypeEnum.SYS_FILE; + } + } + if (sketchNumbers[2] > 0) { return CurrentDesignPictureTypeEnum.NO_PIN; } return CurrentDesignPictureTypeEnum.SYS_FILE; 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 a166eb91..77f44f4f 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -77,7 +77,7 @@ public class AccountServiceImpl extends ServiceImpl impl @Transactional public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) { log.info("aida预先登入accountDTO###{}", JSON.toJSONString(accountDTO)); - Account account = getOneByUserName(accountDTO.getUserName()); + Account account = getOneByEmail(accountDTO.getEmail()); //用户有效期校验 validateUserValidaExpire(account); if ("Third-000000".equals(account.getUserPassword())) { @@ -287,8 +287,7 @@ public class AccountServiceImpl extends ServiceImpl impl private Account getOneByEmail(String email) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(Account::getUserEmail, email); - queryWrapper.lambda().last("limit 1"); + queryWrapper.eq("BINARY user_email", email); List accountList = accountMapper.selectList(queryWrapper); if (CollectionUtil.isEmpty(accountList)) { throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode()); @@ -471,28 +470,27 @@ public class AccountServiceImpl extends ServiceImpl impl String ipAddress = RequestInfoUtil.getIpAddress(request); // 先检测试用订单 QueryWrapper trialOrderQueryWrapper = new QueryWrapper<>(); - trialOrderQueryWrapper.lambda().eq(TrialOrder::getIp, ipAddress); - trialOrderQueryWrapper.lambda().and(wrapper -> - wrapper.eq(TrialOrder::getEmail, accountTrialDTO.getEmail()) - .or() // OR - .like(TrialOrder::getUserName, accountTrialDTO.getUserName())); + trialOrderQueryWrapper.eq("BINARY email", accountTrialDTO.getEmail()); +// trialOrderQueryWrapper.lambda().eq(TrialOrder::getIp, ipAddress); +// trialOrderQueryWrapper.lambda().and(wrapper -> +// wrapper.eq(TrialOrder::getEmail, accountTrialDTO.getEmail()) +// .or() // OR +// .like(TrialOrder::getUserName, accountTrialDTO.getUserName())); List trialOrders = trialOrderMapper.selectList(trialOrderQueryWrapper); if (CollectionUtil.isNotEmpty(trialOrders)) { throw new BusinessException("You have submitted a trial application, please wait for approval."); } // 先检测用户名和邮箱 QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(Account::getUserEmail, accountTrialDTO.getEmail()) - .or() - .eq(Account::getUserName, accountTrialDTO.getUserName()); + qw.eq("BINARY email", accountTrialDTO.getEmail()); List accountList = accountMapper.selectList(qw); if (CollectionUtil.isNotEmpty(accountList)) { if (accountList.get(0).getIsTrial() == 1) { - throw new BusinessException("The username or email has already been registered", ResultEnum.PROMPT.getCode()); + throw new BusinessException("The email has already been registered", ResultEnum.PROMPT.getCode()); }else { Account account = accountList.get(0); if (null == account.getValidEndTime() || account.getValidEndTime() > System.currentTimeMillis()) { - throw new BusinessException("The username or email has already been registered", ResultEnum.PROMPT.getCode()); + throw new BusinessException("The email has already been registered", ResultEnum.PROMPT.getCode()); } } } @@ -502,9 +500,9 @@ public class AccountServiceImpl extends ServiceImpl impl trialOrder.setStatus(0); trialOrder.setIp(ipAddress); trialOrderMapper.insert(trialOrder); - SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,1); - SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,1); - SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,1); +// SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,1); +// SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,1); +// SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,1); // 判断当前的试用订单是否自动批准 if (AutoApproved.getStatus()) { // 改变试用订单状态,新增试用用户 @@ -532,10 +530,10 @@ public class AccountServiceImpl extends ServiceImpl impl accountMapper.insert(account); } // 发送邮件提醒用户试用用户已创建 - SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,2); - SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2); - SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2); - SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3); +// SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,2); +// SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2); +// SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2); + SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry()); } return Boolean.TRUE; } @@ -556,9 +554,7 @@ public class AccountServiceImpl extends ServiceImpl impl trialOrderMapper.updateById(trialOrder); QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(Account::getUserEmail, trialOrder.getEmail()) - .or() - .eq(Account::getUserName, trialOrder.getUserName()); + qw.eq("BINARY email", trialOrder.getEmail()); List accountList = accountMapper.selectList(qw); Account account = new Account(); @@ -582,10 +578,10 @@ public class AccountServiceImpl extends ServiceImpl impl accountMapper.insert(account); } // 发送邮件提醒用户试用用户已创建 - SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,2); - SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2); - SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2); - SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3); +// SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,2); +// SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2); +// SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2); + SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry()); } return Boolean.TRUE; } 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 080523ed..bc09dd9c 100644 --- a/src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java @@ -595,7 +595,7 @@ public class LibraryServiceImpl extends ServiceImpl impl public void checkModel(String value, List modelIds, Integer deleteModelConfirm) { AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder(); QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(Workspace::getUserName, authPrincipalVo.getUsername()); + qw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId()); if (value.equals(Sex.FEMALE.getValue())) { qw.lambda().in(Workspace::getMannequinFemaleId, modelIds); } diff --git a/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java b/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java index 69574b35..6d1478ec 100644 --- a/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java @@ -86,8 +86,8 @@ public class WorkspaceServiceImpl extends ServiceImpl systemFemaleQw = new QueryWrapper<>(); @@ -123,11 +123,11 @@ public class WorkspaceServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); qw.lambda().ne(null != id, Workspace::getId, id); qw.lambda().eq(Workspace::getWorkSpaceName, workSpaceName); - qw.lambda().eq(Workspace::getUserName, userName); + qw.lambda().eq(Workspace::getAccountId, accountId); List workspaces = baseMapper.selectList(qw); if (!CollectionUtils.isEmpty(workspaces)) { throw new BusinessException("the.workspaceName.already.exists", ResultEnum.PROMPT.getCode()); @@ -137,9 +137,9 @@ public class WorkspaceServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); - qw.lambda().eq(Workspace::getUserName, userName); + qw.lambda().eq(Workspace::getAccountId, accountId); IPage page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw); if (page.getTotal() == 0L) { // 给用户新建默认workspace @@ -148,7 +148,7 @@ public class WorkspaceServiceImpl extends ServiceImpl systemFemaleQw = new QueryWrapper<>(); systemFemaleQw.lambda().eq(SysFile::getLevel1Type, "Models"); systemFemaleQw.lambda().eq(SysFile::getLevel2Type, "Female"); @@ -225,7 +225,7 @@ public class WorkspaceServiceImpl extends ServiceImpl qwIsLastIndex = new QueryWrapper<>(); - qwIsLastIndex.lambda().eq(Workspace::getUserName, userName); + qwIsLastIndex.lambda().eq(Workspace::getAccountId, accountId); qwIsLastIndex.lambda().eq(Workspace::getIsLastIndex, 1); qwIsLastIndex.last("limit 1"); List workspaces = workspaceMapper.selectList(qwIsLastIndex); @@ -250,9 +250,9 @@ public class WorkspaceServiceImpl extends ServiceImpl qwOld = new QueryWrapper<>(); - qwOld.lambda().eq(Workspace::getUserName, userName); + qwOld.lambda().eq(Workspace::getAccountId, accountId); qwOld.lambda().eq(Workspace::getIsLastIndex, 1); Workspace oldIsLastIndex = workspaceMapper.selectOne(qwOld); oldIsLastIndex.setIsLastIndex(0); diff --git a/src/main/resources/mapper/primary/WorkspaceMapper.xml b/src/main/resources/mapper/primary/WorkspaceMapper.xml index 9f36d5f6..592084e1 100644 --- a/src/main/resources/mapper/primary/WorkspaceMapper.xml +++ b/src/main/resources/mapper/primary/WorkspaceMapper.xml @@ -7,12 +7,17 @@ + - - - + + + + + + +