标签组列表排序

This commit is contained in:
陈伏伽
2023-10-20 17:38:00 +08:00
parent 63dd1dd5e2
commit d310587c0e
11 changed files with 90 additions and 18 deletions

View File

@@ -25,6 +25,8 @@ public interface HyPartnerLabelGroupMapper {
List<LabelGroupListVo> getLabelGroupList(HyPartnerLabelGroupDO record);
List<LabelGroupListVo> getLabelGroupListOrder(HyPartnerLabelGroupDO record);
int updateByPrimaryKeySelective(HyPartnerLabelGroupDO record);
int updateByPrimaryKey(HyPartnerLabelGroupDO record);

View File

@@ -223,4 +223,15 @@
ORDER BY t1.create_time DESC
</select>
<select id="getLabelGroupListOrder" resultType="com.cool.store.vo.LabelGroupListVo">
SELECT t1.id, t1.label_group_name, t2.`name` AS editName, t2.mobile AS editMobile, t1.edit_date
FROM hy_partner_label_group t1
LEFT JOIN enterprise_user t2 ON t1.edit_user_id = t2.user_id
WHERE t1.deleted = 0
<if test="labelGroupName != null and labelGroupName != ''">
AND t1.label_group_name LIKE CONCAT('%', #{labelGroupName}, '%')
</if>
ORDER BY t1.create_time
</select>
</mapper>

View File

@@ -201,7 +201,7 @@
</update>
<select id="getLabelList" resultType="com.cool.store.vo.LabelListVo">
SELECT t1.id, t2.id AS labelGroupId, t1.label_name, t2.label_group_name, t3.`name` AS editName, t3.mobile AS editMobile, t1.edit_date
SELECT t1.id, t2.id AS labelGroupId, t1.label_name, t2.label_group_name, t3.`name` AS editName, t3.mobile AS editMobile, t1.edit_date,t1.create_time as labelCreateTime,t2.create_time AS groupCreateTime
FROM hy_partner_label t1
LEFT JOIN hy_partner_label_group t2 ON t1.label_group_id = t2.id
LEFT JOIN enterprise_user t3 ON t1.edit_user_id = t3.user_id

View File

@@ -0,0 +1,29 @@
package com.cool.store.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class LabelGroupVO {
@ApiModelProperty(value = "标签组ID")
private Long id;
@ApiModelProperty(value = "标签组名称")
private String labelGroupName;
@ApiModelProperty(value = "标签组创建时间")
private Date groupCreateTime;
@ApiModelProperty(value = "标签列表")
private List<LabelVO> labelList;
@Data
public static class LabelVO {
@ApiModelProperty(value = "标签ID")
private Long id;
@ApiModelProperty(value = "标签名称")
private String labelName;
@ApiModelProperty(value = "标签创建时间")
private Date labelCreateTime;
}
}

View File

@@ -33,4 +33,10 @@ public class LabelListVo {
@ApiModelProperty(value = "标签分组id")
private Long labelGroupId;
@ApiModelProperty(value = "标签创建时间")
private Date labelCreateTime;
@ApiModelProperty(value = "标签组创建时间")
private Date groupCreateTime;
}

View File

@@ -53,4 +53,6 @@ public interface LabelGroupService {
HyPartnerLabelGroupDO selectByPrimaryKey(Long id);
List<LabelGroupListVo> getLabelGroupListOrder();
}

View File

@@ -6,7 +6,7 @@ import com.cool.store.dto.label.LabelListDTO;
import com.cool.store.dto.label.LabelUpdateDTO;
import com.cool.store.entity.HyPartnerLabelDO;
import com.cool.store.exception.ApiException;
import com.cool.store.vo.LabelGroupListVo;
import com.cool.store.vo.LabelGroupVO;
import com.cool.store.vo.LabelListVo;
import java.util.List;
@@ -62,5 +62,5 @@ public interface LabelService {
void addEcLabel(HyPartnerLabelDO hyPartnerLabelDO);
List<LabelGroupListVo> getAllGroupAndLabelList();
List<LabelGroupVO> getAllGroupAndLabelList();
}

View File

@@ -5,7 +5,6 @@ import com.cool.store.dto.label.LabelGroupAddDTO;
import com.cool.store.dto.label.LabelGroupDeleteDTO;
import com.cool.store.dto.label.LabelGroupListDTO;
import com.cool.store.dto.label.LabelGroupUpdateDTO;
import com.cool.store.entity.HyPartnerLabelDO;
import com.cool.store.entity.HyPartnerLabelGroupDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.exception.ApiException;
@@ -16,7 +15,6 @@ import com.cool.store.vo.LabelGroupListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@@ -127,6 +125,15 @@ public class LabelGroupServiceImpl implements LabelGroupService {
labelGroupMapper.insertSelective(hyPartnerLabelGroupDO);
}
/**
* 查询标签组信息列表正序
*/
@Override
public List<LabelGroupListVo> getLabelGroupListOrder() {
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
return labelGroupMapper.getLabelGroupListOrder(labelGroupDO);
}
/**
* 某个标签组内是否有未删除的标签
* @param id 标签组 id

View File

@@ -10,7 +10,7 @@ import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.exception.ApiException;
import com.cool.store.mapper.HyPartnerLabelMapper;
import com.cool.store.service.LabelService;
import com.cool.store.vo.LabelGroupListVo;
import com.cool.store.vo.LabelGroupVO;
import com.cool.store.vo.LabelListVo;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
@@ -118,20 +118,29 @@ public class LabelServiceImpl implements LabelService {
}
@Override
public List<LabelGroupListVo> getAllGroupAndLabelList() {
public List<LabelGroupVO> getAllGroupAndLabelList() {
List<LabelListVo> labelList = labelMapper.getLabelList(new LabelListDTO());
if (CollectionUtils.isEmpty(labelList)) {
log.info("标签列表为空");
return Lists.newArrayList(new LabelGroupListVo());
return Lists.newArrayList(new LabelGroupVO());
}
Map<Long, List<LabelListVo>> idForVo = labelList.stream().collect(Collectors.groupingBy(LabelListVo::getLabelGroupId));
List<LabelGroupListVo> result = idForVo.entrySet().stream().map(entry -> {
LabelGroupListVo labelGroupListVo = new LabelGroupListVo();
labelGroupListVo.setId(entry.getKey());
labelGroupListVo.setLabelGroupName(entry.getValue().get(0).getLabelGroupName());
labelGroupListVo.setLabelList(entry.getValue());
return labelGroupListVo;
}).sorted(Comparator.comparing(LabelGroupListVo::getId)).collect(Collectors.toList());
List<LabelGroupVO> result = idForVo.entrySet().stream().map(entry -> {
LabelGroupVO vo = new LabelGroupVO();
vo.setId(entry.getKey());
vo.setLabelGroupName(entry.getValue().get(0).getLabelGroupName());
vo.setGroupCreateTime(entry.getValue().get(0).getGroupCreateTime());
List<LabelGroupVO.LabelVO> labelList1 = entry.getValue().stream().map(label -> {
LabelGroupVO.LabelVO labelVO = new LabelGroupVO.LabelVO();
labelVO.setId(label.getId());
labelVO.setLabelName(label.getLabelName());
labelVO.setLabelCreateTime(label.getLabelCreateTime());
return labelVO;
}).sorted(Comparator.comparing(LabelGroupVO.LabelVO::getLabelCreateTime))
.collect(Collectors.toList());
vo.setLabelList(labelList1);
return vo;
}).sorted(Comparator.comparing(LabelGroupVO::getGroupCreateTime)).collect(Collectors.toList());
return result;
}

View File

@@ -7,7 +7,7 @@ import com.cool.store.dto.label.LabelUpdateDTO;
import com.cool.store.exception.ApiException;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.LabelService;
import com.cool.store.vo.LabelGroupListVo;
import com.cool.store.vo.LabelGroupVO;
import com.cool.store.vo.LabelListVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -40,8 +40,8 @@ public class LabelController {
@ApiOperation("查询标签组及子标签列表")
@GetMapping("/labelGroupAndLabelList")
public ResponseResult<List<LabelGroupListVo>> getAllLabelList() {
List<LabelGroupListVo> result = labelService.getAllGroupAndLabelList();
public ResponseResult<List<LabelGroupVO>> getAllLabelList() {
List<LabelGroupVO> result = labelService.getAllGroupAndLabelList();
return ResponseResult.success(result);
}

View File

@@ -65,5 +65,11 @@ public class LabelGroupController {
public ResponseResult<List<LabelGroupListVo>> deleteLabelGroup() {
return ResponseResult.success(labelGroupService.getAllLabelGroupList());
}
@ApiOperation("获取所有标签组")
@PostMapping({"/allListAsc"})
public ResponseResult<List<LabelGroupListVo>> getLabelGroupListOrder() {
return ResponseResult.success(labelGroupService.getLabelGroupListOrder());
}
}