TASK: library分类;

This commit is contained in:
shahaibo
2023-11-08 15:22:46 +08:00
parent 269b6fa5fb
commit 94809e149d
7 changed files with 78 additions and 35 deletions

View File

@@ -22,4 +22,7 @@ public class QueryLibraryPageDTO extends PageQueryBaseVo {
@ApiModelProperty("pictureName")
private String pictureName;
@ApiModelProperty("分类ID")
private Long classificationId;
}

View File

@@ -25,4 +25,6 @@ public class QueryLibraryPageServiceDTO extends PageQueryBaseVo {
@ApiModelProperty("pictureName")
private String pictureName;
private Long classificationId;
}

View File

@@ -29,4 +29,6 @@ public interface ClassificationService {
List<ClassificationVO> getClassificationVOList(List<Classification> classificationList);
Boolean relationLibrary(ClassificationDTO classificationDTO);
List<Long> getLibraryIdListByClassificationId(Long classificationId);
}

View File

@@ -24,6 +24,7 @@ import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
@@ -157,6 +158,36 @@ public class ClassificationServiceImpl implements ClassificationService {
return Boolean.TRUE;
}
@Override
public List<Long> getLibraryIdListByClassificationId(Long classificationId) {
List<Long> treeClassificationIdList = getTreeClassificationIdListByClassificationId(classificationId);
QueryWrapper<ClassificationRelLibrary> qw = new QueryWrapper<>();
qw.lambda().in(ClassificationRelLibrary::getClassificationId, treeClassificationIdList);
List<ClassificationRelLibrary> classificationRelLibraryList = classificationRelLibraryMapper.selectList(qw);
Set<Long> collect = classificationRelLibraryList.stream()
.map(ClassificationRelLibrary::getLibraryId)
.collect(Collectors.toSet());
List<Long> libraryIdList = new ArrayList<>(collect);
return libraryIdList;
}
private List<Long> getTreeClassificationIdListByClassificationId(Long classificationId) {
List<Long> classificationIdList = new ArrayList<>();
classificationIdList.add(classificationId);
QueryWrapper<Classification> qw = new QueryWrapper<>();
qw.lambda().eq(Classification::getParentId, classificationId);
List<Classification> childList = classificationMapper.selectList(qw);
if (CollectionUtil.isNotEmpty(childList)) {
for (Classification child : childList) {
List<Long> childTree = getTreeClassificationIdListByClassificationId(child.getId());
if (CollectionUtil.isNotEmpty(childTree)) {
classificationIdList.addAll(childTree);
}
}
}
return classificationIdList;
}
private List<ClassificationVO> recursionClassificationVO(ClassificationVO classificationVO) {
QueryWrapper<Classification> qw = new QueryWrapper<>();
qw.lambda().eq(Classification::getParentId, classificationVO.getId());

View File

@@ -199,13 +199,13 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//调取python 接口
String generateUrl = pythonService.generatePrint(printPath);
if (StringUtils.isEmpty(generateUrl)) {
throw new BusinessException("generate.print.exception");
throw new BusinessException("generate.interface.exception");
}
//用户信息
AuthPrincipalVo userInfo = UserContext.getUserHolder();
CollectionElement element = resolveData(generateUrl, generatePrintDTO.getTimeZone(), userInfo);
if (!this.save(element)) {
throw new BusinessException("generate.print.failed");
throw new BusinessException("save.collectionElement.failed");
}
CollectionGeneratePrintVO collectionGeneratePrint = CopyUtil.copyObject(element, CollectionGeneratePrintVO.class);
collectionGeneratePrint.setDesignType(DesignTypeEnum.COLLECTION.getRealName());

View File

@@ -21,6 +21,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;
@@ -67,6 +68,8 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
@Resource
private WorkspaceService workspaceService;
@Resource
private ClassificationService classificationService;
@Resource
private MinioUtil minioUtil;
@Value("${minio.bucketName.users}")
@@ -129,6 +132,11 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
if (!StringUtils.isEmpty(query.getPictureName())) {
queryWrapper.like("name", query.getPictureName());
}
// 新增分类过滤
if (null != query.getClassificationId()) {
List<Long> libraryIdList = classificationService.getLibraryIdListByClassificationId(query.getClassificationId());
queryWrapper.lambda().in(Library::getId, libraryIdList);
}
queryWrapper.orderByDesc("id");
IPage<Library> page = getBaseMapper().selectPage(
new Page<>(query.getPage(), query.getSize()), queryWrapper);
@@ -309,7 +317,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
public void batchDeleteLibrary(LibraryDeleteDTO deleteDTO) {
List<Library> librarys = libraryMapper.selectBatchIds(deleteDTO.getLibraryIds());
if (CollectionUtils.isEmpty(librarys)) {
throw new BusinessException("librarys.not.found");
throw new BusinessException("libraryList.not.found");
}
List<Long> femaleModelIds = librarys.stream()
.filter(o -> o.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName()) && o.getLevel2Type().equals(Sex.FEMALE.getValue()))
@@ -412,7 +420,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
library.setUrl(sysFile.getUrl());
return library;
} else {
throw new BusinessException("system.error");
throw new BusinessException("unknown.modelType");
}
}
@@ -428,7 +436,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
public void updateLibraryName(LibraryUpdateDTO libraryUpdateDTO) {
List<Library> librarys = getByIds(libraryUpdateDTO.getLibraryIds());
if (CollectionUtils.isEmpty(librarys)) {
throw new BusinessException("librarys.not.found");
throw new BusinessException("libraryList.not.found");
}
QueryWrapper<Library> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", libraryUpdateDTO.getLibraryIds());