Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
xupei
2023-11-21 16:48:10 +08:00
16 changed files with 146 additions and 35 deletions

View File

@@ -80,4 +80,10 @@ public class AccountController {
return Response.success(accountService.changeUserLanguage(language));
}
@ApiOperation(value = "试用用户退出登录")
@GetMapping("/trialUserLogout")
public Response<Boolean> trialUserLogout() {
return Response.success(accountService.trialUserLogout());
}
}

View File

@@ -74,4 +74,6 @@ public class Account implements Serializable {
* 更新时间
*/
private Date updateDate;
private Integer isTrial;
}

View File

@@ -27,4 +27,6 @@ public class AccountAddDTO {
@ApiModelProperty("End time of account validity ")
private String validEndTime;
private Integer isTrial;
}

View File

@@ -26,4 +26,7 @@ public class QueryLibraryPageDTO extends PageQueryBaseVo {
@ApiModelProperty("分类ID")
private List<Long> classificationIdList;
@ApiModelProperty("交集还是并集1交集2并集")
private Integer intersection;
}

View File

@@ -28,4 +28,6 @@ public class QueryLibraryPageServiceDTO extends PageQueryBaseVo {
private List<Long> classificationIdList;
private Integer intersection;
}

View File

@@ -26,4 +26,7 @@ public class AccountLoginVO {
@ApiModelProperty("userId")
private Long userId;
@ApiModelProperty("是否是试用用户")
private Integer isTrial;
}

View File

@@ -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<String> 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<String> all = new ArrayList<>(DesignPythonItem.OUTWEAR_DRESS_BLOUSE);
all.addAll(new ArrayList<>(DesignPythonItem.SKIRT_TROUSERS));
return all;
private List<String> 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<String> 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<String> 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<DesignPythonItem> coverToDesignPythonItem(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType) {
@@ -1568,9 +1589,14 @@ public class PythonService {
print.setPath("none");
return print;
}
List<CollectionElement> printBoardElements = elementVO.getPrintBoardElements()
.stream()
.filter(f -> !elementVO.getHasUseMd5List().contains(f.getMd5())).collect(Collectors.toList());
List<CollectionElement> 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;

View File

@@ -94,4 +94,6 @@ public interface AccountService extends IService<Account> {
String getUserLanguage();
String changeUserLanguage(String language);
Boolean trialUserLogout();
}

View File

@@ -81,4 +81,6 @@ public interface LibraryService extends IService<Library> {
Boolean checkMd5(String level1Type, String level2Type, String sex, String md5);
void batchDeleteLibrary(LibraryDeleteDTO deleteDTO);
void deleteTrialData(Long id);
}

View File

@@ -32,4 +32,5 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
*/
UserLikeChooseVO choose(Long userGroupId);
void deleteTrialData(Long id);
}

View File

@@ -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<AccountMapper, Account> 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<AccountMapper, Account> 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<AccountMapper, Account> 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;
}
}

View File

@@ -244,7 +244,7 @@ public class ClassificationServiceImpl implements ClassificationService {
qw.lambda().eq(Classification::getClassificationName, classificationDTO.getClassificationName());
List<Classification> 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());
}
}
}

View File

@@ -138,18 +138,29 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
// 新增分类过滤
if (CollectionUtil.isNotEmpty(query.getClassificationIdList())) {
List<Long> libraryIdList = new ArrayList<>();
for (int i = 0; i < query.getClassificationIdList().size(); i++) {
List<Long> 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<Long> 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<Library> page = getBaseMapper().selectPage(
@@ -358,6 +369,13 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
}
@Override
public void deleteTrialData(Long userId) {
QueryWrapper<Library> qw = new QueryWrapper<>();
qw.lambda().eq(Library::getAccountId, userId);
libraryMapper.delete(qw);
}
private void checkModel(String value, List<Long> modelIds, Integer deleteModelConfirm) {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
QueryWrapper<Workspace> qw = new QueryWrapper<>();

View File

@@ -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<UserLikeGroupMapper, U
@Resource
private UserLikeService userLikeService;
@Resource
private UserLikeMapper userLikeMapper;
@Resource
private MinioUtil minioUtil;
@@ -129,4 +135,19 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
UserLikeCollectionVO userLikeCollection = collectionService.chooseCollection(group.getCollectionId());
return new UserLikeChooseVO(userGroupId, userLikeVOS, userLikeCollection);
}
@Override
public void deleteTrialData(Long userId) {
QueryWrapper<UserLikeGroup> qw = new QueryWrapper<>();
qw.lambda().eq(UserLikeGroup::getAccountId, userId);
List<Long> userLikeGroupIdList = userLikeGroupMapper.selectList(qw).stream()
.map(UserLikeGroup::getId)
.collect(Collectors.toList());
userLikeGroupMapper.delete(qw);
if (CollectionUtil.isNotEmpty(userLikeGroupIdList)) {
QueryWrapper<UserLike> userLikeQueryWrapper = new QueryWrapper<>();
userLikeQueryWrapper.lambda().in(UserLike::getUserLikeGroupId, userLikeGroupIdList);
userLikeMapper.delete(userLikeQueryWrapper);
}
}
}

View File

@@ -136,7 +136,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
qw.lambda().eq(Workspace::getUserName, userName);
List<Workspace> 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<WorkspaceMapper, Workspace
qw.lambda().eq(Workspace::getIsLastIndex, 1);
List<Workspace> 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;

View File

@@ -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.