BUGFIX:design中的排序问题 倒序问题 再次修改
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.enums.CreditsEventsEnum;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.CollectionSort;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.GenerateService;
|
||||
@@ -101,7 +102,7 @@ public class GenerateController {
|
||||
|
||||
@ApiOperation(value = "请求进行姿势变换")
|
||||
@PostMapping("/poseTransform")
|
||||
public Response<String> poseTransform(@Valid @RequestBody PoseTransformDTO poseTransformDTO) {
|
||||
public Response<ToProductImageResultVO> poseTransform(@Valid @RequestBody PoseTransformDTO poseTransformDTO) {
|
||||
return Response.success(generateService.poseTransform(poseTransformDTO));
|
||||
}
|
||||
|
||||
@@ -115,7 +116,12 @@ public class GenerateController {
|
||||
@ApiOperation("喜欢或取消喜欢姿势变换生成的图片")
|
||||
@PostMapping("/likeOrDislike")
|
||||
public Response<Object> likeOrDislike(@ApiParam("id") @RequestParam Long transformedId, @ApiParam("like || dislike") @RequestParam String likeOrDislike, @RequestParam("projectId") Long projectId, @RequestParam(value = "collectionSortParentId", required = false) Long collectionSortParentId) {
|
||||
return Response.success(generateService.disOrLikePose(transformedId, likeOrDislike, projectId, collectionSortParentId));
|
||||
Object obj = generateService.disOrLikePose(transformedId, likeOrDislike, projectId, collectionSortParentId);
|
||||
if (obj instanceof CollectionSort){
|
||||
return Response.success(((CollectionSort) obj).getId());
|
||||
}else {
|
||||
return Response.success(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改模特比例")
|
||||
|
||||
@@ -187,7 +187,7 @@ public class SavedCollectionController {
|
||||
|
||||
@ApiOperation(value = "toProduct")
|
||||
@PostMapping("/toProduct")
|
||||
public Response<List<ToProductImageResult>> toProduct(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
|
||||
public Response<List<ToProductImageResultVO>> toProduct(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
|
||||
return Response.success(userLikeGroupService.toProduct(toProductImageDTO));
|
||||
}
|
||||
|
||||
@@ -206,7 +206,8 @@ public class SavedCollectionController {
|
||||
@ApiOperation(value = "productImageLike")
|
||||
@PostMapping("/productImageLike")
|
||||
public Response<Long> productImageLike(@Valid @RequestBody ProductImageLikeDTO productImageLikeDTO) {
|
||||
return Response.success(userLikeGroupService.productImageLike(productImageLikeDTO));
|
||||
CollectionSort collectionSort = userLikeGroupService.productImageLike(productImageLikeDTO);
|
||||
return Response.success(Objects.nonNull(collectionSort) ? collectionSort.getId() : null);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "collectionLikeUpdate")
|
||||
@@ -242,7 +243,7 @@ public class SavedCollectionController {
|
||||
|
||||
@ApiOperation(value = "relight")
|
||||
@PostMapping("/relight")
|
||||
public Response<List<ToProductImageResult>> relight(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
|
||||
public Response<List<ToProductImageResultVO>> relight(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
|
||||
return Response.success(userLikeGroupService.relight(toProductImageDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,25 +3,14 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.CollectionSort;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
public interface CollectionSortMapper extends CommonMapper<CollectionSort> {
|
||||
@Update("UPDATE collection_sort SET sort = sort + 1 " +
|
||||
"WHERE project_id = #{projectId} " +
|
||||
"AND relation_type = #{relationType} " +
|
||||
"AND sort < #{originalSort}")
|
||||
void increaseDesignSortBelow(
|
||||
@Param("projectId") Long projectId,
|
||||
@Param("relationType") String relationType,
|
||||
@Param("originalSort") int originalSort
|
||||
);
|
||||
|
||||
@Update("UPDATE collection_sort SET sort = sort + 1 " +
|
||||
"WHERE parent_id = #{parentId} " +
|
||||
"AND relation_type != 'Design' " +
|
||||
"AND sort < #{originalSort}")
|
||||
void increaseGenerateSortBelow(
|
||||
"AND sort > #{originalSort}")
|
||||
void increaseGenerateSortAbove(
|
||||
@Param("parentId") Long parentId,
|
||||
@Param("relationType") String relationType,
|
||||
@Param("originalSort") int originalSort
|
||||
|
||||
@@ -18,6 +18,7 @@ public class CollectionSort extends BaseEntity implements Serializable {
|
||||
|
||||
private Long userLikeGroupId;
|
||||
private Long userLikeId;
|
||||
// 页面排序采用倒序,最新的元素序号最大
|
||||
private Integer sort;
|
||||
private Long projectId;
|
||||
private Long relationId;
|
||||
|
||||
@@ -23,4 +23,6 @@ public class PoseTransformDTO {
|
||||
private String modelName;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private Long userLikeSortId;
|
||||
}
|
||||
|
||||
@@ -8,5 +8,7 @@ import lombok.Data;
|
||||
public class ToProductImageVO extends ToProductImageResult {
|
||||
@ApiModelProperty("collection sort中的parentId, 在这里是父级的userLikeSortId")
|
||||
private Long parentId;
|
||||
@ApiModelProperty("collection sort中的id, 在这里是用的子集里元素的userLikeSortId")
|
||||
private Long userLikeSortId;
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface GenerateService extends IService<Generate> {
|
||||
|
||||
GenerateResultVO modifySketch(GenerateModifyDTO generateModifyDTO);
|
||||
|
||||
String poseTransform(PoseTransformDTO poseTransformDTO);
|
||||
ToProductImageResultVO poseTransform(PoseTransformDTO poseTransformDTO);
|
||||
|
||||
void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl);
|
||||
|
||||
|
||||
@@ -46,15 +46,15 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
|
||||
Boolean exportSave(MultipartFile file, Long projectId, String module);
|
||||
|
||||
List<ToProductImageResult> toProduct(ToProductImageDTO toProductImageDTO);
|
||||
List<ToProductImageResultVO> toProduct(ToProductImageDTO toProductImageDTO);
|
||||
|
||||
void reArrangeSort(Long projectId, Long generateResultId, String relationType, Long parentId);
|
||||
Integer rearrangeChildSort(Long childId, String relationType, Long parentId, Long userLikeSortId);
|
||||
|
||||
void toProduct(String taskId);
|
||||
|
||||
ToProductElementVO toProductImageElementUpload(MultipartFile file, Long projectId);
|
||||
|
||||
Long productImageLike(ProductImageLikeDTO productImageLikeDTO);
|
||||
CollectionSort productImageLike(ProductImageLikeDTO productImageLikeDTO);
|
||||
|
||||
List<MagicToolResultVO> getToProductImageResultList(List<String> taskIdList);
|
||||
|
||||
@@ -68,7 +68,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
|
||||
void relight(String taskId);
|
||||
|
||||
List<ToProductImageResult> relight(ToProductImageDTO toProductImageDTO);
|
||||
List<ToProductImageResultVO> relight(ToProductImageDTO toProductImageDTO);
|
||||
|
||||
List<MagicToolResultVO> getRelightResult(List<String> taskIdList);
|
||||
|
||||
|
||||
@@ -1127,7 +1127,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
@Resource
|
||||
private UserLikeGroupService userLikeGroupService;
|
||||
|
||||
public String poseTransform(PoseTransformDTO poseTransformDTO){
|
||||
public ToProductImageResultVO poseTransform(PoseTransformDTO poseTransformDTO){
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Long projectId = poseTransformDTO.getProjectId();
|
||||
String productImage = poseTransformDTO.getProductImage();
|
||||
@@ -1164,26 +1164,34 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
poseTransformation.setCreateTime(LocalDateTime.now());
|
||||
poseTransformationMapper.insert(poseTransformation);
|
||||
// 满足条件下添加到like
|
||||
addPoseTransferLike(poseTransformDTO, poseTransformation.getId());
|
||||
userLikeGroupService.reArrangeSort(projectId, poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(), poseTransformDTO.getParentId());
|
||||
Integer sort = addPoseTransferLike(poseTransformDTO, poseTransformation.getId());
|
||||
Integer reSort = userLikeGroupService.rearrangeChildSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(),
|
||||
poseTransformDTO.getParentId(), poseTransformDTO.getUserLikeSortId());
|
||||
|
||||
if (flag){
|
||||
// 6、添加预扣除积分到redis
|
||||
creditsService.addRecordToCreditsDeduction(accountId, taskId, creditsEventsEnum);
|
||||
// 6.1 添加积分扣除记录到db
|
||||
creditsService.preInsert(accountId, creditsEventsEnum.getName(), taskId, Boolean.TRUE, null);
|
||||
return taskId;
|
||||
ToProductImageResultVO toProductImageResultVO = new ToProductImageResultVO();
|
||||
toProductImageResultVO.setTaskId(taskId);
|
||||
toProductImageResultVO.setSort(Objects.isNull(reSort) ? sort : reSort);
|
||||
return toProductImageResultVO;
|
||||
}
|
||||
throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode());
|
||||
}
|
||||
|
||||
private void addPoseTransferLike(PoseTransformDTO poseTransformDTO, Long poseTransformationId){
|
||||
private Integer addPoseTransferLike(PoseTransformDTO poseTransformDTO, Long poseTransformationId){
|
||||
if (Objects.nonNull(poseTransformDTO.getParentId())
|
||||
&& !poseTransformDTO.getParentId().equals(0L)){
|
||||
disOrLikePose(poseTransformationId, "like",
|
||||
Object object = disOrLikePose(poseTransformationId, "like",
|
||||
poseTransformDTO.getProjectId(), poseTransformDTO.getParentId());
|
||||
if (object instanceof CollectionSort){
|
||||
return ((CollectionSort) object).getSort();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private PoseTransformationMapper poseTransformationMapper;
|
||||
@@ -1324,13 +1332,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
public Object disOrLikePose(Long transformedId, String likeOrDislike, Long projectId, Long collectionSortParentId){
|
||||
PoseTransformation poseTransformation = poseTransformationMapper.selectById(transformedId);
|
||||
Long collectionSortId = null;
|
||||
CollectionSort collectionSort = null;
|
||||
if (Objects.nonNull(poseTransformation)){
|
||||
if (likeOrDislike.equals("like")){
|
||||
poseTransformation.setIsLiked((byte)1);
|
||||
if (null != collectionSortParentId) {
|
||||
CollectionSort collectionSort = designService.addCollectionSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(), projectId, collectionSortParentId);
|
||||
collectionSortId = collectionSort.getId();
|
||||
collectionSort = designService.addCollectionSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(), projectId, collectionSortParentId);
|
||||
}
|
||||
}else if (likeOrDislike.equals("dislike")){
|
||||
poseTransformation.setIsLiked((byte)0);
|
||||
@@ -1343,8 +1350,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
if (null != collectionSortId) {
|
||||
return collectionSortId;
|
||||
if (Objects.nonNull(collectionSort)) {
|
||||
return collectionSort;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
private PoseTransformationMapper poseTransformationMapper;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<ToProductImageResult> toProduct(ToProductImageDTO toProductImageDTO) {
|
||||
public List<ToProductImageResultVO> toProduct(ToProductImageDTO toProductImageDTO) {
|
||||
// 判断用户当前积分是否够本次生成消耗
|
||||
boolean fluxTask = !StringUtil.isNullOrEmpty(toProductImageDTO.getModelName())
|
||||
&& toProductImageDTO.getModelName().equals("flux");
|
||||
@@ -412,7 +412,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
toProductImageRecordMapper.insert(toProductImageRecord);
|
||||
|
||||
List<ToProductImageResult> result = new ArrayList<>();
|
||||
List<ToProductImageResultVO> result = new ArrayList<>();
|
||||
boolean childFlag = !StringUtil.isNullOrEmpty(toProductImageDTO.getAgeGroup())
|
||||
&& toProductImageDTO.getAgeGroup().equals("Child");
|
||||
int i = 0;
|
||||
@@ -456,7 +456,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}else {
|
||||
sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
|
||||
}
|
||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||
ToProductImageResultVO toProductImageResult = new ToProductImageResultVO();
|
||||
if (fluxTask){
|
||||
if (childFlag){
|
||||
sb.append(", Children's face");
|
||||
@@ -488,11 +488,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue());
|
||||
toProductImageResultMapper.insert(toProductImageResult);
|
||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
result.add(toProductImageResult);
|
||||
// 满足条件情况下默认添加到like
|
||||
addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||
Integer sort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||
// 重新排序
|
||||
reArrangeSort(projectId, toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), toProductImageVO.getParentId());
|
||||
Integer reSort = rearrangeChildSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(),
|
||||
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
||||
// 将生成结果的排序返回
|
||||
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
|
||||
result.add(toProductImageResult);
|
||||
}else {
|
||||
if (StringUtils.isEmpty(prompt)) {
|
||||
sb.append(",high quality clothing details,8K realistic,HDR");
|
||||
@@ -502,7 +505,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
|
||||
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||
ToProductImageResultVO toProductImageResult = new ToProductImageResultVO();
|
||||
|
||||
if (fluxTask){
|
||||
taskId = generateService.flux(creditsEventsEnum, sb.toString(), toProductElement.getUrl(), childFlag);
|
||||
@@ -532,11 +535,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue());
|
||||
toProductImageResultMapper.insert(toProductImageResult);
|
||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
result.add(toProductImageResult);
|
||||
// 满足条件情况下默认添加到like
|
||||
addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||
Integer sort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||
// 重新排序
|
||||
reArrangeSort(projectId, toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), toProductImageVO.getParentId());
|
||||
Integer reSort = rearrangeChildSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(),
|
||||
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
||||
// 将生成结果的排序返回
|
||||
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
|
||||
result.add(toProductImageResult);
|
||||
}
|
||||
i ++;
|
||||
sb = new StringBuilder("The best quality, masterpiece, real image.");
|
||||
@@ -548,57 +554,39 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addToProductLike(Long parentId, Long toProductImageResultId, Long projectId){
|
||||
if (Objects.nonNull(parentId)
|
||||
&& !parentId.equals(0L)){
|
||||
productImageLike(new ProductImageLikeDTO(Collections.singletonList(toProductImageResultId),
|
||||
private Integer addToProductLike(Long parentId, Long toProductImageResultId, Long projectId){
|
||||
if (Objects.nonNull(parentId) && !parentId.equals(0L)){
|
||||
CollectionSort collectionSort = productImageLike(new ProductImageLikeDTO(Collections.singletonList(toProductImageResultId),
|
||||
projectId, parentId));
|
||||
return Objects.nonNull(collectionSort) ? collectionSort.getSort() : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 只有当使用子集中的元素进行生成时,才需要重新排序
|
||||
* @param childId 生成元素的id
|
||||
* @param parentId 父级id
|
||||
* @param relationType 生成功能
|
||||
* @param userLikeSortId 子集排序表中的id
|
||||
*/
|
||||
@Transactional
|
||||
public void reArrangeSort(Long projectId, Long generateResultId, String relationType, Long parentId) {
|
||||
// 1. 处理子集排序
|
||||
rearrangeChildSort(generateResultId, parentId, relationType);
|
||||
// 2. 处理父级排序
|
||||
rearrangeParentSort(projectId, parentId);
|
||||
}
|
||||
|
||||
private void rearrangeChildSort(Long childId, Long parentId, String relationType) {
|
||||
if (Objects.isNull(childId)) {
|
||||
return;
|
||||
public Integer rearrangeChildSort(Long childId, String relationType, Long parentId, Long userLikeSortId) {
|
||||
if (Objects.isNull(userLikeSortId)) {
|
||||
return null;
|
||||
}
|
||||
CollectionSort child = collectionSortMapper.selectOne(new QueryWrapper<CollectionSort>().eq("relation_id", childId));
|
||||
if (child == null || !child.getRelationType().equals(relationType)) {
|
||||
return;
|
||||
if (!child.getRelationType().equals(relationType)) {
|
||||
return null;
|
||||
}
|
||||
if (child.getSort() == 1) {
|
||||
return; // 已经是第一位,无需处理
|
||||
}
|
||||
// 更新其他子集的排序
|
||||
if (!"Design".equals(relationType)) {
|
||||
collectionSortMapper.increaseGenerateSortBelow(parentId, relationType, child.getSort());
|
||||
}
|
||||
// 更新当前子集为第一位
|
||||
child.setSort(1);
|
||||
CollectionSort collectionSort = collectionSortMapper.selectById(userLikeSortId);
|
||||
child.setSort(collectionSort.getSort());
|
||||
// 原来排序的大于等于userLikeSortId的排序的,都要+1
|
||||
collectionSortMapper.increaseGenerateSortAbove(parentId, relationType, collectionSort.getSort() - 1);
|
||||
// 当前的生成结果则填入userLikeSortId的排序位置
|
||||
child.setUpdateTime(LocalDateTime.now());
|
||||
collectionSortMapper.updateById(child);
|
||||
}
|
||||
|
||||
private void rearrangeParentSort(Long projectId, Long parentId) {
|
||||
CollectionSort parent = collectionSortMapper.selectById(parentId);
|
||||
if (parent == null || !"Design".equals(parent.getRelationType())) {
|
||||
return;
|
||||
}
|
||||
if (parent.getSort() == 1) {
|
||||
return; // 已经是第一位,无需处理
|
||||
}
|
||||
// 更新其他父级的排序
|
||||
collectionSortMapper.increaseDesignSortBelow(projectId, "Design", parent.getSort());
|
||||
// 更新当前父级为第一位
|
||||
parent.setSort(1);
|
||||
parent.setUpdateTime(LocalDateTime.now());
|
||||
collectionSortMapper.updateById(parent);
|
||||
return collectionSort.getSort();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -690,7 +678,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long productImageLike(ProductImageLikeDTO productImageLikeDTO) {
|
||||
public CollectionSort productImageLike(ProductImageLikeDTO productImageLikeDTO) {
|
||||
List<Long> toProductImageResultId = productImageLikeDTO.getToProductImageResultId();
|
||||
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
|
||||
qw.lambda().in(ToProductImageResult::getId, toProductImageResultId);
|
||||
@@ -698,19 +686,17 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
toProductImageResult.setIsLike(1);
|
||||
toProductImageResultMapper.update(toProductImageResult, qw);
|
||||
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultId.get(0));
|
||||
Long collectionSortId = null;
|
||||
CollectionSort collectionSort = null;
|
||||
if (toProductImageResult1.getResultType().equals("Relight")) {
|
||||
if (null != productImageLikeDTO.getCollectionSortParentId()) {
|
||||
CollectionSort collectionSort = designService.addCollectionSort(toProductImageResult1.getId(), CollectionType.RELIGHT.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getCollectionSortParentId());
|
||||
collectionSortId = collectionSort.getId();
|
||||
collectionSort = designService.addCollectionSort(toProductImageResult1.getId(), CollectionType.RELIGHT.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getCollectionSortParentId());
|
||||
}
|
||||
}else {
|
||||
if (null != productImageLikeDTO.getCollectionSortParentId()) {
|
||||
CollectionSort collectionSort = designService.addCollectionSort(toProductImageResult1.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getCollectionSortParentId());
|
||||
collectionSortId = collectionSort.getId();
|
||||
collectionSort = designService.addCollectionSort(toProductImageResult1.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getCollectionSortParentId());
|
||||
}
|
||||
}
|
||||
return collectionSortId;
|
||||
return collectionSort;
|
||||
}
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@@ -1046,7 +1032,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<ToProductImageResult> relight(ToProductImageDTO toProductImageDTO) {
|
||||
public List<ToProductImageResultVO> relight(ToProductImageDTO toProductImageDTO) {
|
||||
// 判断用户当前积分是否够本次生成消耗
|
||||
boolean fluxTask = !StringUtil.isNullOrEmpty(toProductImageDTO.getModelName())
|
||||
&& toProductImageDTO.getModelName().equals("flux");
|
||||
@@ -1089,7 +1075,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
toProductImageRecordMapper.insert(toProductImageRecord);
|
||||
|
||||
List<ToProductImageResult> result = new ArrayList<>();
|
||||
List<ToProductImageResultVO> result = new ArrayList<>();
|
||||
|
||||
int i = 0;
|
||||
|
||||
@@ -1108,7 +1094,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
}
|
||||
|
||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||
ToProductImageResultVO toProductImageResult = new ToProductImageResultVO();
|
||||
if (fluxTask){
|
||||
taskId = generateService.flux(creditsEventsEnum, s, toProductImageResult1.getUrl(), false);
|
||||
toProductImageResult.setModelName("flux");
|
||||
@@ -1135,14 +1121,18 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
toProductImageResult.setResultType(CollectionType.RELIGHT.getValue());
|
||||
toProductImageResultMapper.insert(toProductImageResult);
|
||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
result.add(toProductImageResult);
|
||||
|
||||
// 满足条件情况下默认添加到like
|
||||
addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||
Integer sort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||
// 重新排序
|
||||
reArrangeSort(projectId, toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), toProductImageVO.getParentId());
|
||||
Integer reSort = rearrangeChildSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(),
|
||||
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
||||
// 将生成结果的排序返回
|
||||
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
|
||||
result.add(toProductImageResult);
|
||||
}else {
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||
ToProductImageResultVO toProductImageResult = new ToProductImageResultVO();
|
||||
if (fluxTask){
|
||||
taskId = generateService.flux(CreditsEventsEnum.RELIGHT_FLUX, s, toProductElement.getUrl(), false);
|
||||
toProductImageResult.setModelName("flux");
|
||||
@@ -1169,11 +1159,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
toProductImageResult.setResultType(CollectionType.RELIGHT.getValue());
|
||||
toProductImageResultMapper.insert(toProductImageResult);
|
||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
result.add(toProductImageResult);
|
||||
// 满足条件情况下默认添加到like
|
||||
addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||
Integer sort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
||||
// 重新排序
|
||||
reArrangeSort(projectId, toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), toProductImageVO.getParentId());
|
||||
Integer reSort = rearrangeChildSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(),
|
||||
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
|
||||
// 将生成结果的排序返回
|
||||
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
|
||||
result.add(toProductImageResult);
|
||||
}
|
||||
// 添加需要扣除的积分到预扣除区
|
||||
creditsService.addRecordToCreditsDeduction(userHolder.getId(), taskId, creditsEventsEnum);
|
||||
|
||||
Reference in New Issue
Block a user