Commit b3a849c3 by huluobin

标签改成map

parent 68935e39
...@@ -36,6 +36,8 @@ public class OrderCommentLabel implements Serializable { ...@@ -36,6 +36,8 @@ public class OrderCommentLabel implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime; private Date updateTime;
private Integer serveTypeId;
/** /**
* 非数据库字段 * 非数据库字段
*/ */
......
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gogirl.domain.order.serve.OrderCommentLabel; import com.gogirl.domain.order.serve.OrderCommentLabel;
import com.gogirl.infrastructure.common.annotation.GogirlMember; import com.gogirl.infrastructure.common.annotation.GogirlMember;
import com.gogirl.infrastructure.common.base.JsonResult; import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.mapper.order.serve.OrderCommentLabelMapper; import com.gogirl.infrastructure.mapper.order.serve.OrderCommentLabelMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* Created by yinyong on 2018/10/22. * Created by yinyong on 2018/10/22.
...@@ -30,10 +33,23 @@ public class OrderCommentLabelController { ...@@ -30,10 +33,23 @@ public class OrderCommentLabelController {
* @return 所有评论标签列表 * @return 所有评论标签列表
*/ */
@ApiOperation(value = "查询所有标签") @ApiOperation(value = "查询所有标签")
@GetMapping("/customer/orderlabel/queryOrderLabel") @GetMapping("queryOrderLabel")
@GogirlMember @GogirlMember
public JsonResult<List<OrderCommentLabel>> queryOrderLabel() { public JsonResult<Map<Integer, List<OrderCommentLabel>>> queryOrderLabel() {
List<OrderCommentLabel> listOrderCommentLabel = orderCommentLabelMapper.selectList(new QueryWrapper<>()); List<OrderCommentLabel> commentLabelList = orderCommentLabelMapper.selectList(new QueryWrapper<>());
return JsonResult.success(listOrderCommentLabel);
List<OrderCommentLabel> commonLabel = commentLabelList.stream().filter(orderCommentLabel -> orderCommentLabel.getServeTypeId() == null).collect(Collectors.toList());
Map<Integer, List<OrderCommentLabel>> map = commentLabelList.stream().filter(orderCommentLabel -> orderCommentLabel.getServeTypeId() != null)
.collect(Collectors.groupingBy(OrderCommentLabel::getServeTypeId));
if (ListUtil.isNotEmpty(map.get(0))) {
commonLabel.addAll(map.get(0));
}
map.remove(0);
map.forEach((id, commentLabelListVar) -> {
commentLabelListVar.addAll(commentLabelList);
});
return JsonResult.success(map);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment