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.mapper.primary.entity.CollectionSort;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CollectionSortMapper extends CommonMapper<CollectionSort> {
|
||||
@Update("UPDATE collection_sort SET sort = sort + 1 " +
|
||||
"WHERE parent_id = #{parentId} " +
|
||||
@@ -15,4 +18,8 @@ public interface CollectionSortMapper extends CommonMapper<CollectionSort> {
|
||||
@Param("relationType") String relationType,
|
||||
@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.constant.CommonConstant;
|
||||
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.ResultEnum;
|
||||
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.Collection;
|
||||
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.Position;
|
||||
import com.ai.da.model.enums.Sex;
|
||||
@@ -57,6 +59,8 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
@Resource
|
||||
private CollectionSortService collectionSortService;
|
||||
@Resource
|
||||
private CollectionSortMapper collectionSortMapper;
|
||||
@Resource
|
||||
private TCollectionElementRelationMapper collectionElementRelationMapper;
|
||||
|
||||
@Resource
|
||||
@@ -132,6 +136,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Resource
|
||||
private CollectionElementRelModelMapper collectionElementRelModelMapper;
|
||||
@Resource
|
||||
private ToProductImageResultMapper toProductImageResultMapper;
|
||||
@Resource
|
||||
private ToProductImageRecordMapper toProductImageRecordMapper;
|
||||
@Resource
|
||||
private PoseTransformationMapper poseTransformationMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long publish(MultipartFile file, String data) {
|
||||
@@ -200,7 +213,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
Workspace workspace = workspaceMapper.selectById(workspaceId);
|
||||
|
||||
project.setId(null);
|
||||
project.setId(projectId);
|
||||
projectSnapshot.setProject(project);
|
||||
workspace.setId(null);
|
||||
projectSnapshot.setWorkspace(workspace);
|
||||
@@ -525,7 +538,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
|
||||
@Override
|
||||
public PortfolioVO detail(PortfolioDTO portfolioDTO) {
|
||||
// AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
||||
if (vo.getOpenSource() == 1) {
|
||||
@@ -556,19 +569,19 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
vo.setLikeNum(redisUtil.getLikeCount(vo.getId()));
|
||||
String avatar;
|
||||
Account account = accountMapper.selectById(vo.getAccountId());
|
||||
if (Objects.isNull(portfolioDTO.getAccountId())) {
|
||||
if (userHolder == null) {
|
||||
vo.setIsLike(0);
|
||||
vo.setIsFollow(0);
|
||||
avatar = CommonConstant.DEFAULT_AVATAR;
|
||||
} else {
|
||||
boolean postLikedByUser = redisUtil.isPostLikedByUser(portfolioDTO.getId(), portfolioDTO.getAccountId());
|
||||
boolean postLikedByUser = redisUtil.isPostLikedByUser(portfolioDTO.getId(), userHolder.getId());
|
||||
if (postLikedByUser) {
|
||||
vo.setIsLike(1);
|
||||
} else {
|
||||
vo.setIsLike(0);
|
||||
}
|
||||
// 设置当前用户是否关注了所查看作品的作者
|
||||
Integer ifFollowed = getIfFollowed(portfolio.getAccountId(), portfolioDTO.getAccountId());
|
||||
Integer ifFollowed = getIfFollowed(portfolio.getAccountId(), userHolder.getId());
|
||||
vo.setIsFollow(ifFollowed);
|
||||
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.setSelected(0);
|
||||
} 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.setSelected(1);
|
||||
} else {
|
||||
vo.setIsMine(0);
|
||||
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());
|
||||
List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(getSelectedQw);
|
||||
if (CollectionUtils.isEmpty(userLikeGroups)) {
|
||||
@@ -616,18 +629,17 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ProjectChooseVO choose(PortfolioDTO portfolioDTO) {
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
Long accountId = authPrincipalVo.getId();
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||
|
||||
String snapshot = portfolio.getSnapshot();
|
||||
ProjectSnapshot projectSnapshot = JSONObject.parseObject(snapshot, ProjectSnapshot.class);
|
||||
|
||||
Project project = projectSnapshot.getProject();
|
||||
|
||||
Long projectId = project.getId();
|
||||
|
||||
UserLikeGroup userLikeGroup = projectSnapshot.getUserLikeGroup();
|
||||
Project projectOld = projectSnapshot.getProject();
|
||||
Workspace workspaceOld = projectSnapshot.getWorkspace();
|
||||
List<CollectionElement> collectionElementListOld = projectSnapshot.getCollectionElementList();
|
||||
UserLikeGroup userLikeGroupOld = projectSnapshot.getUserLikeGroup();
|
||||
List<UserLikeSnapshot> userLikeListOld = projectSnapshot.getUserLikeList();
|
||||
Project project = CopyUtil.copyObject(projectOld, Project.class);
|
||||
|
||||
project.setCreateTime(LocalDateTime.now());
|
||||
project.setId(null);
|
||||
@@ -653,182 +665,230 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
|
||||
Long projectIdNew = project.getId();
|
||||
|
||||
Workspace workspaceCopy = projectSnapshot.getWorkspace();
|
||||
workspaceCopy.setAccountId(accountId);
|
||||
workspaceCopy.setProjectId(projectIdNew);
|
||||
workspaceCopy.setId(null);
|
||||
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);
|
||||
workspaceOld.setAccountId(accountId);
|
||||
workspaceOld.setProjectId(projectIdNew);
|
||||
workspaceOld.setId(null);
|
||||
workspaceMapper.insert(workspaceOld);
|
||||
|
||||
// 复制collectionElement
|
||||
for (CollectionElement element : collectionElementListOld) {
|
||||
element.setCollectionId(collectionIdNew);
|
||||
element.setProjectId(projectIdNew);
|
||||
if (element.getLevel1Type().equals(CollectionLevel1TypeEnum.MODEL.getRealName())) {
|
||||
LambdaQueryWrapper<CollectionElementRelModel> relModelLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
relModelLambdaQueryWrapper.eq(CollectionElementRelModel::getCollectionElementId, element.getId());
|
||||
CollectionElementRelModel collectionElementRelModelCopy = collectionElementRelModelMapper.selectOne(relModelLambdaQueryWrapper);
|
||||
// element.setCollectionId(collectionIdNew);
|
||||
element.setId(null);
|
||||
element.setCreateDate(new Date());
|
||||
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);
|
||||
}
|
||||
|
||||
if (Objects.nonNull(userLikeGroup)) {
|
||||
Long portfolioUserLikeGroupId = userLikeGroup.getId();
|
||||
}
|
||||
|
||||
UserLikeGroup userLikeGroupNew = projectSnapshot.getUserLikeGroup();
|
||||
userLikeGroupNew.setId(null);
|
||||
userLikeGroupNew.setCollectionId(collectionIdNew);
|
||||
userLikeGroupNew.setCreateDate(new Date());
|
||||
userLikeGroupNew.setProjectId(projectIdNew);
|
||||
|
||||
if (userLikeGroupOld != null) {
|
||||
|
||||
Long collectionIdOld = userLikeGroupOld.getCollectionId();
|
||||
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 (Objects.equals(portfolio.getAccountId(), accountId)) {
|
||||
userLikeGroupNew.setOriginal(1);
|
||||
userLikeGroupOld.setOriginal(1);
|
||||
} else {
|
||||
userLikeGroupNew.setOriginal(0);
|
||||
userLikeGroupNew.setOriginalAccountId(portfolio.getAccountId());
|
||||
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
|
||||
userLikeGroupOld.setOriginal(0);
|
||||
userLikeGroupOld.setOriginalAccountId(portfolio.getAccountId());
|
||||
userLikeGroupOld.setOriginalPortfolioId(portfolio.getId());
|
||||
}
|
||||
} else {
|
||||
userLikeGroupNew.setOriginal(0);
|
||||
userLikeGroupNew.setOriginalAccountId(portfolio.getOriginalAccountId());
|
||||
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
|
||||
userLikeGroupOld.setOriginal(0);
|
||||
userLikeGroupOld.setOriginalAccountId(portfolio.getOriginalAccountId());
|
||||
userLikeGroupOld.setOriginalPortfolioId(portfolio.getId());
|
||||
}
|
||||
userLikeGroupNew.setAccountId(accountId);
|
||||
userLikeGroupNew.setUpdateDate(new Date());
|
||||
userLikeGroupMapper.insert(userLikeGroupNew);
|
||||
userLikeGroupOld.setAccountId(accountId);
|
||||
userLikeGroupOld.setUpdateDate(new Date());
|
||||
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);
|
||||
// 这里插入的accountId是原作者的(二创),是否需要修改?
|
||||
designPythonOutfitMapper.insert(designPythonOutfit);
|
||||
Long designOutfitIdNew = designPythonOutfit.getId();
|
||||
userLike.setDesignOutfitId(designOutfitIdNew);
|
||||
//根据designId进行分组
|
||||
Map<Long, List<UserLikeSnapshot>> userLikeMapByDesignId = userLikeListOld.stream()
|
||||
.filter(userLikeSnapshot -> userLikeSnapshot.getDesignItem() != null)
|
||||
.collect(Collectors.groupingBy(userLikeSnapshot -> userLikeSnapshot.getDesignItem().getDesignId()));
|
||||
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<>();
|
||||
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = userLike.getTDesignPythonOutfitDetailList();
|
||||
if (CollectionUtil.isNotEmpty(tDesignPythonOutfitDetails)){
|
||||
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
||||
tDesignPythonOutfitDetail.setId(null);
|
||||
tDesignPythonOutfitDetail.setUserId(accountId);
|
||||
tDesignPythonOutfitDetail.setDesignId(design.getId());
|
||||
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
||||
tDesignPythonOutfitDetail.setCreateDate(LocalDateTime.now());
|
||||
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
||||
for (UserLikeSnapshot userLikeSnapshot : userLikeListOld1) {
|
||||
|
||||
|
||||
// 4. 处理DesignItem数据
|
||||
DesignItem designItem = userLikeSnapshot.getDesignItem();
|
||||
if (designItem != null) {
|
||||
designItem.setId(null);
|
||||
designItem.setAccountId(accountId);
|
||||
designItem.setDesignId(design.getId());
|
||||
designItem.setCollectionId(collectionIdNew);
|
||||
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);
|
||||
designPythonOutfitMapper.updateById(designPythonOutfit);
|
||||
// 2. 处理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.setDesignId(design.getId());
|
||||
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
||||
userLike.setCreateDate(new Date());
|
||||
userLikeMapper.insert(userLike);
|
||||
userLike.setUserLikeGroupId(userLikeGroupIdNew);
|
||||
userLike.setDesignItemId(designItem.getId());
|
||||
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表
|
||||
collectionSortService.addCollectionSort(userLike.getId(), "Design", projectIdNew, null);
|
||||
//此集合为根据UserLikeId查询到的非Design类型的集合
|
||||
List<CollectionSort> collectionSorts = collectionSortMapper.queryCollectionSortsIsNotDesignByUserLikeRelationId(userLikeSnapshot.getId());
|
||||
if (collectionSorts != null && !collectionSorts.isEmpty()) {
|
||||
for (CollectionSort collectionSort : collectionSorts) {
|
||||
|
||||
List<DesignItemDetailSnapshot> designItemDetailList = userLike.getDesignItemDetailList();
|
||||
if (CollectionUtil.isNotEmpty(designItemDetailList)) {
|
||||
for (DesignItemDetailSnapshot designItemDetailOld : designItemDetailList) {
|
||||
designItemDetailOld.setId(null);
|
||||
designItemDetailOld.setAccountId(accountId);
|
||||
designItemDetailOld.setDesignId(design.getId());
|
||||
designItemDetailOld.setDesignItemId(designItemIdNew);
|
||||
designItemDetailOld.setCreateDate(new Date());
|
||||
designItemDetailMapper.insert(designItemDetailOld);
|
||||
Long designItemDetailIdNew = designItemDetailOld.getId();
|
||||
CollectionSort collectionSortNew = new CollectionSort();
|
||||
if (collectionSort.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue()) || collectionSort.getRelationType().equals(CollectionType.RELIGHT.getValue())) {
|
||||
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(collectionSort.getRelationId());
|
||||
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
|
||||
toProductImageRecord.setId(null);
|
||||
toProductImageRecord.setProjectId(projectIdNew);
|
||||
toProductImageRecord.setCreateTime(LocalDateTime.now());
|
||||
toProductImageRecord.setUserLikeGroupId(userLikeGroupIdNew);
|
||||
toProductImageRecordMapper.insert(toProductImageRecord);
|
||||
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.setId(project.getId());
|
||||
|
||||
|
||||
return userLikeGroupService.choose(projectDTO);
|
||||
}
|
||||
|
||||
@@ -1271,6 +1331,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
|
||||
/**
|
||||
* 获取关注列表
|
||||
*
|
||||
* @param accountId
|
||||
* @return
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user