Commit 299049ab by Jason Song Committed by GitHub

Merge pull request #325 from lepdou/history

bugfix cluster sort
parents 35f07cfb 13ce22ab
...@@ -16,7 +16,7 @@ import org.hibernate.annotations.Where; ...@@ -16,7 +16,7 @@ import org.hibernate.annotations.Where;
@Table(name = "Cluster") @Table(name = "Cluster")
@SQLDelete(sql = "Update Cluster set isDeleted = 1 where id = ?") @SQLDelete(sql = "Update Cluster set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0") @Where(clause = "isDeleted = 0")
public class Cluster extends BaseEntity { public class Cluster extends BaseEntity implements Comparable<Cluster> {
@Column(name = "Name", nullable = false) @Column(name = "Name", nullable = false)
private String name; private String name;
...@@ -43,4 +43,17 @@ public class Cluster extends BaseEntity { ...@@ -43,4 +43,17 @@ public class Cluster extends BaseEntity {
public String toString() { public String toString() {
return toStringHelper().add("name", name).add("appId", appId).toString(); return toStringHelper().add("name", name).add("appId", appId).toString();
} }
@Override
public int compareTo(Cluster o) {
if (o == null || getId() > o.getId()) {
return 1;
}
if (getId() == o.getId()) {
return 0;
}
return -1;
}
} }
...@@ -46,6 +46,7 @@ public class ClusterService { ...@@ -46,6 +46,7 @@ public class ClusterService {
} }
List<Cluster> clusters = clusterRepository.findByAppId(appId); List<Cluster> clusters = clusterRepository.findByAppId(appId);
Collections.sort(clusters);
if (clusters == null) { if (clusters == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
......
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