Merge remote-tracking branch 'origin/dev-ltx' into dev/3.1_release_merge
This commit is contained in:
@@ -2,8 +2,11 @@ package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeGroup;
|
||||
import com.ai.da.mapper.primary.entity.CollectionElementRelModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
@@ -16,4 +19,57 @@ public interface UserLikeGroupMapper extends CommonMapper<UserLikeGroup> {
|
||||
Long insertUserLikeGroup(UserLikeGroup userLikeGroup);
|
||||
|
||||
List<UserLikeGroup> getMoreThan50UserLikeAccount();
|
||||
|
||||
/**
|
||||
* 批量查询模块内容,使用JOIN优化避免N+1查询
|
||||
* @param userLikeGroupId 用户喜欢组ID
|
||||
* @param projectId 项目ID
|
||||
* @param relationTypes 关联类型列表
|
||||
* @return 模块内容映射列表
|
||||
*/
|
||||
List<Map<String, Object>> getModuleContentBatch(@Param("userLikeGroupId") Long userLikeGroupId,
|
||||
@Param("projectId") Long projectId,
|
||||
@Param("relationTypes") List<String> relationTypes);
|
||||
|
||||
/**
|
||||
* 批量查询ToProductImageResult及相关数据
|
||||
* @param projectId 项目ID
|
||||
* @param resultType 结果类型
|
||||
* @return ToProductImageResult及相关数据列表
|
||||
*/
|
||||
List<Map<String, Object>> getToProductImageResultBatch(@Param("projectId") Long projectId,
|
||||
@Param("resultType") String resultType);
|
||||
|
||||
/**
|
||||
* 批量查询UserLike及相关设计数据
|
||||
* @param relationIds 关联ID列表
|
||||
* @return UserLike及相关数据列表
|
||||
*/
|
||||
List<Map<String, Object>> getUserLikeBatch(@Param("relationIds") List<Long> relationIds);
|
||||
|
||||
/**
|
||||
* 批量查询ToProductElement数据
|
||||
* @param elementIds 元素ID列表
|
||||
* @return ToProductElement数据列表
|
||||
*/
|
||||
List<Map<String, Object>> getToProductElementBatch(@Param("elementIds") List<Long> elementIds);
|
||||
|
||||
/**
|
||||
* 批量查询TDesignPythonOutfit数据
|
||||
* @param outfitIds 服装ID列表
|
||||
* @return TDesignPythonOutfit数据列表
|
||||
*/
|
||||
List<Map<String, Object>> getDesignPythonOutfitBatch(@Param("outfitIds") List<Long> outfitIds);
|
||||
|
||||
/**
|
||||
* 批量查询ToProductImageRecord数据
|
||||
* @param recordIds ToProductImageRecord ID列表
|
||||
* @return 查询结果
|
||||
*/
|
||||
List<Map<String, Object>> getToProductImageRecordBatch(@Param("recordIds") List<Long> recordIds);
|
||||
|
||||
/**
|
||||
* 批量查询CollectionElementRelModel
|
||||
*/
|
||||
List<CollectionElementRelModel> getCollectionElementRelModelBatch(@Param("collectionElementIds") List<Long> collectionElementIds);
|
||||
}
|
||||
|
||||
@@ -1950,138 +1950,134 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
moduleChooseVO.setSketchBoard(list);
|
||||
}else if (module.equals(Module.design.name())) {
|
||||
DesignModuleChooseVO vo = new DesignModuleChooseVO();
|
||||
QueryWrapper<CollectionSort> userLikeSortQueryWrapper = new QueryWrapper<>();
|
||||
userLikeSortQueryWrapper.lambda().eq(CollectionSort::getProjectId, projectDTO.getId());
|
||||
userLikeSortQueryWrapper.lambda().isNull(CollectionSort::getParentId);
|
||||
userLikeSortQueryWrapper.lambda().eq(CollectionSort::getRelationType, CollectionType.DESIGN.getValue());
|
||||
userLikeSortQueryWrapper.lambda().orderByAsc(CollectionSort::getSort);
|
||||
List<CollectionSort> userLikeSortList = collectionSortMapper.selectList(userLikeSortQueryWrapper);
|
||||
|
||||
if (CollectionUtils.isEmpty(userLikeSortList)) {
|
||||
// 使用批量查询获取design模块的所有数据
|
||||
List<String> relationTypes = Arrays.asList(
|
||||
CollectionType.DESIGN.getValue(),
|
||||
CollectionType.TO_PRODUCT_IMAGE.getValue(),
|
||||
CollectionType.RELIGHT.getValue(),
|
||||
CollectionType.POSE_TRANSFORM.getValue()
|
||||
);
|
||||
|
||||
List<Map<String, Object>> moduleContentList = userLikeGroupMapper.getModuleContentBatch(
|
||||
null, projectDTO.getId(), relationTypes);
|
||||
|
||||
if (CollectionUtils.isEmpty(moduleContentList)) {
|
||||
moduleChooseVO.setDesign(vo);
|
||||
}else {
|
||||
} else {
|
||||
// 按parent_id分组处理数据
|
||||
Map<Long, List<Map<String, Object>>> groupedByParent = moduleContentList.stream()
|
||||
.collect(Collectors.groupingBy(item -> {
|
||||
Object parentId = item.get("parent_id");
|
||||
return parentId == null ? 0L : ((Number) parentId).longValue();
|
||||
}));
|
||||
|
||||
List<AllCollectionVO> list = new ArrayList<>();
|
||||
|
||||
for (CollectionSort collectionSort : userLikeSortList) {
|
||||
UserLike userLike = userLikeMapper.selectById(collectionSort.getRelationId());
|
||||
UserLikeVO o = CopyUtil.copyObject(userLike, UserLikeVO.class);
|
||||
TDesignPythonOutfit tDesignPythonOutfit1 = designPythonOutfitMapper.selectById(o.getDesignOutfitId());
|
||||
o.setUrl(tDesignPythonOutfit1.getDesignUrl());
|
||||
if (o.getUrl().contains("/")) {
|
||||
int index = o.getUrl().lastIndexOf("/");
|
||||
o.setPictureName(o.getUrl().substring(index + 1));
|
||||
}
|
||||
o.setDesignOutfitUrl(getMinioUrl(o.getUrl()));
|
||||
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, o.getDesignItemId());
|
||||
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(tDesignPythonOutfits)) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = tDesignPythonOutfits.get(0);
|
||||
o.setDesignOutfitId(tDesignPythonOutfit.getId());
|
||||
// 处理顶级design项目(parent_id为null的)
|
||||
List<Map<String, Object>> topLevelDesigns = groupedByParent.get(0L);
|
||||
if (topLevelDesigns != null) {
|
||||
for (Map<String, Object> designData : topLevelDesigns) {
|
||||
if (!CollectionType.DESIGN.getValue().equals(designData.get("relation_type"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
o.setSort(collectionSort.getSort());
|
||||
o.setUserLikeSortId(collectionSort.getId());
|
||||
o.setRelationType(collectionSort.getRelationType());
|
||||
UserLikeVO o = new UserLikeVO();
|
||||
o.setId(((Number) designData.get("user_like_id")).longValue());
|
||||
o.setDesignItemId(((Number) designData.get("design_item_id")).longValue());
|
||||
o.setDesignOutfitId(((Number) designData.get("design_outfit_id")).longValue());
|
||||
|
||||
String designUrl = (String) designData.get("design_url");
|
||||
o.setUrl(designUrl);
|
||||
if (designUrl != null && designUrl.contains("/")) {
|
||||
int index = designUrl.lastIndexOf("/");
|
||||
o.setPictureName(designUrl.substring(index + 1));
|
||||
}
|
||||
o.setDesignOutfitUrl(getMinioUrl(designUrl));
|
||||
|
||||
o.setSort(((Number) designData.get("sort")).intValue());
|
||||
o.setUserLikeSortId(((Number) designData.get("sort_id")).longValue());
|
||||
o.setRelationType((String) designData.get("relation_type"));
|
||||
o.setCollectionType(CollectionType.DESIGN.getValue());
|
||||
o.setResultType(CollectionType.DESIGN.getValue());
|
||||
QueryWrapper<CollectionSort> childCollectionQw = new QueryWrapper<>();
|
||||
childCollectionQw.lambda().eq(CollectionSort::getParentId, collectionSort.getId());
|
||||
childCollectionQw.lambda().orderByAsc(CollectionSort::getSort);
|
||||
List<CollectionSort> childSortList = collectionSortMapper.selectList(childCollectionQw);
|
||||
|
||||
// 处理子项目
|
||||
List<AllCollectionVO> childList = new ArrayList<>();
|
||||
for (CollectionSort userLikeSort : childSortList) {
|
||||
if (userLikeSort.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue())) {
|
||||
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(userLikeSort.getRelationId());
|
||||
if (isGenerateTaskFailed(toProductImageResult.getStatus(), toProductImageResult.getCreateTime())){
|
||||
Long parentSortId = ((Number) designData.get("sort_id")).longValue();
|
||||
List<Map<String, Object>> childItems = groupedByParent.get(parentSortId);
|
||||
|
||||
if (childItems != null) {
|
||||
for (Map<String, Object> childData : childItems) {
|
||||
String relationType = (String) childData.get("relation_type");
|
||||
|
||||
if (CollectionType.TO_PRODUCT_IMAGE.getValue().equals(relationType) ||
|
||||
CollectionType.RELIGHT.getValue().equals(relationType)) {
|
||||
|
||||
// 检查任务状态
|
||||
String status = (String) childData.get("result_status");
|
||||
Object createTimeObj = childData.get("result_create_time");
|
||||
LocalDateTime createTime = createTimeObj != null ?
|
||||
((java.sql.Timestamp) createTimeObj).toLocalDateTime() : null;
|
||||
if (isGenerateTaskFailed(status, createTime)) {
|
||||
continue;
|
||||
}
|
||||
toProductImageResult.setUrl(getMinioUrl(toProductImageResult.getUrl()));
|
||||
ToProductImageResultVO toProductImageResultVO = CopyUtil.copyObject(toProductImageResult, ToProductImageResultVO.class);
|
||||
|
||||
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
|
||||
if (Objects.isNull(toProductImageRecord)) {
|
||||
log.warn("toProductRecord不存在,projectId:{}, toProductImageResultId:{}", projectDTO.getId(), toProductImageResult.getId());
|
||||
continue;
|
||||
}
|
||||
toProductImageResultVO.setPrompt(toProductImageRecord.getPrompt());
|
||||
ToProductImageResultVO toProductImageResultVO = new ToProductImageResultVO();
|
||||
toProductImageResultVO.setId(((Number) childData.get("to_product_result_id")).longValue());
|
||||
toProductImageResultVO.setUrl(getMinioUrl((String) childData.get("result_url")));
|
||||
toProductImageResultVO.setElementType((String) childData.get("element_type"));
|
||||
toProductImageResultVO.setElementId(((Number) childData.get("element_id")).longValue());
|
||||
toProductImageResultVO.setPrompt((String) childData.get("prompt"));
|
||||
|
||||
if (toProductImageResultVO.getElementType().equals("ProductElement")) {
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl(toProductElement.getUrl()));
|
||||
}else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl(tDesignPythonOutfit.getDesignUrl()));
|
||||
}else {
|
||||
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl(toProductImageResult1.getUrl()));
|
||||
// 设置sourceUrl
|
||||
String elementType = (String) childData.get("element_type");
|
||||
if ("ProductElement".equals(elementType)) {
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl((String) childData.get("element_url")));
|
||||
} else if ("DesignOutfit".equals(elementType)) {
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl((String) childData.get("design_url")));
|
||||
}
|
||||
toProductImageResultVO.setCollectionType(CollectionType.TO_PRODUCT_IMAGE.getValue());
|
||||
toProductImageResultVO.setSort(userLikeSort.getSort());
|
||||
toProductImageResultVO.setUserLikeSortId(userLikeSort.getId());
|
||||
toProductImageResultVO.setRelationType(userLikeSort.getRelationType());
|
||||
toProductImageResultVO.setParentId(userLikeSort.getParentId());
|
||||
|
||||
toProductImageResultVO.setSort(((Number) childData.get("sort")).intValue());
|
||||
toProductImageResultVO.setUserLikeSortId(((Number) childData.get("sort_id")).longValue());
|
||||
toProductImageResultVO.setRelationType(relationType);
|
||||
toProductImageResultVO.setParentId(((Number) childData.get("parent_id")).longValue());
|
||||
childList.add(toProductImageResultVO);
|
||||
} else if (userLikeSort.getRelationType().equals(CollectionType.RELIGHT.getValue())) {
|
||||
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(userLikeSort.getRelationId());
|
||||
if (isGenerateTaskFailed(toProductImageResult.getStatus(), toProductImageResult.getCreateTime())){
|
||||
continue;
|
||||
}
|
||||
toProductImageResult.setUrl(getMinioUrl(toProductImageResult.getUrl()));
|
||||
ToProductImageResultVO toProductImageResultVO = CopyUtil.copyObject(toProductImageResult, ToProductImageResultVO.class);
|
||||
|
||||
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
|
||||
if (Objects.isNull(toProductImageRecord)) {
|
||||
log.warn("toProductRecord不存在,projectId:{}, toProductImageResultId:{}", projectDTO.getId(), toProductImageResult.getId());
|
||||
} else if (CollectionType.POSE_TRANSFORM.getValue().equals(relationType)) {
|
||||
// 检查任务状态
|
||||
String status = (String) childData.get("pose_status");
|
||||
Object createTimeObj = childData.get("pose_create_time");
|
||||
LocalDateTime createTime = createTimeObj != null ?
|
||||
((java.sql.Timestamp) createTimeObj).toLocalDateTime() : null;
|
||||
if (isGenerateTaskFailed(status, createTime)) {
|
||||
continue;
|
||||
}
|
||||
toProductImageResultVO.setPrompt(toProductImageRecord.getPrompt());
|
||||
|
||||
if (toProductImageResultVO.getElementType().equals("ProductElement")) {
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl(toProductElement.getUrl()));
|
||||
}else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl(tDesignPythonOutfit.getDesignUrl()));
|
||||
}else {
|
||||
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl(toProductImageResult1.getUrl()));
|
||||
}
|
||||
toProductImageResultVO.setCollectionType(CollectionType.RELIGHT.getValue());
|
||||
toProductImageResultVO.setSort(userLikeSort.getSort());
|
||||
toProductImageResultVO.setUserLikeSortId(userLikeSort.getId());
|
||||
toProductImageResultVO.setRelationType(userLikeSort.getRelationType());
|
||||
toProductImageResultVO.setParentId(userLikeSort.getParentId());
|
||||
childList.add(toProductImageResultVO);
|
||||
} else if (userLikeSort.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())) {
|
||||
PoseTransformation item = poseTransformationMapper.selectById(userLikeSort.getRelationId());
|
||||
if (isGenerateTaskFailed(item.getTaskStatus(), item.getCreateTime())){
|
||||
continue;
|
||||
}
|
||||
PoseTransformationVO poseTransformationVO = new PoseTransformationVO();
|
||||
poseTransformationVO.setId(item.getId());
|
||||
poseTransformationVO.setTaskId(item.getUniqueId());
|
||||
poseTransformationVO.setProductImage(getMinioUrl(item.getProductImage()));
|
||||
poseTransformationVO.setGifUrl(getMinioUrl(item.getGifUrl()));
|
||||
poseTransformationVO.setVideoUrl(getMinioUrl(item.getVideoUrl()));
|
||||
poseTransformationVO.setFirstFrameUrl(getMinioUrl(item.getFirstFrameUrl()));
|
||||
poseTransformationVO.setIsLiked(item.getIsLiked());
|
||||
poseTransformationVO.setId(((Number) childData.get("pose_id")).longValue());
|
||||
poseTransformationVO.setTaskId((String) childData.get("pose_unique_id"));
|
||||
poseTransformationVO.setProductImage(getMinioUrl((String) childData.get("pose_product_image")));
|
||||
poseTransformationVO.setGifUrl(getMinioUrl((String) childData.get("pose_gif_url")));
|
||||
poseTransformationVO.setVideoUrl(getMinioUrl((String) childData.get("pose_video_url")));
|
||||
poseTransformationVO.setFirstFrameUrl(getMinioUrl((String) childData.get("pose_first_frame_url")));
|
||||
poseTransformationVO.setIsLiked(((Number) childData.get("pose_is_liked")).byteValue());
|
||||
poseTransformationVO.setCollectionType(CollectionType.POSE_TRANSFORM.getValue());
|
||||
poseTransformationVO.setSort(userLikeSort.getSort());
|
||||
poseTransformationVO.setUserLikeSortId(userLikeSort.getId());
|
||||
poseTransformationVO.setRelationType(userLikeSort.getRelationType());
|
||||
poseTransformationVO.setSort(((Number) childData.get("sort")).intValue());
|
||||
poseTransformationVO.setUserLikeSortId(((Number) childData.get("sort_id")).longValue());
|
||||
poseTransformationVO.setRelationType(relationType);
|
||||
poseTransformationVO.setResultType(CollectionType.POSE_TRANSFORM.getValue());
|
||||
poseTransformationVO.setParentId(userLikeSort.getParentId());
|
||||
poseTransformationVO.setModelName(item.getModelName());
|
||||
poseTransformationVO.setPoseId(item.getPoseId());
|
||||
poseTransformationVO.setStatus(item.getTaskStatus());
|
||||
poseTransformationVO.setParentId(((Number) childData.get("parent_id")).longValue());
|
||||
poseTransformationVO.setModelName((String) childData.get("pose_model_name"));
|
||||
poseTransformationVO.setPoseId(((Number) childData.get("pose_pose_id")).intValue());
|
||||
poseTransformationVO.setStatus(status);
|
||||
childList.add(poseTransformationVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
o.setChildList(childList);
|
||||
|
||||
list.add(o);
|
||||
}
|
||||
}
|
||||
vo.setUserLikeDetails(list);
|
||||
}
|
||||
|
||||
@@ -2126,6 +2122,28 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
// 准备返回对象
|
||||
ToProductOrRelightVO resultVO = new ToProductOrRelightVO();
|
||||
|
||||
// 批量查询ToProductImageRecord数据
|
||||
List<Long> recordIds = allResults.stream()
|
||||
.map(ToProductImageResult::getToProductImageRecordId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<Long, String> recordPromptMap = new HashMap<>();
|
||||
if (!recordIds.isEmpty()) {
|
||||
List<Map<String, Object>> recordData = userLikeGroupMapper.getToProductImageRecordBatch(recordIds);
|
||||
recordPromptMap = recordData.stream()
|
||||
.collect(Collectors.toMap(
|
||||
data -> ((Number) data.get("record_id")).longValue(),
|
||||
data -> {
|
||||
String prompt = (String) data.get("prompt");
|
||||
return prompt != null ? prompt : ""; // 提供默认值
|
||||
},
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
// 处理URL转换和分类
|
||||
List<ToProductImageResultVO> likedList = new ArrayList<>();
|
||||
List<ToProductImageResultVO> normalList = new ArrayList<>();
|
||||
@@ -2137,10 +2155,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
ToProductImageResultVO vo = CopyUtil.copyObject(result, ToProductImageResultVO.class);
|
||||
// 设置sourceUrl
|
||||
setSourceUrl(vo);
|
||||
// 设置prompt
|
||||
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(result.getToProductImageRecordId());
|
||||
if (Objects.nonNull(toProductImageRecord)){
|
||||
vo.setPrompt(toProductImageRecord.getPrompt());
|
||||
// 设置prompt(使用批量查询结果)
|
||||
if (result.getToProductImageRecordId() != null) {
|
||||
String prompt = recordPromptMap.get(result.getToProductImageRecordId());
|
||||
vo.setPrompt(prompt);
|
||||
}
|
||||
vo.setParentId(getUnlikedResultParentId(result, null));
|
||||
// 按isLike分类
|
||||
@@ -2196,12 +2214,22 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
.collect(Collectors.toList());
|
||||
List<CollectionElementVO> list = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(collectionElements)) {
|
||||
// 批量查询CollectionElementRelModel数据
|
||||
List<Long> collectionElementIds = collectionElements.stream()
|
||||
.map(CollectionElement::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<CollectionElementRelModel> relModels = userLikeGroupMapper.getCollectionElementRelModelBatch(collectionElementIds);
|
||||
Map<Long, CollectionElementRelModel> relModelMap = relModels.stream()
|
||||
.collect(Collectors.toMap(CollectionElementRelModel::getCollectionElementId, rel -> rel));
|
||||
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
CollectionElementRelModel relModel = getCollectionElementRelModel(collectionElementVO.getId());
|
||||
CollectionElementRelModel relModel = relModelMap.get(collectionElementVO.getId());
|
||||
collectionElementVO.setUrl(getMinioUrl(collectionElementVO.getUrl()));
|
||||
if (relModel != null) {
|
||||
collectionElementVO.setMannequinRelationId(relModel.getRelationId());
|
||||
collectionElementVO.setMannequinRelationType(relModel.getRelationType());
|
||||
}
|
||||
collectionElementVO.setCollectionId(collectionElement.getId());
|
||||
list.add(collectionElementVO);
|
||||
}
|
||||
|
||||
@@ -35,4 +35,160 @@
|
||||
ORDER BY COUNT(*) DESC
|
||||
;
|
||||
</select>
|
||||
|
||||
<!-- 批量查询模块内容,使用JOIN优化避免N+1查询 -->
|
||||
<select id="getModuleContentBatch" resultType="java.util.Map">
|
||||
SELECT
|
||||
cs.id as sort_id,
|
||||
cs.parent_id,
|
||||
cs.relation_id,
|
||||
cs.relation_type,
|
||||
cs.sort,
|
||||
-- UserLike相关字段
|
||||
ul.id as user_like_id,
|
||||
ul.design_item_id,
|
||||
ul.design_outfit_id,
|
||||
-- TDesignPythonOutfit相关字段
|
||||
tdpo.design_url,
|
||||
-- ToProductImageResult相关字段
|
||||
tpir.id as to_product_result_id,
|
||||
tpir.url as result_url,
|
||||
tpir.element_type,
|
||||
tpir.element_id,
|
||||
tpir.status as result_status,
|
||||
tpir.create_time as result_create_time,
|
||||
tpir.to_product_image_record_id,
|
||||
-- ToProductImageRecord相关字段
|
||||
tpir2.prompt,
|
||||
-- ToProductElement相关字段
|
||||
tpe.url as element_url,
|
||||
-- PoseTransformation相关字段
|
||||
pt.unique_id as pose_task_id,
|
||||
pt.product_image as pose_product_image,
|
||||
pt.gif_url as pose_gif_url,
|
||||
pt.video_url as pose_video_url,
|
||||
pt.first_frame_url as pose_first_frame_url,
|
||||
pt.is_liked as pose_is_liked,
|
||||
pt.model_name as pose_model_name,
|
||||
pt.pose_id,
|
||||
pt.task_status as pose_status,
|
||||
pt.create_time as pose_create_time
|
||||
FROM collection_sort cs
|
||||
LEFT JOIN t_user_like ul ON cs.relation_type = 'Design' AND cs.relation_id = ul.id
|
||||
LEFT JOIN t_design_python_outfit tdpo ON ul.design_outfit_id = tdpo.id
|
||||
LEFT JOIN to_product_image_result tpir ON cs.relation_type IN ('ToProductImage', 'Relight') AND cs.relation_id = tpir.id
|
||||
LEFT JOIN to_product_image_record tpir2 ON tpir.to_product_image_record_id = tpir2.id
|
||||
LEFT JOIN to_product_element tpe ON tpir.element_type = 'ProductElement' AND tpir.element_id = tpe.id
|
||||
LEFT JOIN t_pose_transformation pt ON cs.relation_type = 'PoseTransform' AND cs.relation_id = pt.id
|
||||
WHERE cs.project_id = #{projectId}
|
||||
<if test="relationTypes != null and relationTypes.size() > 0">
|
||||
AND cs.relation_type IN
|
||||
<foreach collection="relationTypes" item="type" open="(" separator="," close=")">
|
||||
#{type}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY cs.parent_id, cs.sort
|
||||
</select>
|
||||
|
||||
<!-- 批量查询ToProductImageResult及相关数据 -->
|
||||
<select id="getToProductImageResultBatch" resultType="java.util.Map">
|
||||
SELECT
|
||||
tpir.id,
|
||||
tpir.url,
|
||||
tpir.element_type,
|
||||
tpir.element_id,
|
||||
tpir.status,
|
||||
tpir.create_time,
|
||||
tpir.is_like,
|
||||
tpir.to_product_image_record_id,
|
||||
tpir.project_id,
|
||||
tpir.result_type,
|
||||
-- ToProductImageRecord相关字段
|
||||
tpir2.prompt,
|
||||
-- ToProductElement相关字段
|
||||
tpe.url as element_url,
|
||||
-- TDesignPythonOutfit相关字段
|
||||
tdpo.design_url as outfit_url
|
||||
FROM to_product_image_result tpir
|
||||
LEFT JOIN to_product_image_record tpir2 ON tpir.to_product_image_record_id = tpir2.id
|
||||
LEFT JOIN to_product_element tpe ON tpir.element_type = 'ProductElement' AND tpir.element_id = tpe.id
|
||||
LEFT JOIN t_design_python_outfit tdpo ON tpir.element_type = 'DesignOutfit' AND tpir.element_id = tdpo.id
|
||||
WHERE tpir.project_id = #{projectId}
|
||||
AND tpir.result_type = #{resultType}
|
||||
</select>
|
||||
|
||||
<!-- 批量查询UserLike及相关设计数据 -->
|
||||
<select id="getUserLikeBatch" resultType="java.util.Map">
|
||||
SELECT
|
||||
ul.id,
|
||||
ul.design_item_id,
|
||||
ul.design_outfit_id,
|
||||
ul.account_id,
|
||||
ul.create_date,
|
||||
ul.update_date,
|
||||
-- TDesignPythonOutfit相关字段
|
||||
tdpo.design_url,
|
||||
tdpo.design_item_id as outfit_design_item_id
|
||||
FROM t_user_like ul
|
||||
LEFT JOIN t_design_python_outfit tdpo ON ul.design_outfit_id = tdpo.id
|
||||
WHERE ul.id IN
|
||||
<foreach collection="relationIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 批量查询ToProductElement数据 -->
|
||||
<select id="getToProductElementBatch" resultType="java.util.Map">
|
||||
SELECT
|
||||
id,
|
||||
url,
|
||||
project_id,
|
||||
create_time,
|
||||
update_time
|
||||
FROM to_product_element
|
||||
WHERE id IN
|
||||
<foreach collection="elementIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 批量查询design模块的python outfit数据 -->
|
||||
<select id="getDesignPythonOutfitBatch" resultType="java.util.Map">
|
||||
SELECT
|
||||
tpo.id as outfit_id,
|
||||
tpo.parent_id,
|
||||
tpo.url as outfit_url,
|
||||
tpo.is_liked as outfit_is_liked,
|
||||
cs.sort,
|
||||
cs.id as sort_id
|
||||
FROM t_design_python_outfit tpo
|
||||
LEFT JOIN collection_sort cs ON cs.relation_id = tpo.id AND cs.relation_type = 'DesignPythonOutfit'
|
||||
WHERE tpo.parent_id IN
|
||||
<foreach collection="outfitIds" item="outfitId" open="(" close=")" separator=",">
|
||||
#{outfitId}
|
||||
</foreach>
|
||||
ORDER BY tpo.parent_id, cs.sort
|
||||
</select>
|
||||
|
||||
<!-- 批量查询ToProductImageRecord数据 -->
|
||||
<select id="getToProductImageRecordBatch" resultType="java.util.Map">
|
||||
SELECT
|
||||
id as record_id,
|
||||
prompt
|
||||
FROM to_product_image_record
|
||||
WHERE id IN
|
||||
<foreach collection="recordIds" item="recordId" open="(" close=")" separator=",">
|
||||
#{recordId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 批量查询CollectionElementRelModel -->
|
||||
<select id="getCollectionElementRelModelBatch" resultType="com.ai.da.mapper.primary.entity.CollectionElementRelModel">
|
||||
SELECT id, collection_element_id, relation_id, relation_type
|
||||
FROM collection_element_rel_model
|
||||
WHERE collection_element_id IN
|
||||
<foreach collection="collectionElementIds" item="collectionElementId" open="(" separator="," close=")">
|
||||
#{collectionElementId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user