REQ-2655: 分类统计时对分类进行排序

This commit is contained in:
yanglin 2024-07-10 15:21:47 +08:00
parent 53e199872d
commit e1fc4dad26
5 changed files with 30 additions and 2 deletions

View File

@ -85,6 +85,7 @@ public class GroupTemplateService {
return true;
});
}
leafNodes.sort(NodeComparator.INSTANCE);
return leafNodes;
}

View File

@ -0,0 +1,23 @@
package cn.axzo.msg.center.message.service.group;
import cn.axzo.maokai.api.vo.response.tree.ValueNode;
import java.util.Comparator;
/**
* @author yanglin
*/
class NodeComparator implements Comparator<ValueNode<NodeWrapper>> {
static final NodeComparator INSTANCE = new NodeComparator();
private NodeComparator() {
}
@Override
public int compare(ValueNode<NodeWrapper> n1, ValueNode<NodeWrapper> n2) {
Long id1 = n1.getValue().unwrap().getId();
Long id2 = n2.getValue().unwrap().getId();
return Long.compare(id1, id2);
}
}

View File

@ -58,6 +58,7 @@ public class RootNodeWrapper {
.map(this::findValueNode)
.map(node -> node.orElse(null))
.filter(Objects::nonNull)
.sorted(NodeComparator.INSTANCE)
.collect(toList());
}

View File

@ -269,6 +269,7 @@ public class TodoRangeQueryService {
GroupStat groupStat = new GroupStat();
stats.add(groupStat);
MessageGroupNode node = valueNode.getValue().unwrap();
groupStat.setNodeId(node.getId());
groupStat.setGroupCode(node.getCode());
groupStat.setGroupName(node.getName());
groupStat.setGroupIcon(node.getIcon());

View File

@ -65,9 +65,11 @@ public class PendingMessageStatisticResponseV2 implements Serializable {
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class GroupStat {
/**
* 分类id
*/
private Long nodeId;
/**
* 分类名称
*/