|
|
|
|
@@ -0,0 +1,474 @@
|
|
|
|
|
package com.ai.da.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.ai.da.common.context.UserContext;
|
|
|
|
|
import com.ai.da.common.response.PageBaseResponse;
|
|
|
|
|
import com.ai.da.common.response.Response;
|
|
|
|
|
import com.ai.da.common.utils.CopyUtil;
|
|
|
|
|
import com.ai.da.common.utils.MinioUtil;
|
|
|
|
|
import com.ai.da.mapper.primary.*;
|
|
|
|
|
import com.ai.da.mapper.primary.entity.*;
|
|
|
|
|
import com.ai.da.model.dto.PortfolioDTO;
|
|
|
|
|
import com.ai.da.model.dto.QueryPortfolioPageDTO;
|
|
|
|
|
import com.ai.da.model.enums.Position;
|
|
|
|
|
import com.ai.da.model.enums.Sex;
|
|
|
|
|
import com.ai.da.model.vo.*;
|
|
|
|
|
import com.ai.da.service.*;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.google.common.base.Function;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private UserLikeGroupMapper userLikeGroupMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CollectionMapper collectionMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CollectionElementService collectionElementService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CollectionElementMapper collectionElementMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private TCollectionElementRelationMapper collectionElementRelationMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private PortfolioMapper portfolioMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private UserLikeService userLikeService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private UserLikeMapper userLikeMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private DesignItemMapper designItemMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private DesignItemDetailMapper designItemDetailMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private DesignItemDetailPrintMapper designItemDetailPrintMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MinioUtil minioUtil;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private WorkspaceService workspaceService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private DesignMapper designMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private UserLikeGroupService userLikeGroupService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean publish(PortfolioDTO portfolioDTO) {
|
|
|
|
|
if (portfolioDTO.getPortfolioType().equals("History")) {
|
|
|
|
|
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
|
|
|
|
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
|
|
|
|
|
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
|
|
|
|
|
userLikeGroupNew.setAccountId(-1L);
|
|
|
|
|
Long collectionIdOld = userLikeGroup.getCollectionId();
|
|
|
|
|
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
|
|
|
|
|
List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
|
|
|
|
|
collectionOld.setId(null);
|
|
|
|
|
collectionMapper.insert(collectionOld);
|
|
|
|
|
Long collectionIdNew = collectionOld.getId();
|
|
|
|
|
userLikeGroupNew.setCollectionId(collectionIdNew);
|
|
|
|
|
userLikeGroupMapper.insert(userLikeGroupNew);
|
|
|
|
|
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
|
|
|
|
|
for (CollectionElement element : collectionElementListOld) {
|
|
|
|
|
element.setCollectionId(collectionIdNew);
|
|
|
|
|
element.setId(null);
|
|
|
|
|
collectionElementMapper.insert(element);
|
|
|
|
|
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
|
|
|
|
|
collectionElementRelationNew.setCollectionId(collectionIdNew);
|
|
|
|
|
collectionElementRelationNew.setElementId(element.getId());
|
|
|
|
|
collectionElementRelationNew.setCreateDate(new Date());
|
|
|
|
|
collectionElementRelationMapper.insert(collectionElementRelationNew);
|
|
|
|
|
}
|
|
|
|
|
Portfolio portfolio = new Portfolio();
|
|
|
|
|
Long coverIdOld = portfolioDTO.getCoverId();
|
|
|
|
|
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
|
|
|
|
|
portfolio.setPortfolioType("History");
|
|
|
|
|
portfolio.setCollectionId(collectionIdNew);
|
|
|
|
|
portfolio.setAccountId(authPrincipalVo.getId());
|
|
|
|
|
portfolio.setCreateDate(LocalDateTime.now());
|
|
|
|
|
portfolio.setUpdateDate(LocalDateTime.now());
|
|
|
|
|
portfolio.setStatus(1);
|
|
|
|
|
portfolio.setIsDeleted(0);
|
|
|
|
|
portfolio.setUserLikeGroupSourceId(portfolioDTO.getUserLikeGroupId());
|
|
|
|
|
portfolioMapper.insert(portfolio);
|
|
|
|
|
|
|
|
|
|
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
|
|
|
|
|
// List<Long> designPythonOutfitIdList = userLikeList.stream().map(UserLike::getDesignOutfitId).collect(Collectors.toList());
|
|
|
|
|
//
|
|
|
|
|
// QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
|
|
|
|
// qw.lambda().in(TDesignPythonOutfit::getId, designPythonOutfitIdList);
|
|
|
|
|
// List<TDesignPythonOutfit> designPythonOutfits = designPythonOutfitMapper.selectList(qw);
|
|
|
|
|
Long coverIdNew = null;
|
|
|
|
|
Boolean flag = false;
|
|
|
|
|
for (UserLike userLike : userLikeList) {
|
|
|
|
|
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
|
|
|
|
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
|
|
|
|
|
designPythonOutfit.setDesignId(-1L);
|
|
|
|
|
designPythonOutfit.setDesignItemId(-1L);
|
|
|
|
|
designPythonOutfit.setCollectionId(collectionIdNew);
|
|
|
|
|
if (designPythonOutfit.getId().equals(coverIdOld)) {
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
designPythonOutfit.setId(null);
|
|
|
|
|
designPythonOutfitMapper.insert(designPythonOutfit);
|
|
|
|
|
Long designOutfitIdNew = designPythonOutfit.getId();
|
|
|
|
|
userLike.setDesignOutfitId(designOutfitIdNew);
|
|
|
|
|
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
|
|
|
|
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
|
|
|
|
|
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
|
|
|
|
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
|
|
|
|
|
tDesignPythonOutfitDetail.setId(null);
|
|
|
|
|
tDesignPythonOutfitDetail.setDesignId(-1L);
|
|
|
|
|
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
|
|
|
|
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
coverIdNew = designOutfitIdNew;
|
|
|
|
|
portfolio.setCoverId(coverIdNew);
|
|
|
|
|
portfolioMapper.updateById(portfolio);
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Long designItemIdOld = userLike.getDesignItemId();
|
|
|
|
|
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
|
|
|
|
|
designItemOld.setId(null);
|
|
|
|
|
designItemOld.setAccountId(-1L);
|
|
|
|
|
designItemOld.setDesignId(-1L);
|
|
|
|
|
designItemOld.setCollectionId(collectionIdNew);
|
|
|
|
|
designItemMapper.insert(designItemOld);
|
|
|
|
|
Long designItemIdNew = designItemOld.getDesignId();
|
|
|
|
|
|
|
|
|
|
designPythonOutfit.setDesignItemId(designItemIdNew);
|
|
|
|
|
designPythonOutfitMapper.updateById(designPythonOutfit);
|
|
|
|
|
|
|
|
|
|
userLike.setDesignItemId(designItemIdNew);
|
|
|
|
|
userLike.setId(null);
|
|
|
|
|
userLike.setDesignId(-1L);
|
|
|
|
|
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
|
|
|
|
userLikeMapper.insert(userLike);
|
|
|
|
|
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld);
|
|
|
|
|
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
|
|
|
|
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
|
|
|
|
|
Long designItemDetailIdOld = designItemDetailOld.getId();
|
|
|
|
|
designItemDetailOld.setAccountId(-1L);
|
|
|
|
|
designItemDetailOld.setDesignId(-1L);
|
|
|
|
|
designItemDetailOld.setDesignItemId(designItemIdNew);
|
|
|
|
|
designItemDetailMapper.insert(designItemDetailOld);
|
|
|
|
|
Long designItemDetailIdNew = designItemDetailOld.getId();
|
|
|
|
|
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
|
|
|
|
DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper);
|
|
|
|
|
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
|
|
|
|
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Boolean.TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PortfolioVO update(PortfolioDTO portfolioDTO) {
|
|
|
|
|
if (portfolioDTO.getPortfolioType().equals("History")) {
|
|
|
|
|
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
|
|
|
|
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
|
|
|
|
|
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
|
|
|
|
|
userLikeGroupNew.setAccountId(-1L);
|
|
|
|
|
Long collectionIdOld = userLikeGroup.getCollectionId();
|
|
|
|
|
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
|
|
|
|
|
List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
|
|
|
|
|
collectionOld.setId(null);
|
|
|
|
|
collectionMapper.insert(collectionOld);
|
|
|
|
|
Long collectionIdNew = collectionOld.getId();
|
|
|
|
|
userLikeGroupNew.setCollectionId(collectionIdNew);
|
|
|
|
|
userLikeGroupMapper.insert(userLikeGroupNew);
|
|
|
|
|
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
|
|
|
|
|
for (CollectionElement element : collectionElementListOld) {
|
|
|
|
|
element.setCollectionId(collectionIdNew);
|
|
|
|
|
element.setId(null);
|
|
|
|
|
collectionElementMapper.insert(element);
|
|
|
|
|
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
|
|
|
|
|
collectionElementRelationNew.setCollectionId(collectionIdNew);
|
|
|
|
|
collectionElementRelationNew.setElementId(element.getId());
|
|
|
|
|
collectionElementRelationMapper.insert(collectionElementRelationNew);
|
|
|
|
|
}
|
|
|
|
|
Portfolio portfolio = getPortfolioByUserGroupIdSource(portfolioDTO.getUserLikeGroupId());
|
|
|
|
|
Long coverIdOld = portfolioDTO.getCoverId();
|
|
|
|
|
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
|
|
|
|
|
// portfolio.setPortfolioType("History");
|
|
|
|
|
portfolio.setCollectionId(collectionIdNew);
|
|
|
|
|
portfolio.setAccountId(authPrincipalVo.getId());
|
|
|
|
|
portfolio.setCreateDate(LocalDateTime.now());
|
|
|
|
|
portfolio.setUpdateDate(LocalDateTime.now());
|
|
|
|
|
portfolio.setStatus(1);
|
|
|
|
|
portfolio.setIsDeleted(0);
|
|
|
|
|
portfolioMapper.updateById(portfolio);
|
|
|
|
|
|
|
|
|
|
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
|
|
|
|
|
|
|
|
|
|
Long coverIdNew = null;
|
|
|
|
|
Boolean flag = false;
|
|
|
|
|
for (UserLike userLike : userLikeList) {
|
|
|
|
|
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
|
|
|
|
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
|
|
|
|
|
designPythonOutfit.setDesignId(-1L);
|
|
|
|
|
designPythonOutfit.setDesignItemId(-1L);
|
|
|
|
|
designPythonOutfit.setCollectionId(collectionIdNew);
|
|
|
|
|
if (!flag && designPythonOutfit.getId() == coverIdOld) {
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
designPythonOutfit.setId(null);
|
|
|
|
|
designPythonOutfitMapper.insert(designPythonOutfit);
|
|
|
|
|
Long designOutfitIdNew = designPythonOutfit.getId();
|
|
|
|
|
userLike.setDesignOutfitId(designOutfitIdNew);
|
|
|
|
|
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
|
|
|
|
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
|
|
|
|
|
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
|
|
|
|
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
|
|
|
|
|
tDesignPythonOutfitDetail.setId(null);
|
|
|
|
|
tDesignPythonOutfitDetail.setDesignId(-1L);
|
|
|
|
|
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
|
|
|
|
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
coverIdNew = designPythonOutfit.getId();
|
|
|
|
|
portfolio.setCoverId(coverIdNew);
|
|
|
|
|
portfolioMapper.updateById(portfolio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Long designItemIdOld = userLike.getDesignItemId();
|
|
|
|
|
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
|
|
|
|
|
designItemOld.setId(null);
|
|
|
|
|
designItemOld.setAccountId(-1L);
|
|
|
|
|
designItemOld.setDesignId(-1L);
|
|
|
|
|
designItemOld.setCollectionId(collectionIdNew);
|
|
|
|
|
designItemMapper.insert(designItemOld);
|
|
|
|
|
Long designItemIdNew = designItemOld.getDesignId();
|
|
|
|
|
|
|
|
|
|
designPythonOutfit.setDesignItemId(designItemIdNew);
|
|
|
|
|
designPythonOutfitMapper.updateById(designPythonOutfit);
|
|
|
|
|
|
|
|
|
|
userLike.setDesignItemId(designItemIdNew);
|
|
|
|
|
userLike.setId(null);
|
|
|
|
|
userLike.setDesignId(-1L);
|
|
|
|
|
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
|
|
|
|
userLikeMapper.insert(userLike);
|
|
|
|
|
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld);
|
|
|
|
|
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
|
|
|
|
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
|
|
|
|
|
Long designItemDetailIdOld = designItemDetailOld.getId();
|
|
|
|
|
designItemDetailOld.setAccountId(-1L);
|
|
|
|
|
designItemDetailOld.setDesignId(-1L);
|
|
|
|
|
designItemDetailOld.setDesignItemId(designItemIdNew);
|
|
|
|
|
designItemDetailMapper.insert(designItemDetailOld);
|
|
|
|
|
Long designItemDetailIdNew = designItemDetailOld.getId();
|
|
|
|
|
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
|
|
|
|
DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper);
|
|
|
|
|
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
|
|
|
|
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Portfolio getPortfolioByUserGroupIdSource(Long userLikeGroupId) {
|
|
|
|
|
QueryWrapper<Portfolio> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(Portfolio::getUserLikeGroupSourceId, userLikeGroupId);
|
|
|
|
|
return portfolioMapper.selectOne(qw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageBaseResponse<PortfolioVO> page(QueryPortfolioPageDTO query) {
|
|
|
|
|
QueryWrapper<Portfolio> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().orderByDesc(Portfolio::getUpdateDate);
|
|
|
|
|
IPage<Portfolio> page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()),qw);
|
|
|
|
|
IPage<PortfolioVO> convert = page.convert((Function<Portfolio, PortfolioVO>) portfolio -> {
|
|
|
|
|
if (portfolio != null) {
|
|
|
|
|
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
|
|
|
|
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(vo.getCoverId());
|
|
|
|
|
vo.setDesignPythonOutfitUrl(minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60));
|
|
|
|
|
return vo;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
return PageBaseResponse.success(convert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PortfolioVO detail(PortfolioDTO portfolioDTO) {
|
|
|
|
|
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
|
|
|
|
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
|
|
|
|
Long collectionId = portfolio.getCollectionId();
|
|
|
|
|
List<CollectionElement> collectionElementList = collectionElementService.getByCollectionId(collectionId);
|
|
|
|
|
for (CollectionElement element : collectionElementList) {
|
|
|
|
|
if (StringUtils.isEmpty(element.getUrl())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
element.setUrl(minioUtil.getPresignedUrl(element.getUrl(), 24 * 60));
|
|
|
|
|
}
|
|
|
|
|
vo.setCollectionElementList(collectionElementList);
|
|
|
|
|
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(TDesignPythonOutfit::getCollectionId, portfolio.getCollectionId());
|
|
|
|
|
List<TDesignPythonOutfit> designPythonOutfitList = designPythonOutfitMapper.selectList(qw);
|
|
|
|
|
for (TDesignPythonOutfit tDesignPythonOutfit : designPythonOutfitList) {
|
|
|
|
|
tDesignPythonOutfit.setDesignUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
|
|
|
|
}
|
|
|
|
|
vo.setDesignPythonOutfitList(designPythonOutfitList);
|
|
|
|
|
return vo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public UserLikeChooseVO choose(PortfolioDTO portfolioDTO) {
|
|
|
|
|
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
|
|
|
|
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
|
|
|
|
|
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
|
|
|
|
|
userLikeGroupNew.setAccountId(authPrincipalVo.getId());
|
|
|
|
|
Long collectionIdOld = userLikeGroup.getCollectionId();
|
|
|
|
|
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
|
|
|
|
|
List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
|
|
|
|
|
collectionOld.setId(null);
|
|
|
|
|
collectionMapper.insert(collectionOld);
|
|
|
|
|
Long collectionIdNew = collectionOld.getId();
|
|
|
|
|
|
|
|
|
|
Workspace workspace = workspaceService.getCurrentWorkspace();
|
|
|
|
|
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("");
|
|
|
|
|
}else {
|
|
|
|
|
design.setSingleOverall("single");
|
|
|
|
|
design.setSwitchCategory(workspace.getPosition());
|
|
|
|
|
}
|
|
|
|
|
design.setCreateDate(new Date());
|
|
|
|
|
designMapper.insert(design);
|
|
|
|
|
|
|
|
|
|
userLikeGroupNew.setCollectionId(collectionIdNew);
|
|
|
|
|
userLikeGroupMapper.insert(userLikeGroupNew);
|
|
|
|
|
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
|
|
|
|
|
for (CollectionElement element : collectionElementListOld) {
|
|
|
|
|
element.setCollectionId(collectionIdNew);
|
|
|
|
|
element.setId(null);
|
|
|
|
|
collectionElementMapper.insert(element);
|
|
|
|
|
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
|
|
|
|
|
collectionElementRelationNew.setCollectionId(collectionIdNew);
|
|
|
|
|
collectionElementRelationNew.setElementId(element.getId());
|
|
|
|
|
collectionElementRelationNew.setCreateDate(new Date());
|
|
|
|
|
collectionElementRelationMapper.insert(collectionElementRelationNew);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
|
|
|
|
|
|
|
|
|
|
for (UserLike userLike : userLikeList) {
|
|
|
|
|
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
|
|
|
|
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
|
|
|
|
|
designPythonOutfit.setDesignId(design.getId());
|
|
|
|
|
designPythonOutfit.setDesignItemId(-1L);
|
|
|
|
|
designPythonOutfit.setCollectionId(collectionIdNew);
|
|
|
|
|
|
|
|
|
|
designPythonOutfit.setId(null);
|
|
|
|
|
designPythonOutfitMapper.insert(designPythonOutfit);
|
|
|
|
|
Long designOutfitIdNew = designPythonOutfit.getId();
|
|
|
|
|
userLike.setDesignOutfitId(designOutfitIdNew);
|
|
|
|
|
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
|
|
|
|
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
|
|
|
|
|
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
|
|
|
|
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
|
|
|
|
|
tDesignPythonOutfitDetail.setId(null);
|
|
|
|
|
tDesignPythonOutfitDetail.setDesignId(-1L);
|
|
|
|
|
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
|
|
|
|
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Long designItemIdOld = userLike.getDesignItemId();
|
|
|
|
|
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
|
|
|
|
|
designItemOld.setId(null);
|
|
|
|
|
designItemOld.setAccountId(-1L);
|
|
|
|
|
designItemOld.setDesignId(-1L);
|
|
|
|
|
designItemOld.setCollectionId(collectionIdNew);
|
|
|
|
|
designItemMapper.insert(designItemOld);
|
|
|
|
|
Long designItemIdNew = designItemOld.getDesignId();
|
|
|
|
|
|
|
|
|
|
designPythonOutfit.setDesignItemId(designItemIdNew);
|
|
|
|
|
designPythonOutfitMapper.updateById(designPythonOutfit);
|
|
|
|
|
|
|
|
|
|
userLike.setDesignItemId(designItemIdNew);
|
|
|
|
|
userLike.setId(null);
|
|
|
|
|
userLike.setDesignId(design.getId());
|
|
|
|
|
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
|
|
|
|
userLikeMapper.insert(userLike);
|
|
|
|
|
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld);
|
|
|
|
|
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
|
|
|
|
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
|
|
|
|
|
Long designItemDetailIdOld = designItemDetailOld.getId();
|
|
|
|
|
designItemDetailOld.setAccountId(authPrincipalVo.getId());
|
|
|
|
|
designItemDetailOld.setDesignId(design.getId());
|
|
|
|
|
designItemDetailOld.setDesignItemId(designItemIdNew);
|
|
|
|
|
designItemDetailMapper.insert(designItemDetailOld);
|
|
|
|
|
Long designItemDetailIdNew = designItemDetailOld.getId();
|
|
|
|
|
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
|
|
|
|
DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper);
|
|
|
|
|
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
|
|
|
|
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return userLikeGroupService.choose(userLikeGroupNew.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|