diff --git a/src/main/java/com/ai/da/controller/AccountController.java b/src/main/java/com/ai/da/controller/AccountController.java index 03f3a9d3..4a0c6cc0 100644 --- a/src/main/java/com/ai/da/controller/AccountController.java +++ b/src/main/java/com/ai/da/controller/AccountController.java @@ -80,4 +80,10 @@ public class AccountController { return Response.success(accountService.changeUserLanguage(language)); } + @ApiOperation(value = "试用用户退出登录") + @GetMapping("/trialUserLogout") + public Response trialUserLogout() { + return Response.success(accountService.trialUserLogout()); + } + } diff --git a/src/main/java/com/ai/da/mapper/entity/Account.java b/src/main/java/com/ai/da/mapper/entity/Account.java index a0388007..a05dad84 100644 --- a/src/main/java/com/ai/da/mapper/entity/Account.java +++ b/src/main/java/com/ai/da/mapper/entity/Account.java @@ -74,4 +74,6 @@ public class Account implements Serializable { * 更新时间 */ private Date updateDate; + + private Integer isTrial; } diff --git a/src/main/java/com/ai/da/model/dto/AccountAddDTO.java b/src/main/java/com/ai/da/model/dto/AccountAddDTO.java index 82f08e87..22de2a4f 100644 --- a/src/main/java/com/ai/da/model/dto/AccountAddDTO.java +++ b/src/main/java/com/ai/da/model/dto/AccountAddDTO.java @@ -27,4 +27,6 @@ public class AccountAddDTO { @ApiModelProperty("End time of account validity ") private String validEndTime; + private Integer isTrial; + } diff --git a/src/main/java/com/ai/da/model/dto/QueryLibraryPageDTO.java b/src/main/java/com/ai/da/model/dto/QueryLibraryPageDTO.java index eb957138..8aa40cdc 100644 --- a/src/main/java/com/ai/da/model/dto/QueryLibraryPageDTO.java +++ b/src/main/java/com/ai/da/model/dto/QueryLibraryPageDTO.java @@ -26,4 +26,7 @@ public class QueryLibraryPageDTO extends PageQueryBaseVo { @ApiModelProperty("分类ID") private List classificationIdList; + + @ApiModelProperty("交集还是并集:1交集2并集") + private Integer intersection; } diff --git a/src/main/java/com/ai/da/model/dto/QueryLibraryPageServiceDTO.java b/src/main/java/com/ai/da/model/dto/QueryLibraryPageServiceDTO.java index 9aec4e99..3e39b329 100644 --- a/src/main/java/com/ai/da/model/dto/QueryLibraryPageServiceDTO.java +++ b/src/main/java/com/ai/da/model/dto/QueryLibraryPageServiceDTO.java @@ -28,4 +28,6 @@ public class QueryLibraryPageServiceDTO extends PageQueryBaseVo { private List classificationIdList; + private Integer intersection; + } diff --git a/src/main/java/com/ai/da/model/vo/AccountLoginVO.java b/src/main/java/com/ai/da/model/vo/AccountLoginVO.java index 52e2e5d9..0f3bddea 100644 --- a/src/main/java/com/ai/da/model/vo/AccountLoginVO.java +++ b/src/main/java/com/ai/da/model/vo/AccountLoginVO.java @@ -26,4 +26,7 @@ public class AccountLoginVO { @ApiModelProperty("userId") private Long userId; + @ApiModelProperty("是否是试用用户") + private Integer isTrial; + } diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 5a1080f9..3733ab53 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -9,6 +9,7 @@ import com.ai.da.common.utils.*; import com.ai.da.mapper.entity.CollectionElement; import com.ai.da.mapper.entity.DesignHistory; import com.ai.da.model.dto.*; +import com.ai.da.model.enums.Sex; import com.ai.da.model.vo.*; import com.ai.da.python.vo.*; import com.ai.da.service.DesignHistoryService; @@ -263,7 +264,7 @@ public class PythonService { DesignPythonItemPrint designPythonItemPrint = getRandomPrint(elementVO, designPrintPictureType); elementVO.setDesignPythonItemPrint(designPythonItemPrint); //参数透传 确定本次designSingle如果需要print对应的种类 - elementVO.setDesignPrintPictureTypeLayoutList(calculateCurrentDesignPintPictureTypeLayout()); + elementVO.setDesignPrintPictureTypeLayoutList(calculateCurrentDesignPintPictureTypeLayout(elementVO.getModelSex())); //designSingle具体参数组装 DesignPythonObject pythonObject = new DesignPythonObject(); pythonObject.setItems(coverToDesignPythonItem(elementVO, designPictureType)); @@ -370,18 +371,33 @@ public class PythonService { } //计算当前的Print图片类型具体分布位置 0. 上衣 1.下衣 2.上衣和下衣都print - private List calculateCurrentDesignPintPictureTypeLayout() { - Long randomIndex = RandomsUtil.randomSysFile(0L, 3L); - if (randomIndex == 0) { - return DesignPythonItem.OUTWEAR_DRESS_BLOUSE; - } - if (randomIndex == 1) { - return DesignPythonItem.SKIRT_TROUSERS; - } - if (randomIndex == 2) { - List all = new ArrayList<>(DesignPythonItem.OUTWEAR_DRESS_BLOUSE); - all.addAll(new ArrayList<>(DesignPythonItem.SKIRT_TROUSERS)); - return all; + private List calculateCurrentDesignPintPictureTypeLayout(String modelSex) { + if (modelSex.equals(Sex.FEMALE.getValue())) { + Long randomIndex = RandomsUtil.randomSysFile(0L, 3L); + if (randomIndex == 0) { + return DesignPythonItem.OUTWEAR_DRESS_BLOUSE; + } + if (randomIndex == 1) { + return DesignPythonItem.SKIRT_TROUSERS; + } + if (randomIndex == 2) { + List all = new ArrayList<>(DesignPythonItem.OUTWEAR_DRESS_BLOUSE); + all.addAll(new ArrayList<>(DesignPythonItem.SKIRT_TROUSERS)); + return all; + } + }else if (modelSex.equals(Sex.MALE.getValue())) { + Long randomIndex = RandomsUtil.randomSysFile(0L, 3L); + if (randomIndex == 0) { + return DesignPythonItem.TOPS; + } + if (randomIndex == 1) { + return DesignPythonItem.BOTTOMS; + } + if (randomIndex == 2) { + List all = new ArrayList<>(DesignPythonItem.TOPS); + all.addAll(new ArrayList<>(DesignPythonItem.BOTTOMS)); + return all; + } } return null; } @@ -399,12 +415,17 @@ public class PythonService { if (CollectionUtils.isEmpty(printBoardElements)) { return 0; } - long totalNum = printBoardElements.size() / 2; - long pinNum = printBoardElements.stream().filter(f -> f.getHasPin() == 1).count(); - if (pinNum >= totalNum) { + long noPinNum = printBoardElements.stream().filter(f -> f.getHasPin() == 0).count(); + if (noPinNum == 0L) { return 0; + }else { + long pinNum = printBoardElements.stream().filter(f -> f.getHasPin() == 1).count(); + if (8 - pinNum < 4) { + return RandomsUtil.randomSysFile(0L, 8 - pinNum + 1); + }else { + return RandomsUtil.randomSysFile(0L, 4L + 1); + } } - return totalNum - pinNum; } private List coverToDesignPythonItem(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType) { @@ -1568,9 +1589,14 @@ public class PythonService { print.setPath("none"); return print; } - List printBoardElements = elementVO.getPrintBoardElements() - .stream() - .filter(f -> !elementVO.getHasUseMd5List().contains(f.getMd5())).collect(Collectors.toList()); + List printBoardElements; + if (designPrintPictureType.equals(CurrentDesignPrintPictureTypeEnum.PIN)) { + printBoardElements = elementVO.getPrintBoardElements() + .stream() + .filter(f -> !elementVO.getHasUseMd5List().contains(f.getMd5())).collect(Collectors.toList()); + }else { + printBoardElements = elementVO.getPrintBoardElements(); + } if (CollectionUtil.isEmpty(printBoardElements)) { print.setPath("none"); return print; diff --git a/src/main/java/com/ai/da/service/AccountService.java b/src/main/java/com/ai/da/service/AccountService.java index 0df98b28..0e133b36 100644 --- a/src/main/java/com/ai/da/service/AccountService.java +++ b/src/main/java/com/ai/da/service/AccountService.java @@ -94,4 +94,6 @@ public interface AccountService extends IService { String getUserLanguage(); String changeUserLanguage(String language); + + Boolean trialUserLogout(); } diff --git a/src/main/java/com/ai/da/service/LibraryService.java b/src/main/java/com/ai/da/service/LibraryService.java index 218c7150..8bdb6af5 100644 --- a/src/main/java/com/ai/da/service/LibraryService.java +++ b/src/main/java/com/ai/da/service/LibraryService.java @@ -81,4 +81,6 @@ public interface LibraryService extends IService { Boolean checkMd5(String level1Type, String level2Type, String sex, String md5); void batchDeleteLibrary(LibraryDeleteDTO deleteDTO); + + void deleteTrialData(Long id); } diff --git a/src/main/java/com/ai/da/service/UserLikeGroupService.java b/src/main/java/com/ai/da/service/UserLikeGroupService.java index 551263f1..ff7aa862 100644 --- a/src/main/java/com/ai/da/service/UserLikeGroupService.java +++ b/src/main/java/com/ai/da/service/UserLikeGroupService.java @@ -32,4 +32,5 @@ public interface UserLikeGroupService extends IService { */ UserLikeChooseVO choose(Long userGroupId); + void deleteTrialData(Long id); } 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 38d7b728..4e6fd355 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -9,6 +9,8 @@ import com.ai.da.common.response.ResultEnum; import com.ai.da.common.security.jwt.JWTTokenHelper; import com.ai.da.common.utils.*; import com.ai.da.mapper.AccountMapper; +import com.ai.da.mapper.LibraryMapper; +import com.ai.da.mapper.UserLikeGroupMapper; import com.ai.da.mapper.entity.Account; import com.ai.da.mapper.entity.AccountLoginLog; import com.ai.da.model.dto.*; @@ -18,6 +20,8 @@ import com.ai.da.model.vo.AccountPreLoginVO; import com.ai.da.model.vo.AuthPrincipalVo; import com.ai.da.service.AccountLoginLogService; import com.ai.da.service.AccountService; +import com.ai.da.service.LibraryService; +import com.ai.da.service.UserLikeGroupService; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -50,7 +54,13 @@ public class AccountServiceImpl extends ServiceImpl impl private JWTTokenHelper jwtTokenHelper; @Resource - AccountLoginLogService accountLoginLogService; + private AccountLoginLogService accountLoginLogService; + + @Resource + private LibraryService libraryService; + + @Resource + private UserLikeGroupService userLikeGroupService; @Override @@ -355,6 +365,7 @@ public class AccountServiceImpl extends ServiceImpl impl account.setValidStartTime(Long.valueOf(accountAddDTO.getValidStartTime())); account.setValidEndTime(Long.valueOf(accountAddDTO.getValidEndTime())); account.setCreateDate(new Date()); + account.setIsTrial(accountAddDTO.getIsTrial()); return accountMapper.insert(account) > 0; } @@ -419,4 +430,16 @@ public class AccountServiceImpl extends ServiceImpl impl String accountToken = createAccountToken(account); return accountToken; } + + @Override + public Boolean trialUserLogout() { + AuthPrincipalVo userInfo = UserContext.getUserHolder(); + Account account = accountMapper.selectById(userInfo.getId()); + if (account.getIsTrial() != 1) { + throw new BusinessException("用户为正式用户"); + } + libraryService.deleteTrialData(userInfo.getId()); + userLikeGroupService.deleteTrialData(userInfo.getId()); + return Boolean.TRUE; + } } diff --git a/src/main/java/com/ai/da/service/impl/ClassificationServiceImpl.java b/src/main/java/com/ai/da/service/impl/ClassificationServiceImpl.java index 2a6c665a..d2453d2d 100644 --- a/src/main/java/com/ai/da/service/impl/ClassificationServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/ClassificationServiceImpl.java @@ -244,7 +244,7 @@ public class ClassificationServiceImpl implements ClassificationService { qw.lambda().eq(Classification::getClassificationName, classificationDTO.getClassificationName()); List classificationList = classificationMapper.selectList(qw); if (CollectionUtil.isNotEmpty(classificationList)) { - throw new BusinessException("classificationName.already.exists", ResultEnum.WARNING.getCode()); + throw new BusinessException("classificationName.already.exists", ResultEnum.PROMPT.getCode()); } } } 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 bd426491..b16a9dd0 100644 --- a/src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java @@ -138,18 +138,29 @@ public class LibraryServiceImpl extends ServiceImpl impl // 新增分类过滤 if (CollectionUtil.isNotEmpty(query.getClassificationIdList())) { List libraryIdList = new ArrayList<>(); - for (int i = 0; i < query.getClassificationIdList().size(); i++) { - List libraryIdListByClassificationId = classificationService.getLibraryIdListByClassificationId(query.getClassificationIdList().get(i)); - if (i == 0) { - libraryIdList.addAll(libraryIdListByClassificationId); - }else { - libraryIdList.retainAll(libraryIdListByClassificationId); + if (query.getIntersection() == 1) { + for (Long classificationId : query.getClassificationIdList()) { + libraryIdList.addAll(classificationService.getLibraryIdListByClassificationId(classificationId)); } - if (CollectionUtil.isEmpty(libraryIdList)) { + if (CollectionUtil.isNotEmpty(libraryIdList)) { + queryWrapper.lambda().in(Library::getId, libraryIdList); + }else { return PageBaseResponse.success(new Page<>()); } + }else { + for (int i = 0; i < query.getClassificationIdList().size(); i++) { + List libraryIdListByClassificationId = classificationService.getLibraryIdListByClassificationId(query.getClassificationIdList().get(i)); + if (i == 0) { + libraryIdList.addAll(libraryIdListByClassificationId); + }else { + libraryIdList.retainAll(libraryIdListByClassificationId); + } + if (CollectionUtil.isEmpty(libraryIdList)) { + return PageBaseResponse.success(new Page<>()); + } + } + queryWrapper.lambda().in(Library::getId, libraryIdList); } - queryWrapper.lambda().in(Library::getId, libraryIdList); } queryWrapper.orderByDesc("id"); IPage page = getBaseMapper().selectPage( @@ -358,6 +369,13 @@ public class LibraryServiceImpl extends ServiceImpl impl } + @Override + public void deleteTrialData(Long userId) { + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(Library::getAccountId, userId); + libraryMapper.delete(qw); + } + private void checkModel(String value, List modelIds, Integer deleteModelConfirm) { AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder(); QueryWrapper qw = new QueryWrapper<>(); diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index f5da4974..b9e73868 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -6,7 +6,9 @@ import com.ai.da.common.utils.DateUtil; import com.ai.da.common.utils.MinioUtil; import com.ai.da.mapper.TDesignPythonOutfitMapper; import com.ai.da.mapper.UserLikeGroupMapper; +import com.ai.da.mapper.UserLikeMapper; import com.ai.da.mapper.entity.TDesignPythonOutfit; +import com.ai.da.mapper.entity.UserLike; import com.ai.da.mapper.entity.UserLikeGroup; import com.ai.da.model.vo.*; import com.ai.da.service.AccountService; @@ -23,6 +25,7 @@ import java.util.Date; import java.util.List; import java.util.Objects; import java.util.TimeZone; +import java.util.stream.Collectors; /** * 服务实现类 @@ -42,6 +45,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); + qw.lambda().eq(UserLikeGroup::getAccountId, userId); + List userLikeGroupIdList = userLikeGroupMapper.selectList(qw).stream() + .map(UserLikeGroup::getId) + .collect(Collectors.toList()); + userLikeGroupMapper.delete(qw); + if (CollectionUtil.isNotEmpty(userLikeGroupIdList)) { + QueryWrapper userLikeQueryWrapper = new QueryWrapper<>(); + userLikeQueryWrapper.lambda().in(UserLike::getUserLikeGroupId, userLikeGroupIdList); + userLikeMapper.delete(userLikeQueryWrapper); + } + } } 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 11fc106b..2acacda2 100644 --- a/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java @@ -136,7 +136,7 @@ public class WorkspaceServiceImpl extends ServiceImpl workspaces = baseMapper.selectList(qw); if (!CollectionUtils.isEmpty(workspaces)) { - throw new BusinessException("the.workspaceName.already.exists", ResultEnum.WARNING.getCode()); + throw new BusinessException("the.workspaceName.already.exists", ResultEnum.PROMPT.getCode()); } } @@ -475,7 +475,7 @@ public class WorkspaceServiceImpl extends ServiceImpl workspaces = workspaceMapper.selectList(qw); if (!CollectionUtils.isEmpty(workspaces)) { - throw new BusinessException("unable.to.delete.the.workspace.you.are.currently.using", ResultEnum.WARNING.getCode()); + throw new BusinessException("unable.to.delete.the.workspace.you.are.currently.using", ResultEnum.PROMPT.getCode()); } workspaceMapper.deleteBatchIds(deleteIds); return deleteIds; diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties index 5fbaa235..5d0f6e2f 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -141,12 +141,12 @@ the.verification.code.has.expired=Verification code has expired. Please request verification.code.error=Verification code entered is incorrect. Please check and try again. the.number.of.PIN.top.or.bottom.or.outerwear.sketchBoard.cannot.be.more.than.8=You cannot have more than 8 PIN tops, bottoms, or outerwear in the sketchBoard. Please adjust accordingly. hsv.value.cannot.exceed.the.maximum.of.8=hsv value cannot exceed the maximum of 8. - -# Warnings: -# 用来提醒用户可能会导致不良后果的操作,但不一定是错误。用户需要认真考虑是否继续当前操作。 the.workspaceName.already.exists=A workspace with this name already exists. unable.to.delete.the.workspace.you.are.currently.using=The workspace you are currently using cannot be deleted. Please select another workspace before trying to delete. classificationName.already.exists=The label name you've entered already exists. Please enter a different label name to avoid duplication. + +# Warnings: +# 用来提醒用户可能会导致不良后果的操作,但不一定是错误。用户需要认真考虑是否继续当前操作。 the.classification.you.deleted.has.associated.library=The label you are attempting to delete is associated with existing data. Are you sure you wish to proceed with deletion? the.model.has.been.referenced.by.the.workspace=This model is currently in use by a workspace. Deleting it might affect the workspace. Confirm deletion only if you are sure.