TASK:模特相关接口;
This commit is contained in:
@@ -3,6 +3,7 @@ package com.ai.da.controller;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.system.UserInfo;
|
||||
import com.ai.da.common.config.FileProperties;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.LibraryLevel1TypeEnum;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
@@ -68,17 +69,25 @@ public class LibraryController {
|
||||
@ApiParam("二级类型 争对 Sketchboard; 有 Outwear Dress Blouse Skirt Trousers")
|
||||
@RequestParam(value = "level2Type",required = false) String level2Type,
|
||||
@ApiParam("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取")
|
||||
@RequestParam(value = "timeZone") String timeZone) {
|
||||
@RequestParam(value = "timeZone") String timeZone,
|
||||
@RequestParam(value = "modelType") String modelType,
|
||||
@RequestParam(value = "sex") String sex) {
|
||||
Assert.isTrue(!StringUtils.isEmpty(file.getOriginalFilename()),"Please select a file!");
|
||||
Integer high =null;
|
||||
Integer width =null;
|
||||
if(level1Type.equals(LibraryLevel1TypeEnum.MODELS.getRealName())){
|
||||
if (StringUtils.isEmpty(modelType)) {
|
||||
throw new BusinessException("modelType can't be null");
|
||||
}
|
||||
if (StringUtils.isEmpty(sex)) {
|
||||
throw new BusinessException("sex can't be null");
|
||||
}
|
||||
FileVO fileVO = FileUtil.getFileSize(file);
|
||||
high = fileVO.getHigh();
|
||||
width = fileVO.getWidth();
|
||||
}
|
||||
return Response.success(libraryService.upload(new LibraryUploadDTO(file, level1Type,level2Type,
|
||||
timeZone, MD5Utils.encryptFile(file),high,width)));
|
||||
timeZone, MD5Utils.encryptFile(file),high,width,modelType,sex)));
|
||||
}
|
||||
@ApiOperation(value = "保存或者编辑template打点")
|
||||
@PostMapping("/saveOrEditTemplatePoint")
|
||||
|
||||
@@ -94,8 +94,8 @@ public class WorkspaceController {
|
||||
@GetMapping("/getMannequins")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@ApiOperation(value = "获取模特")
|
||||
public Response<List<ModelsVO>> getMannequins() {
|
||||
List<ModelsVO> modelsVO = workspaceService.getMannequins();
|
||||
public Response<List<ModelsVO>> getMannequins(@RequestParam("sex") String sex) {
|
||||
List<ModelsVO> modelsVO = workspaceService.getMannequins(sex);
|
||||
return Response.success(modelsVO);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ public class Design implements Serializable {
|
||||
*/
|
||||
private Long templateId;
|
||||
|
||||
private String modelType;
|
||||
|
||||
/**
|
||||
* system scale值
|
||||
*/
|
||||
|
||||
@@ -31,9 +31,14 @@ public class LibraryModelPoint implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联的 libraryId
|
||||
* modelType
|
||||
*/
|
||||
private Long libraryId;
|
||||
private String modelType;
|
||||
|
||||
/**
|
||||
* 关联的 library或sys Id
|
||||
*/
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 左肩
|
||||
|
||||
@@ -34,6 +34,8 @@ public class DesignCollectionDTO {
|
||||
@ApiModelProperty("系统取图比列")
|
||||
private BigDecimal systemScale;
|
||||
|
||||
private String modelType;
|
||||
|
||||
@ApiModelProperty("templateId")
|
||||
private Long templateId;
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ public class LibraryModelPointDTO implements Serializable {
|
||||
|
||||
@NotNull(message = "libraryId cannot be empty!")
|
||||
@ApiModelProperty("libraryId")
|
||||
private Long libraryId;
|
||||
private Long relationId;
|
||||
|
||||
private String modelType;
|
||||
|
||||
@ApiModelProperty("templateId")
|
||||
private Long templateId;
|
||||
|
||||
@@ -36,4 +36,8 @@ public class LibraryUploadDTO {
|
||||
*/
|
||||
private Integer width;
|
||||
|
||||
private String modelType;
|
||||
|
||||
private String modelSex;
|
||||
|
||||
}
|
||||
|
||||
28
src/main/java/com/ai/da/model/enums/ModelType.java
Normal file
28
src/main/java/com/ai/da/model/enums/ModelType.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.ai.da.model.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* @Author: SHAHAIBO
|
||||
* @Date: 2023/08/01 17:21
|
||||
* @Description: 模特类型枚举类
|
||||
*/
|
||||
public enum ModelType implements IEnumDisplay {
|
||||
|
||||
SYSTEM("System"),
|
||||
|
||||
LIBRARY("Library")
|
||||
;
|
||||
|
||||
private String value;
|
||||
|
||||
ModelType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ public class LibraryUpdateVo implements Serializable {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String modelType;
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
private Long accountId;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public interface WorkspaceService extends IService<Workspace> {
|
||||
|
||||
Workspace getByIdNew(Long id);
|
||||
|
||||
List<ModelsVO> getMannequins();
|
||||
List<ModelsVO> getMannequins(String sex);
|
||||
|
||||
void systemFileCopy();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.ai.da.mapper.CollectionElementMapper;
|
||||
import com.ai.da.mapper.entity.*;
|
||||
import com.ai.da.mapper.entity.Collection;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.enums.ModelType;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.PythonService;
|
||||
import com.ai.da.python.vo.DesignPythonItem;
|
||||
@@ -441,14 +442,24 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
Assert.notNull(switchCategory, "unknown parameter switchCategory!");
|
||||
}
|
||||
//校验template
|
||||
// if(Objects.nonNull(designDTO.getTemplateId())){
|
||||
if(Objects.nonNull(designDTO.getTemplateId())){
|
||||
// LibraryModelPoint modelPoint = libraryModelPointService.getById(designDTO.getTemplateId());
|
||||
// Assert.notNull(modelPoint, "template cannot by empty!");
|
||||
// Library library = libraryService.getById(modelPoint.getLibraryId());
|
||||
// Assert.notNull(library, "template library cannot by empty!");
|
||||
// elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint,library.getHigh(),library.getWidth(),library.getUrl()));
|
||||
// }
|
||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(null,null,null,null));
|
||||
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||
Library byId = libraryService.getById(designDTO.getTemplateId());
|
||||
QueryWrapper<LibraryModelPoint> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
|
||||
qw.lambda().eq(LibraryModelPoint::getRelationId, byId.getId());
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getOne(qw);
|
||||
if (Objects.isNull(modelPoint)) {
|
||||
throw new BusinessException("error modelPoint get");
|
||||
}
|
||||
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint,1654,1170,byId.getUrl()));
|
||||
}
|
||||
}
|
||||
// elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(null,1654,1170,null));
|
||||
return elementVO;
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -164,7 +164,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
if (Objects.nonNull(design.getTemplateId())){
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
|
||||
Assert.notNull(modelPoint,"template does not exists!");
|
||||
Library library = libraryService.getById(modelPoint.getLibraryId());
|
||||
Library library = libraryService.getById(modelPoint.getRelationId());
|
||||
// ??和上面重复
|
||||
Assert.notNull(modelPoint,"template does not exists!");
|
||||
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl());
|
||||
@@ -205,7 +205,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
if (Objects.nonNull(design.getTemplateId())){
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
|
||||
Assert.notNull(modelPoint,"template does not exists!");
|
||||
Library library = libraryService.getById(modelPoint.getLibraryId());
|
||||
Library library = libraryService.getById(modelPoint.getRelationId());
|
||||
Assert.notNull(modelPoint,"template does not exists!");
|
||||
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl());
|
||||
}
|
||||
@@ -386,7 +386,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
if (Objects.nonNull(design.getTemplateId())){
|
||||
LibraryModelPoint modelPoint = libraryModelPointService.getById(design.getTemplateId());
|
||||
Assert.notNull(modelPoint,"template does not exists!");
|
||||
Library library = libraryService.getById(modelPoint.getLibraryId());
|
||||
Library library = libraryService.getById(modelPoint.getRelationId());
|
||||
Assert.notNull(library,"template does not exists!");
|
||||
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint,library.getHigh(),library.getWidth(),library.getUrl());
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.ai.da.model.dto.DesignSingleDTO;
|
||||
import com.ai.da.model.dto.DesignSingleItemDTO;
|
||||
import com.ai.da.model.dto.LibraryModelPointDTO;
|
||||
import com.ai.da.model.dto.ModelsDotDTO;
|
||||
import com.ai.da.model.enums.ModelType;
|
||||
import com.ai.da.model.vo.LibraryModelPointVO;
|
||||
import com.ai.da.model.vo.LibraryUpdateVo;
|
||||
import com.ai.da.python.PythonService;
|
||||
@@ -51,7 +52,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
|
||||
|
||||
@Override
|
||||
public LibraryModelPointVO saveOrEditTemplatePoint(LibraryModelPointDTO libraryModelPointDTO) {
|
||||
Library library = libraryService.getById(libraryModelPointDTO.getLibraryId());
|
||||
Library library = libraryService.getById(libraryModelPointDTO.getRelationId());
|
||||
Assert.notNull(library,"library does not exist!");
|
||||
LibraryModelPointVO libraryModelPointVO =CopyUtil.copyObject(libraryModelPointDTO,LibraryModelPointVO.class);;
|
||||
if(Objects.isNull(libraryModelPointDTO.getTemplateId())){
|
||||
@@ -87,6 +88,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
|
||||
@Override
|
||||
public List<LibraryModelPointVO> selectByLibraryIds(List<Long> libraryIds) {
|
||||
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
|
||||
queryWrapper.in("library_id", libraryIds);
|
||||
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
|
||||
if(CollectionUtils.isEmpty(libraryModelPoints)){
|
||||
|
||||
@@ -10,8 +10,10 @@ import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.FileUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.LibraryMapper;
|
||||
import com.ai.da.mapper.SysFileMapper;
|
||||
import com.ai.da.mapper.entity.*;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.enums.ModelType;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.LibraryModelPointService;
|
||||
import com.ai.da.service.LibraryService;
|
||||
@@ -44,6 +46,8 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
@Resource
|
||||
private LibraryMapper libraryMapper;
|
||||
@Resource
|
||||
private SysFileMapper sysFileMapper;
|
||||
@Resource
|
||||
private FileProperties fileProperties;
|
||||
@Resource
|
||||
private LibraryModelPointService libraryModelPointService;
|
||||
@@ -157,34 +161,53 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
bucketName = users;
|
||||
break;
|
||||
case MARKETING_SKETCH:
|
||||
break;
|
||||
throw new BusinessException("MARKETING_SKETCH type have been removed");
|
||||
default:
|
||||
throw new BusinessException("unknown level1_type");
|
||||
}
|
||||
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||
//保存element元素
|
||||
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
|
||||
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
|
||||
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
|
||||
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(filePath, 480));
|
||||
return libraryUpdateVo;
|
||||
if (libraryUploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
|
||||
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
|
||||
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
|
||||
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(filePath, 480));
|
||||
return libraryUpdateVo;
|
||||
}else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Library resolveData(LibraryUploadDTO uploadDTO, AuthPrincipalVo userInfo, String filePath) {
|
||||
Library library = CopyUtil.copyObject(uploadDTO, Library.class);
|
||||
library.setAccountId(userInfo.getId());
|
||||
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
|
||||
library.setUrl(filePath);
|
||||
//按时区计算
|
||||
library.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
|
||||
if (uploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||
Library library = CopyUtil.copyObject(uploadDTO, Library.class);
|
||||
library.setAccountId(userInfo.getId());
|
||||
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
|
||||
library.setUrl(filePath);
|
||||
//按时区计算
|
||||
library.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
|
||||
// String linuxDomain = fileProperties.getLinuxDomain();
|
||||
// if (!StringUtils.isEmpty(linuxDomain)) {
|
||||
// //linux 系统
|
||||
// String oldPath = fileProperties.getSys().getPath();
|
||||
// library.setUrl(file.getAbsolutePath().replace(oldPath, linuxDomain));
|
||||
// }
|
||||
libraryMapper.insert(library);
|
||||
return library;
|
||||
libraryMapper.insert(library);
|
||||
return library;
|
||||
}else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
|
||||
sysFile.setLevel1Type("Models");
|
||||
sysFile.setLevel2Type(uploadDTO.getModelSex());
|
||||
sysFile.setUrl(filePath);
|
||||
sysFile.setMd5(uploadDTO.getMd5());
|
||||
sysFileMapper.insert(sysFile);
|
||||
return null;
|
||||
}else {
|
||||
throw new BusinessException("unknown model type");
|
||||
}
|
||||
}
|
||||
|
||||
private String calculateFileUrl(LibraryLevel1TypeEnum level1TypeEnum, String level2Type, Long userId) {
|
||||
|
||||
@@ -184,7 +184,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModelsVO> getMannequins() {
|
||||
public List<ModelsVO> getMannequins(String sex) {
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
List<ModelsVO> result = new ArrayList<>();
|
||||
QueryWrapper<Library> libraryQueryWrapper = new QueryWrapper<>();
|
||||
@@ -197,11 +197,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
ModelVO modelVO = new ModelVO();
|
||||
modelVO.setId(library.getId());
|
||||
modelVO.setUrl(library.getUrl());
|
||||
if (library.getUrl().startsWith("aida-")) {
|
||||
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(library.getUrl(), 10));
|
||||
}else {
|
||||
modelVO.setPresignedUrl(library.getUrl());
|
||||
}
|
||||
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(library.getUrl(), 480));
|
||||
modelVOList.add(modelVO);
|
||||
}
|
||||
ModelsVO vo = new ModelsVO();
|
||||
@@ -210,8 +206,10 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
result.add(vo);
|
||||
}
|
||||
QueryWrapper<SysFile> sysFileQueryWrapper = new QueryWrapper<>();
|
||||
sysFileQueryWrapper.lambda().eq(SysFile::getLevel1Type, SysFileLevel1TypeEnum.ACCESSORIES.getRealName());
|
||||
sysFileQueryWrapper.lambda().eq(SysFile::getLevel2Type, SysFileLevel2TypeEnum.BODY.getRealName());
|
||||
// sysFileQueryWrapper.lambda().eq(SysFile::getLevel1Type, SysFileLevel1TypeEnum.ACCESSORIES.getRealName());
|
||||
// sysFileQueryWrapper.lambda().eq(SysFile::getLevel2Type, SysFileLevel2TypeEnum.BODY.getRealName());
|
||||
sysFileQueryWrapper.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
sysFileQueryWrapper.lambda().eq(SysFile::getLevel2Type, sex);
|
||||
List<SysFile> sysFileList = sysFileMapper.selectList(sysFileQueryWrapper);
|
||||
if (!CollectionUtils.isEmpty(sysFileList)) {
|
||||
List<ModelVO> modelVOList = new ArrayList<>();
|
||||
@@ -219,11 +217,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
ModelVO modelVO = new ModelVO();
|
||||
modelVO.setId(sysFile.getId());
|
||||
modelVO.setUrl(sysFile.getUrl());
|
||||
if (sysFile.getUrl().startsWith("aida-")) {
|
||||
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(sysFile.getUrl(), 10));
|
||||
}else {
|
||||
modelVO.setPresignedUrl(sysFile.getUrl());
|
||||
}
|
||||
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(sysFile.getUrl(), 480));
|
||||
modelVOList.add(modelVO);
|
||||
}
|
||||
ModelsVO vo = new ModelsVO();
|
||||
|
||||
Reference in New Issue
Block a user