Merge remote-tracking branch 'origin/dev-xp' into dev_shb
# Conflicts: # src/main/java/com/ai/da/service/impl/DesignServiceImpl.java # src/main/java/com/ai/da/service/impl/LibraryServiceImpl.java
This commit is contained in:
@@ -279,7 +279,24 @@ public class MinioUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将桶名、文件名从url中分离出来
|
||||||
|
* @param url 带桶名、文件名的url
|
||||||
|
* @param expiry 图片过期时间
|
||||||
|
* @return 可以直接访问的minio图片地址
|
||||||
|
*/
|
||||||
|
public String splitThenGetPreviewUrl(String url,int expiry){
|
||||||
|
String[] parts = url.split("/");
|
||||||
|
String bucketName = parts[0];
|
||||||
|
StringBuilder fileName = new StringBuilder();
|
||||||
|
for (int i = 1; i < parts.length; i++){
|
||||||
|
fileName.append(parts[i]);
|
||||||
|
if (i != parts.length -1){
|
||||||
|
fileName.append("/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getPresignedUrl(bucketName, String.valueOf(fileName),expiry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.ai.da.model.vo.GenerateLikeVO;
|
|||||||
import com.ai.da.service.GenerateService;
|
import com.ai.da.service.GenerateService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -46,4 +47,11 @@ public class GenerateController {
|
|||||||
return Response.success(generateService.generateLike(generateLikeDTO));
|
return Response.success(generateService.generateLike(generateLikeDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "取消喜欢")
|
||||||
|
@GetMapping("/dislike")
|
||||||
|
public Response<Boolean> dislike(@ApiParam("generateDetailId") @RequestParam Long generateDetailId,
|
||||||
|
@ApiParam("timeZone") @RequestParam String timeZone) {
|
||||||
|
return Response.success(generateService.generateDislike(generateDetailId,timeZone));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ public class GenerateDetail {
|
|||||||
*/
|
*/
|
||||||
private Byte isLike;
|
private Byte isLike;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 喜欢的图片添加到library对应的id
|
||||||
|
*/
|
||||||
|
private Long libraryId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,4 +32,11 @@ public class DesignItemClothesDetailVO {
|
|||||||
|
|
||||||
@ApiModelProperty("对应图层信息")
|
@ApiModelProperty("对应图层信息")
|
||||||
private List<DesignPythonOutfitVO> layersObject;
|
private List<DesignPythonOutfitVO> layersObject;
|
||||||
|
|
||||||
|
public DesignItemClothesDetailVO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DesignItemClothesDetailVO(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1354,7 +1354,7 @@ public class PythonService {
|
|||||||
bodyPath = designLibraryModelPoint.getTemplateUrl();
|
bodyPath = designLibraryModelPoint.getTemplateUrl();
|
||||||
} else {
|
} else {
|
||||||
// bodyPath = "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png";
|
// bodyPath = "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png";
|
||||||
bodyPath = "model_1693218345.2714431.png";
|
bodyPath = "aida-mannequins/model_1693218345.2714431.png";
|
||||||
}
|
}
|
||||||
response.add(new DesignPythonItem(SysFileLevel2TypeEnum.BODY.getRealName(),bodyPath,pythonTAllInfoService.getImageIdByPath(bodyPath)));
|
response.add(new DesignPythonItem(SysFileLevel2TypeEnum.BODY.getRealName(),bodyPath,pythonTAllInfoService.getImageIdByPath(bodyPath)));
|
||||||
return response;
|
return response;
|
||||||
@@ -1363,8 +1363,8 @@ public class PythonService {
|
|||||||
|
|
||||||
|
|
||||||
private DesignPythonItemPrint resolveDesignSinglePrint(DesignSinglePrintDTO printObject, String clothesPath) {
|
private DesignPythonItemPrint resolveDesignSinglePrint(DesignSinglePrintDTO printObject, String clothesPath) {
|
||||||
if (Objects.isNull(printObject)) {
|
if (Objects.isNull(printObject.getPath()) || CollectionUtil.isEmpty(printObject.getPrints())) {
|
||||||
return null;
|
return new DesignPythonItemPrint(new ArrayList<>(),false);
|
||||||
}
|
}
|
||||||
DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class);
|
DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class);
|
||||||
if(StringUtils.isEmpty(printObject.getPath())){
|
if(StringUtils.isEmpty(printObject.getPath())){
|
||||||
@@ -1528,8 +1528,8 @@ public class PythonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject designNew(DesignPythonObjects designPythonObjects) {
|
public JSONObject designNew(DesignPythonObjects designPythonObjects) {
|
||||||
//限流校验
|
// todo 限流校验
|
||||||
AccessLimitUtils.validate("design",5);
|
// AccessLimitUtils.validate("design",5);
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||||
@@ -1561,7 +1561,7 @@ public class PythonService {
|
|||||||
log.error("PythonService##design异常###{}", ExceptionUtil.getThrowableList(ioException));
|
log.error("PythonService##design异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
}
|
}
|
||||||
//去除限流
|
//去除限流
|
||||||
AccessLimitUtils.validateOut("design");
|
// AccessLimitUtils.validateOut("design");
|
||||||
if (Objects.isNull(response)) {
|
if (Objects.isNull(response)) {
|
||||||
log.error("PythonService##design异常###{}", "response or body is empty!");
|
log.error("PythonService##design异常###{}", "response or body is empty!");
|
||||||
throw new BusinessException("system error!");
|
throw new BusinessException("system error!");
|
||||||
@@ -1641,9 +1641,9 @@ public class PythonService {
|
|||||||
content.put("user_id", userId);
|
content.put("user_id", userId);
|
||||||
content.put("image_url", url);
|
content.put("image_url", url);
|
||||||
content.put("category", category);
|
content.put("category", category);
|
||||||
content.put("mode",mode); //
|
content.put("mode",mode);
|
||||||
content.put("str", text);
|
content.put("str", text);
|
||||||
content.put("version",modelName);
|
content.put("version",2);
|
||||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
// .url(accessPythonIp + ":2828/aida/diffusion")
|
// .url(accessPythonIp + ":2828/aida/diffusion")
|
||||||
@@ -1659,6 +1659,15 @@ public class PythonService {
|
|||||||
log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content));
|
log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content));
|
||||||
response = client.newCall(request).execute();
|
response = client.newCall(request).execute();
|
||||||
bodyString = response.body().string();
|
bodyString = response.body().string();
|
||||||
|
// bodyString = "{\n" +
|
||||||
|
// " \"code\": 200,\n" +
|
||||||
|
// " \"data\": {\n" +
|
||||||
|
// " \"list\": [\n" +
|
||||||
|
// " \"aida-users/12/print_1695088687_0.png\"\n" +
|
||||||
|
// " ]\n" +
|
||||||
|
// " },\n" +
|
||||||
|
// " \"msg\": \"OK!\"\n" +
|
||||||
|
// "}";
|
||||||
} catch (IOException ioException) {
|
} catch (IOException ioException) {
|
||||||
log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
|
log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
}
|
}
|
||||||
@@ -1669,10 +1678,11 @@ public class PythonService {
|
|||||||
log.error("PythonService##generateSketchOrPrint异常###{}", "response or body is empty!");
|
log.error("PythonService##generateSketchOrPrint异常###{}", "response or body is empty!");
|
||||||
throw new BusinessException("generate exception!");
|
throw new BusinessException("generate exception!");
|
||||||
}
|
}
|
||||||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(bodyString));
|
JSONObject jsonObject = JSON.parseObject(bodyString);
|
||||||
Boolean result = jsonObject.getBoolean("successful");
|
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
|
||||||
|
// Boolean result = Boolean.TRUE;
|
||||||
if (result) {
|
if (result) {
|
||||||
return setGenerateImageList(jsonObject.getJSONObject("date"));
|
return setGenerateImageList(jsonObject.getJSONObject("data"));
|
||||||
}
|
}
|
||||||
log.info("generateSketchOrPrintPrint失败###{}", jsonObject);
|
log.info("generateSketchOrPrintPrint失败###{}", jsonObject);
|
||||||
//生成失败
|
//生成失败
|
||||||
@@ -1708,13 +1718,13 @@ public class PythonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> setGenerateImageList(JSONObject jsonObject){
|
private static List<String> setGenerateImageList(JSONObject jsonObject){
|
||||||
if (Objects.isNull(jsonObject.getJSONObject("list"))){
|
List<String> imageUrlList = JSONObject.parseArray(jsonObject.get("list").toString(),String.class);
|
||||||
|
if (imageUrlList.size() == 0){
|
||||||
log.error("PythonService##generateSketchOrPrint异常###{}","diffusion response list is null");
|
log.error("PythonService##generateSketchOrPrint异常###{}","diffusion response list is null");
|
||||||
|
|
||||||
// todo 如果这里返回为空,是判断出错还是返回给前端空
|
// todo 如果这里返回为空,是判断出错还是返回给前端空
|
||||||
throw new BusinessException("Some errors occurred, please try again later");
|
throw new BusinessException("Some errors occurred, please try again later");
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSONArray.parseArray(JSONObject.toJSONString(jsonObject.get("list")), String.class);
|
return imageUrlList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,4 +60,9 @@ public class DesignPythonItemPrint {
|
|||||||
public DesignPythonItemPrint(String path) {
|
public DesignPythonItemPrint(String path) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DesignPythonItemPrint(List<String> print_path_list, Boolean ifSingle) {
|
||||||
|
this.print_path_list = print_path_list;
|
||||||
|
IfSingle = ifSingle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,6 @@ public interface GenerateService extends IService<Generate> {
|
|||||||
GenerateCollectionVO generateThroughImageText(GenerateThroughImageTextDTO generateThroughImageTextDTO);
|
GenerateCollectionVO generateThroughImageText(GenerateThroughImageTextDTO generateThroughImageTextDTO);
|
||||||
|
|
||||||
GenerateLikeVO generateLike(GenerateLikeDTO generateLikeDTO);
|
GenerateLikeVO generateLike(GenerateLikeDTO generateLikeDTO);
|
||||||
|
|
||||||
|
Boolean generateDislike(Long generateDetailId,String timeZone);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
|
|
||||||
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId());
|
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId());
|
||||||
// todo designPythonOutFit 空指针
|
// todo designPythonOutFit 空指针
|
||||||
return assembleDesignSingleResponse(designItem.getId(),minioUtil.getPresignedUrl(bucketName,designPythonOutfit.getDesignUrl(),5),
|
return assembleDesignSingleResponse(designItem.getId(),minioUtil.splitThenGetPreviewUrl(designPythonOutfit.getDesignUrl(),480),
|
||||||
designSingleIncludeLayersDTO.getDesignSingleItemDTOList(),detailsVO);
|
designSingleIncludeLayersDTO.getDesignSingleItemDTOList(),detailsVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,6 +423,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
|
|
||||||
DesignSingleVO designSingleVO = new DesignSingleVO();
|
DesignSingleVO designSingleVO = new DesignSingleVO();
|
||||||
ArrayList<DesignItemClothesDetailVO> clothes = new ArrayList<>();
|
ArrayList<DesignItemClothesDetailVO> clothes = new ArrayList<>();
|
||||||
|
DesignItemClothesDetailVO body = new DesignItemClothesDetailVO("body");
|
||||||
designSingleVO.setDesignItemId(designItemId);
|
designSingleVO.setDesignItemId(designItemId);
|
||||||
designSingleVO.setDesignItemUrl(designItemUrl);
|
designSingleVO.setDesignItemUrl(designItemUrl);
|
||||||
designSingleVO.setClothes(clothes);
|
designSingleVO.setClothes(clothes);
|
||||||
@@ -433,9 +434,13 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor()));
|
designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor()));
|
||||||
designItemClothesDetailVO.setPrintObject(new DesignPythonItemPrint(singleItem.getPrintObject().getPath()));
|
designItemClothesDetailVO.setPrintObject(new DesignPythonItemPrint(singleItem.getPrintObject().getPath()));
|
||||||
designItemClothesDetailVO.setLayersObject(layersObject.stream().filter(
|
designItemClothesDetailVO.setLayersObject(layersObject.stream().filter(
|
||||||
layers -> singleItem.getType().toLowerCase().equals(layers.getImageCategory().split("_")[0])).collect(Collectors.toList()));
|
layers -> singleItem.getType().toLowerCase().equals(layers.getImageCategory().split("_")[0])
|
||||||
|
).collect(Collectors.toList()));
|
||||||
|
body.setLayersObject(layersObject.stream().filter(layers -> layers.getImageCategory().equals("body")).collect(Collectors.toList()));
|
||||||
|
|
||||||
clothes.add(designItemClothesDetailVO);
|
clothes.add(designItemClothesDetailVO);
|
||||||
});
|
});
|
||||||
|
clothes.add(body);
|
||||||
|
|
||||||
return designSingleVO;
|
return designSingleVO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -827,6 +827,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
d.setPrintObject(new DesignPythonItemPrint());
|
d.setPrintObject(new DesignPythonItemPrint());
|
||||||
}));
|
}));
|
||||||
return editDesignItemLayer(flag, designPythonOutfit, designItem.getDesignUrl(), editResponseColor(designItemDetails, response));
|
return editDesignItemLayer(flag, designPythonOutfit, designItem.getDesignUrl(), editResponseColor(designItemDetails, response));
|
||||||
|
return editDesignItemLayer(flag,designPythonOutfit,
|
||||||
|
minIoUtil.splitThenGetPreviewUrl(designItem.getDesignUrl(),480),
|
||||||
|
editResponseColor(designItemDetails,response));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String converTypeToLevel1(String type) {
|
private String converTypeToLevel1(String type) {
|
||||||
@@ -924,7 +927,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 2、将查询出的图层信息填充到designItemDetailVO中
|
// 2、将查询出的图层信息填充到designItemDetailVO中
|
||||||
designItemDetailVO.setDesignItemUrl(designPythonOutfit.getDesignUrl());
|
designItemDetailVO.setDesignItemUrl(minIoUtil.splitThenGetPreviewUrl(designPythonOutfit.getDesignUrl(),480));
|
||||||
// 2.1 填充clothes
|
// 2.1 填充clothes
|
||||||
designItemDetailVO.getClothes().forEach(c -> {
|
designItemDetailVO.getClothes().forEach(c -> {
|
||||||
String type = c.getType().toLowerCase();
|
String type = c.getType().toLowerCase();
|
||||||
@@ -938,14 +941,14 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
String type = o.getType().toLowerCase();
|
String type = o.getType().toLowerCase();
|
||||||
List<DesignPythonOutfitVO> outfitVOS = detailsVO.stream().filter(detail -> detail.getImageCategory().equals(type + "_back") ||
|
List<DesignPythonOutfitVO> outfitVOS = detailsVO.stream().filter(detail -> detail.getImageCategory().equals(type + "_back") ||
|
||||||
detail.getImageCategory().equals(type + "_front") ||
|
detail.getImageCategory().equals(type + "_front") ||
|
||||||
detail.getImageCategory().equals("body")).collect(Collectors.toList());
|
detail.getImageCategory().equals(type + "_left") ||
|
||||||
|
detail.getImageCategory().equals(type + "_right") ||
|
||||||
|
detail.getImageCategory().equals(type)).collect(Collectors.toList());
|
||||||
o.setLayersObject(outfitVOS);
|
o.setLayersObject(outfitVOS);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
designItemDetailVO.setDesignItemUrl(designItemUrl);
|
designItemDetailVO.setDesignItemUrl(designItemUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return designItemDetailVO;
|
return designItemDetailVO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.ai.da.common.enums.GenerateModeEnum;
|
|||||||
import com.ai.da.common.enums.ModelNameEnum;
|
import com.ai.da.common.enums.ModelNameEnum;
|
||||||
import com.ai.da.common.utils.DateUtil;
|
import com.ai.da.common.utils.DateUtil;
|
||||||
import com.ai.da.common.utils.MD5Utils;
|
import com.ai.da.common.utils.MD5Utils;
|
||||||
|
import com.ai.da.common.utils.MinioUtil;
|
||||||
import com.ai.da.mapper.CollectionElementMapper;
|
import com.ai.da.mapper.CollectionElementMapper;
|
||||||
import com.ai.da.mapper.GenerateDetailMapper;
|
import com.ai.da.mapper.GenerateDetailMapper;
|
||||||
import com.ai.da.mapper.GenerateMapper;
|
import com.ai.da.mapper.GenerateMapper;
|
||||||
@@ -21,6 +22,7 @@ import com.ai.da.service.LibraryService;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -44,6 +46,11 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
|
|||||||
@Resource
|
@Resource
|
||||||
private CollectionElementService collectionElementService;
|
private CollectionElementService collectionElementService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MinioUtil minioUtil;
|
||||||
|
@Value("${minio.bucketName4}")
|
||||||
|
private String bucketName4;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GenerateCaptionVO generateCaption(Long sketchElementId) {
|
public GenerateCaptionVO generateCaption(Long sketchElementId) {
|
||||||
CollectionElement collectionElement = collectionElementMapper.selectById(sketchElementId);
|
CollectionElement collectionElement = collectionElementMapper.selectById(sketchElementId);
|
||||||
@@ -86,7 +93,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
|
|||||||
int mode = GenerateModeEnum.TEXT.getValue().equals(generate.getGenerateType()) ? GenerateModeEnum.TEXT.getCode() : GenerateModeEnum.TEXT_IMAGE.getCode();
|
int mode = GenerateModeEnum.TEXT.getValue().equals(generate.getGenerateType()) ? GenerateModeEnum.TEXT.getCode() : GenerateModeEnum.TEXT_IMAGE.getCode();
|
||||||
String category = generateThroughImageTextDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()) ? "sketch" :
|
String category = generateThroughImageTextDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()) ? "sketch" :
|
||||||
generateThroughImageTextDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()) ? "print" : "moodboard";
|
generateThroughImageTextDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()) ? "print" : "moodboard";
|
||||||
List<String> generatedSketchUrl = pythonService.generateSketchOrPrint(accountId,collectionElement.getUrl(),category,text,mode,generateThroughImageTextDTO.getVersion());
|
List<String> generatedSketchUrl = pythonService.generateSketchOrPrint(accountId,Objects.isNull(elementId) ? null : collectionElement.getUrl(),
|
||||||
|
category,text,mode,generateThroughImageTextDTO.getVersion());
|
||||||
|
|
||||||
// List<String> generatedSketchUrl = Arrays.asList("testUrl1","testUrl2","testUrl3","testUrl4");
|
// List<String> generatedSketchUrl = Arrays.asList("testUrl1","testUrl2","testUrl3","testUrl4");
|
||||||
|
|
||||||
@@ -102,7 +110,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
|
|||||||
|
|
||||||
GenerateCollectionItemVO generateCollectionItemVO = new GenerateCollectionItemVO();
|
GenerateCollectionItemVO generateCollectionItemVO = new GenerateCollectionItemVO();
|
||||||
generateCollectionItemVO.setGenerateItemId(generateDetail.getId());
|
generateCollectionItemVO.setGenerateItemId(generateDetail.getId());
|
||||||
generateCollectionItemVO.setGenerateItemUrl(item);
|
generateCollectionItemVO.setGenerateItemUrl(minioUtil.splitThenGetPreviewUrl(item,480));
|
||||||
generatedCollectionItems.add(generateCollectionItemVO);
|
generatedCollectionItems.add(generateCollectionItemVO);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -145,17 +153,44 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
|
|||||||
Assert.isTrue(generateLikeDTO.getLevel1Type().equals(generate.getLevel1Type()),"level1Type does not match");
|
Assert.isTrue(generateLikeDTO.getLevel1Type().equals(generate.getLevel1Type()),"level1Type does not match");
|
||||||
|
|
||||||
// 2、将like的图片信息存入library
|
// 2、将like的图片信息存入library
|
||||||
|
// 2.1、不能重复喜欢
|
||||||
|
Library libraryDetail = libraryService.getById(generateDetail.getLibraryId());
|
||||||
|
Assert.isTrue(Objects.isNull(generateDetail.getLibraryId()) || Objects.isNull(libraryDetail),
|
||||||
|
"Duplicate likes are not allowed");
|
||||||
|
// 2.2、添加到library
|
||||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||||
Long accountId = userInfo.getId();
|
Long accountId = userInfo.getId();
|
||||||
Library library = setLibrary(accountId, generateLikeDTO, generateDetail.getUrl());
|
Library library = setLibrary(accountId, generateLikeDTO, generateDetail.getUrl());
|
||||||
libraryService.save(library);
|
libraryService.save(library);
|
||||||
|
|
||||||
// 3、更新generateDetail表的isLike列
|
// 3、更新generateDetail表的isLike列和libraryId列
|
||||||
updateLikeStatus(generateLikeDTO.getGenerateDetailId(),(byte)1);
|
updateLikeStatus(generateLikeDTO.getGenerateDetailId(),(byte)1,library.getId(),generateLikeDTO.getTimeZone());
|
||||||
|
|
||||||
return new GenerateLikeVO(library.getId());
|
return new GenerateLikeVO(library.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean generateDislike(Long generateDetailId, String timeZone) {
|
||||||
|
// 1、确定generateDetail中是否有这条记录
|
||||||
|
GenerateDetail generateDetail = generateDetailMapper.selectById(generateDetailId);
|
||||||
|
Assert.notNull(generateDetail,"generateItem does not exist");
|
||||||
|
|
||||||
|
// 2、修改generateDetail表中的isLike、libraryId字段
|
||||||
|
updateLikeStatus(generateDetailId,(byte)0,0L,timeZone);
|
||||||
|
|
||||||
|
// 3、确定library中是否添加该条记录
|
||||||
|
Library libraryDetail = libraryService.getById(generateDetail.getLibraryId());
|
||||||
|
if (Objects.isNull(libraryDetail)){
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4、删除library相关记录
|
||||||
|
libraryService.removeById(libraryDetail.getId());
|
||||||
|
|
||||||
|
// 5、返回成功
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
public Library setLibrary(Long accountId,GenerateLikeDTO generateLikeDTO,String imageUrl){
|
public Library setLibrary(Long accountId,GenerateLikeDTO generateLikeDTO,String imageUrl){
|
||||||
Library library = new Library();
|
Library library = new Library();
|
||||||
library.setAccountId(accountId);
|
library.setAccountId(accountId);
|
||||||
@@ -163,17 +198,19 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> im
|
|||||||
library.setLevel2Type(StringUtil.isNullOrEmpty(generateLikeDTO.getLevel2Type()) ? null : generateLikeDTO.getLevel2Type());
|
library.setLevel2Type(StringUtil.isNullOrEmpty(generateLikeDTO.getLevel2Type()) ? null : generateLikeDTO.getLevel2Type());
|
||||||
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
|
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
|
||||||
library.setUrl(imageUrl);
|
library.setUrl(imageUrl);
|
||||||
library.setMd5(MD5Utils.encryptFile(imageUrl,Boolean.FALSE));
|
library.setMd5(MD5Utils.encryptFile(minioUtil.splitThenGetPreviewUrl(imageUrl,5),Boolean.FALSE));
|
||||||
library.setCreateDate(DateUtil.getByTimeZone(generateLikeDTO.getTimeZone()));
|
library.setCreateDate(DateUtil.getByTimeZone(generateLikeDTO.getTimeZone()));
|
||||||
return library;
|
return library;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLikeStatus(Long generateDetailId,Byte hasLike){
|
public void updateLikeStatus(Long generateDetailId,Byte hasLike,Long libraryId,String timeZone){
|
||||||
QueryWrapper<GenerateDetail> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<GenerateDetail> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("id", generateDetailId);
|
queryWrapper.eq("id", generateDetailId);
|
||||||
|
|
||||||
GenerateDetail generateDetail = new GenerateDetail();
|
GenerateDetail generateDetail = new GenerateDetail();
|
||||||
generateDetail.setIsLike(hasLike);
|
generateDetail.setIsLike(hasLike);
|
||||||
|
generateDetail.setLibraryId(libraryId);
|
||||||
|
generateDetail.setUpdateDate(DateUtil.getByTimeZone(timeZone));
|
||||||
generateDetailMapper.update(generateDetail,queryWrapper);
|
generateDetailMapper.update(generateDetail,queryWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import com.ai.da.common.response.PageBaseResponse;
|
|||||||
import com.ai.da.common.utils.CopyUtil;
|
import com.ai.da.common.utils.CopyUtil;
|
||||||
import com.ai.da.common.utils.DateUtil;
|
import com.ai.da.common.utils.DateUtil;
|
||||||
import com.ai.da.common.utils.MinioUtil;
|
import com.ai.da.common.utils.MinioUtil;
|
||||||
|
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.LibraryMapper;
|
||||||
import com.ai.da.mapper.entity.*;
|
import com.ai.da.mapper.entity.*;
|
||||||
import com.ai.da.model.dto.*;
|
import com.ai.da.model.dto.*;
|
||||||
@@ -124,6 +126,9 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
IPage<QueryLibraryPageVO> convert = page.convert((Function<Library, QueryLibraryPageVO>) library -> {
|
IPage<QueryLibraryPageVO> convert = page.convert((Function<Library, QueryLibraryPageVO>) library -> {
|
||||||
QueryLibraryPageVO libraryPageVO = CopyUtil.copyObject(library,QueryLibraryPageVO.class);
|
QueryLibraryPageVO libraryPageVO = CopyUtil.copyObject(library,QueryLibraryPageVO.class);
|
||||||
libraryPageVO.setDesignType(DesignTypeEnum.LIBRARY.getRealName());
|
libraryPageVO.setDesignType(DesignTypeEnum.LIBRARY.getRealName());
|
||||||
|
if (library.getUrl().startsWith("aida")){
|
||||||
|
libraryPageVO.setUrl(minioUtil.splitThenGetPreviewUrl(library.getUrl(),480));
|
||||||
|
}
|
||||||
if(finalMap != null && finalMap.containsKey(library.getId())){
|
if(finalMap != null && finalMap.containsKey(library.getId())){
|
||||||
libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId()));
|
libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
|||||||
|
|
||||||
@Value("${minio.bucketName.clothing}")
|
@Value("${minio.bucketName.clothing}")
|
||||||
private String bucketName2;
|
private String bucketName2;
|
||||||
|
@Value("${minio.bucketName3}")
|
||||||
|
private String bucketName3;
|
||||||
@Resource
|
@Resource
|
||||||
private MinioUtil minIoUtil;
|
private MinioUtil minIoUtil;
|
||||||
@Override
|
@Override
|
||||||
@@ -52,10 +54,14 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
|||||||
}
|
}
|
||||||
|
|
||||||
DesignPythonOutfitVO designPythonOutfitVO = CopyUtil.copyObject(detail,DesignPythonOutfitVO.class);
|
DesignPythonOutfitVO designPythonOutfitVO = CopyUtil.copyObject(detail,DesignPythonOutfitVO.class);
|
||||||
designPythonOutfitVO.setPosition((List<Long>) JSON.parse(detail.getPosition()));
|
designPythonOutfitVO.setPosition(StringUtil.isNullOrEmpty(detail.getPosition()) ? null : (List<Long>) JSON.parse(detail.getPosition()));
|
||||||
designPythonOutfitVO.setImageSize((List<Long>) JSON.parse(detail.getImageSize()));
|
designPythonOutfitVO.setImageSize(StringUtil.isNullOrEmpty(detail.getImageSize()) ? null : (List<Long>) JSON.parse(detail.getImageSize()));
|
||||||
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.getPresignedUrl(bucketName2,detail.getImageUrl(),5));
|
if (detail.getImageCategory().equals("body")){
|
||||||
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.getPresignedUrl(bucketName2,detail.getMaskUrl(),5));
|
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getImageUrl(),480));
|
||||||
|
}else {
|
||||||
|
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getImageUrl(),480));
|
||||||
|
}
|
||||||
|
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getMaskUrl(),480));
|
||||||
return designPythonOutfitVO;
|
return designPythonOutfitVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ minio.accessKey=minioadmin
|
|||||||
minio.secretKey=minioadmin
|
minio.secretKey=minioadmin
|
||||||
minio.bucketName=aida-results
|
minio.bucketName=aida-results
|
||||||
minio.bucketName2=aida-clothing
|
minio.bucketName2=aida-clothing
|
||||||
|
minio.bucketName3=aida-mannequins
|
||||||
|
minio.bucketName4=aida-users
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user