fix:二创报错
This commit is contained in:
@@ -3,8 +3,11 @@ package com.ai.da.mapper.primary;
|
|||||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||||
import com.ai.da.mapper.primary.entity.CollectionSort;
|
import com.ai.da.mapper.primary.entity.CollectionSort;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.apache.ibatis.annotations.Update;
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface CollectionSortMapper extends CommonMapper<CollectionSort> {
|
public interface CollectionSortMapper extends CommonMapper<CollectionSort> {
|
||||||
@Update("UPDATE collection_sort SET sort = sort + 1 " +
|
@Update("UPDATE collection_sort SET sort = sort + 1 " +
|
||||||
"WHERE parent_id = #{parentId} " +
|
"WHERE parent_id = #{parentId} " +
|
||||||
@@ -15,4 +18,8 @@ public interface CollectionSortMapper extends CommonMapper<CollectionSort> {
|
|||||||
@Param("relationType") String relationType,
|
@Param("relationType") String relationType,
|
||||||
@Param("originalSort") int originalSort
|
@Param("originalSort") int originalSort
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@Select("SELECT * FROM collection_sort WHERE parent_id IN (SELECT id FROM collection_sort WHERE relation_id = #{relationId})")
|
||||||
|
List<CollectionSort> queryCollectionSortsIsNotDesignByUserLikeRelationId(@Param("relationId") Long relationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||||||
import com.ai.da.common.config.exception.BusinessException;
|
import com.ai.da.common.config.exception.BusinessException;
|
||||||
import com.ai.da.common.constant.CommonConstant;
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
import com.ai.da.common.context.UserContext;
|
import com.ai.da.common.context.UserContext;
|
||||||
|
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
||||||
import com.ai.da.common.response.PageBaseResponse;
|
import com.ai.da.common.response.PageBaseResponse;
|
||||||
import com.ai.da.common.response.ResultEnum;
|
import com.ai.da.common.response.ResultEnum;
|
||||||
import com.ai.da.common.utils.CopyUtil;
|
import com.ai.da.common.utils.CopyUtil;
|
||||||
@@ -13,6 +14,7 @@ import com.ai.da.mapper.primary.*;
|
|||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
import com.ai.da.mapper.primary.entity.Collection;
|
import com.ai.da.mapper.primary.entity.Collection;
|
||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
|
import com.ai.da.model.enums.CollectionType;
|
||||||
import com.ai.da.model.enums.DesignProcess;
|
import com.ai.da.model.enums.DesignProcess;
|
||||||
import com.ai.da.model.enums.Position;
|
import com.ai.da.model.enums.Position;
|
||||||
import com.ai.da.model.enums.Sex;
|
import com.ai.da.model.enums.Sex;
|
||||||
@@ -57,6 +59,8 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
@Resource
|
@Resource
|
||||||
private CollectionSortService collectionSortService;
|
private CollectionSortService collectionSortService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private CollectionSortMapper collectionSortMapper;
|
||||||
|
@Resource
|
||||||
private TCollectionElementRelationMapper collectionElementRelationMapper;
|
private TCollectionElementRelationMapper collectionElementRelationMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -132,6 +136,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
@Resource
|
@Resource
|
||||||
private ProjectMapper projectMapper;
|
private ProjectMapper projectMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CollectionElementRelModelMapper collectionElementRelModelMapper;
|
||||||
|
@Resource
|
||||||
|
private ToProductImageResultMapper toProductImageResultMapper;
|
||||||
|
@Resource
|
||||||
|
private ToProductImageRecordMapper toProductImageRecordMapper;
|
||||||
|
@Resource
|
||||||
|
private PoseTransformationMapper poseTransformationMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long publish(MultipartFile file, String data) {
|
public Long publish(MultipartFile file, String data) {
|
||||||
@@ -200,7 +213,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||||
Workspace workspace = workspaceMapper.selectById(workspaceId);
|
Workspace workspace = workspaceMapper.selectById(workspaceId);
|
||||||
|
|
||||||
project.setId(null);
|
project.setId(projectId);
|
||||||
projectSnapshot.setProject(project);
|
projectSnapshot.setProject(project);
|
||||||
workspace.setId(null);
|
workspace.setId(null);
|
||||||
projectSnapshot.setWorkspace(workspace);
|
projectSnapshot.setWorkspace(workspace);
|
||||||
@@ -525,7 +538,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PortfolioVO detail(PortfolioDTO portfolioDTO) {
|
public PortfolioVO detail(PortfolioDTO portfolioDTO) {
|
||||||
// AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||||
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
||||||
if (vo.getOpenSource() == 1) {
|
if (vo.getOpenSource() == 1) {
|
||||||
@@ -556,19 +569,19 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
vo.setLikeNum(redisUtil.getLikeCount(vo.getId()));
|
vo.setLikeNum(redisUtil.getLikeCount(vo.getId()));
|
||||||
String avatar;
|
String avatar;
|
||||||
Account account = accountMapper.selectById(vo.getAccountId());
|
Account account = accountMapper.selectById(vo.getAccountId());
|
||||||
if (Objects.isNull(portfolioDTO.getAccountId())) {
|
if (userHolder == null) {
|
||||||
vo.setIsLike(0);
|
vo.setIsLike(0);
|
||||||
vo.setIsFollow(0);
|
vo.setIsFollow(0);
|
||||||
avatar = CommonConstant.DEFAULT_AVATAR;
|
avatar = CommonConstant.DEFAULT_AVATAR;
|
||||||
} else {
|
} else {
|
||||||
boolean postLikedByUser = redisUtil.isPostLikedByUser(portfolioDTO.getId(), portfolioDTO.getAccountId());
|
boolean postLikedByUser = redisUtil.isPostLikedByUser(portfolioDTO.getId(), userHolder.getId());
|
||||||
if (postLikedByUser) {
|
if (postLikedByUser) {
|
||||||
vo.setIsLike(1);
|
vo.setIsLike(1);
|
||||||
} else {
|
} else {
|
||||||
vo.setIsLike(0);
|
vo.setIsLike(0);
|
||||||
}
|
}
|
||||||
// 设置当前用户是否关注了所查看作品的作者
|
// 设置当前用户是否关注了所查看作品的作者
|
||||||
Integer ifFollowed = getIfFollowed(portfolio.getAccountId(), portfolioDTO.getAccountId());
|
Integer ifFollowed = getIfFollowed(portfolio.getAccountId(), userHolder.getId());
|
||||||
vo.setIsFollow(ifFollowed);
|
vo.setIsFollow(ifFollowed);
|
||||||
avatar = StringUtil.isNullOrEmpty(account.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : account.getAvatar();
|
avatar = StringUtil.isNullOrEmpty(account.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : account.getAvatar();
|
||||||
}
|
}
|
||||||
@@ -589,17 +602,17 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Objects.isNull(portfolioDTO.getAccountId())) {
|
if (userHolder == null) {
|
||||||
vo.setIsMine(0);
|
vo.setIsMine(0);
|
||||||
vo.setSelected(0);
|
vo.setSelected(0);
|
||||||
} else {
|
} else {
|
||||||
if (Objects.equals(vo.getAccountId(), portfolioDTO.getAccountId()) || Objects.equals(vo.getOriginalAccountId(), portfolioDTO.getAccountId())) {
|
if (Objects.equals(vo.getAccountId(), userHolder.getId()) || Objects.equals(vo.getOriginalAccountId(), userHolder.getId())) {
|
||||||
vo.setIsMine(1);
|
vo.setIsMine(1);
|
||||||
vo.setSelected(1);
|
vo.setSelected(1);
|
||||||
} else {
|
} else {
|
||||||
vo.setIsMine(0);
|
vo.setIsMine(0);
|
||||||
QueryWrapper<UserLikeGroup> getSelectedQw = new QueryWrapper<>();
|
QueryWrapper<UserLikeGroup> getSelectedQw = new QueryWrapper<>();
|
||||||
getSelectedQw.lambda().eq(UserLikeGroup::getAccountId, portfolioDTO.getAccountId());
|
getSelectedQw.lambda().eq(UserLikeGroup::getAccountId, userHolder.getId());
|
||||||
getSelectedQw.lambda().eq(UserLikeGroup::getOriginalPortfolioId, vo.getId());
|
getSelectedQw.lambda().eq(UserLikeGroup::getOriginalPortfolioId, vo.getId());
|
||||||
List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(getSelectedQw);
|
List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(getSelectedQw);
|
||||||
if (CollectionUtils.isEmpty(userLikeGroups)) {
|
if (CollectionUtils.isEmpty(userLikeGroups)) {
|
||||||
@@ -616,18 +629,17 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ProjectChooseVO choose(PortfolioDTO portfolioDTO) {
|
public ProjectChooseVO choose(PortfolioDTO portfolioDTO) {
|
||||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
Long accountId = authPrincipalVo.getId();
|
|
||||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||||
|
|
||||||
String snapshot = portfolio.getSnapshot();
|
String snapshot = portfolio.getSnapshot();
|
||||||
ProjectSnapshot projectSnapshot = JSONObject.parseObject(snapshot, ProjectSnapshot.class);
|
ProjectSnapshot projectSnapshot = JSONObject.parseObject(snapshot, ProjectSnapshot.class);
|
||||||
|
Project projectOld = projectSnapshot.getProject();
|
||||||
Project project = projectSnapshot.getProject();
|
Workspace workspaceOld = projectSnapshot.getWorkspace();
|
||||||
|
List<CollectionElement> collectionElementListOld = projectSnapshot.getCollectionElementList();
|
||||||
Long projectId = project.getId();
|
UserLikeGroup userLikeGroupOld = projectSnapshot.getUserLikeGroup();
|
||||||
|
List<UserLikeSnapshot> userLikeListOld = projectSnapshot.getUserLikeList();
|
||||||
UserLikeGroup userLikeGroup = projectSnapshot.getUserLikeGroup();
|
Project project = CopyUtil.copyObject(projectOld, Project.class);
|
||||||
|
|
||||||
project.setCreateTime(LocalDateTime.now());
|
project.setCreateTime(LocalDateTime.now());
|
||||||
project.setId(null);
|
project.setId(null);
|
||||||
@@ -653,182 +665,230 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
|
|
||||||
Long projectIdNew = project.getId();
|
Long projectIdNew = project.getId();
|
||||||
|
|
||||||
Workspace workspaceCopy = projectSnapshot.getWorkspace();
|
workspaceOld.setAccountId(accountId);
|
||||||
workspaceCopy.setAccountId(accountId);
|
workspaceOld.setProjectId(projectIdNew);
|
||||||
workspaceCopy.setProjectId(projectIdNew);
|
workspaceOld.setId(null);
|
||||||
workspaceCopy.setId(null);
|
workspaceMapper.insert(workspaceOld);
|
||||||
workspaceMapper.insert(workspaceCopy);
|
|
||||||
|
|
||||||
Workspace workspace = workspaceService.getCurrentWorkspace();
|
|
||||||
|
|
||||||
List<CollectionElement> collectionElementListOld = projectSnapshot.getCollectionElementList();
|
|
||||||
Long collectionIdNew;
|
|
||||||
if (collectionElementListOld.isEmpty()){
|
|
||||||
throw new BusinessException("No elements in collection.");
|
|
||||||
} else {
|
|
||||||
Long collectionIdOld = collectionElementListOld.get(0).getCollectionId();
|
|
||||||
Collection collection = collectionMapper.selectById(collectionIdOld);
|
|
||||||
if (Objects.nonNull(collection) && Objects.nonNull(collection.getMoodTemplateId())){
|
|
||||||
CollectionElement moodTemplateElement = collectionElementMapper.selectById(collection.getMoodTemplateId());
|
|
||||||
if (Objects.nonNull(moodTemplateElement)){
|
|
||||||
moodTemplateElement.setId(null);
|
|
||||||
moodTemplateElement.setAccountId(accountId);
|
|
||||||
moodTemplateElement.setProjectId(projectIdNew);
|
|
||||||
moodTemplateElement.setCreateDate(new Date());
|
|
||||||
collectionElementMapper.insert(moodTemplateElement);
|
|
||||||
|
|
||||||
collection.setMoodTemplateId(String.valueOf(moodTemplateElement.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
collection.setId(null);
|
|
||||||
collection.setAccountId(accountId);
|
|
||||||
collection.setCreateDate(new Date());
|
|
||||||
collectionMapper.insert(collection);
|
|
||||||
|
|
||||||
collectionIdNew = collection.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
Design design = new Design();
|
|
||||||
design.setCollectionId(collectionIdNew);
|
|
||||||
design.setAccountId(authPrincipalVo.getId());
|
|
||||||
if (workspace.getSex().equals(Sex.FEMALE.getValue())) {
|
|
||||||
design.setTemplateId(workspace.getMannequinFemaleId());
|
|
||||||
design.setModelType(workspace.getMannequinFemaleType());
|
|
||||||
} else {
|
|
||||||
design.setTemplateId(workspace.getMannequinMaleId());
|
|
||||||
design.setModelType(workspace.getMannequinMaleType());
|
|
||||||
}
|
|
||||||
design.setSystemScale(BigDecimal.valueOf(workspace.getSystemDesignerPercentage()));
|
|
||||||
if (workspace.getPosition().equals(Position.OVERALL.getValue())) {
|
|
||||||
design.setSingleOverall("overall");
|
|
||||||
design.setSwitchCategory("");
|
|
||||||
project.setProcess(DesignProcess.SERIES_DESIGN.name());
|
|
||||||
} else {
|
|
||||||
design.setSingleOverall("single");
|
|
||||||
design.setSwitchCategory(workspace.getPosition());
|
|
||||||
project.setProcess(DesignProcess.SINGLE_DESIGN.name());
|
|
||||||
}
|
|
||||||
design.setCreateDate(new Date());
|
|
||||||
designMapper.insert(design);
|
|
||||||
projectMapper.updateById(project);
|
|
||||||
|
|
||||||
|
// 复制collectionElement
|
||||||
for (CollectionElement element : collectionElementListOld) {
|
for (CollectionElement element : collectionElementListOld) {
|
||||||
element.setCollectionId(collectionIdNew);
|
if (element.getLevel1Type().equals(CollectionLevel1TypeEnum.MODEL.getRealName())) {
|
||||||
element.setProjectId(projectIdNew);
|
LambdaQueryWrapper<CollectionElementRelModel> relModelLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
relModelLambdaQueryWrapper.eq(CollectionElementRelModel::getCollectionElementId, element.getId());
|
||||||
|
CollectionElementRelModel collectionElementRelModelCopy = collectionElementRelModelMapper.selectOne(relModelLambdaQueryWrapper);
|
||||||
|
// element.setCollectionId(collectionIdNew);
|
||||||
element.setId(null);
|
element.setId(null);
|
||||||
element.setCreateDate(new Date());
|
element.setCreateDate(new Date());
|
||||||
element.setUpdateDate(null);
|
element.setUpdateDate(null);
|
||||||
|
element.setAccountId(accountId);
|
||||||
|
element.setProjectId(projectIdNew);
|
||||||
|
collectionElementMapper.insert(element);
|
||||||
|
Long collectionElementNewID = element.getId();
|
||||||
|
if (collectionElementRelModelCopy != null) {
|
||||||
|
collectionElementRelModelCopy.setId(null);
|
||||||
|
collectionElementRelModelCopy.setCollectionElementId(collectionElementNewID);
|
||||||
|
collectionElementRelModelMapper.insert(collectionElementRelModelCopy);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
} else {
|
||||||
|
// element.setCollectionId(collectionIdNew);
|
||||||
|
element.setId(null);
|
||||||
|
element.setCreateDate(new Date());
|
||||||
|
element.setUpdateDate(null);
|
||||||
|
element.setAccountId(accountId);
|
||||||
|
element.setProjectId(projectIdNew);
|
||||||
collectionElementMapper.insert(element);
|
collectionElementMapper.insert(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Objects.nonNull(userLikeGroup)) {
|
}
|
||||||
Long portfolioUserLikeGroupId = userLikeGroup.getId();
|
|
||||||
|
|
||||||
UserLikeGroup userLikeGroupNew = projectSnapshot.getUserLikeGroup();
|
|
||||||
userLikeGroupNew.setId(null);
|
if (userLikeGroupOld != null) {
|
||||||
userLikeGroupNew.setCollectionId(collectionIdNew);
|
|
||||||
userLikeGroupNew.setCreateDate(new Date());
|
Long collectionIdOld = userLikeGroupOld.getCollectionId();
|
||||||
userLikeGroupNew.setProjectId(projectIdNew);
|
Collection collectionCopy = collectionMapper.selectById(collectionIdOld);
|
||||||
|
collectionCopy.setId(null);
|
||||||
|
collectionCopy.setAccountId(accountId);
|
||||||
|
collectionCopy.setCreateDate(new Date());
|
||||||
|
collectionMapper.insert(collectionCopy);
|
||||||
|
Long collectionIdNew = collectionCopy.getId();
|
||||||
|
|
||||||
|
userLikeGroupOld.setId(null);
|
||||||
|
userLikeGroupOld.setCollectionId(collectionIdNew);
|
||||||
|
userLikeGroupOld.setCreateDate(new Date());
|
||||||
|
userLikeGroupOld.setProjectId(projectIdNew);
|
||||||
if (portfolio.getOriginal() == 1) {
|
if (portfolio.getOriginal() == 1) {
|
||||||
if (Objects.equals(portfolio.getAccountId(), accountId)) {
|
if (Objects.equals(portfolio.getAccountId(), accountId)) {
|
||||||
userLikeGroupNew.setOriginal(1);
|
userLikeGroupOld.setOriginal(1);
|
||||||
} else {
|
} else {
|
||||||
userLikeGroupNew.setOriginal(0);
|
userLikeGroupOld.setOriginal(0);
|
||||||
userLikeGroupNew.setOriginalAccountId(portfolio.getAccountId());
|
userLikeGroupOld.setOriginalAccountId(portfolio.getAccountId());
|
||||||
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
|
userLikeGroupOld.setOriginalPortfolioId(portfolio.getId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
userLikeGroupNew.setOriginal(0);
|
userLikeGroupOld.setOriginal(0);
|
||||||
userLikeGroupNew.setOriginalAccountId(portfolio.getOriginalAccountId());
|
userLikeGroupOld.setOriginalAccountId(portfolio.getOriginalAccountId());
|
||||||
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
|
userLikeGroupOld.setOriginalPortfolioId(portfolio.getId());
|
||||||
}
|
}
|
||||||
userLikeGroupNew.setAccountId(accountId);
|
userLikeGroupOld.setAccountId(accountId);
|
||||||
userLikeGroupNew.setUpdateDate(new Date());
|
userLikeGroupOld.setUpdateDate(new Date());
|
||||||
userLikeGroupMapper.insert(userLikeGroupNew);
|
userLikeGroupMapper.insert(userLikeGroupOld);
|
||||||
|
Long userLikeGroupIdNew = userLikeGroupOld.getId();
|
||||||
|
|
||||||
List<UserLikeSnapshot> userLikeList = projectSnapshot.getUserLikeList();
|
|
||||||
if (CollectionUtil.isNotEmpty(userLikeList)) {
|
|
||||||
for (UserLikeSnapshot userLike : userLikeList) {
|
|
||||||
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
|
||||||
TDesignPythonOutfit designPythonOutfit = userLike.getDesignPythonOutfit();
|
|
||||||
designPythonOutfit.setDesignId(design.getId());
|
|
||||||
designPythonOutfit.setDesignItemId(-1L);
|
|
||||||
designPythonOutfit.setCollectionId(collectionIdNew);
|
|
||||||
designPythonOutfit.setCreateDate(LocalDateTime.now());
|
|
||||||
|
|
||||||
designPythonOutfit.setId(null);
|
//根据designId进行分组
|
||||||
// 这里插入的accountId是原作者的(二创),是否需要修改?
|
Map<Long, List<UserLikeSnapshot>> userLikeMapByDesignId = userLikeListOld.stream()
|
||||||
designPythonOutfitMapper.insert(designPythonOutfit);
|
.filter(userLikeSnapshot -> userLikeSnapshot.getDesignItem() != null)
|
||||||
Long designOutfitIdNew = designPythonOutfit.getId();
|
.collect(Collectors.groupingBy(userLikeSnapshot -> userLikeSnapshot.getDesignItem().getDesignId()));
|
||||||
userLike.setDesignOutfitId(designOutfitIdNew);
|
userLikeMapByDesignId.forEach((designId, userLikeListOld1) -> {
|
||||||
|
Design design = designMapper.selectById(designId);
|
||||||
|
design.setId(null);
|
||||||
|
design.setCollectionId(collectionIdNew);
|
||||||
|
design.setAccountId(accountId);
|
||||||
|
design.setCreateDate(new Date());
|
||||||
|
designMapper.insert(design);
|
||||||
|
|
||||||
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
for (UserLikeSnapshot userLikeSnapshot : userLikeListOld1) {
|
||||||
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
|
||||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = userLike.getTDesignPythonOutfitDetailList();
|
|
||||||
if (CollectionUtil.isNotEmpty(tDesignPythonOutfitDetails)){
|
// 4. 处理DesignItem数据
|
||||||
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
DesignItem designItem = userLikeSnapshot.getDesignItem();
|
||||||
tDesignPythonOutfitDetail.setId(null);
|
if (designItem != null) {
|
||||||
tDesignPythonOutfitDetail.setUserId(accountId);
|
designItem.setId(null);
|
||||||
tDesignPythonOutfitDetail.setDesignId(design.getId());
|
designItem.setAccountId(accountId);
|
||||||
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
designItem.setDesignId(design.getId());
|
||||||
tDesignPythonOutfitDetail.setCreateDate(LocalDateTime.now());
|
designItem.setCollectionId(collectionIdNew);
|
||||||
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
designItem.setCreateDate(new Date());
|
||||||
|
designItemMapper.insert(designItem);
|
||||||
|
|
||||||
|
// 5. 处理DesignItemDetailSnapshot数据
|
||||||
|
List<DesignItemDetailSnapshot> itemDetailSnapshots = userLikeSnapshot.getDesignItemDetailList();
|
||||||
|
if (itemDetailSnapshots != null && !itemDetailSnapshots.isEmpty()) {
|
||||||
|
for (DesignItemDetailSnapshot itemDetailSnapshot : itemDetailSnapshots) {
|
||||||
|
//只复制未删除的
|
||||||
|
if (itemDetailSnapshot.getIsDeleted() == 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 转换为原实体类
|
||||||
|
DesignItemDetail designItemDetail = CopyUtil.copyObject(itemDetailSnapshot, DesignItemDetail.class);
|
||||||
|
designItemDetail.setId(null);
|
||||||
|
// 更新外键为新插入的designItem的ID
|
||||||
|
designItemDetail.setDesignItemId(designItem.getId());
|
||||||
|
designItemDetail.setDesignId(design.getId());
|
||||||
|
designItemDetail.setCreateDate(new Date());
|
||||||
|
designItemDetail.setAccountId(accountId);
|
||||||
|
designItemDetailMapper.insert(designItemDetail);
|
||||||
|
|
||||||
|
// 6. 处理DesignItemDetailPrint数据
|
||||||
|
List<DesignItemDetailPrint> prints = itemDetailSnapshot.getDesignItemDetailPrintList();
|
||||||
|
if (prints != null && !prints.isEmpty()) {
|
||||||
|
for (DesignItemDetailPrint print : prints) {
|
||||||
|
print.setId(null);
|
||||||
|
print.setCreateDate(LocalDateTime.now());
|
||||||
|
// 更新外键为新插入的designItemDetail的ID
|
||||||
|
print.setDesignItemDetailId(designItemDetail.getId());
|
||||||
|
designItemDetailPrintMapper.insert(print);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DesignItem designItemOld = userLike.getDesignItem();
|
|
||||||
designItemOld.setId(null);
|
|
||||||
designItemOld.setAccountId(accountId);
|
|
||||||
designItemOld.setDesignId(design.getId());
|
|
||||||
designItemOld.setCollectionId(collectionIdNew);
|
|
||||||
designItemOld.setCreateDate(new Date());
|
|
||||||
designItemMapper.insert(designItemOld);
|
|
||||||
Long designItemIdNew = designItemOld.getId();
|
|
||||||
|
|
||||||
designPythonOutfit.setDesignItemId(designItemIdNew);
|
// 2. 处理DesignPythonOutfit数据
|
||||||
designPythonOutfitMapper.updateById(designPythonOutfit);
|
TDesignPythonOutfit outfit = userLikeSnapshot.getDesignPythonOutfit();
|
||||||
|
if (outfit != null) {
|
||||||
|
// 清除原有ID,使用新ID插入
|
||||||
|
outfit.setId(null);
|
||||||
|
outfit.setDesignId(design.getId());
|
||||||
|
outfit.setCollectionId(collectionIdNew);
|
||||||
|
outfit.setCreateDate(LocalDateTime.now());
|
||||||
|
outfit.setDesignItemId(designItem.getId());
|
||||||
|
designPythonOutfitMapper.insert(outfit);
|
||||||
|
|
||||||
|
// 3. 处理TDesignPythonOutfitDetail数据
|
||||||
|
List<TDesignPythonOutfitDetail> outfitDetails = userLikeSnapshot.getTDesignPythonOutfitDetailList();
|
||||||
|
if (outfitDetails != null && !outfitDetails.isEmpty()) {
|
||||||
|
for (TDesignPythonOutfitDetail detail : outfitDetails) {
|
||||||
|
detail.setId(null);
|
||||||
|
// 更新外键为新插入的outfit的ID
|
||||||
|
detail.setDesignPythonOutfitId(outfit.getId());
|
||||||
|
detail.setCreateDate(LocalDateTime.now());
|
||||||
|
detail.setUpdateDate(LocalDateTime.now());
|
||||||
|
detail.setUserId(accountId);
|
||||||
|
detail.setDesignId(design.getId());
|
||||||
|
designPythonOutfitDetailMapper.insert(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UserLike userLike = CopyUtil.copyObject(userLikeSnapshot, UserLike.class);
|
||||||
|
|
||||||
userLike.setDesignItemId(designItemIdNew);
|
|
||||||
userLike.setId(null);
|
userLike.setId(null);
|
||||||
userLike.setDesignId(design.getId());
|
userLike.setDesignId(design.getId());
|
||||||
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
userLike.setUserLikeGroupId(userLikeGroupIdNew);
|
||||||
userLike.setCreateDate(new Date());
|
userLike.setDesignItemId(designItem.getId());
|
||||||
userLikeMapper.insert(userLike);
|
userLike.setDesignOutfitId(outfit.getId());
|
||||||
|
userLikeService.save(userLike);
|
||||||
|
CollectionSort collectionSortDesign = new CollectionSort();
|
||||||
|
collectionSortDesign.setProjectId(project.getId());
|
||||||
|
collectionSortDesign.setRelationId(userLike.getId());
|
||||||
|
collectionSortDesign.setRelationType(CollectionType.DESIGN.getValue());
|
||||||
|
collectionSortDesign.setCreateTime(LocalDateTime.now());
|
||||||
|
int nextSort = collectionSortService.getNextSort(projectIdNew, null);
|
||||||
|
collectionSortDesign.setSort(nextSort);
|
||||||
|
collectionSortMapper.insert(collectionSortDesign);
|
||||||
|
|
||||||
// 加入collection_sort表
|
//此集合为根据UserLikeId查询到的非Design类型的集合
|
||||||
collectionSortService.addCollectionSort(userLike.getId(), "Design", projectIdNew, null);
|
List<CollectionSort> collectionSorts = collectionSortMapper.queryCollectionSortsIsNotDesignByUserLikeRelationId(userLikeSnapshot.getId());
|
||||||
|
if (collectionSorts != null && !collectionSorts.isEmpty()) {
|
||||||
|
for (CollectionSort collectionSort : collectionSorts) {
|
||||||
|
|
||||||
List<DesignItemDetailSnapshot> designItemDetailList = userLike.getDesignItemDetailList();
|
CollectionSort collectionSortNew = new CollectionSort();
|
||||||
if (CollectionUtil.isNotEmpty(designItemDetailList)) {
|
if (collectionSort.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue()) || collectionSort.getRelationType().equals(CollectionType.RELIGHT.getValue())) {
|
||||||
for (DesignItemDetailSnapshot designItemDetailOld : designItemDetailList) {
|
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(collectionSort.getRelationId());
|
||||||
designItemDetailOld.setId(null);
|
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
|
||||||
designItemDetailOld.setAccountId(accountId);
|
toProductImageRecord.setId(null);
|
||||||
designItemDetailOld.setDesignId(design.getId());
|
toProductImageRecord.setProjectId(projectIdNew);
|
||||||
designItemDetailOld.setDesignItemId(designItemIdNew);
|
toProductImageRecord.setCreateTime(LocalDateTime.now());
|
||||||
designItemDetailOld.setCreateDate(new Date());
|
toProductImageRecord.setUserLikeGroupId(userLikeGroupIdNew);
|
||||||
designItemDetailMapper.insert(designItemDetailOld);
|
toProductImageRecordMapper.insert(toProductImageRecord);
|
||||||
Long designItemDetailIdNew = designItemDetailOld.getId();
|
toProductImageResult.setId(null);
|
||||||
|
toProductImageResult.setProjectId(projectIdNew);
|
||||||
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
|
toProductImageResult.setUserLikeGroupId(userLikeGroupIdNew);
|
||||||
|
toProductImageResultMapper.insert(toProductImageResult);
|
||||||
|
collectionSortNew.setRelationId(toProductImageResult.getId());
|
||||||
|
} else if (collectionSort.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())) {
|
||||||
|
PoseTransformation poseTransformation = poseTransformationMapper.selectById(collectionSort.getRelationId());
|
||||||
|
poseTransformation.setId(null);
|
||||||
|
poseTransformation.setProjectId(projectIdNew);
|
||||||
|
poseTransformation.setCreateTime(LocalDateTime.now());
|
||||||
|
poseTransformation.setUpdateTime(LocalDateTime.now());
|
||||||
|
poseTransformation.setAccountId(accountId);
|
||||||
|
poseTransformationMapper.insert(poseTransformation);
|
||||||
|
collectionSortNew.setRelationId(poseTransformation.getId());
|
||||||
|
|
||||||
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailOld.getDesignItemDetailPrintList();
|
|
||||||
if (CollectionUtil.isNotEmpty(designItemDetailPrintList)) {
|
|
||||||
for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) {
|
|
||||||
designItemDetailPrint.setId(null);
|
|
||||||
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
|
||||||
designItemDetailPrint.setCreateDate(LocalDateTime.now());
|
|
||||||
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
collectionSortNew.setProjectId(project.getId());
|
||||||
|
collectionSortNew.setRelationType(collectionSort.getRelationType());
|
||||||
|
collectionSortNew.setCreateTime(LocalDateTime.now());
|
||||||
|
collectionSortNew.setParentId(collectionSortDesign.getId());
|
||||||
|
int nextSort2 = collectionSortService.getNextSort(projectIdNew, collectionSortDesign.getId());
|
||||||
|
collectionSortNew.setSort(nextSort2);
|
||||||
|
collectionSortMapper.insert(collectionSortNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
ProjectDTO projectDTO = new ProjectDTO();
|
ProjectDTO projectDTO = new ProjectDTO();
|
||||||
projectDTO.setId(project.getId());
|
projectDTO.setId(project.getId());
|
||||||
|
|
||||||
|
|
||||||
return userLikeGroupService.choose(projectDTO);
|
return userLikeGroupService.choose(projectDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1271,6 +1331,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取关注列表
|
* 获取关注列表
|
||||||
|
*
|
||||||
* @param accountId
|
* @param accountId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user