修改 获取design detail接口的返回数据格式

This commit is contained in:
xupei
2023-09-08 15:54:30 +08:00
parent 15bbe55182
commit 41111bc0e4
7 changed files with 76 additions and 32 deletions

View File

@@ -3,10 +3,8 @@ package com.ai.da.model.vo;
import com.ai.da.python.vo.DesignPythonItemPrint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
@@ -31,4 +29,7 @@ public class DesignItemClothesDetailVO {
@ApiModelProperty("对应的print图片对象")
private DesignPythonItemPrint printObject;
@ApiModelProperty("对应图层信息")
private List<DesignPythonOutfitVO> layersObject;
}

View File

@@ -15,7 +15,8 @@ public class DesignItemDetailVO {
private Long designItemId;
@ApiModelProperty("designItem图片")
private DesignPythonOutfitVO designItemUrl;
// private DesignPythonOutfitVO designItemUrl;
private String designItemUrl;
@ApiModelProperty("design高级图片")
private String highDesignUrl;

View File

@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("designItem detail others 响应")
public class DesignItemOthersDetailVO {
@@ -24,4 +26,7 @@ public class DesignItemOthersDetailVO {
@ApiModelProperty("对应的print图片的绝对路径")
private DesignPythonItemPrint printObject;
@ApiModelProperty("对应图层信息")
private List<DesignPythonOutfitVO> layersObject;
}

View File

@@ -1,24 +1,37 @@
package com.ai.da.model.vo;
import com.ai.da.mapper.entity.TDesignPythonOutfitDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("designItem detail从python端获取的合成图+各图层响应")
public class DesignPythonOutfitVO {
@ApiModelProperty("当前图片无图层信息时,为空")
private Long designPythonOutfitId;
/**
* ID
*/
@ApiModelProperty(value = "ID")
private Long id;
@ApiModelProperty("合成图")
String designPythonOutfitUrl;
// TODO
// 需明确,不需要的数据不要返回
@ApiModelProperty("各部分图层信息")
List<TDesignPythonOutfitDetail> designItemDetailLayers;
/**
* 图层
*/
@ApiModelProperty(value = "图层名")
private String imageCategory;
/**
* 对应的图片的绝对路径
*/
@ApiModelProperty(value = "对应的图片的绝对路径")
private String imageUrl;
/**
* mask_url
*/
@ApiModelProperty(value = "遮罩")
private String maskUrl;
/**
* 位置
*/
@ApiModelProperty(value = "位置")
private String position;
}

View File

@@ -2,6 +2,7 @@ package com.ai.da.service;
import com.ai.da.mapper.entity.TDesignPythonOutfitDetail;
import com.ai.da.model.vo.DesignPythonOutfitVO;
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -31,4 +32,6 @@ public interface ITDesignPythonOutfitDetailService extends IService<TDesignPytho
* @return
*/
List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId);
DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail);
}

View File

@@ -682,7 +682,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}));
//single 和 Models(模特)时候 系统元素为空
List<DesignItemDetail> filterDetail2 =designItemDetails.stream()
.filter(f -> SYS_HAIRSTYLE_SHOES.contains(f.getType()) )
// .filter(f -> SYS_HAIRSTYLE_SHOES.contains(f.getType()) )
.filter(f -> SYS_HAIRSTYLE_SHOES_BODY.contains(f.getType()) )
.collect(Collectors.toList());
response.setOthers(CopyUtil.copyList(filterDetail2,DesignItemOthersDetailVO.class,(o,d)->{
d.setId(o.getBusinessId());
@@ -728,12 +729,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return design.getId();
}
/**
*
* @param designItemDetails
* @param designItemDetailVO
* @return
*/
private DesignItemDetailVO editResponseColor(List<DesignItemDetail> designItemDetails,DesignItemDetailVO designItemDetailVO){
/*designItemDetails.forEach(d -> {
if (!StringUtil.isNullOrEmpty(d.getColor())){
@@ -778,25 +773,40 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
private DesignItemDetailVO editDesignItemLayer(Boolean flag,TDesignPythonOutfit designPythonOutfit,String designItemId,DesignItemDetailVO designItemDetailVO){
DesignPythonOutfitVO designPythonOutfitVO = new DesignPythonOutfitVO();
private DesignItemDetailVO editDesignItemLayer(Boolean flag,TDesignPythonOutfit designPythonOutfit,String designItemUrl,DesignItemDetailVO designItemDetailVO){
ArrayList<DesignPythonOutfitVO> detailsVO = new ArrayList<>();
if (flag){
// 1、判断designPythonOutfitId查出的图层信息是否为空不允许为空系统内部错误
List<TDesignPythonOutfitDetail> details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId());
Assert.notEmpty(details,"Some errors occurred, please restart the design");
details.forEach(detail -> {
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail));
});
// 2、将查询出的图层信息填充到designItemDetailVO中
designPythonOutfitVO.setDesignPythonOutfitId(designPythonOutfit.getId());
designPythonOutfitVO.setDesignPythonOutfitUrl(designPythonOutfit.getDesignUrl());
designPythonOutfitVO.setDesignItemDetailLayers(details);
}else{
designPythonOutfitVO.setDesignPythonOutfitUrl(designItemId);
}
designItemDetailVO.setDesignItemUrl(designPythonOutfit.getDesignUrl());
// 2.1 填充clothes
designItemDetailVO.getClothes().forEach(c -> {
String type = c.getType().toLowerCase();
List<DesignPythonOutfitVO> outfitVOS = detailsVO.stream().filter(detail -> detail.getImageCategory().equals(type + "_back") ||
detail.getImageCategory().equals(type + "_front")).collect(Collectors.toList());
designItemDetailVO.setDesignItemUrl(designPythonOutfitVO);
c.setLayersObject(outfitVOS);
});
// 2.2 填充others
designItemDetailVO.getOthers().forEach(o -> {
String type = o.getType().toLowerCase();
List<DesignPythonOutfitVO> outfitVOS = detailsVO.stream().filter(detail -> detail.getImageCategory().equals(type + "_back") ||
detail.getImageCategory().equals(type + "_front") ||
detail.getImageCategory().equals("body")).collect(Collectors.toList());
o.setLayersObject(outfitVOS);
});
}else{
designItemDetailVO.setDesignItemUrl(designItemUrl);
}
return designItemDetailVO;
}
}

View File

@@ -1,7 +1,9 @@
package com.ai.da.service.impl;
import com.ai.da.common.utils.CopyUtil;
import com.ai.da.mapper.TDesignPythonOutfitDetailMapper;
import com.ai.da.mapper.entity.TDesignPythonOutfitDetail;
import com.ai.da.model.vo.DesignPythonOutfitVO;
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
import com.ai.da.service.ITDesignPythonOutfitDetailService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -10,6 +12,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
import java.util.Objects;
/**
* design item详情表 服务实现类
@@ -31,7 +34,15 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
queryWrapper.eq("design_python_outfit_id",designPythonOutfitId);
return baseMapper.selectList(queryWrapper);
}
@Override
public DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail){
if (Objects.isNull(detail)) {
return null;
}
return CopyUtil.copyObject(detail,DesignPythonOutfitVO.class);
}
}