TASK:collection sort;
This commit is contained in:
@@ -4,6 +4,7 @@ import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||
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.DesignService;
|
||||
@@ -76,7 +77,7 @@ public class DesignController {
|
||||
|
||||
@ApiOperation(value = "Design sort")
|
||||
@PostMapping("/sort")
|
||||
public Response<Boolean> sort(@Valid @RequestBody UserLikeSortDTO userLikeSortDTO) {
|
||||
public Response<Boolean> sort(@Valid @RequestBody CollectionSortDTO userLikeSortDTO) {
|
||||
return Response.success(designService.sort(userLikeSortDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,12 @@ public class SavedCollectionController {
|
||||
return Response.success(userLikeGroupService.productImageLike(productImageLikeDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "collectionLikeUpdate")
|
||||
@PostMapping("/collectionLikeUpdate")
|
||||
public Response<Boolean> collectionLikeUpdate(@Valid @RequestBody CollectionLikeUpdateDTO collectionLikeUpdateDTO) {
|
||||
return Response.success(userLikeGroupService.collectionLikeUpdate(collectionLikeUpdateDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "productImageUnLike")
|
||||
@PostMapping("/productImageUnLike")
|
||||
public Response<Boolean> productImageUnLike(@Valid @RequestBody ProductImageLikeDTO productImageLikeDTO) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.CollectionSort;
|
||||
|
||||
public interface CollectionSortMapper extends CommonMapper<CollectionSort> {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeSort;
|
||||
|
||||
public interface UserLikeSortMapper extends CommonMapper<UserLikeSort> {
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import java.util.Date;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("collection_sort")
|
||||
public class UserLikeSort implements Serializable {
|
||||
public class CollectionSort implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CollectionLikeUpdateDTO {
|
||||
private Long userLikeSortId;
|
||||
private Long relationId;
|
||||
private String relationType;
|
||||
}
|
||||
13
src/main/java/com/ai/da/model/dto/CollectionSortDTO.java
Normal file
13
src/main/java/com/ai/da/model/dto/CollectionSortDTO.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.CollectionSort;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CollectionSortDTO{
|
||||
private Long userLikeGroupId;
|
||||
|
||||
List<CollectionSort> userLikeSortList;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.UserLikeSort;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserLikeSortDTO{
|
||||
private Long userLikeGroupId;
|
||||
|
||||
List<UserLikeSort> userLikeSortList;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.mapper.primary.entity.CollectionSort;
|
||||
import com.ai.da.mapper.primary.entity.Design;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeSort;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.vo.DesignPythonObjects;
|
||||
@@ -61,7 +61,7 @@ public interface DesignService extends IService<Design> {
|
||||
*/
|
||||
DesignLikeVO like(DesignLikeDTO designLikeDTO);
|
||||
|
||||
UserLikeSort addCollectionSort(Long relationId, String relationType, Long projectId);
|
||||
CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId);
|
||||
|
||||
int getNextSort(Long projectId);
|
||||
|
||||
@@ -75,7 +75,7 @@ public interface DesignService extends IService<Design> {
|
||||
|
||||
void deleteCollectionSort(Long relationId, String relationType, Long projectId);
|
||||
|
||||
UserLikeSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId);
|
||||
CollectionSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId);
|
||||
|
||||
/**
|
||||
* generateHighDesign
|
||||
@@ -121,7 +121,7 @@ public interface DesignService extends IService<Design> {
|
||||
|
||||
void processDesignBatch(Map<String, Object> designBatchResult);
|
||||
|
||||
Boolean sort(UserLikeSortDTO userLikeSortDTO);
|
||||
Boolean sort(CollectionSortDTO userLikeSortDTO);
|
||||
|
||||
IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO);
|
||||
|
||||
|
||||
@@ -113,4 +113,6 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
void toProductBatch(String taskId, String url, String progress);
|
||||
|
||||
void relightBatch(String taskId, String url, String progress);
|
||||
|
||||
Boolean collectionLikeUpdate(CollectionLikeUpdateDTO collectionLikeUpdateDTO);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
private DesignBatchMapper designBatchMapper;
|
||||
|
||||
@Resource
|
||||
private UserLikeSortMapper userLikeSortMapper;
|
||||
private CollectionSortMapper collectionSortMapper;
|
||||
@Resource
|
||||
private ProjectService projectService;
|
||||
@Resource
|
||||
@@ -1203,7 +1203,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
userLikeService.save(userLike);
|
||||
Long userLikeSortId;
|
||||
UserLikeSort userLikeSort = addCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), designLikeDTO.getProjectId());
|
||||
CollectionSort userLikeSort = addCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), designLikeDTO.getProjectId());
|
||||
userLikeSortId = userLikeSort.getId();
|
||||
groupDetailId = userLike.getId();
|
||||
String designUrl = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId()).getDesignUrl();
|
||||
@@ -1217,24 +1217,24 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserLikeSort addCollectionSort(Long relationId, String relationType, Long projectId) {
|
||||
public CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId) {
|
||||
int sort = getNextSort(projectId);
|
||||
UserLikeSort userLikeSort = new UserLikeSort();
|
||||
CollectionSort userLikeSort = new CollectionSort();
|
||||
// userLikeSort.setUserLikeGroupId(userGroupId);
|
||||
// userLikeSort.setUserLikeId(relationId);
|
||||
userLikeSort.setProjectId(projectId);
|
||||
userLikeSort.setRelationId(relationId);
|
||||
userLikeSort.setRelationType(relationType);
|
||||
userLikeSort.setSort(sort);
|
||||
userLikeSortMapper.insert(userLikeSort);
|
||||
collectionSortMapper.insert(userLikeSort);
|
||||
return userLikeSort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextSort(Long projectId) {
|
||||
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(UserLikeSort::getProjectId, projectId);
|
||||
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(qw);
|
||||
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionSort::getProjectId, projectId);
|
||||
List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw);
|
||||
if (CollectionUtils.isEmpty(userLikeSorts)) {
|
||||
return 1;
|
||||
}
|
||||
@@ -1328,30 +1328,30 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
|
||||
@Override
|
||||
public void deleteCollectionSort(Long relationId, String relationType, Long projectId) {
|
||||
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(UserLikeSort::getProjectId, projectId);
|
||||
qw.lambda().orderByDesc(UserLikeSort::getSort);
|
||||
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(qw);
|
||||
UserLikeSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId);
|
||||
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionSort::getProjectId, projectId);
|
||||
qw.lambda().orderByDesc(CollectionSort::getSort);
|
||||
List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw);
|
||||
CollectionSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId);
|
||||
Long userLikeSortId = userLikeSort.getId();
|
||||
for (UserLikeSort likeSort : userLikeSorts) {
|
||||
for (CollectionSort likeSort : userLikeSorts) {
|
||||
if (Objects.equals(likeSort.getId(), userLikeSortId)) {
|
||||
userLikeSortMapper.deleteById(likeSort);
|
||||
collectionSortMapper.deleteById(likeSort);
|
||||
break;
|
||||
}else {
|
||||
likeSort.setSort(likeSort.getSort() - 1);
|
||||
userLikeSortMapper.updateById(likeSort);
|
||||
collectionSortMapper.updateById(likeSort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserLikeSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId) {
|
||||
QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(UserLikeSort::getRelationId, userLikeId);
|
||||
qw.lambda().eq(UserLikeSort::getRelationType, relationType);
|
||||
qw.lambda().eq(UserLikeSort::getProjectId, projectId);
|
||||
UserLikeSort userLikeSort = userLikeSortMapper.selectOne(qw);
|
||||
public CollectionSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId) {
|
||||
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionSort::getRelationId, userLikeId);
|
||||
qw.lambda().eq(CollectionSort::getRelationType, relationType);
|
||||
qw.lambda().eq(CollectionSort::getProjectId, projectId);
|
||||
CollectionSort userLikeSort = collectionSortMapper.selectOne(qw);
|
||||
return userLikeSort;
|
||||
}
|
||||
|
||||
@@ -2570,12 +2570,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sort(UserLikeSortDTO userLikeSortDTO) {
|
||||
public Boolean sort(CollectionSortDTO userLikeSortDTO) {
|
||||
// QueryWrapper<UserLikeSort> qw = new QueryWrapper<>();
|
||||
// qw.lambda().eq(UserLikeSort::getUserLikeGroupId, userLikeSortDTO.getUserLikeGroupId());
|
||||
// userLikeSortMapper.delete(qw);
|
||||
for (UserLikeSort userLikeSort : userLikeSortDTO.getUserLikeSortList()) {
|
||||
userLikeSortMapper.updateById(userLikeSort);
|
||||
for (CollectionSort userLikeSort : userLikeSortDTO.getUserLikeSortList()) {
|
||||
collectionSortMapper.updateById(userLikeSort);
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
@Resource
|
||||
private ProductImageAttributeMapper productImageAttributeMapper;
|
||||
@Resource
|
||||
private UserLikeSortMapper userLikeSortMapper;
|
||||
private CollectionSortMapper collectionSortMapper;
|
||||
@Resource
|
||||
private ClassificationService classificationService;
|
||||
@Resource
|
||||
@@ -201,17 +201,17 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userGroupId);
|
||||
String sex = null;
|
||||
|
||||
QueryWrapper<UserLikeSort> userLikeSortQw = new QueryWrapper<>();
|
||||
userLikeSortQw.lambda().eq(UserLikeSort::getUserLikeGroupId, userGroupId);
|
||||
List<UserLikeSort> userLikeSortList = userLikeSortMapper.selectList(userLikeSortQw);
|
||||
QueryWrapper<CollectionSort> userLikeSortQw = new QueryWrapper<>();
|
||||
userLikeSortQw.lambda().eq(CollectionSort::getUserLikeGroupId, userGroupId);
|
||||
List<CollectionSort> userLikeSortList = collectionSortMapper.selectList(userLikeSortQw);
|
||||
if (CollectionUtil.isEmpty(userLikeSortList)) {
|
||||
Integer sort = 1;
|
||||
for (UserLikeVO userLikeVO : userLikeVOS) {
|
||||
UserLikeSort userLikeSort = new UserLikeSort();
|
||||
CollectionSort userLikeSort = new CollectionSort();
|
||||
userLikeSort.setUserLikeId(userLikeVO.getId());
|
||||
userLikeSort.setUserLikeGroupId(userGroupId);
|
||||
userLikeSort.setSort(sort);
|
||||
userLikeSortMapper.insert(userLikeSort);
|
||||
collectionSortMapper.insert(userLikeSort);
|
||||
sort ++;
|
||||
}
|
||||
}
|
||||
@@ -232,11 +232,11 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
o.setDesignOutfitId(tDesignPythonOutfit.getId());
|
||||
}
|
||||
|
||||
QueryWrapper<UserLikeSort> userLikeSortQueryWrapper = new QueryWrapper<>();
|
||||
userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getUserLikeId, o.getId());
|
||||
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(userLikeSortQueryWrapper);
|
||||
QueryWrapper<CollectionSort> userLikeSortQueryWrapper = new QueryWrapper<>();
|
||||
userLikeSortQueryWrapper.lambda().eq(CollectionSort::getUserLikeId, o.getId());
|
||||
List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(userLikeSortQueryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(userLikeSorts)) {
|
||||
UserLikeSort userLikeSort = userLikeSorts.get(0);
|
||||
CollectionSort userLikeSort = userLikeSorts.get(0);
|
||||
o.setSort(userLikeSort.getSort());
|
||||
o.setUserLikeSortId(userLikeSort.getId());
|
||||
}
|
||||
@@ -1520,16 +1520,16 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
moduleChooseVO.setSketchBoard(list);
|
||||
}else if (module.equals(Module.design.name())) {
|
||||
DesignModuleChooseVO vo = new DesignModuleChooseVO();
|
||||
QueryWrapper<UserLikeSort> userLikeSortQueryWrapper = new QueryWrapper<>();
|
||||
userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getProjectId, projectDTO.getId());
|
||||
userLikeSortQueryWrapper.lambda().orderByAsc(UserLikeSort::getSort);
|
||||
List<UserLikeSort> userLikeSortList = userLikeSortMapper.selectList(userLikeSortQueryWrapper);
|
||||
QueryWrapper<CollectionSort> userLikeSortQueryWrapper = new QueryWrapper<>();
|
||||
userLikeSortQueryWrapper.lambda().eq(CollectionSort::getProjectId, projectDTO.getId());
|
||||
userLikeSortQueryWrapper.lambda().orderByAsc(CollectionSort::getSort);
|
||||
List<CollectionSort> userLikeSortList = collectionSortMapper.selectList(userLikeSortQueryWrapper);
|
||||
|
||||
if (CollectionUtils.isEmpty(userLikeSortList)) {
|
||||
moduleChooseVO.setDesign(vo);
|
||||
}else {
|
||||
List<AllCollectionVO> list = new ArrayList<>();
|
||||
for (UserLikeSort userLikeSort : userLikeSortList) {
|
||||
for (CollectionSort userLikeSort : userLikeSortList) {
|
||||
if (userLikeSort.getRelationType().equals(CollectionType.DESIGN.getValue())) {
|
||||
UserLike userLike = userLikeMapper.selectById(userLikeSort.getRelationId());
|
||||
UserLikeVO o = CopyUtil.copyObject(userLike, UserLikeVO.class);
|
||||
@@ -2466,4 +2466,29 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean collectionLikeUpdate(CollectionLikeUpdateDTO collectionLikeUpdateDTO) {
|
||||
CollectionSort collectionSort = collectionSortMapper.selectById(collectionLikeUpdateDTO.getUserLikeSortId());
|
||||
Long relationIdOld = collectionSort.getRelationId();
|
||||
collectionSort.setRelationId(collectionLikeUpdateDTO.getRelationId());
|
||||
collectionSortMapper.updateById(collectionSort);
|
||||
if (collectionLikeUpdateDTO.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue()) || collectionLikeUpdateDTO.getRelationType().equals(CollectionType.RELIGHT.getValue())) {
|
||||
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(collectionLikeUpdateDTO.getRelationId());
|
||||
toProductImageResult.setIsLike(1);
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
ToProductImageResult toProductImageResultOld = toProductImageResultMapper.selectById(relationIdOld);
|
||||
toProductImageResultOld.setIsLike(0);
|
||||
toProductImageResultMapper.updateById(toProductImageResultOld);
|
||||
}else if (collectionLikeUpdateDTO.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())) {
|
||||
PoseTransformation poseTransformation = poseTransformationMapper.selectById(collectionLikeUpdateDTO.getRelationId());
|
||||
poseTransformation.setIsLiked((byte) 1);
|
||||
poseTransformationMapper.updateById(poseTransformation);
|
||||
PoseTransformation poseTransformationOld = poseTransformationMapper.selectById(relationIdOld);
|
||||
poseTransformationOld.setIsLiked((byte) 0);
|
||||
poseTransformationMapper.updateById(poseTransformationOld);
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user