TASK: ToProduct Relight Pose新增删除接口

This commit is contained in:
2025-07-16 19:14:41 +08:00
parent 301f58bc62
commit 5b3a52152a
8 changed files with 112 additions and 10 deletions

View File

@@ -146,6 +146,17 @@ public class GenerateController {
return Response.success(generateService.getAllPose());
}
@ApiOperation(value = "删除pose transfer的结果")
@GetMapping("/deleteResult")
public Response<String> deleteToProductRelightResult(@RequestParam("projectId") Long projectId, @RequestParam("id") Long id){
try{
generateService.deleteGeneratedPose(projectId, id);
return Response.success();
}catch (Exception e){
return Response.fail(e.getMessage());
}
}
/*@ApiOperation(value = "万象 t2i 创建异步任务")
@GetMapping("/createAsyncTask")
public Response<String> createAsyncTask(@RequestParam("prompt") String prompt){

View File

@@ -23,11 +23,13 @@ import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.Pattern;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@@ -36,6 +38,7 @@ import java.util.stream.Collectors;
@Api(tags = "History模块(saved Collection)")
@Slf4j
@RestController
@Validated
@RequestMapping("/api/history")
public class SavedCollectionController {
@Resource
@@ -260,6 +263,19 @@ public class SavedCollectionController {
return Response.success(magicToolResultVOList);
}
@ApiOperation(value = "删除toProduct Relight的结果")
@GetMapping("/deleteResult")
public Response<String> deleteResult(@RequestParam("id") Long id,
@RequestParam("projectId") Long projectId,
@RequestParam("type") @Pattern(regexp = "^(Relight|ToProductImage)$", message = "Please choose type from 'Relight|ToProductImage'") String type){
try{
userLikeGroupService.deleteToProductRelightResult(id, projectId, type);
return Response.success();
}catch (Exception e){
return Response.fail(e.getMessage());
}
}
@ApiOperation(value = "likeHistoryRelSketch")
@PostMapping("/likeHistoryRelSketch")
public Response<String> likeHistoryRelSketch() {

View File

@@ -1,5 +1,6 @@
package com.ai.da.mapper.primary.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -29,6 +30,7 @@ public class PoseTransformation extends BaseEntity {
private byte isLiked;
@TableField("is_deleted")
private byte isDeleted;
private String modelName;

View File

@@ -1,6 +1,7 @@
package com.ai.da.mapper.primary.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -62,4 +63,8 @@ public class ToProductImageResult implements Serializable {
private String modelName;
private String taskStatus;
@ApiModelProperty(value = "是否删除1:是 0:否")
@TableField
private byte isDeleted = 0;
}

View File

@@ -75,6 +75,8 @@ public interface GenerateService extends IService<Generate> {
void processPoseTransformResultBatch(String taskId, String progress);
void deleteGeneratedPose(Long projectId, Long id);
String createAsyncTask(GenerateThroughImageTextDTO generateThroughImageTextDTO);
GenerateResultVO getAsyncTaskResult(String taskId);

View File

@@ -74,6 +74,8 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
List<MagicToolResultVO> getRelightResult(List<String> taskIdList);
void deleteToProductRelightResult(Long id, Long projectId, String type);
String likeHistoryRelSketch();
String download();

View File

@@ -29,6 +29,7 @@ import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -1725,16 +1726,15 @@ 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<>());
}
}
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;
}
@@ -1829,6 +1829,38 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
}
}
@Resource
private CollectionSortMapper collectionSortMapper;
@Transactional(rollbackFor = Exception.class)
public void deleteGeneratedPose(Long projectId, Long id){
Long accountId = UserContext.getUserHolder().getId();
// 1、删除generate中的结果
UpdateWrapper<PoseTransformation> wrapper = new UpdateWrapper<>();
wrapper.eq("id", id)
.set("is_deleted", 1) // 手动设置
.set("update_time", LocalDateTime.now());
int update = poseTransformationMapper.update(null, wrapper);
log.info("删除PoseTransfer 结果, id为{}, 影响行数={}", id, update);
if (update != 0) {
// 2、如果有排序删除排序,排序后是否需要重置排序计数器以及后续排序数字
// 先校验type的值是不是ToProductImage、Relight、PoseTransfer
if (id == null || projectId == null) {
throw new IllegalArgumentException("参数不能为null");
}
Project project = projectService.getById(projectId);
if (!project.getAccountId().equals(accountId)){
throw new IllegalArgumentException("项目id不属于当前账号请仅对自己的账号数据进行处理");
}
int deletedRows = collectionSortMapper.delete(new QueryWrapper<CollectionSort>()
.eq("project_id", projectId)
.eq("relation_id", id).eq("relation_type", "PoseTransfer"));
log.info("deleteGeneratedPose 删除记录id={}, type={}, 影响行数={}", id, "PoseTransfer", deletedRows);
}
}
/**
* 万象专业版

View File

@@ -1332,6 +1332,38 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
}
@Transactional(rollbackFor = Exception.class)
public void deleteToProductRelightResult(Long id, Long projectId, String type){
Long accountId = UserContext.getUserHolder().getId();
// 1、删除toProductResult中的结果
Project project = projectService.getById(projectId);
if (!project.getAccountId().equals(accountId)){
throw new IllegalArgumentException("项目id不属于当前账号请仅对自己的账号数据进行处理");
}
UpdateWrapper<ToProductImageResult> wrapper = new UpdateWrapper<>();
wrapper.eq("id", id)
.eq("project_id", projectId)
.set("is_deleted", 1); // 手动设置
int update = toProductImageResultMapper.update(null, wrapper);
log.info("删除{} 结果, id为{}, 影响行数={}", type, id, update);
if (update != 0) {
// 2、如果有排序删除排序,排序后是否需要重置排序计数器以及后续排序数字
// 先校验type的值是不是ToProductImage、Relight、PoseTransfer
if (id == null || type == null || projectId == null) {
throw new IllegalArgumentException("参数不能为null");
}
int deletedRows = collectionSortMapper.delete(new QueryWrapper<CollectionSort>()
.eq("project_id", projectId)
.eq("relation_id", id).eq("relation_type", type));
log.info("deleteToProductRelightResult 删除记录id={}, type={}, 影响行数={}", id, type, deletedRows);
}
}
@Override
public String likeHistoryRelSketch() {
QueryWrapper<UserLikeGroup> qw = new QueryWrapper<>();