diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7705263..34d6455 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,8 @@ - - + + @@ -16,7 +16,7 @@ - + @@ -61,6 +61,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -142,6 +165,8 @@ @@ -247,15 +272,6 @@ - - - - - - - - - @@ -578,7 +594,7 @@ - + 1529592741848 @@ -630,7 +646,7 @@ - @@ -739,13 +755,6 @@ - - - - - - - @@ -1381,6 +1390,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/cn/edu/hust/session/CategorySortKey.java b/src/main/java/cn/edu/hust/session/CategorySortKey.java new file mode 100644 index 0000000..3fa8435 --- /dev/null +++ b/src/main/java/cn/edu/hust/session/CategorySortKey.java @@ -0,0 +1,112 @@ +package cn.edu.hust.session; + +import scala.math.Ordered; + +public class CategorySortKey implements Ordered { + + private Long clickCount; + private Long orderCount; + private Long payCount; + + @Override + public int compare(CategorySortKey categorySortKey) { + if(clickCount-categorySortKey.getClickCount()!=0) + { + return (int) (clickCount-categorySortKey.getClickCount()); + }else if(clickCount-categorySortKey.getClickCount()==0&&orderCount-categorySortKey.getOrderCount()!=0) + { + return (int) (orderCount-categorySortKey.getOrderCount()); + } + else if(clickCount-categorySortKey.getClickCount()==0&&orderCount-categorySortKey.getOrderCount()==0&&payCount-categorySortKey.getPayCount()!=0) + return (int) (payCount-categorySortKey.getPayCount()); + return 0; + } + + @Override + public boolean $less(CategorySortKey categorySortKey) { + if(clickCountcategorySortKey.getClickCount()) + { + return true; + }else if(clickCount==categorySortKey.getClickCount()&&orderCount>categorySortKey.getOrderCount()) + { + return true; + } + else if(clickCount==categorySortKey.getClickCount()&&orderCount==categorySortKey.getOrderCount()&&payCount>categorySortKey.getPayCount()) + return true; + + return false; + } + + @Override + public boolean $less$eq(CategorySortKey categorySortKey) { + if($less(categorySortKey)) + { + return true; + } + else if(clickCount==categorySortKey.getClickCount()&&orderCount==categorySortKey.getOrderCount()&&payCount==categorySortKey.getPayCount()) + return true; + return false; + } + + @Override + public boolean $greater$eq(CategorySortKey categorySortKey) { + if($greater(categorySortKey)) + { + return true; + }else if(clickCount==categorySortKey.getClickCount()&&orderCount==categorySortKey.getOrderCount()&&payCount==categorySortKey.getPayCount()) + return true; + return false; + } + + @Override + public int compareTo(CategorySortKey categorySortKey) { + if(clickCount-categorySortKey.getClickCount()!=0) + { + return (int) (clickCount-categorySortKey.getClickCount()); + }else if(clickCount-categorySortKey.getClickCount()==0&&orderCount-categorySortKey.getOrderCount()!=0) + { + return (int) (orderCount-categorySortKey.getOrderCount()); + } + else if(clickCount-categorySortKey.getClickCount()==0&&orderCount-categorySortKey.getOrderCount()==0&&payCount-categorySortKey.getPayCount()!=0) + return (int) (payCount-categorySortKey.getPayCount()); + return 0; + } + + public Long getClickCount() { + return clickCount; + } + + public void setClickCount(Long clickCount) { + this.clickCount = clickCount; + } + + public Long getOrderCount() { + return orderCount; + } + + public void setOrderCount(Long orderCount) { + this.orderCount = orderCount; + } + + public Long getPayCount() { + return payCount; + } + + public void setPayCount(Long payCount) { + this.payCount = payCount; + } +}