diff --git a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java index 7b5462dd..15f2e95b 100644 --- a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java +++ b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java @@ -355,7 +355,8 @@ public class SendEmailUtil { } private final static Long UPGRADE_NOTIFICATION_ID = 118855L; - public static void sendUpgradeNotification(Account account, String senderAddress) { + private final static Long UPGRADE_NOTIFICATION_ID_CHINESE = 122898L; + public static void sendUpgradeNotification(Account account, String senderAddress, Integer type) { try { // 实例化一个认证对象 Credential cred = new Credential(SECRET_ID, SECRET_KEy); @@ -374,8 +375,13 @@ public class SendEmailUtil { // 根据邮件类型设置不同的主题和模板 String subject = ""; Template template = new Template(); - subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance"; - template.setTemplateID(UPGRADE_NOTIFICATION_ID); + if (type == 1) { + subject = "Upcoming System Upgrade for AiDA 3.0"; + template.setTemplateID(UPGRADE_NOTIFICATION_ID); + }else { + subject = "即将到来的AiDA 3.0系统升级"; + template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE); + } template.setTemplateData(buildAccountData(account)); req.setSubject(subject); diff --git a/src/main/java/com/ai/da/controller/PortfolioController.java b/src/main/java/com/ai/da/controller/PortfolioController.java new file mode 100644 index 00000000..32337e46 --- /dev/null +++ b/src/main/java/com/ai/da/controller/PortfolioController.java @@ -0,0 +1,59 @@ +package com.ai.da.controller; + +import com.ai.da.common.response.PageBaseResponse; +import com.ai.da.common.response.Response; +import com.ai.da.model.dto.PortfolioDTO; +import com.ai.da.model.dto.QueryPortfolioPageDTO; +import com.ai.da.model.vo.PortfolioVO; +import com.ai.da.model.vo.UserLikeChooseVO; +import com.ai.da.service.PortfolioService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.Valid; + +@Api(tags = "Portfolio模块") +@Slf4j +@RestController +@RequestMapping("/api/portfolio") +public class PortfolioController { + + @Resource + private PortfolioService portfolioService; + + @ApiOperation(value = "发布作品集") + @PostMapping("/publish") + public Response preLogin(@Valid @RequestBody PortfolioDTO portfolioDTO) { + return Response.success(portfolioService.publish(portfolioDTO)); + } + + @ApiOperation(value = "作品集page") + @PostMapping("/page") + public Response> page(@Valid @RequestBody QueryPortfolioPageDTO query) { + return Response.success(portfolioService.page(query)); + } + + @ApiOperation(value = "作品详情") + @PostMapping("/detail") + public Response detail(@Valid @RequestBody PortfolioDTO portfolioDTO) { + return Response.success(portfolioService.detail(portfolioDTO)); + } + + @ApiOperation(value = "选择作品") + @PostMapping("/choose") + public Response choose(@Valid @RequestBody PortfolioDTO portfolioDTO) { + return Response.success(portfolioService.choose(portfolioDTO)); + } + + @ApiOperation(value = "更新作品") + @PostMapping("/update") + public Response update(@Valid @RequestBody PortfolioDTO portfolioDTO) { + return Response.success(portfolioService.update(portfolioDTO)); + } +} diff --git a/src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java b/src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java new file mode 100644 index 00000000..54ef023b --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java @@ -0,0 +1,7 @@ +package com.ai.da.mapper.primary; + +import com.ai.da.common.config.mybatis.plus.CommonMapper; +import com.ai.da.mapper.primary.entity.Portfolio; + +public interface PortfolioMapper extends CommonMapper { +} diff --git a/src/main/java/com/ai/da/mapper/primary/entity/Portfolio.java b/src/main/java/com/ai/da/mapper/primary/entity/Portfolio.java new file mode 100644 index 00000000..3c1831ca --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/entity/Portfolio.java @@ -0,0 +1,55 @@ +package com.ai.da.mapper.primary.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +@Data +@ApiModel(value = "Portfolio对象", description = "作品集") +@TableName("portfolio") +public class Portfolio implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "ID") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty(value = "collection ID") + private Long collectionId; + + @ApiModelProperty(value = "userLikeGroup源") + private Long userLikeGroupSourceId; + + @ApiModelProperty(value = "作品名称") + private String portfolioName; + + @ApiModelProperty(value = "作品描述") + private String portfolioDes; + + @ApiModelProperty(value = "作品类型") + private String portfolioType; + + @ApiModelProperty(value = "封面ID") + private Long coverId; + + @ApiModelProperty(value = "作品状态1公开0隐藏") + private Integer status; + + @ApiModelProperty(value = "作品集作者ID") + private Long accountId; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createDate; + + @ApiModelProperty(value = "更新时间") + private LocalDateTime updateDate; + + @ApiModelProperty(value = "是否删除") + private Integer isDeleted; +} diff --git a/src/main/java/com/ai/da/model/dto/PortfolioDTO.java b/src/main/java/com/ai/da/model/dto/PortfolioDTO.java new file mode 100644 index 00000000..90f39bb0 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/PortfolioDTO.java @@ -0,0 +1,10 @@ +package com.ai.da.model.dto; + +import com.ai.da.mapper.primary.entity.Portfolio; +import lombok.Data; + +@Data +public class PortfolioDTO extends Portfolio { + private Long userLikeGroupId; + +} diff --git a/src/main/java/com/ai/da/model/dto/QueryPortfolioPageDTO.java b/src/main/java/com/ai/da/model/dto/QueryPortfolioPageDTO.java new file mode 100644 index 00000000..8694035b --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/QueryPortfolioPageDTO.java @@ -0,0 +1,14 @@ +package com.ai.da.model.dto; + +import com.ai.da.model.vo.PageQueryBaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel("作品集分页查询") +public class QueryPortfolioPageDTO extends PageQueryBaseVo { + +} diff --git a/src/main/java/com/ai/da/model/vo/PortfolioVO.java b/src/main/java/com/ai/da/model/vo/PortfolioVO.java new file mode 100644 index 00000000..b313cc9a --- /dev/null +++ b/src/main/java/com/ai/da/model/vo/PortfolioVO.java @@ -0,0 +1,16 @@ +package com.ai.da.model.vo; + +import com.ai.da.mapper.primary.entity.CollectionElement; +import com.ai.da.mapper.primary.entity.Portfolio; +import com.ai.da.mapper.primary.entity.TDesignPythonOutfit; +import lombok.Data; + +import java.util.List; + +@Data +public class PortfolioVO extends Portfolio { + private String designPythonOutfitUrl; + + private List collectionElementList; + private List designPythonOutfitList; +} diff --git a/src/main/java/com/ai/da/service/PortfolioService.java b/src/main/java/com/ai/da/service/PortfolioService.java new file mode 100644 index 00000000..683f8c09 --- /dev/null +++ b/src/main/java/com/ai/da/service/PortfolioService.java @@ -0,0 +1,21 @@ +package com.ai.da.service; + +import com.ai.da.common.response.PageBaseResponse; +import com.ai.da.mapper.primary.entity.Portfolio; +import com.ai.da.model.dto.PortfolioDTO; +import com.ai.da.model.dto.QueryPortfolioPageDTO; +import com.ai.da.model.vo.PortfolioVO; +import com.ai.da.model.vo.UserLikeChooseVO; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface PortfolioService extends IService { + Boolean publish(PortfolioDTO portfolioDTO); + + PortfolioVO update(PortfolioDTO portfolioDTO); + + PageBaseResponse page(QueryPortfolioPageDTO query); + + PortfolioVO detail(PortfolioDTO portfolioDTO); + + UserLikeChooseVO choose(PortfolioDTO portfolioDTO); +} diff --git a/src/main/java/com/ai/da/service/UserLikeService.java b/src/main/java/com/ai/da/service/UserLikeService.java index 510d1e0c..b04d64da 100644 --- a/src/main/java/com/ai/da/service/UserLikeService.java +++ b/src/main/java/com/ai/da/service/UserLikeService.java @@ -23,4 +23,6 @@ public interface UserLikeService extends IService { UserLike getByDesignItemId(Long designItemId); void updateDate(Long designItemId,String timeZone); + + List getUserLikeList(Long id); } diff --git a/src/main/java/com/ai/da/service/WorkspaceService.java b/src/main/java/com/ai/da/service/WorkspaceService.java index 17a66f29..87b5675c 100644 --- a/src/main/java/com/ai/da/service/WorkspaceService.java +++ b/src/main/java/com/ai/da/service/WorkspaceService.java @@ -46,4 +46,6 @@ public interface WorkspaceService extends IService { void maleDataInsert() throws FileNotFoundException; List delete(List workspaceList); + + Workspace getCurrentWorkspace(); } diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 77f44f4f..a5932fae 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -184,6 +184,7 @@ public class AccountServiceImpl extends ServiceImpl impl } private void validateUserValidaExpire(Account account) { + Long currentTime = new Date().getTime(); if (Objects.nonNull(account.getValidStartTime())) { if (currentTime < account.getValidStartTime()) { @@ -884,15 +885,23 @@ public class AccountServiceImpl extends ServiceImpl impl @Override public void upgradeNotification() { QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("id", 88L); queryWrapper.and(wrapper -> - wrapper.gt("valid_end_time", 1709515797000L) + wrapper.gt("valid_end_time", 1715817600000L) .or().isNull("valid_end_time")) .isNotNull("user_email"); List accountList = accountMapper.selectList(queryWrapper); System.out.println(accountList); for (Account account : accountList) { - SendEmailUtil.sendUpgradeNotification(account, null); +// SendEmailUtil.sendUpgradeNotification(account, null, 0); +// SendEmailUtil.sendUpgradeNotification(account, null, 1); + if (account.getLanguage().equals(Language.CHINESE_SIMPLIFIED.name())) { + SendEmailUtil.sendUpgradeNotification(account, null, 0); + }else { + // 英文 + SendEmailUtil.sendUpgradeNotification(account, null, 1); + } } } diff --git a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java index 0a6bfb8c..72b46e5b 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java @@ -353,14 +353,16 @@ public class CollectionElementServiceImpl extends ServiceImpl colorBoards = elementVO.getColorBoards(); for (CollectionColorDTO colorBoard : colorBoards) { - String colorImg = colorBoard.getGradient().getColorImg(); - String[] parts = colorImg.split(","); - String imageType = parts[0].split("/")[1].split(";")[0]; - String base64Data = parts[1]; - String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType); - colorBoard.setGradientMinioUrl(gradientMinioUrl); - colorBoard.getGradient().setColorImg(null); - colorBoard.setGradientString(JSON.toJSONString(colorBoard.getGradient())); + if (Objects.nonNull(colorBoard.getGradient())) { + String colorImg = colorBoard.getGradient().getColorImg(); + String[] parts = colorImg.split(","); + String imageType = parts[0].split("/")[1].split(";")[0]; + String base64Data = parts[1]; + String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType); + colorBoard.setGradientMinioUrl(gradientMinioUrl); + colorBoard.getGradient().setColorImg(null); + colorBoard.setGradientString(JSON.toJSONString(colorBoard.getGradient())); + } } elementVO.setColorBoards(colorBoards); List usedElementIds = elementVO.getUsedElementIds(); @@ -781,7 +783,9 @@ public class CollectionElementServiceImpl extends ServiceImpl 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 collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld); + collectionOld.setId(null); + collectionMapper.insert(collectionOld); + Long collectionIdNew = collectionOld.getId(); + userLikeGroupNew.setCollectionId(collectionIdNew); + userLikeGroupMapper.insert(userLikeGroupNew); +// List 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 userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId()); +// List designPythonOutfitIdList = userLikeList.stream().map(UserLike::getDesignOutfitId).collect(Collectors.toList()); +// +// QueryWrapper qw = new QueryWrapper<>(); +// qw.lambda().in(TDesignPythonOutfit::getId, designPythonOutfitIdList); +// List 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 qw = new QueryWrapper<>(); + qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld); + List 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 designItemDetailQueryWrapper = new QueryWrapper<>(); + designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld); + List 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 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 collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld); + collectionOld.setId(null); + collectionMapper.insert(collectionOld); + Long collectionIdNew = collectionOld.getId(); + userLikeGroupNew.setCollectionId(collectionIdNew); + userLikeGroupMapper.insert(userLikeGroupNew); +// List 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 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 qw = new QueryWrapper<>(); + qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld); + List 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 designItemDetailQueryWrapper = new QueryWrapper<>(); + designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld); + List 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 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 qw = new QueryWrapper<>(); + qw.lambda().eq(Portfolio::getUserLikeGroupSourceId, userLikeGroupId); + return portfolioMapper.selectOne(qw); + } + + @Override + public PageBaseResponse page(QueryPortfolioPageDTO query) { + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().orderByDesc(Portfolio::getUpdateDate); + IPage page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()),qw); + IPage convert = page.convert((Function) 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 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 qw = new QueryWrapper<>(); + qw.lambda().eq(TDesignPythonOutfit::getCollectionId, portfolio.getCollectionId()); + List 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 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 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 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 qw = new QueryWrapper<>(); + qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld); + List 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 designItemDetailQueryWrapper = new QueryWrapper<>(); + designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld); + List 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 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()); + } +} diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index 29d70e13..4f5ff929 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -123,15 +123,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl userLikeVOS = userLikeService.getGroupDetail(userGroupId); String sex = null; -// if (CollectionUtil.isNotEmpty(userLikeVOS)) { -// Long designId = userLikeVOS.get(0).getDesignId(); -// Design design = designMapper.selectById(designId); -// if (design.getModelType().equals(ModelType.SYSTEM.getValue())) { -// sex = sysFileMapper.selectById(design.getTemplateId()).getLevel2Type(); -// }else { -// sex = libraryMapper.selectById(design.getTemplateId()).getLevel2Type(); -// } -// } userLikeVOS.forEach(o -> { TDesignPythonOutfit tDesignPythonOutfit1 = designPythonOutfitMapper.selectById(o.getDesignOutfitId()); o.setUrl(tDesignPythonOutfit1.getDesignUrl()); diff --git a/src/main/java/com/ai/da/service/impl/UserLikeServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeServiceImpl.java index 29b53710..9d44d2dd 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeServiceImpl.java @@ -81,4 +81,11 @@ public class UserLikeServiceImpl extends ServiceImpl i baseMapper.update(null,uw); } + @Override + public List getUserLikeList(Long id) { + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(UserLike::getUserLikeGroupId, id); + return userLikeMapper.selectList(qw); + } + } diff --git a/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java b/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java index 6d1478ec..27cf5854 100644 --- a/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java @@ -37,6 +37,7 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.annotation.Resource; +import javax.naming.Context; import java.io.*; import java.nio.file.Files; import java.util.ArrayList; @@ -483,6 +484,20 @@ public class WorkspaceServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); + qw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId()); + qw.lambda().eq(Workspace::getIsLastIndex, 1); +// qw.lambda().eq(Workspace::getIsDeleted, 0); + List workspaces = workspaceMapper.selectList(qw); + if (CollectionUtils.isEmpty(workspaces)) { + throw new BusinessException("workspace not found."); + } + return workspaces.get(0); + } + // public static void main(String[] args) throws FileNotFoundException { // String b = "C:\\workspace\\fileData\\aida_men_library\\top\\mens_test_9992.png"; // File pngFile = new File(b);