从library删除generate的图片时需要取消该图片的like标签
This commit is contained in:
@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,4 +19,8 @@ public class LibraryDeleteDTO {
|
||||
private List<Long> libraryIds;
|
||||
|
||||
private Integer deleteModelConfirm;
|
||||
|
||||
@NotEmpty(message = "timeZone.cannot.be.empty")
|
||||
@ApiModelProperty("时区")
|
||||
private String timeZone;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.entity.Design;
|
||||
import com.ai.da.mapper.entity.Generate;
|
||||
import com.ai.da.mapper.entity.GenerateDetail;
|
||||
import com.ai.da.model.dto.GenerateLikeDTO;
|
||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||
import com.ai.da.model.vo.GenerateCaptionVO;
|
||||
@@ -9,6 +9,8 @@ import com.ai.da.model.vo.GenerateCollectionVO;
|
||||
import com.ai.da.model.vo.GenerateLikeVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GenerateService extends IService<Generate> {
|
||||
|
||||
GenerateCaptionVO generateCaption(Long sketchElementId);
|
||||
@@ -18,4 +20,8 @@ public interface GenerateService extends IService<Generate> {
|
||||
GenerateLikeVO generateLike(GenerateLikeDTO generateLikeDTO);
|
||||
|
||||
Boolean generateDislike(Long generateDetailId, String timeZone);
|
||||
|
||||
void updateLikeStatusBatch(List<Long> generateDetailIdList, Byte hasLike, Long libraryId, String timeZone);
|
||||
|
||||
List<GenerateDetail> selectBatchByLibraryId(List<Long> libraryId);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.google.common.collect.Lists;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
@@ -399,6 +400,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
DesignItem designItem = selectById(designSingleIncludeLayersDTO.getDesignItemId());
|
||||
@@ -486,6 +488,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException {
|
||||
ComposeLayersVO designItemLayer = positionAndScaleVO.getLayers();
|
||||
// 1、校验designItem是是否存在
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.minio.errors.MinioException;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
@@ -65,6 +66,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public GenerateCollectionVO generateThroughImageText(GenerateThroughImageTextDTO generateThroughImageTextDTO) {
|
||||
// 1、获取用户信息
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
@@ -161,6 +163,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public GenerateLikeVO generateLike(GenerateLikeDTO generateLikeDTO) {
|
||||
// 1、判断参数是否正确
|
||||
// 1.1 必须参数是否非空
|
||||
@@ -207,6 +210,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean generateDislike(Long generateDetailId, String timeZone) {
|
||||
// 1、确定generateDetail中是否有这条记录
|
||||
GenerateDetail generateDetail = generateDetailMapper.selectById(generateDetailId);
|
||||
@@ -259,4 +263,23 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
generateDetail.setUpdateDate(DateUtil.getByTimeZone(timeZone));
|
||||
generateDetailMapper.update(generateDetail, queryWrapper);
|
||||
}
|
||||
|
||||
public void updateLikeStatusBatch(List<Long> generateDetailIdList, Byte hasLike, Long libraryId, String timeZone){
|
||||
QueryWrapper<GenerateDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", generateDetailIdList);
|
||||
|
||||
GenerateDetail generateDetail = new GenerateDetail();
|
||||
generateDetail.setIsLike(hasLike);
|
||||
generateDetail.setLibraryId(libraryId);
|
||||
generateDetail.setUpdateDate(DateUtil.getByTimeZone(timeZone));
|
||||
|
||||
generateDetailMapper.update(generateDetail, queryWrapper);
|
||||
}
|
||||
|
||||
public List<GenerateDetail> selectBatchByLibraryId(List<Long> libraryId){
|
||||
QueryWrapper<GenerateDetail> qw = new QueryWrapper<>();
|
||||
qw.in("library_id",libraryId);
|
||||
|
||||
return generateDetailMapper.selectList(qw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.ai.da.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.system.UserInfo;
|
||||
import com.ai.da.common.config.FileProperties;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
@@ -14,7 +13,6 @@ import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.LibraryMapper;
|
||||
import com.ai.da.mapper.SysFileMapper;
|
||||
import com.ai.da.mapper.WorkspaceMapper;
|
||||
import com.ai.da.mapper.entity.*;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.enums.MannequinType;
|
||||
@@ -22,10 +20,7 @@ import com.ai.da.model.enums.ModelType;
|
||||
import com.ai.da.model.enums.Sex;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.vo.ModelPathObject;
|
||||
import com.ai.da.service.ClassificationService;
|
||||
import com.ai.da.service.LibraryModelPointService;
|
||||
import com.ai.da.service.LibraryService;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -39,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -73,6 +69,8 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
@Resource
|
||||
private ClassificationService classificationService;
|
||||
@Resource
|
||||
private GenerateService generateService;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
|
||||
@Value("${minio.bucketName.users}")
|
||||
@@ -339,6 +337,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchDeleteLibrary(LibraryDeleteDTO deleteDTO) {
|
||||
List<Library> librarys = libraryMapper.selectBatchIds(deleteDTO.getLibraryIds());
|
||||
if (CollectionUtils.isEmpty(librarys)) {
|
||||
@@ -360,6 +359,19 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
||||
checkModel(Sex.MALE.getValue(), maleModelIds, deleteDTO.getDeleteModelConfirm());
|
||||
}
|
||||
libraryMapper.deleteBatchIds(deleteDTO.getLibraryIds());
|
||||
|
||||
// 1、确定该libraryId是否被generateDetail引用
|
||||
List<GenerateDetail> generateDetails = generateService.selectBatchByLibraryId(deleteDTO.getLibraryIds());
|
||||
|
||||
// 2、有,则更新generateDetail表的is_like字段和library_id字段
|
||||
if (!generateDetails.isEmpty()){
|
||||
generateService.updateLikeStatusBatch(
|
||||
generateDetails.stream().map(GenerateDetail::getId).collect(Collectors.toList()),
|
||||
(byte)0,
|
||||
0L,
|
||||
deleteDTO.getTimeZone()
|
||||
);
|
||||
}
|
||||
// for (Library library : librarys) {
|
||||
// if (library.getUrl().startsWith(sysImage)) {
|
||||
// continue;
|
||||
|
||||
Reference in New Issue
Block a user