TASK:aida;

This commit is contained in:
shahaibo
2024-06-27 15:33:26 +08:00
parent 58a78a5366
commit 9b438c78a3
19 changed files with 312 additions and 60 deletions

View File

@@ -1,5 +1,6 @@
package com.ai.da.common.config;
import com.ai.da.common.utils.ExcelReader;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.common.utils.SendEmailUtil;
import com.ai.da.mapper.primary.*;
@@ -26,6 +27,9 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Component
@@ -34,6 +38,7 @@ public class MyTaskScheduler {
@PostConstruct
public void test() {
// clearMinio();
// addSystemFileStyle();
}
@Resource
@@ -214,30 +219,104 @@ public class MyTaskScheduler {
private AttributeRetrievalMapper attributeRetrievalMapper;
public void addSystemFileStyle() {
String directoryPath = "C:\\Users\\10233\\Downloads\\blouse done\\blouse done\\废土风";
List<String> fileNames = getFileNames(directoryPath);
for (String fileName : fileNames) {
String tableName = "female_top";
String style = "feitufeng";
Long idByFileName = attributeRetrievalMapper.getIdByFileName(fileName, tableName);
attributeRetrievalMapper.updateStyleById(idByFileName, style, tableName);
ExecutorService executorService = Executors.newFixedThreadPool(5);
try {
String[] filePaths = {
"C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Blouse style output updated25.6.2024.xlsx",
"C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Dress style output updated25.6.2024.xlsx",
"C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Outerwear style output.xlsx",
"C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Skirt style output .xlsx",
"C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Trousers style output.xlsx"
};
for (String filePath : filePaths) {
executorService.submit(() -> processExcelFile(filePath));
}
} finally {
executorService.shutdown();
try {
if (!executorService.awaitTermination(60, TimeUnit.MINUTES)) {
executorService.shutdownNow();
}
} catch (InterruptedException e) {
executorService.shutdownNow();
}
}
}
public static List<String> getFileNames(String directoryPath) {
List<String> fileNames = new ArrayList<>();
Path path = Paths.get(directoryPath);
private void processExcelFile(String filePath) {
System.out.println("线程开始");
try {
List<List<String>> excelData = ExcelReader.readExcel(filePath);
String tableName = getTableNameFromFilePath(filePath);
String prefix = getPrefixFromFilePath(filePath);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
for (Path entry : stream) {
if (Files.isRegularFile(entry)) {
fileNames.add(entry.getFileName().toString());
for (List<String> columnData : excelData) {
String style = columnData.get(0);
for (int i = 1; i < columnData.size(); i++) {
String fileName = columnData.get(i);
if (StringUtils.isBlank(fileName)) {
continue;
}
if ("X".equals(style)) {
attributeRetrievalMapper.updateStyleByFileName("X", prefix + fileName, tableName);
System.out.println(fileName);
} else {
attributeRetrievalMapper.updateStyleByFileName(style, prefix + fileName, tableName);
System.out.println(fileName);
}
}
}
} catch (IOException e) {
System.err.println("Error reading directory: " + e.getMessage());
e.printStackTrace();
}
return fileNames;
}
private String getTableNameFromFilePath(String filePath) {
if (filePath.contains("Blouse")) {
return "female_top";
} else if (filePath.contains("Dress")) {
return "female_dress";
} else if (filePath.contains("Outerwear")) {
return "female_outwear";
} else if (filePath.contains("Skirt")) {
return "female_skirt";
} else if (filePath.contains("Trousers")) {
return "female_pants";
}
return "";
}
private String getPrefixFromFilePath(String filePath) {
if (filePath.contains("Blouse")) {
return "blouse/";
} else if (filePath.contains("Dress")) {
return "dress/";
} else if (filePath.contains("Outerwear")) {
return "outwear/";
} else if (filePath.contains("Skirt")) {
return "skirt/";
} else if (filePath.contains("Trousers")) {
return "trousers/";
}
return "";
}
// public static List<String> getFileNames(String directoryPath) {
// List<String> fileNames = new ArrayList<>();
// Path path = Paths.get(directoryPath);
//
// try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
// for (Path entry : stream) {
// if (Files.isRegularFile(entry)) {
// fileNames.add(entry.getFileName().toString());
// }
// }
// } catch (IOException e) {
// System.err.println("Error reading directory: " + e.getMessage());
// }
//
// return fileNames;
// }
}

View File

@@ -0,0 +1,33 @@
package com.ai.da.common.utils;
import lombok.Data;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Data
public class ExcelReader {
public static List<List<String>> readExcel(String filePath) throws IOException {
List<List<String>> data = new ArrayList<>();
try (FileInputStream fis = new FileInputStream(filePath);
Workbook workbook = new XSSFWorkbook(fis)) {
Sheet sheet = workbook.getSheetAt(0);
int numberOfColumns = sheet.getRow(0).getLastCellNum();
for (int i = 0; i < numberOfColumns; i++) {
List<String> columnData = new ArrayList<>();
for (Row row : sheet) {
columnData.add(row.getCell(i).getStringCellValue());
}
data.add(columnData);
}
}
return data;
}
}

View File

@@ -405,6 +405,22 @@ public class MinioUtil {
}
}
public String getPresignedUrl(String path, int expiry, boolean resetCache) {
if (resetCache || LocalCacheUtils.getPresignedUrlCache(path) == null) {
if (!path.contains("/")) {
throw new BusinessException("The path is error!");
}
int index = path.indexOf("/");
String bucketName = path.substring(0, index);
String fileName = path.substring(index + 1);
String presignedUrl = getPresignedUrl(bucketName, fileName, expiry);
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
return presignedUrl;
} else {
return LocalCacheUtils.getPresignedUrlCache(path);
}
}
/**
* 将桶名、文件名从url中分离出来
*

View File

@@ -32,6 +32,12 @@ public class PortfolioController {
return Response.success(portfolioService.publish(canvas, data));
}
@ApiOperation(value = "删除作品集")
@GetMapping("/delete")
public Response<Boolean> delete(@RequestParam("id") Long id) {
return Response.success(portfolioService.delete(id));
}
@CrossOrigin
@ApiOperation(value = "作品集page")
@PostMapping("/page")

View File

@@ -209,7 +209,7 @@ public class SavedCollectionController {
@ApiOperation("productImageLikeList")
@PostMapping("/productImageLikeList")
public Response<List<ToProductImageResult>> productImageLikeList(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
public Response<List<ToProductImageResultVO>> productImageLikeList(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
return Response.success(userLikeGroupService.productImageLikeList(toProductImageDTO));
}

View File

@@ -17,13 +17,15 @@ import java.util.List;
public interface AttributeRetrievalMapper {
List<AttributeRetrieval> getSystemSketchPool(@Param("attributeRetrievalAttrDict") AttributeRetrieval attributeRetrievalAttrDict, @Param("tableName") String tableName, @Param("poolNum") int poolNum);
List<AttributeRetrieval> getSystemSketchPool(@Param("attributeRetrievalAttrDict") AttributeRetrieval attributeRetrievalAttrDict, @Param("tableName") String tableName, @Param("poolNum") int poolNum, @Param("style") String style);
AttributeRetrieval getSystemRandom(String tableName);
AttributeRetrieval getSystemRandom(String tableName, String style);
List<AttributeRetrieval> getSystemSketchPoolBySameCategory(AttributeRetrieval attributeRetrievalAttrDict, String tableName);
List<AttributeRetrieval> getSystemSketchPoolBySameCategory(AttributeRetrieval attributeRetrievalAttrDict, String tableName, String style);
Long getIdByFileName(String fileName, String tableName);
void updateStyleById(Long idByFileName, String style, String tableName);
void updateStyleByFileName(String style, String fileName, String tableName);
}

View File

@@ -33,4 +33,6 @@ public class SysFileVO implements Serializable {
*/
private String md5;
private String level3Type;
}

View File

@@ -0,0 +1,9 @@
package com.ai.da.model.vo;
import com.ai.da.mapper.primary.entity.ToProductImageResult;
import lombok.Data;
@Data
public class ToProductImageResultVO extends ToProductImageResult {
private String sourceUrl;
}

View File

@@ -45,4 +45,6 @@ public class ValidateElementVO {
//透传sysFileVo用(attribute_retrieval 接口限定sysFile范围)
List<SysFileVO> sysFileVo;
private String modelSex;
private String style;
}

View File

@@ -602,7 +602,7 @@ public class PythonService {
} else if (systemScale.compareTo(BigDecimal.ONE) != 0) {
BigDecimal collectNoPinSize = BigDecimal.valueOf(collectionNoPinSize);
poolNum = collectNoPinSize.divide(systemScale, 0, RoundingMode.DOWN).intValue();
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum);
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum, elementVO.getStyle());
collectionElements.addAll(list);
int randomNum = RandomsUtil.randomSysFile(collectionElements.size());
if (randomNum < collectionNoPinSize) {
@@ -612,7 +612,7 @@ public class PythonService {
}
}
}
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum);
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum, elementVO.getStyle());
int randomNum = RandomsUtil.randomSysFile(list.size());
return coverSketchToDesignPythonItem(null, list.get(randomNum), elementVO);
}
@@ -622,7 +622,7 @@ public class PythonService {
}
private DesignPythonItem processAttributeRecognitionBySameCategory(JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory) {
List<CollectionElement> list = getSystemSketchPoolBySameCategory(attributeRecognition, styleCategory, elementVO.getModelSex());
List<CollectionElement> list = getSystemSketchPoolBySameCategory(attributeRecognition, styleCategory, elementVO.getModelSex(), elementVO.getStyle());
int randomNum = RandomsUtil.randomSysFile(list.size());
return coverSketchToDesignPythonItem(null, list.get(randomNum), elementVO);
}
@@ -630,7 +630,7 @@ public class PythonService {
@Resource
private AttributeRetrievalMapper attributeRetrievalMapper;
private List<CollectionElement> getSystemSketchPool(JSONObject attributeRecognition, String styleCategory, String modelSex, int poolNum) {
private List<CollectionElement> getSystemSketchPool(JSONObject attributeRecognition, String styleCategory, String modelSex, int poolNum, String style) {
/**
* female trousers->female_pants
* female blouse->female_top
@@ -644,19 +644,19 @@ public class PythonService {
AttributeRetrieval attributeRetrievalAttrDict = toAttrDict(attrDictJSON);
String tableName;
tableName = getTableName(modelSex, styleCategory);
List<AttributeRetrieval> attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum);
List<AttributeRetrieval> attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style);
if (CollectionUtil.isEmpty(attributeRetrievalList) || attributeRetrievalList.size() < poolNum) {
attributeRetrievalAttrDict.setDesign(null);
attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum);
attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style);
}
if (CollectionUtil.isEmpty(attributeRetrievalList) || attributeRetrievalList.size() < poolNum) {
attributeRetrievalAttrDict.setSilhouette(null);
attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum);
attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style);
}
return toColoectionElementList(attributeRetrievalList, styleCategory, modelSex);
}
private List<CollectionElement> getSystemSketchPoolBySameCategory(JSONObject attributeRecognition, String styleCategory, String modelSex) {
private List<CollectionElement> getSystemSketchPoolBySameCategory(JSONObject attributeRecognition, String styleCategory, String modelSex, String style) {
/**
* female trousers->female_pants
* female blouse->female_top
@@ -712,7 +712,7 @@ public class PythonService {
}
}
List<AttributeRetrieval> attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName);
List<AttributeRetrieval> attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName, style);
if (CollectionUtil.isEmpty(attributeRetrievalList)) {
System.out.println(attributeRetrievalAttrDict);
System.out.println(tableName);
@@ -935,7 +935,7 @@ public class PythonService {
Integer randomNum = RandomsUtil.randomSysFile(dressings.size());
String category = dressings.get(randomNum).getStyleCategory();
String tableName = getTableName(validateElementVO.getModelSex(), category);
AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName);
AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName, validateElementVO.getStyle());
CollectionElement collectionElement = toCollectionElement(attributeRetrieval, category, validateElementVO.getModelSex());
return coverSketchToDesignPythonItem(null, collectionElement, validateElementVO);
}
@@ -975,7 +975,7 @@ public class PythonService {
Integer randomNum = RandomsUtil.randomSysFile(dressings.size());
String category = dressings.get(randomNum).getStyleCategory();
String tableName = getTableName(validateElementVO.getModelSex(), category);
AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName);
AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName, validateElementVO.getStyle());
CollectionElement collectionElement = toCollectionElement(attributeRetrieval, category, validateElementVO.getModelSex());
return coverSketchToDesignPythonItem(null, collectionElement, validateElementVO);
}
@@ -2801,23 +2801,23 @@ public class PythonService {
private List<DesignPythonItem> coverToModelsDotPythonItem(ModelsDotDTO modelsDotDTO) {
List<DesignPythonItem> response = Lists.newArrayList();
if (modelsDotDTO.getTemplateUrl().contains("female")) {
DesignPythonItem dress = new DesignPythonItem();
dress.setType(SysFileLevel2TypeEnum.DRESS.getRealName());
dress.setColor("none");
dress.setIcon("none");
// DesignPythonItem dress = new DesignPythonItem();
// dress.setType(SysFileLevel2TypeEnum.DRESS.getRealName());
// dress.setColor("none");
// dress.setIcon("none");
DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint();
designPythonItemPrint.setIfSingle(false);
designPythonItemPrint.setPrint_path_list(new ArrayList<>());
dress.setPrint(designPythonItemPrint);
dress.setPath("aida-sys-image/images/female/blouse/blouse_p5_817.jpg");
response.add(dress);
// dress.setPrint(designPythonItemPrint);
// dress.setPath("aida-sys-image/images/female/blouse/blouse_p5_817.jpg");
// response.add(dress);
DesignPythonItem skirt = new DesignPythonItem();
skirt.setType(SysFileLevel2TypeEnum.TROUSERS.getRealName());
skirt.setType(SysFileLevel2TypeEnum.DRESS.getRealName());
skirt.setColor("none");
skirt.setIcon("none");
skirt.setPrint(designPythonItemPrint);
skirt.setPath("aida-sys-image/images/female/trousers/trousers_974.jpg");
skirt.setPath("aida-sys-image/images/female/dress/0628002038.jpeg");
response.add(skirt);
} else {
DesignPythonItem top = new DesignPythonItem();
@@ -2839,7 +2839,7 @@ public class PythonService {
designPythonItemPrint1.setIfSingle(false);
designPythonItemPrint1.setPrint_path_list(new ArrayList<>());
bottom.setPrint(designPythonItemPrint1);
bottom.setPath("aida-sys-image/images/male/bottoms/mens_test_10007.png");
bottom.setPath("aida-sys-image/images/male/bottoms/mens_test_12.png");
response.add(bottom);
}
@@ -3348,4 +3348,46 @@ public class PythonService {
//生成失败
throw new BusinessException("toProductImage.interface.exception");
}
public Boolean relight(String url, String taskId, String prompt) {
// todo 限流校验
// AccessLimitUtils.validate("design",5);
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
.build();
MediaType mediaType = MediaType.parse("application/json");
//关闭FastJson的引用检测 防止出现$ref 现象
Map<String, String> map = new HashMap<>();
map.put("tasks_id", taskId);
map.put("image_url", url);
map.put("prompt", prompt);
log.info("relightImage请求python 参数:####{}", map);
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
RequestBody body = RequestBody.create(mediaType, param);
Request request = new Request.Builder()
// .url(accessPythonIp + ":" + accessPythonPort + "/api/generate_product_image")
// .url(accessPythonIp + ":9996/api/generate_product_image")
.url(accessPythonIp + ":9994/api/generate_relight_image")
.method("POST", body)
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
.addHeader("Content-Type", "application/json")
.build();
Response response;
String responseBody;
try {
response = client.newCall(request).execute();
} catch (IOException ioException) {
log.error("PythonService##relightImage异常###{}", ExceptionUtil.getThrowableList(ioException));
throw new BusinessException("relightImage.interface.exception");
}
if (response.isSuccessful()) {
return Boolean.TRUE;
}
log.error("PythonService##relightImage异常response###{}", response);
//生成失败
throw new BusinessException("relightImage.interface.exception");
}
}

View File

@@ -37,4 +37,6 @@ public interface PortfolioService extends IService<Portfolio> {
Long viewsGet(Long id);
Boolean commentDelete(CommentDTO commentDTO);
Boolean delete(Long id);
}

View File

@@ -53,7 +53,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
CanvasElementUpload canvasElementUpload(MultipartFile file);
List<ToProductImageResult> productImageLikeList(ToProductImageDTO toProductImageDTO);
List<ToProductImageResultVO> productImageLikeList(ToProductImageDTO toProductImageDTO);
Boolean productImageUnLike(ProductImageLikeDTO productImageLikeDTO);

View File

@@ -13,6 +13,7 @@ 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.Sex;
import com.ai.da.model.enums.StyleEnum;
import com.ai.da.model.vo.*;
import com.ai.da.python.PythonService;
import com.ai.da.python.vo.DesignPythonItem;
@@ -578,6 +579,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
elementVO.setStyle(byId.getLevel3Type());
}
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
}

View File

@@ -997,7 +997,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
.collect(Collectors.toList());
response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> {
d.setId(o.getId());
d.setPath(minioUtil.getPresignedUrl(o.getPath(), 24 * 60));
d.setPath(minioUtil.getPresignedUrl(o.getPath(), 24 * 60, true));
d.setMinIOPath(o.getPath());
d.setLevel1Type(converTypeToLevel1(o.getType()));
d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class));

View File

@@ -281,6 +281,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
path = "models/" + libraryUploadDTO.getModelSex().toLowerCase();
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
String newFilePath = processMannequins(filePath);
// String newFilePath = filePath;
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());

View File

@@ -431,11 +431,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
Canvas canvas = canvasMapper.selectById(vo.getCanvasId());
vo.setCanvasUrl(minioUtil.getPresignedUrl(canvas.getUrl(), 24 * 60));
vo.setLikeNum(redisUtil.getLikeCount(vo.getId()));
boolean postLikedByUser = redisUtil.isPostLikedByUser(portfolioDTO.getId(), userHolder.getId());
if (postLikedByUser) {
vo.setIsLike(1);
}else {
if (userHolder == null) {
vo.setIsLike(0);
}else {
boolean postLikedByUser = redisUtil.isPostLikedByUser(portfolioDTO.getId(), userHolder.getId());
if (postLikedByUser) {
vo.setIsLike(1);
}else {
vo.setIsLike(0);
}
}
redisUtil.increaseViewCount(portfolioDTO.getId());
vo.setViewNums(redisUtil.getViewCount(portfolioDTO.getId()));
@@ -643,8 +647,11 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
Long id = commentDTO.getId();
Portfolio portfolio = portfolioMapper.selectById(commentDTO.getPortfolioId());
Comment comment = commentMapper.selectById(id);
if (!Objects.equals(comment.getAccountId(), commentDTO.getAccountId()) || !Objects.equals(portfolio.getAccountId(), commentDTO.getAccountId())) {
throw new BusinessException("You do not have the permission to delete this comment");
AuthPrincipalVo userHolder = UserContext.getUserHolder();
if (!Objects.equals(portfolio.getAccountId(), userHolder.getId())) {
if (!Objects.equals(comment.getAccountId(), userHolder.getId())) {
throw new BusinessException("You do not have the permission to delete this comment");
}
}
// 删除主评论
commentMapper.deleteById(id);
@@ -659,6 +666,17 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
return Boolean.TRUE;
}
@Override
public Boolean delete(Long id) {
AuthPrincipalVo userHolder = UserContext.getUserHolder();
Portfolio portfolio = portfolioMapper.selectById(id);
if (!Objects.equals(portfolio.getAccountId(), userHolder.getId())) {
throw new BusinessException("You do not have the permission to delete portfolio.");
}
portfolioMapper.deleteById(id);
return Boolean.TRUE;
}
private List<CommentVO> getChildCommentVOList(Long id) {
QueryWrapper<Comment> qw = new QueryWrapper<>();
qw.lambda().eq(Comment::getParentLevel1Id, id);

View File

@@ -346,8 +346,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductElement.getUrl(), 24 * 60));
}else {
UserLike userLike = userLikeMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPresignedUrl(userLike.getUrl(), 24 * 60));
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
}
}
} else if (Objects.isNull(magicToolResultVO)) {
@@ -401,7 +401,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
@Override
public List<ToProductImageResult> productImageLikeList(ToProductImageDTO toProductImageDTO) {
public List<ToProductImageResultVO> productImageLikeList(ToProductImageDTO toProductImageDTO) {
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
qw.lambda().eq(ToProductImageResult::getIsLike, 1);
qw.lambda().eq(ToProductImageResult::getUserLikeGroupId, toProductImageDTO.getUserLikeGroupId());
@@ -409,7 +409,20 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
for (ToProductImageResult toProductImageResult : toProductImageResults) {
toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
}
return toProductImageResults;
List<ToProductImageResultVO> toProductImageResultVOS = CopyUtil.copyList(toProductImageResults, ToProductImageResultVO.class);
for (ToProductImageResultVO toProductImageResultVO : toProductImageResultVOS) {
if (toProductImageResultVO.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductElement.getUrl(), 24 * 60));
}else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
}else {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductImageResult1.getUrl(), 24 * 60));
}
}
return toProductImageResultVOS;
}
@Override
@@ -443,15 +456,15 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
String prompt = toProductImageDTO.getPrompt();
String s = pythonService.promptTranslate(prompt);
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
if (toProductImageVO.getElementType().equals("ProductImage")) {
if (toProductImageVO.getElementType().equals("ToProductImage")) {
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
i ++;
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageVO.getElementId());
// 走模型
pythonService.toProductImage(toProductImageResult1.getUrl(), taskId, s);
pythonService.relight(toProductImageResult1.getUrl(), taskId, s);
ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(toProductImageResult1.getId());
toProductImageResult.setElementType("ProductImage");
toProductImageResult.setElementType("ToProductImage");
toProductImageResult.setCreateTime(LocalDateTime.now());
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
// toProductImageResult.setUrl(productImageUrl);
@@ -465,7 +478,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
// 走模型
pythonService.toProductImage(toProductElement.getUrl(), taskId, s);
pythonService.relight(toProductElement.getUrl(), taskId, s);
ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(toProductElement.getId());
toProductImageResult.setElementType("ProductElement");
@@ -488,7 +501,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
List<MagicToolResultVO> results = new ArrayList<>();
Set<String> collect = new HashSet<>();
taskIdList.forEach(taskId -> {
String key = toProductImageResultKey + ":" + taskId;
String key = relightResultKey + ":" + taskId;
MagicToolResultVO magicToolResultVO = new Gson().fromJson(redisUtil.getFromString(key), MagicToolResultVO.class);
if (!Objects.isNull(magicToolResultVO) && !StringUtil.isNullOrEmpty(magicToolResultVO.getUrl())) {
String url = magicToolResultVO.getUrl();