Merge branch 'dev/dev_xp' into dev/3.1_release_merge
# Conflicts: # src/main/java/com/ai/da/python/PythonService.java # src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java
This commit is contained in:
@@ -32,7 +32,8 @@ public class CommonConstant {
|
||||
|
||||
public static final String GENERATE_LOGO_SINGLE_CANCEL = "/api/generate_single_logo_cancel/";
|
||||
|
||||
public static final String POSE_TRANSFORMATION_CANCEL = "/api/pose_transform_cancel/";
|
||||
// public static final String POSE_TRANSFORMATION_CANCEL = "/api/pose_transform_cancel/";
|
||||
public static final String POSE_TRANSFORMATION_CANCEL = "/api/comfyui_i_2_video_cancel/";
|
||||
|
||||
public static final String PYTHON_PORT_9996 = "9996";
|
||||
|
||||
|
||||
@@ -68,4 +68,7 @@ public enum CollectionLevel2TypeEnum {
|
||||
public static List<String> printType() {
|
||||
return Arrays.asList(LOGO.getRealName(), SLOGAN.getRealName(), Pattern.getRealName());
|
||||
}
|
||||
public static CollectionLevel2TypeEnum ofWithLoweCase(String realName) {
|
||||
return Stream.of(CollectionLevel2TypeEnum.values()).filter(v -> v.getRealName().toLowerCase().equals(realName)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
29
src/main/java/com/ai/da/common/enums/MotionModeEnum.java
Normal file
29
src/main/java/com/ai/da/common/enums/MotionModeEnum.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
public enum MotionModeEnum {
|
||||
POSE_TO_VIDEO(1, "/api/comfyui_image_pose_2_video"),
|
||||
|
||||
PROMPT_TO_VIDEO(2, "/api/comfyui_image_2_video"),
|
||||
|
||||
FIRST_LAST_FRAME_TO_VIDEO(3, "/api/comfyui_flf_2_video")
|
||||
;
|
||||
|
||||
private int code;
|
||||
|
||||
private String url;
|
||||
|
||||
MotionModeEnum(int code, String url) {
|
||||
this.code = code;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public static MotionModeEnum of(int code) {
|
||||
return Stream.of(MotionModeEnum.values()).filter(v -> v.getCode()== code).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ public enum PoseEnum {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("id", String.valueOf(id));
|
||||
map.put("gif", gifPath);
|
||||
map.put("video", videoPath);
|
||||
map.put("firstFrame", firstFramePath);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -908,6 +908,47 @@ public class MinioUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将A桶中的对象复制到B桶中
|
||||
* @return
|
||||
*/
|
||||
public void copyObject(String sourceBucket, String sourceObject, String targetBucket, String targetObject) {
|
||||
// 检查目标桶是否存在
|
||||
boolean found;
|
||||
try {
|
||||
found = minioClient.bucketExists(BucketExistsArgs.builder()
|
||||
.bucket(targetBucket)
|
||||
.build());
|
||||
} catch (Exception e) {
|
||||
log.error("目标桶{},不存在", targetBucket);
|
||||
throw new BusinessException("Copy object failed");
|
||||
}
|
||||
|
||||
if (found) {
|
||||
// 复制对象
|
||||
try {
|
||||
minioClient.copyObject(
|
||||
CopyObjectArgs.builder()
|
||||
.bucket(targetBucket)
|
||||
.object(targetObject)
|
||||
.source(
|
||||
CopySource.builder()
|
||||
.bucket(sourceBucket)
|
||||
.object(sourceObject)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("对象复制失败");
|
||||
throw new BusinessException("Copy object failed");
|
||||
}
|
||||
log.info("对象复制成功");
|
||||
} else {
|
||||
log.error("目标桶{},不存在", targetBucket);
|
||||
throw new BusinessException("Copy object failed");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -126,5 +126,11 @@ public class AffiliateController {
|
||||
return Response.success(affiliateService.getAllAffiliateUsername());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改affiliate状态,Active | Inactive | Delete")
|
||||
@GetMapping("/modifyAffiliateStatus")
|
||||
public Response<String> modifyAffiliateStatus(@RequestParam Long affiliateId, @RequestParam String operationType) {
|
||||
affiliateService.modifyAffiliateStatus(affiliateId, operationType);
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -243,4 +243,10 @@ public class LibraryController {
|
||||
return Response.success(libraryService.getAllSubAccLib(order, page, size));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "将系统sketch添加到library")
|
||||
@GetMapping("addSysSketchToLibrary")
|
||||
public Response<String> addSysSketchToLibrary(Long clothId, String path) {
|
||||
return Response.success(libraryService.addSysSketchToLibrary(clothId, path));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,4 +30,6 @@ public class Affiliate extends BaseEntity{
|
||||
private String link;
|
||||
|
||||
private String promotionMethod;
|
||||
|
||||
private Integer isDeleted;
|
||||
}
|
||||
|
||||
@@ -97,4 +97,16 @@ public class Library implements Serializable {
|
||||
this.md5 = md5;
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Library(Long accountId, String level1Type, String level2Type, String level3Type, String ageGroup, String name, String url, String md5, Date createDate) {
|
||||
this.accountId = accountId;
|
||||
this.level1Type = level1Type;
|
||||
this.level2Type = level2Type;
|
||||
this.level3Type = level3Type;
|
||||
this.ageGroup = ageGroup;
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.md5 = md5;
|
||||
this.createDate = createDate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ public class PoseTransformation extends BaseEntity {
|
||||
|
||||
private String productImage;
|
||||
|
||||
private String lastFrameProductImage;
|
||||
|
||||
private int poseId;
|
||||
|
||||
private String gifUrl;
|
||||
@@ -37,6 +39,8 @@ public class PoseTransformation extends BaseEntity {
|
||||
|
||||
private String taskStatus;
|
||||
|
||||
private String prompt;
|
||||
|
||||
public PoseTransformation() {
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,13 @@ public class PoseTransformDTO {
|
||||
@ApiModelProperty("项目id")
|
||||
private Long projectId;
|
||||
|
||||
@ApiModelProperty("图片的minio地址")
|
||||
@ApiModelProperty("图片的minio地址 | 首帧图片的minio地址")
|
||||
@NotBlank(message = "please select a product image")
|
||||
private String productImage;
|
||||
|
||||
@ApiModelProperty("尾帧图片的minio地址")
|
||||
private String lastFrameProductImage;
|
||||
|
||||
@ApiModelProperty("pose的编号")
|
||||
@NotNull(message = "please select a pose")
|
||||
private Integer poseId;
|
||||
@@ -31,4 +34,10 @@ public class PoseTransformDTO {
|
||||
|
||||
@ApiModelProperty("是否默认喜欢")
|
||||
private Boolean isDefaultLike;
|
||||
|
||||
@ApiModelProperty("动作描述")
|
||||
private String prompt;
|
||||
|
||||
@ApiModelProperty("生成模式 1.pose2video | 2.prompt2video | 3.FLFrame2video ")
|
||||
private int mode;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ public class DesignItemClothesDetailVO {
|
||||
@ApiModelProperty("对应图片minIO路径")
|
||||
private String minIOPath;
|
||||
|
||||
@ApiModelProperty("图片所属:sys, user")
|
||||
private String scope;
|
||||
|
||||
@ApiModelProperty(" 颜色 存 RGB值 中间空格分隔 比如 58 58 169")
|
||||
// private String color;
|
||||
private PantoneVO color;
|
||||
|
||||
@@ -4093,7 +4093,7 @@ public class PythonService {
|
||||
//生成失败
|
||||
throw new BusinessException("segProduct.interface.exception");
|
||||
}
|
||||
public Boolean poseTransformation(String productImage, int poseId, String taskId) {
|
||||
public Boolean poseTransformation(JSONObject content, String apiUri) {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
@@ -4101,17 +4101,11 @@ public class PythonService {
|
||||
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
Map<String, String> content = Maps.newHashMap();
|
||||
content.put("image_url", productImage);
|
||||
content.put("tasks_id", taskId);
|
||||
content.put("pose_id", String.valueOf(poseId));
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||
|
||||
// String uri = "/api/pose_transform";
|
||||
String uri = "/api/comfyui_pose_transform";
|
||||
log.info("poseTransformation 请求地址: {}", accessPythonIp + ":" + accessPythonPort + uri);
|
||||
log.info("poseTransformation 请求地址: {}", accessPythonIp + ":" + accessPythonPort + apiUri);
|
||||
Request request = new Request.Builder()
|
||||
.url(accessPythonIp + ":" + accessPythonPort + uri)
|
||||
.url(accessPythonIp + ":" + accessPythonPort + apiUri)
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
|
||||
@@ -41,4 +41,6 @@ public interface AffiliateService extends IService<Affiliate> {
|
||||
void calcCouponsCommission();
|
||||
|
||||
List<Map<String, Object>> getAllAffiliateUsername();
|
||||
|
||||
void modifyAffiliateStatus(Long affiliateId, String operationType);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ public interface DesignItemDetailService extends IService<DesignItemDetail> {
|
||||
void saveDesignItemDetailCanvas(Long designItemDetailId, Long exportFileId);
|
||||
|
||||
DesignItemDetailCanvas getDIDCByDesignItemDetailId(Long designItemDetailId);
|
||||
|
||||
void updateDetailPathById(Long id, String path);
|
||||
}
|
||||
|
||||
@@ -98,4 +98,6 @@ public interface LibraryService extends IService<Library> {
|
||||
PageBaseResponse<Library> getPublicLib(String order, long page, long size);
|
||||
|
||||
PageBaseResponse<Library> getAllSubAccLib(String order, long page, long size);
|
||||
|
||||
String addSysSketchToLibrary(Long clothId, String path);
|
||||
}
|
||||
|
||||
@@ -554,5 +554,23 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
|
||||
coupon.setUnpaidCommission(unpaidCommission);
|
||||
}
|
||||
|
||||
// operationType Active -> 激活 | Inactive -> 关闭 | Delete -> 删除
|
||||
@Override
|
||||
public void modifyAffiliateStatus(Long affiliateId, String operationType) {
|
||||
Affiliate affiliate = baseMapper.selectById(affiliateId);
|
||||
if (Objects.isNull(affiliate)) {
|
||||
throw new BusinessException("unknow.affiliate");
|
||||
}
|
||||
|
||||
if (operationType.equals("Delete")) {
|
||||
affiliate.setIsDeleted(1);
|
||||
} else if (operationType.equals("Active") || operationType.equals("Inactive")) {
|
||||
affiliate.setStatus(operationType);
|
||||
} else {
|
||||
throw new BusinessException("unknown.operationType");
|
||||
}
|
||||
|
||||
updateById(affiliate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -130,4 +131,16 @@ public class DesignItemDetailServiceImpl extends ServiceImpl<DesignItemDetailMap
|
||||
|
||||
return designItemDetailCanvasMapper.selectOne(qw);
|
||||
}
|
||||
|
||||
public void updateDetailPathById(Long id, String path) {
|
||||
if (Objects.nonNull(id)) {
|
||||
DesignItemDetail designItemDetail = baseMapper.selectById(id);
|
||||
if (Objects.nonNull(designItemDetail)) {
|
||||
designItemDetail.setPath(path);
|
||||
designItemDetail.setUpdateDate(new Date());
|
||||
|
||||
baseMapper.updateById(designItemDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1462,6 +1462,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
d.setId(o.getId());
|
||||
d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60, true));
|
||||
d.setMinIOPath(o.getPath());
|
||||
d.setScope(o.getPath().startsWith("aida-sys-image") ? "sys" : "user");
|
||||
d.setLevel1Type(converTypeToLevel1(o.getType()));
|
||||
d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class));
|
||||
if (!StringUtil.isNullOrEmpty(o.getUndividedLayer())){
|
||||
|
||||
@@ -2499,17 +2499,23 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
} else {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
taskId = uuid + "-" + accountId;
|
||||
isRequestSuccess = pythonService.poseTransformation(productImage, poseId, taskId);
|
||||
|
||||
com.alibaba.fastjson.JSONObject params = createParamsForMotion(poseTransformDTO, taskId);
|
||||
String api = params.getString("api");
|
||||
params.remove("api");
|
||||
isRequestSuccess = pythonService.poseTransformation(params, api);
|
||||
}
|
||||
|
||||
poseTransformation.setProjectId(projectId);
|
||||
poseTransformation.setAccountId(accountId);
|
||||
poseTransformation.setUniqueId(taskId);
|
||||
poseTransformation.setProductImage(productImage);
|
||||
poseTransformation.setLastFrameProductImage(poseTransformDTO.getLastFrameProductImage());
|
||||
poseTransformation.setPoseId(poseId);
|
||||
poseTransformation.setIsLiked((byte) 0);
|
||||
String taskStatus = isRequestSuccess ? "Executing" : "Fail";
|
||||
poseTransformation.setTaskStatus(taskStatus);
|
||||
poseTransformation.setPrompt(poseTransformDTO.getPrompt());
|
||||
poseTransformation.setCreateTime(LocalDateTime.now());
|
||||
poseTransformationMapper.insert(poseTransformation);
|
||||
// 当需要默认like
|
||||
@@ -2996,7 +3002,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
public List<Map<String, String>> getAllPose() {
|
||||
List<Map<String, String>> propertyList = PoseEnum.getPropertyList();
|
||||
propertyList.forEach(item -> {
|
||||
item.put("gif", minioUtil.getPreSignedUrl(item.get("gif"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
// item.put("gif", minioUtil.getPreSignedUrl(item.get("gif"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
item.put("video", minioUtil.getPreSignedUrl(item.get("video"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
item.put("firstFrame", minioUtil.getPreSignedUrl(item.get("firstFrame"), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
});
|
||||
return propertyList;
|
||||
@@ -4083,11 +4090,11 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
// 处理不同状态
|
||||
switch (statusEnum) {
|
||||
case TASK_NOT_FOUND:
|
||||
// 审核没过
|
||||
// 审核没过
|
||||
case REQUEST_MODERATED:
|
||||
// 审核没过
|
||||
// 审核没过
|
||||
case CONTENT_MODERATED:
|
||||
// 出错
|
||||
// 出错
|
||||
case ERROR:
|
||||
return "Fail";
|
||||
case PENDING_F:
|
||||
@@ -4198,6 +4205,34 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
com.alibaba.fastjson.JSONObject createParamsForMotion(PoseTransformDTO poseTransformDTO, String taskId) {
|
||||
|
||||
com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject();
|
||||
params.put("tasks_id", taskId);
|
||||
// 判断当前使用的哪种生成模式
|
||||
MotionModeEnum motionModeEnum = MotionModeEnum.of(poseTransformDTO.getMode());
|
||||
switch (motionModeEnum){
|
||||
case POSE_TO_VIDEO:
|
||||
params.put("pose_id", poseTransformDTO.getPoseId());
|
||||
params.put("image_url", poseTransformDTO.getProductImage());
|
||||
break;
|
||||
case PROMPT_TO_VIDEO:
|
||||
params.put("image_url", poseTransformDTO.getProductImage());
|
||||
params.put("prompt", poseTransformDTO.getPrompt());
|
||||
break;
|
||||
case FIRST_LAST_FRAME_TO_VIDEO:
|
||||
params.put("start_image_url", poseTransformDTO.getProductImage());
|
||||
params.put("end_image_url", poseTransformDTO.getLastFrameProductImage());
|
||||
params.put("prompt", poseTransformDTO.getPrompt());
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException("unknown.mode");
|
||||
}
|
||||
params.put("api", motionModeEnum.getUrl());
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据豆包错误码和详细信息返回用户友好的错误信息
|
||||
*
|
||||
|
||||
@@ -25,6 +25,7 @@ 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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
@@ -54,6 +55,8 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ai.da.common.enums.CollectionLevel2TypeEnum.OUTWEAR;
|
||||
|
||||
/**
|
||||
* 服务实现类
|
||||
*
|
||||
@@ -62,39 +65,25 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> implements LibraryService {
|
||||
@Resource
|
||||
private LibraryMapper libraryMapper;
|
||||
@Resource
|
||||
private SysFileMapper sysFileMapper;
|
||||
@Resource
|
||||
private SysFileExtraMapper sysFileExtraMapper;
|
||||
@Resource
|
||||
private FileProperties fileProperties;
|
||||
@Resource
|
||||
private LibraryModelPointService libraryModelPointService;
|
||||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
@Resource
|
||||
private ClassificationService classificationService;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Resource
|
||||
private AccountMapper accountMapper;
|
||||
@Resource
|
||||
private EductionLibraryMapper eductionLibraryMapper;
|
||||
@Resource
|
||||
private EnterpriseLibraryMapper enterpriseLibraryMapper;
|
||||
@Resource
|
||||
private LibraryCopyMapper libraryCopyMapper;
|
||||
@Resource
|
||||
private LibraryModelPointCopyMapper libraryModelPointCopyMapper;
|
||||
@Resource
|
||||
private PythonTAllInfoService pythonTAllInfoService;
|
||||
@Resource
|
||||
private BrandRelLibraryMapper brandRelLibraryMapper;
|
||||
@Resource
|
||||
private GenerateDetailMapper generateDetailMapper;
|
||||
private final AccountMapper accountMapper;
|
||||
private final BrandRelLibraryMapper brandRelLibraryMapper;
|
||||
private final ClassificationService classificationService;
|
||||
private final DesignItemDetailService designItemDetailService;
|
||||
private final EductionLibraryMapper eductionLibraryMapper;
|
||||
private final EnterpriseLibraryMapper enterpriseLibraryMapper;
|
||||
private final FileProperties fileProperties;
|
||||
private final GenerateDetailMapper generateDetailMapper;
|
||||
private final MinioUtil minioUtil;
|
||||
private final LibraryMapper libraryMapper;
|
||||
private final LibraryCopyMapper libraryCopyMapper;
|
||||
private final LibraryModelPointMapper libraryModelPointMapper;
|
||||
private final LibraryModelPointCopyMapper libraryModelPointCopyMapper;
|
||||
private final PythonTAllInfoService pythonTAllInfoService;
|
||||
private final SysFileMapper sysFileMapper;
|
||||
private final SysFileExtraMapper sysFileExtraMapper;
|
||||
private final WorkspaceService workspaceService;
|
||||
|
||||
@Value("${minio.bucketName.users}")
|
||||
private String users;
|
||||
@@ -110,7 +99,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
private String fastApiPythonAddress;
|
||||
|
||||
private static List<String> top = Arrays.asList(CollectionLevel2TypeEnum.DRESS.getRealName(),
|
||||
CollectionLevel2TypeEnum.OUTWEAR.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
|
||||
OUTWEAR.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
|
||||
private static List<String> bottom = Arrays.asList(CollectionLevel2TypeEnum.SKIRT.getRealName(),
|
||||
CollectionLevel2TypeEnum.TROUSERS.getRealName());
|
||||
|
||||
@@ -233,7 +222,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
.filter(library -> library.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName()))
|
||||
.map(Library::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<LibraryModelPointVO> libraryModelPointVOS = libraryModelPointService.selectByLibraryIds(libraryIds);
|
||||
List<LibraryModelPointVO> libraryModelPointVOS = selectByLibraryIds(libraryIds);
|
||||
if (!CollectionUtils.isEmpty(libraryModelPointVOS)) {
|
||||
map = libraryModelPointVOS.stream()
|
||||
.collect(Collectors.toMap(LibraryModelPointVO::getRelationId, v -> v));
|
||||
@@ -307,6 +296,25 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
return PageBaseResponse.success(pageResult);
|
||||
}
|
||||
|
||||
public List<LibraryModelPointVO> selectByLibraryIds(List<Long> libraryIds) {
|
||||
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
|
||||
queryWrapper.in("relation_id", libraryIds);
|
||||
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(libraryModelPoints)) {
|
||||
return null;
|
||||
}
|
||||
return CopyUtil.copyList(libraryModelPoints, LibraryModelPointVO.class, (o, d) -> {
|
||||
d.setTemplateId(o.getId());
|
||||
d.setHandLeft(JSON.parseObject(o.getHandLeft(), List.class));
|
||||
d.setHandRight(JSON.parseObject(o.getHandRight(), List.class));
|
||||
d.setShoulderRight(JSON.parseObject(o.getShoulderRight(), List.class));
|
||||
d.setShoulderLeft(JSON.parseObject(o.getShoulderLeft(), List.class));
|
||||
d.setWaistbandRight(JSON.parseObject(o.getWaistbandRight(), List.class));
|
||||
d.setWaistbandLeft(JSON.parseObject(o.getWaistbandLeft(), List.class));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibraryUpdateVo upload(LibraryUploadDTO libraryUploadDTO) {
|
||||
//用户信息
|
||||
@@ -659,7 +667,8 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
|
||||
libraryModelPoint.setRelationId(newInsert.getId());
|
||||
libraryModelPoint.setId(null);
|
||||
libraryModelPointService.saveOrUpdate(libraryModelPoint);
|
||||
// libraryModelPointService.saveOrUpdate(libraryModelPoint);
|
||||
libraryModelPointMapper.insert(libraryModelPoint);
|
||||
continue;
|
||||
}
|
||||
if (libraryCopy.getLevel1Type().equals("Sketchboard")) {
|
||||
@@ -913,12 +922,12 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
libraryMapper.insert(library);
|
||||
|
||||
// 添加点位信息到library
|
||||
LibraryModelPoint sysModelPoint = libraryModelPointService.getByRelationId(sysModelId, "System");
|
||||
LibraryModelPoint sysModelPoint = getByRelationId(sysModelId, "System");
|
||||
sysModelPoint.setId(null);
|
||||
sysModelPoint.setModelType("Library");
|
||||
sysModelPoint.setRelationId(library.getId());
|
||||
sysModelPoint.setCreateDate(new Date());
|
||||
libraryModelPointService.save(sysModelPoint);
|
||||
libraryModelPointMapper.insert(sysModelPoint);
|
||||
|
||||
Map<String, String> resp = new HashMap<>();
|
||||
resp.put("id", library.getId().toString());
|
||||
@@ -926,6 +935,19 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
return resp;
|
||||
}
|
||||
|
||||
public LibraryModelPoint getByRelationId(Long relationId, String modelType) {
|
||||
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(LibraryModelPoint::getRelationId, relationId)
|
||||
.eq(LibraryModelPoint::getModelType, modelType)
|
||||
.last("limit 1");
|
||||
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(libraryModelPoints)) {
|
||||
throw new BusinessException("modelPoint.not.found");
|
||||
}
|
||||
return libraryModelPoints.get(0);
|
||||
}
|
||||
|
||||
|
||||
public boolean saveToOrganizationLibrary(Long libraryId){
|
||||
// 1、判断该用户是否属于某个组织
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
@@ -1030,4 +1052,53 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将系统sketch添加到个人library
|
||||
*/
|
||||
public String addSysSketchToLibrary(Long clothId, String path) {
|
||||
// 1. 判断当前路径是不是系统sketch
|
||||
if (!path.startsWith("aida-sys-image/images")) {
|
||||
throw new BusinessException("Non-system Sketch file cannot be added to personal library.", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
|
||||
// 2. 是。获取当前用户id,随机生成4位数
|
||||
String sourceObject = path.substring(path.indexOf("/") + 1);
|
||||
String subPath = sourceObject.substring(sourceObject.indexOf("images/") + 1, sourceObject.lastIndexOf("."));
|
||||
String gender = subPath.substring(0, subPath.indexOf("/")).equals("female") ? "female" : "male";
|
||||
String category = subPath.substring(subPath.indexOf("/") + 1, subPath.lastIndexOf("/"));
|
||||
CollectionLevel2TypeEnum collectionLevel2TypeEnum = CollectionLevel2TypeEnum.ofWithLoweCase(category);
|
||||
if (Objects.nonNull(collectionLevel2TypeEnum)){
|
||||
category = collectionLevel2TypeEnum.getRealName();
|
||||
} else {
|
||||
category = OUTWEAR.getRealName();
|
||||
}
|
||||
String suffix = sourceObject.substring(sourceObject.lastIndexOf(".") + 1);
|
||||
Long userId = UserContext.getUserHolder().getId();
|
||||
String name = subPath.substring(subPath.lastIndexOf("/") + 1) + "_" + RandomsUtil.generateVerifyCode(1000L, 9999L);
|
||||
String targetObject = userId + "/sketchboard/" + gender + "/" + category + "/" +
|
||||
name + "." + suffix;
|
||||
|
||||
// 3. 复制图片到用户个人图片文件夹下
|
||||
minioUtil.copyObject(sysImage, sourceObject, users, targetObject);
|
||||
|
||||
// 4. 存储到数据库中
|
||||
String targetPath = users + "/" + targetObject;
|
||||
String md5 = MD5Utils.encryptFile(minioUtil.getPreSignedUrl(targetPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false);
|
||||
Library library = new Library(userId, CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName(),
|
||||
category, gender, "Adult", name, targetPath, md5, new Date());
|
||||
saveOne(library);
|
||||
|
||||
// 5. 更新designItemDetail中的图片路径
|
||||
if (Objects.nonNull(clothId)) {
|
||||
designItemDetailService.updateDetailPathById(clothId, targetPath);
|
||||
}
|
||||
return minioUtil.getPreSignedUrl(targetPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* todo 低分辨率下载
|
||||
*/
|
||||
public void downloadSysSketchWithWatermark() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user