标签组及子标签接口
This commit is contained in:
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Fun Li 2023/8/10 13:33
|
||||
@@ -27,4 +28,7 @@ public class LabelGroupListVo {
|
||||
@ApiModelProperty("编辑时间")
|
||||
private Date editDate;
|
||||
|
||||
@ApiModelProperty("标签列表")
|
||||
private List<LabelListVo> labelList;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +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.LabelListVo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -61,4 +62,5 @@ public interface LabelService {
|
||||
|
||||
void addEcLabel(HyPartnerLabelDO hyPartnerLabelDO);
|
||||
|
||||
List<LabelGroupListVo> getAllGroupAndLabelList();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ 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.LabelListVo;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -18,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -116,6 +117,24 @@ public class LabelServiceImpl implements LabelService {
|
||||
labelMapper.insertSelective(hyPartnerLabelDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LabelGroupListVo> getAllGroupAndLabelList() {
|
||||
List<LabelListVo> labelList = labelMapper.getLabelList(new LabelListDTO());
|
||||
if (CollectionUtils.isEmpty(labelList)) {
|
||||
log.info("标签列表为空");
|
||||
return Lists.newArrayList(new LabelGroupListVo());
|
||||
}
|
||||
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());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Boolean whetherLabelRepeat(HyPartnerLabelDO label) throws ApiException {
|
||||
Long id = label.getId();
|
||||
label.setId(null);
|
||||
|
||||
@@ -7,16 +7,14 @@ 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.LabelListVo;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,6 +38,13 @@ public class LabelController {
|
||||
return ResponseResult.success(new PageInfo<>(result));
|
||||
}
|
||||
|
||||
@ApiOperation("查询标签组及子标签列表")
|
||||
@GetMapping("/labelGroupAndLabelList")
|
||||
public ResponseResult<List<LabelGroupListVo>> getAllLabelList() {
|
||||
List<LabelGroupListVo> result = labelService.getAllGroupAndLabelList();
|
||||
return ResponseResult.success(result);
|
||||
}
|
||||
|
||||
@ApiOperation("新增标签")
|
||||
@PostMapping("/add")
|
||||
public ResponseResult addLabel(@RequestBody LabelAddDTO dto) throws ApiException {
|
||||
|
||||
Reference in New Issue
Block a user