TASK: 拼贴功能保存用户上传的图片并返回

This commit is contained in:
2025-07-15 18:11:12 +08:00
parent 64318de24a
commit 301f58bc62
6 changed files with 54 additions and 4 deletions

View File

@@ -141,4 +141,5 @@ public interface CollectionElementService extends IService<CollectionElement> {
List<CollectionElementVO> selectedImageSeg(List<MultipartFile> files, Long id, String type, String sourceType);
void updateElementLevel2Type(Long elementId, String level2Type);
}

View File

@@ -13,6 +13,7 @@ import com.ai.da.mapper.primary.GenerateDetailMapper;
import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.*;
import com.ai.da.model.enums.ModelType;
import com.ai.da.model.enums.Module;
import com.ai.da.model.enums.Sex;
import com.ai.da.model.vo.*;
import com.ai.da.python.PythonService;
@@ -96,10 +97,15 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//用户信息
AuthPrincipalVo userInfo = UserContext.getUserHolder();
CollectionLevel1TypeEnum level1TypeEnum = CollectionLevel1TypeEnum.uploadOf(uploadDTO.getLevel1Type());
if (Objects.isNull(level1TypeEnum)) {
String name;
if (Objects.isNull(level1TypeEnum) && !uploadDTO.getLevel1Type().equals(Module.deReconstruction.getValue())) {
throw new BusinessException("unknown.parameter.level1Type");
} else if (uploadDTO.getLevel1Type().equals(Module.deReconstruction.getValue())){
name = "Construction";
} else {
name = level1TypeEnum.getRealName();
}
String objectName = userInfo.getId() + "/" + level1TypeEnum.getRealName();
String objectName = userInfo.getId() + "/" + name;
String path = minioUtil.upload(collectionElement, objectName, uploadDTO.getFile());
String level2Type = null;
@@ -108,6 +114,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
throw new BusinessException("gender.cannot.be.empty");
}
level2Type = pythonService.getClothCategory(path,uploadDTO.getGender());
}else if (!StringUtil.isNullOrEmpty(uploadDTO.getLevel2Type())){
level2Type = uploadDTO.getLevel2Type();
}
//保存element元素
@@ -187,6 +195,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//按时区计算
element.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
element.setLevel2Type(level2Type);
if (Objects.nonNull(uploadDTO.getProjectId())){
element.setProjectId(uploadDTO.getProjectId());
}
// String linuxDomain = fileProperties.getLinuxDomain();
// if (!StringUtils.isEmpty(linuxDomain)) {
// //linux 系统
@@ -1101,4 +1112,13 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return vo;
}
public void updateElementLevel2Type(Long elementId, String level2Type){
CollectionElement collectionElement = baseMapper.selectById(elementId);
if (Objects.nonNull(collectionElement)){
collectionElement.setLevel2Type(level2Type);
collectionElement.setUpdateDate(new Date());
baseMapper.updateById(collectionElement);
}
}
}

View File

@@ -1725,6 +1725,16 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
String messageFromResource = BusinessException.getMessageFromResource(clothCategory.toUpperCase());
vo.setCategory(clothCategory);
vo.setCategoryValue(messageFromResource);
List<CollectionElement> collectionElements = collectionElementService.getByProjectId(projectId);
if (!collectionElements.isEmpty()){
collectionElements.forEach(item -> {
item.setUrl(StringUtil.isNullOrEmpty(item.getUrl()) ? null : minioUtil.getPreSignedUrl(item.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
});
vo.setUploadImages(collectionElements);
}else {
vo.setUploadImages(new ArrayList<>());
}
}
return vo;
}