标签组列表排序
This commit is contained in:
@@ -25,6 +25,8 @@ public interface HyPartnerLabelGroupMapper {
|
|||||||
|
|
||||||
List<LabelGroupListVo> getLabelGroupList(HyPartnerLabelGroupDO record);
|
List<LabelGroupListVo> getLabelGroupList(HyPartnerLabelGroupDO record);
|
||||||
|
|
||||||
|
List<LabelGroupListVo> getLabelGroupListOrder(HyPartnerLabelGroupDO record);
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(HyPartnerLabelGroupDO record);
|
int updateByPrimaryKeySelective(HyPartnerLabelGroupDO record);
|
||||||
|
|
||||||
int updateByPrimaryKey(HyPartnerLabelGroupDO record);
|
int updateByPrimaryKey(HyPartnerLabelGroupDO record);
|
||||||
|
|||||||
@@ -223,4 +223,15 @@
|
|||||||
ORDER BY t1.create_time DESC
|
ORDER BY t1.create_time DESC
|
||||||
</select>
|
</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>
|
</mapper>
|
||||||
@@ -201,7 +201,7 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="getLabelList" resultType="com.cool.store.vo.LabelListVo">
|
<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
|
FROM hy_partner_label t1
|
||||||
LEFT JOIN hy_partner_label_group t2 ON t1.label_group_id = t2.id
|
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
|
LEFT JOIN enterprise_user t3 ON t1.edit_user_id = t3.user_id
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -33,4 +33,10 @@ public class LabelListVo {
|
|||||||
@ApiModelProperty(value = "标签分组id")
|
@ApiModelProperty(value = "标签分组id")
|
||||||
private Long labelGroupId;
|
private Long labelGroupId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标签创建时间")
|
||||||
|
private Date labelCreateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标签组创建时间")
|
||||||
|
private Date groupCreateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,4 +53,6 @@ public interface LabelGroupService {
|
|||||||
|
|
||||||
HyPartnerLabelGroupDO selectByPrimaryKey(Long id);
|
HyPartnerLabelGroupDO selectByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
List<LabelGroupListVo> getLabelGroupListOrder();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.cool.store.dto.label.LabelListDTO;
|
|||||||
import com.cool.store.dto.label.LabelUpdateDTO;
|
import com.cool.store.dto.label.LabelUpdateDTO;
|
||||||
import com.cool.store.entity.HyPartnerLabelDO;
|
import com.cool.store.entity.HyPartnerLabelDO;
|
||||||
import com.cool.store.exception.ApiException;
|
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 com.cool.store.vo.LabelListVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -62,5 +62,5 @@ public interface LabelService {
|
|||||||
|
|
||||||
void addEcLabel(HyPartnerLabelDO hyPartnerLabelDO);
|
void addEcLabel(HyPartnerLabelDO hyPartnerLabelDO);
|
||||||
|
|
||||||
List<LabelGroupListVo> getAllGroupAndLabelList();
|
List<LabelGroupVO> getAllGroupAndLabelList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.cool.store.dto.label.LabelGroupAddDTO;
|
|||||||
import com.cool.store.dto.label.LabelGroupDeleteDTO;
|
import com.cool.store.dto.label.LabelGroupDeleteDTO;
|
||||||
import com.cool.store.dto.label.LabelGroupListDTO;
|
import com.cool.store.dto.label.LabelGroupListDTO;
|
||||||
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
import com.cool.store.dto.label.LabelGroupUpdateDTO;
|
||||||
import com.cool.store.entity.HyPartnerLabelDO;
|
|
||||||
import com.cool.store.entity.HyPartnerLabelGroupDO;
|
import com.cool.store.entity.HyPartnerLabelGroupDO;
|
||||||
import com.cool.store.enums.ErrorCodeEnum;
|
import com.cool.store.enums.ErrorCodeEnum;
|
||||||
import com.cool.store.exception.ApiException;
|
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.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -127,6 +125,15 @@ public class LabelGroupServiceImpl implements LabelGroupService {
|
|||||||
labelGroupMapper.insertSelective(hyPartnerLabelGroupDO);
|
labelGroupMapper.insertSelective(hyPartnerLabelGroupDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询标签组信息列表正序
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<LabelGroupListVo> getLabelGroupListOrder() {
|
||||||
|
HyPartnerLabelGroupDO labelGroupDO = new HyPartnerLabelGroupDO();
|
||||||
|
return labelGroupMapper.getLabelGroupListOrder(labelGroupDO);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 某个标签组内是否有未删除的标签
|
* 某个标签组内是否有未删除的标签
|
||||||
* @param id 标签组 id
|
* @param id 标签组 id
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import com.cool.store.enums.ErrorCodeEnum;
|
|||||||
import com.cool.store.exception.ApiException;
|
import com.cool.store.exception.ApiException;
|
||||||
import com.cool.store.mapper.HyPartnerLabelMapper;
|
import com.cool.store.mapper.HyPartnerLabelMapper;
|
||||||
import com.cool.store.service.LabelService;
|
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.cool.store.vo.LabelListVo;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -118,20 +118,29 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LabelGroupListVo> getAllGroupAndLabelList() {
|
public List<LabelGroupVO> getAllGroupAndLabelList() {
|
||||||
List<LabelListVo> labelList = labelMapper.getLabelList(new LabelListDTO());
|
List<LabelListVo> labelList = labelMapper.getLabelList(new LabelListDTO());
|
||||||
if (CollectionUtils.isEmpty(labelList)) {
|
if (CollectionUtils.isEmpty(labelList)) {
|
||||||
log.info("标签列表为空");
|
log.info("标签列表为空");
|
||||||
return Lists.newArrayList(new LabelGroupListVo());
|
return Lists.newArrayList(new LabelGroupVO());
|
||||||
}
|
}
|
||||||
Map<Long, List<LabelListVo>> idForVo = labelList.stream().collect(Collectors.groupingBy(LabelListVo::getLabelGroupId));
|
Map<Long, List<LabelListVo>> idForVo = labelList.stream().collect(Collectors.groupingBy(LabelListVo::getLabelGroupId));
|
||||||
List<LabelGroupListVo> result = idForVo.entrySet().stream().map(entry -> {
|
List<LabelGroupVO> result = idForVo.entrySet().stream().map(entry -> {
|
||||||
LabelGroupListVo labelGroupListVo = new LabelGroupListVo();
|
LabelGroupVO vo = new LabelGroupVO();
|
||||||
labelGroupListVo.setId(entry.getKey());
|
vo.setId(entry.getKey());
|
||||||
labelGroupListVo.setLabelGroupName(entry.getValue().get(0).getLabelGroupName());
|
vo.setLabelGroupName(entry.getValue().get(0).getLabelGroupName());
|
||||||
labelGroupListVo.setLabelList(entry.getValue());
|
vo.setGroupCreateTime(entry.getValue().get(0).getGroupCreateTime());
|
||||||
return labelGroupListVo;
|
List<LabelGroupVO.LabelVO> labelList1 = entry.getValue().stream().map(label -> {
|
||||||
}).sorted(Comparator.comparing(LabelGroupListVo::getId)).collect(Collectors.toList());
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.cool.store.dto.label.LabelUpdateDTO;
|
|||||||
import com.cool.store.exception.ApiException;
|
import com.cool.store.exception.ApiException;
|
||||||
import com.cool.store.response.ResponseResult;
|
import com.cool.store.response.ResponseResult;
|
||||||
import com.cool.store.service.LabelService;
|
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.cool.store.vo.LabelListVo;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
@@ -40,8 +40,8 @@ public class LabelController {
|
|||||||
|
|
||||||
@ApiOperation("查询标签组及子标签列表")
|
@ApiOperation("查询标签组及子标签列表")
|
||||||
@GetMapping("/labelGroupAndLabelList")
|
@GetMapping("/labelGroupAndLabelList")
|
||||||
public ResponseResult<List<LabelGroupListVo>> getAllLabelList() {
|
public ResponseResult<List<LabelGroupVO>> getAllLabelList() {
|
||||||
List<LabelGroupListVo> result = labelService.getAllGroupAndLabelList();
|
List<LabelGroupVO> result = labelService.getAllGroupAndLabelList();
|
||||||
return ResponseResult.success(result);
|
return ResponseResult.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,5 +65,11 @@ public class LabelGroupController {
|
|||||||
public ResponseResult<List<LabelGroupListVo>> deleteLabelGroup() {
|
public ResponseResult<List<LabelGroupListVo>> deleteLabelGroup() {
|
||||||
return ResponseResult.success(labelGroupService.getAllLabelGroupList());
|
return ResponseResult.success(labelGroupService.getAllLabelGroupList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取所有标签组")
|
||||||
|
@PostMapping({"/allListAsc"})
|
||||||
|
public ResponseResult<List<LabelGroupListVo>> getLabelGroupListOrder() {
|
||||||
|
return ResponseResult.success(labelGroupService.getLabelGroupListOrder());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user