Ver código fonte

菜单调整

wangliang 2 anos atrás
pai
commit
45972daa47

+ 17 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/MenuDto.java

@@ -8,9 +8,13 @@ import java.io.Serializable;
 import java.util.Objects;
 
 /**
- * @Date: 2021/4/13.
+ * @Description: 菜单dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/9/16
  */
-public class MenuDto implements Serializable {
+public class MenuDto implements Serializable, Comparable<MenuDto> {
 
     @JsonSerialize(using = ToStringSerializer.class)
     private Long id;
@@ -94,4 +98,15 @@ public class MenuDto implements Serializable {
     public void setUrl(String url) {
         this.url = url;
     }
+
+    @Override
+    public int compareTo(MenuDto o) {
+        if (o.getSequence() < this.getSequence()) {
+            return 1;
+        } else if (o.getSequence() > this.getSequence()) {
+            return -1;
+        } else {
+            return 0;
+        }
+    }
 }

+ 12 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/PrivilegeDto.java

@@ -11,7 +11,11 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * @Date: 2021/3/29.
+ * @Description: 权限dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/9/16
  */
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class PrivilegeDto implements Serializable, Comparable<PrivilegeDto> {
@@ -129,6 +133,12 @@ public class PrivilegeDto implements Serializable, Comparable<PrivilegeDto> {
 
     @Override
     public int compareTo(PrivilegeDto o) {
-        return o.getSequence() < this.getSequence() ? 1 : -1;
+        if (o.getSequence() < this.getSequence()) {
+            return 1;
+        } else if (o.getSequence() > this.getSequence()) {
+            return -1;
+        } else {
+            return 0;
+        }
     }
 }

+ 12 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysPrivilegeServiceImpl.java

@@ -287,6 +287,18 @@ public class SysPrivilegeServiceImpl extends ServiceImpl<SysPrivilegeMapper, Sys
             if (Objects.nonNull(map.get(v.getParentId())) && !CollectionUtils.isEmpty(map.get(v.getParentId()).getChildren())) {
                 Collections.sort(map.get(v.getParentId()).getChildren());
             }
+            if (!CollectionUtils.isEmpty(v.getButtons())) {
+                Collections.sort(v.getButtons());
+            }
+            if (!CollectionUtils.isEmpty(v.getLinks())) {
+                Collections.sort(v.getLinks());
+            }
+            if (!CollectionUtils.isEmpty(v.getLists())) {
+                Collections.sort(v.getLists());
+            }
+            if (!CollectionUtils.isEmpty(v.getConditions())) {
+                Collections.sort(v.getConditions());
+            }
         });
         for (Long key : deleteKeys) {
             map.remove(key);