From c327574106f470c72638e9f34c7f8cd26d78a2bf Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 24 一月 2024 23:48:36 +0800
Subject: [PATCH] 分类授权,数据授权接口修改

---
 Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/IClassifyAuthService.java         |    6 
 Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java |   27 ++
 Source/UBCS/ubcs-service-api/ubcs-system-api/src/main/java/com/vci/ubcs/system/dto/ClassifyAuthDTO.java          |   30 +++
 Source/UBCS-WEB/src/components/Theme/ClassifyAuthDialog.vue                                                      |  246 ++++++++++++-----------
 Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/ClassifyAuthController.java    |    8 
 Source/UBCS-WEB/src/components/Theme/DataAuthDialog.vue                                                          |  249 +++++++++++++-----------
 Source/UBCS-WEB/src/components/Master/MasterTree.vue                                                             |    4 
 Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml                              |   18 +
 Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java     |    6 
 Source/UBCS-WEB/src/api/system/classifyAuth.js                                                                   |    3 
 10 files changed, 335 insertions(+), 262 deletions(-)

diff --git a/Source/UBCS-WEB/src/api/system/classifyAuth.js b/Source/UBCS-WEB/src/api/system/classifyAuth.js
index 179fb9f..1649b0b 100644
--- a/Source/UBCS-WEB/src/api/system/classifyAuth.js
+++ b/Source/UBCS-WEB/src/api/system/classifyAuth.js
@@ -12,9 +12,10 @@
 
 export const saveOrUpdate = (data) => {
     return request({
+      headers:{'Content-Type':'application/json'},
       url: '/api/ubcs-system/classifyAuth/saveOrUpdate',
       method: 'post',
-      data: data
+      data: JSON.stringify(data)
     })
 }
 
diff --git a/Source/UBCS-WEB/src/components/Master/MasterTree.vue b/Source/UBCS-WEB/src/components/Master/MasterTree.vue
index 4f8c904..3abe4a1 100644
--- a/Source/UBCS-WEB/src/components/Master/MasterTree.vue
+++ b/Source/UBCS-WEB/src/components/Master/MasterTree.vue
@@ -57,7 +57,7 @@
         delBtn: false,
         defaultExpandAll: false,
         menu: false,
-        lazy: true,
+        // lazy: true,
         treeLoad: (node, resolve) => {
           if (node.data != false) {
             const parentId = (node.level === 0) ? 0 : node.data.oid;
@@ -214,7 +214,7 @@
     //鏍戠偣鍑讳簨浠�
     async nodeClick(data) {
       try {
-        // console.log(data)
+        console.log(data)
         this.TreeValue = data.label.split("</span>")[1].trim();
         // console.log('TreeValue',this.TreeValue)
         this.$emit('TreeValue', this.TreeValue)
diff --git a/Source/UBCS-WEB/src/components/Theme/ClassifyAuthDialog.vue b/Source/UBCS-WEB/src/components/Theme/ClassifyAuthDialog.vue
index 35216a7..9a32e26 100644
--- a/Source/UBCS-WEB/src/components/Theme/ClassifyAuthDialog.vue
+++ b/Source/UBCS-WEB/src/components/Theme/ClassifyAuthDialog.vue
@@ -137,76 +137,7 @@
     visible() {
       if (this.visible) {
         this.isShowDialog = this.visible;
-        return new Promise((resolve, reject) => {
-          getButtonByParentCode({ code: "classifyTree" })
-            .then((res) => {
-              // 璁板綍鎸夐挳鏁版嵁
-              this.classifyAuthButton = res.data.data;
-              const list = res.data.data;
-              let tempData = [];
-              // 瑙掕壊鍒�
-              tempData.push({
-                label: "瑙掕壊",
-                prop: "roleData",
-                type: "select",
-                width: 150,
-              });
-              // 缂栫爜椤瑰垎绫绘巿鏉�
-              tempData.push({
-                label: "缂栫爜椤瑰垎绫绘巿鏉�",
-                prop: "classifyItem",
-                type: "text",
-                width: 180,
-              });
-              list.forEach((item) => {
-                let columnItem = {
-                  label: item.name,
-                  prop: item.id,
-                  code: item.code,
-                  type: "checkbox",
-                  width: 180,
-                };
-                tempData.push(columnItem);
-              });
-              this.classifyAuthHeader = tempData;
-              resolve();
-            })
-            .catch((err) => {
-              reject(err);
-            });
-          // 鑾峰彇瑙掕壊鍒楄〃
-          getPage(1, -1, null).then((res) => {
-            this.roleList = res.data.data.records;
-          });
-          // 鑾峰彇璇ュ垎绫讳笅宸叉巿鏉冪殑鍒嗙被鎺堟潈淇℃伅
-          getClassifyAuthList({
-            classifyId: this.classifyData.oid,
-            authType: "classify_auth",
-          }).then((res) => {
-            //console.log(res.data.data);
-            let authDatas = res.data.data;
-            if (authDatas.length > 0) {
-              authDatas.forEach((authData, index) => {
-                let item = {
-                  oid: authData.oid,
-                  roleData: authData.roleId,
-                  classifyItem: this.classifyData.label,
-                  authButton:{},
-                  index: index,
-                  uuid: uuidv4(), //鐢熸垚鍞竴鐨刬d
-                };
-                //灏嗘寜閽缃繘鍘�
-                authData.buttonIdList.forEach((data) => {
-                  Vue.set(item, data, true);
-                });
-                this.classifyAuthData.push(item);
-                this.addIndex = this.classifyAuthData.length - 1; //娣诲姞琛屼笅鏍囩瓑浜巆lassifyAuthData鐨勯暱搴�-1
-                this.roleHandlerMethods(authData.roleId, "create", index);
-                // console.log('index', index)
-              });
-            }
-          });
-        });
+        this.loadAuthPage();
       }
     },
   },
@@ -215,7 +146,6 @@
       if (this.classifyAuthData.length < 0) {
         return;
       }
-
       getButtonsByRoleId({ roleId: id, code: "classifyTree" }).then((res) => {
         // 鎵惧埌this.classifyAuthButton涓病鏈夊搴旂殑灞炴��
         const filteredItems = this.classifyAuthButton.filter((item) => {
@@ -344,61 +274,68 @@
       this.selectList = list;
     },
     // 淇濆瓨鍒嗙被鎺堟潈淇℃伅
-    submit() {
-      if (this.classifyAuthData.length <= 0) {
-        this.$message.warning("鎺堟潈鍒楄〃涓虹┖锛�");
-        return;
-      }
+    async submit() {
+      let form = {
+        classifyAuthList: [],
+        isCLear: false, //榛樿鏄竻绌�
+        classifyId: this.classifyData.oid,
+      };
       let isRepeat = false;
-      // 閬嶅巻鏁扮粍锛屾瘮杈冨悗闈㈢殑瀵硅薄鐨剅oleData鏄惁涓庡墠闈㈢殑瀵硅薄鐩哥瓑
-      for (let i = 0; i < this.classifyAuthData.length - 1; i++) {
-        let currentRoleId = this.classifyAuthData[i].roleData;
-        for (let j = i + 1; j < this.classifyAuthData.length; j++) {
-          if (currentRoleId === this.classifyAuthData[j].roleData) {
-            isRepeat = true;
+      if(this.classifyAuthData.length > 0){
+        // 閬嶅巻鏁扮粍锛屾瘮杈冨悗闈㈢殑瀵硅薄鐨剅oleData鏄惁涓庡墠闈㈢殑瀵硅薄鐩哥瓑
+        for (let i = 0; i < this.classifyAuthData.length - 1; i++) {
+          let currentRoleId = this.classifyAuthData[i].roleData;
+          for (let j = i + 1; j < this.classifyAuthData.length; j++) {
+            if (currentRoleId === this.classifyAuthData[j].roleData) {
+              isRepeat = true;
+              break;
+            }
+          }
+          if (isRepeat) {
             break;
           }
         }
+
         if (isRepeat) {
-          break;
-        }
-      }
-      if (isRepeat) {
-        this.$message.warning("瑙掕壊鍜屽垎绫诲凡缁忓瓨鍦紝璇烽噸鏂伴厤缃紒");
-        return;
-      }
-      let form = [];
-      let flag = false;
-      this.classifyAuthData.forEach((item) => {
-        let itemButtonList = [];
-        //绛涢�夊嚭鎸夐挳鍕鹃�変负true鐨勫垪
-        for (let key in item) {
-          if (item[key] === true) {
-            itemButtonList.push(key);
-          }
-        }
-        /**濡傛灉itemButtonList涓虹┖璇佹槑鏄紝
-         娣诲姞浜嗚鑹蹭絾鏄病鍕鹃�変换浣曠殑鎸夐挳*/
-        if (itemButtonList.length <= 0) {
-          flag = true;
+          this.$message.warning("瑙掕壊鍜屽垎绫诲凡缁忓瓨鍦紝璇烽噸鏂伴厤缃紒");
           return;
         }
-        let data = {
-          oid: item.oid,
-          roleId: item.roleData,
-          classifyId: this.classifyData.oid,
-          buttonIds: itemButtonList.join(","),
-          authType: "classify_auth",
-        };
-        form.push(data);
-      });
-      if (flag) {
-        this.$message.warning("鏈夋湭鍕鹃�夋搷浣滅殑鏉冮檺锛屼笉鍏佽鎺堟潈");
-        return;
+        
+        let flag = false;
+        this.classifyAuthData.forEach((item) => {
+          let itemButtonList = [];
+          //绛涢�夊嚭鎸夐挳鍕鹃�変负true鐨勫垪
+          for (let key in item) {
+            if (item[key] === true) {
+              itemButtonList.push(key);
+            }
+          }
+          /**濡傛灉itemButtonList涓虹┖璇佹槑鏄紝
+           娣诲姞浜嗚鑹蹭絾鏄病鍕鹃�変换浣曠殑鎸夐挳*/
+          if (itemButtonList.length <= 0) {
+            flag = true;
+            return;
+          }
+          let data = {
+            oid: item.oid,
+            roleId: item.roleData,
+            classifyId: this.classifyData.oid,
+            buttonIds: itemButtonList.join(","),
+            authType: "classify_auth",
+          };
+          form.classifyAuthList.push(data);
+        });
+        if (flag) {
+          this.$message.warning("鏈夋湭鍕鹃�夋搷浣滅殑鏉冮檺锛屼笉鍏佽鎺堟潈");
+          return;
+        }
+      }else {
+        // 涓虹┖璇佹槑鏄竻绌烘巿鏉冨垪琛�
+        form.isCLear = true;
       }
-      // console.log(form)
+      // console.log(JSON.stringify(form))
       // 璋冪敤淇濆瓨鍒嗙被鎺堟潈鐨勬帴鍙�
-      saveOrUpdate(form).then(
+      await saveOrUpdate(form).then(
         (res) => {
           this.$message({
             type: "success",
@@ -410,6 +347,8 @@
           window.console.log(error);
         }
       );
+      this.classifyAuthData = [];
+      this.loadAuthPage();
     },
     // 鍏ㄩ�夋寜閽�
     selectAllButton() {
@@ -423,6 +362,79 @@
       });
       //console.log("this.selectList",this.selectList);
     },
+    // 鍔犺浇鎺堟潈鍒楄〃
+    loadAuthPage() {
+      return new Promise((resolve, reject) => {
+        getButtonByParentCode({ code: "classifyTree" })
+          .then((res) => {
+            // 璁板綍鎸夐挳鏁版嵁
+            this.classifyAuthButton = res.data.data;
+            const list = res.data.data;
+            let tempData = [];
+            // 瑙掕壊鍒�
+            tempData.push({
+              label: "瑙掕壊",
+              prop: "roleData",
+              type: "select",
+              width: 150,
+            });
+            // 缂栫爜椤瑰垎绫绘巿鏉�
+            tempData.push({
+              label: "缂栫爜椤瑰垎绫绘巿鏉�",
+              prop: "classifyItem",
+              type: "text",
+              width: 180,
+            });
+            list.forEach((item) => {
+              let columnItem = {
+                label: item.name,
+                prop: item.id,
+                code: item.code,
+                type: "checkbox",
+                width: 180,
+              };
+              tempData.push(columnItem);
+            });
+            this.classifyAuthHeader = tempData;
+            resolve();
+          })
+          .catch((err) => {
+            reject(err);
+          });
+        // 鑾峰彇瑙掕壊鍒楄〃
+        getPage(1, -1, null).then((res) => {
+          this.roleList = res.data.data.records;
+        });
+        // 鑾峰彇璇ュ垎绫讳笅宸叉巿鏉冪殑鍒嗙被鎺堟潈淇℃伅
+        getClassifyAuthList({
+          classifyId: this.classifyData.oid,
+          authType: "classify_auth",
+        }).then((res) => {
+          //console.log(res.data.data);
+          let authDatas = res.data.data;
+          if (authDatas.length > 0) {
+            authDatas.forEach((authData, index) => {
+              let item = {
+                oid: authData.oid,
+                roleData: authData.roleId,
+                classifyItem: this.classifyData.label,
+                authButton:{},
+                index: index,
+                uuid: uuidv4(), //鐢熸垚鍞竴鐨刬d
+              };
+              //灏嗘寜閽缃繘鍘�
+              authData.buttonIdList.forEach((data) => {
+                Vue.set(item, data, true);
+              });
+              this.classifyAuthData.push(item);
+              this.addIndex = this.classifyAuthData.length - 1; //娣诲姞琛屼笅鏍囩瓑浜巆lassifyAuthData鐨勯暱搴�-1
+              this.roleHandlerMethods(authData.roleId, "create", index);
+              // console.log('index', index)
+            });
+          }
+        });
+      });
+    },
   },
 };
 </script>
diff --git a/Source/UBCS-WEB/src/components/Theme/DataAuthDialog.vue b/Source/UBCS-WEB/src/components/Theme/DataAuthDialog.vue
index 69e0326..c6b6510 100644
--- a/Source/UBCS-WEB/src/components/Theme/DataAuthDialog.vue
+++ b/Source/UBCS-WEB/src/components/Theme/DataAuthDialog.vue
@@ -122,70 +122,7 @@
     visible() {
       if (this.visible) {
         this.isShowDialog = this.visible;
-        return new Promise((resolve, reject) => {
-          getButtonByParentCode({code: this.classifyData.attributes.id}).then(res => {
-            // 璁板綍鎸夐挳鏁版嵁
-            this.classifyAuthButton = res.data.data;
-            const list = res.data.data;
-            let tempData = [];
-            // 瑙掕壊鍒�
-            tempData.push({
-              label: "瑙掕壊",
-              prop: "roleData",
-              type: "select",
-              width: 150,
-            });
-            // 缂栫爜椤瑰垎绫绘巿鏉�
-            tempData.push({
-              label: "缂栫爜椤规暟鎹巿鏉�",
-              prop: "classifyItem",
-              type: "text",
-              width: 180,
-            });
-            list.forEach(item => {
-              let columnItem = {
-                label: item.name,
-                prop: item.id,
-                code: item.code,
-                type: "checkbox",
-                width: 180,
-              };
-              tempData.push(columnItem);
-            })
-            this.classifyAuthHeader = tempData
-            resolve();
-          }).catch(err => {
-            reject(err)
-          });
-          // 鑾峰彇瑙掕壊鍒楄〃
-          getPage(1, -1, null).then(res => {
-            this.roleList = res.data.data.records;
-          });
-          // 鑾峰彇璇ュ垎绫讳笅宸叉巿鏉冪殑鍒嗙被鎺堟潈淇℃伅
-          getClassifyAuthList({classifyId: this.classifyData.oid, authType: "data_auth"}).then(res => {
-            //console.log(res.data.data);
-            let authDatas = res.data.data;
-            if (authDatas.length > 0) {
-              authDatas.forEach((authData, index) => {
-                let item = {
-                  oid: authData.oid,
-                  roleData: authData.roleId,
-                  classifyItem: this.classifyData.label,
-                  index: index,
-                  authButton:{},
-                  uuid: uuidv4(),//鐢熸垚鍞竴鐨刬d
-                }
-                //灏嗘寜閽缃繘鍘�
-                authData.buttonIdList.forEach(data => {
-                  Vue.set(item, data, true);
-                });
-                this.classifyAuthData.push(item);
-                this.addIndex = this.classifyAuthData.length - 1; //娣诲姞琛屼笅鏍囩瓑浜巆lassifyAuthData鐨勯暱搴�-1
-                this.roleHandlerMethods(authData.roleId, 'create', index)
-              })
-            }
-          });
-        });
+        this.loadAuthPage();
       }
     },
   },
@@ -323,69 +260,76 @@
       this.selectList = list;
     },
     // 淇濆瓨鍒嗙被鎺堟潈淇℃伅
-    submit() {
-      if (this.classifyAuthData.length <= 0) {
-        this.$message.warning('鎺堟潈鍒楄〃涓虹┖锛�')
-        return;
-      }
+    async submit() {
+      let form = {
+        classifyAuthList: [],
+        isCLear: false, //榛樿鏄竻绌�
+        classifyId: this.classifyData.oid,
+      };
       let isRepeat = false;
-      // 閬嶅巻鏁扮粍锛屾瘮杈冨悗闈㈢殑瀵硅薄鐨剅oleData鏄惁涓庡墠闈㈢殑瀵硅薄鐩哥瓑
-      for (let i = 0; i < this.classifyAuthData.length - 1; i++) {
-        let currentRoleId = this.classifyAuthData[i].roleData;
-        for (let j = i + 1; j < this.classifyAuthData.length; j++) {
-          if (currentRoleId === this.classifyAuthData[j].roleData) {
-            isRepeat = true;
+      if (this.classifyAuthData.length > 0) {
+        // 閬嶅巻鏁扮粍锛屾瘮杈冨悗闈㈢殑瀵硅薄鐨剅oleData鏄惁涓庡墠闈㈢殑瀵硅薄鐩哥瓑
+        for (let i = 0; i < this.classifyAuthData.length - 1; i++) {
+          let currentRoleId = this.classifyAuthData[i].roleData;
+          for (let j = i + 1; j < this.classifyAuthData.length; j++) {
+            if (currentRoleId === this.classifyAuthData[j].roleData) {
+              isRepeat = true;
+              break;
+            }
+          }
+          if (isRepeat) {
             break;
           }
         }
         if (isRepeat) {
-          break;
-        }
-      }
-      if (isRepeat) {
-        this.$message.warning("瑙掕壊鍜屽垎绫诲凡缁忓瓨鍦紝璇烽噸鏂伴厤缃紒");
-        return;
-      }
-      let form = [];
-      let flag = false;
-      this.classifyAuthData.forEach(item => {
-        let itemButtonList = [];
-        //绛涢�夊嚭鎸夐挳鍕鹃�変负true鐨勫垪
-        for (let key in item) {
-          if (item[key] === true) {
-            itemButtonList.push(key);
-          }
-        }
-        /**濡傛灉itemButtonList涓虹┖璇佹槑鏄紝
-         娣诲姞浜嗚鑹蹭絾鏄病鍕鹃�変换浣曠殑鎸夐挳*/
-        if (itemButtonList.length <= 0) {
-          flag = true;
+          this.$message.warning("瑙掕壊鍜屽垎绫诲凡缁忓瓨鍦紝璇烽噸鏂伴厤缃紒");
           return;
         }
-        let data = {
-          oid: item.oid,
-          roleId: item.roleData,
-          classifyId: this.classifyData.oid,
-          buttonIds: itemButtonList.join(","),
-          authType: "data_auth",
-        }
-        form.push(data);
-      });
-      if (flag) {
-        this.$message.warning('鏈夋湭鍕鹃�夋搷浣滅殑鏉冮檺锛屼笉鍏佽鎺堟潈')
-        return;
-      }
-      // console.log(form)
-      // 璋冪敤淇濆瓨鍒嗙被鎺堟潈鐨勬帴鍙�
-      saveOrUpdate(form).then(res => {
-        this.$message({
-          type: "success",
-          message: res.data.msg,
+        let flag = false;
+        this.classifyAuthData.forEach(item => {
+          let itemButtonList = [];
+          //绛涢�夊嚭鎸夐挳鍕鹃�変负true鐨勫垪
+          for (let key in item) {
+            if (item[key] === true) {
+              itemButtonList.push(key);
+            }
+          }
+          /**濡傛灉itemButtonList涓虹┖璇佹槑鏄紝
+           娣诲姞浜嗚鑹蹭絾鏄病鍕鹃�変换浣曠殑鎸夐挳*/
+          if (itemButtonList.length <= 0) {
+            flag = true;
+            return;
+          }
+          let data = {
+            oid: item.oid,
+            roleId: item.roleData,
+            classifyId: this.classifyData.oid,
+            buttonIds: itemButtonList.join(","),
+            authType: "data_auth",
+          }
+          form.classifyAuthList.push(data);
         });
-        // this.isShowDialog = false
-      }, (error) => {
-        window.console.log(error);
-      })
+        if (flag) {
+          this.$message.warning('鏈夋湭鍕鹃�夋搷浣滅殑鏉冮檺锛屼笉鍏佽鎺堟潈')
+          return;
+        }
+        // console.log(form)
+        // 璋冪敤淇濆瓨鍒嗙被鎺堟潈鐨勬帴鍙�
+        await saveOrUpdate(form).then(res => {
+          this.$message({
+            type: "success",
+            message: res.data.msg,
+          });
+          // this.isShowDialog = false
+        }, (error) => {
+          window.console.log(error);
+        })
+      }else{
+        // 涓虹┖璇佹槑鏄竻绌烘巿鏉冨垪琛�
+        form.isCLear = true;
+      }
+      this.classifyAuthData = [];
+      this.loadAuthPage();
     },
     // 鍏ㄩ�夋寜閽�
     selectAllButton() {
@@ -399,6 +343,73 @@
       });
       //console.log("this.selectList",this.selectList);
     },
+    loadAuthPage() {
+      return new Promise((resolve, reject) => {
+        console.log(this.classifyData);
+        getButtonByParentCode({code: this.classifyData.attributes.id}).then(res => {
+          // 璁板綍鎸夐挳鏁版嵁
+          this.classifyAuthButton = res.data.data;
+          const list = res.data.data;
+          let tempData = [];
+          // 瑙掕壊鍒�
+          tempData.push({
+            label: "瑙掕壊",
+            prop: "roleData",
+            type: "select",
+            width: 150,
+          });
+          // 缂栫爜椤瑰垎绫绘巿鏉�
+          tempData.push({
+            label: "缂栫爜椤规暟鎹巿鏉�",
+            prop: "classifyItem",
+            type: "text",
+            width: 180,
+          });
+          list.forEach(item => {
+            let columnItem = {
+              label: item.name,
+              prop: item.id,
+              code: item.code,
+              type: "checkbox",
+              width: 180,
+            };
+            tempData.push(columnItem);
+          })
+          this.classifyAuthHeader = tempData
+          resolve();
+        }).catch(err => {
+          reject(err)
+        });
+        // 鑾峰彇瑙掕壊鍒楄〃
+        getPage(1, -1, null).then(res => {
+          this.roleList = res.data.data.records;
+        });
+        // 鑾峰彇璇ュ垎绫讳笅宸叉巿鏉冪殑鍒嗙被鎺堟潈淇℃伅
+        getClassifyAuthList({classifyId: this.classifyData.oid, authType: "data_auth"}).then(res => {
+          //console.log(res.data.data);
+          let authDatas = res.data.data;
+          if (authDatas.length > 0) {
+            authDatas.forEach((authData, index) => {
+              let item = {
+                oid: authData.oid,
+                roleData: authData.roleId,
+                classifyItem: this.classifyData.label,
+                index: index,
+                authButton:{},
+                uuid: uuidv4(),//鐢熸垚鍞竴鐨刬d
+              }
+              //灏嗘寜閽缃繘鍘�
+              authData.buttonIdList.forEach(data => {
+                Vue.set(item, data, true);
+              });
+              this.classifyAuthData.push(item);
+              this.addIndex = this.classifyAuthData.length - 1; //娣诲姞琛屼笅鏍囩瓑浜巆lassifyAuthData鐨勯暱搴�-1
+              this.roleHandlerMethods(authData.roleId, 'create', index)
+            })
+          }
+        });
+      });
+    },
   },
 };
 </script>
diff --git a/Source/UBCS/ubcs-service-api/ubcs-system-api/src/main/java/com/vci/ubcs/system/dto/ClassifyAuthDTO.java b/Source/UBCS/ubcs-service-api/ubcs-system-api/src/main/java/com/vci/ubcs/system/dto/ClassifyAuthDTO.java
new file mode 100644
index 0000000..78c9f1f
--- /dev/null
+++ b/Source/UBCS/ubcs-service-api/ubcs-system-api/src/main/java/com/vci/ubcs/system/dto/ClassifyAuthDTO.java
@@ -0,0 +1,30 @@
+package com.vci.ubcs.system.dto;
+
+import com.vci.ubcs.system.entity.ClassifyAuth;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.util.List;
+
+/**
+ * @author ludc
+ * @date 2024/1/24 17:57
+ */
+@Data
+public class ClassifyAuthDTO {
+
+
+	private List<ClassifyAuth> classifyAuthList;
+
+	/**
+	 * 鏄惁娓呯┖ true鏄竻绌猴紝false涓嶆槸娓呯┖
+	 */
+//	@NotBlank(message = "蹇呬紶鍙傛暟isCLear涓嶈兘涓虹┖")
+	private Boolean isCLear;
+
+	/**
+	 * 鍒嗙被id
+	 */
+//	@NotBlank(message = "蹇呬紶鍙傛暟classifyId涓嶈兘涓虹┖")
+	private String classifyId;
+}
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
index aced92e..da10e36 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
@@ -562,6 +562,7 @@
 		}
 		if(StringUtils.isNotBlank(id) || StringUtils.isNotBlank(lcStatus) ){
 			//String tableName = this.getTableName(treeQueryObject.getConditionMap().get("btmTypeId"),treeQueryObject.getConditionMap().get("id"), treeQueryObject.getConditionMap().get("lcStatus"));
+			// TODO: 2024-1-24 23:25鎴戝幓鎺変簡鎳掑姞杞斤紝鍥犱负浼氬奖鍝嶆暟鎹巿鏉冭繃婊わ紝鑰屼笖杩欏効鎰熻娌″繀瑕佸仛鎳掑姞杞�
 			doList = codeClassifyMapper
 				.selectCodeClassifyDOByTree(
 					treeQueryObject.getConditionMap().get("id"),
@@ -598,11 +599,8 @@
 			if(!viewClassByRoleIds.isSuccess() && viewClassByRoleIds.getData().isEmpty()){
 				throw new ServiceException("涓绘暟鎹煡鐪嬫潈闄愭湭閰嶇疆锛屾垨閰嶇疆鏈夎锛�");
 			}
-			long startTime = System.currentTimeMillis();
 			// 杩囨护
 			filterTreeNodes(tree,viewClassByRoleIds.getData());
-			long endTime = System.currentTimeMillis();
-			System.out.println(("鎵ц鏃堕棿锛�"+(endTime-startTime)/1000)+"s");
 		}
 		// 鍔犺浇鍒嗙被鏄惁鍏锋湁瀛愬垎绫�
 		tree.parallelStream().forEach(item -> {
@@ -624,7 +622,7 @@
 			/*Boolean checkHasChild = checkHasChild(tree.getOid());
 			tree.setLeaf(!checkHasChild);*/
 			if (classifyIds.contains(tree.getOid())) {
-				// 濡傛灉椤跺眰鑺傜偣瀛樺湪浜� classifyIds 涓紝鐩存帴淇濈暀鍏跺瓙鑺傜偣闆嗗悎
+				// 濡傛灉椤跺眰鑺傜偣瀛樺湪 classifyIds 锛岀洿鎺ヤ繚鐣欏叾瀛愯妭鐐归泦鍚�
 				continue;
 			}
 			if (tree.getChildren() != null && !tree.getChildren().isEmpty()) {
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml
index 870f09a..044e2b9 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml
@@ -320,13 +320,17 @@
         left join pl_code_resemblerule coderesembleruleoid
         on codeclassify0.codeResembleRuleOid = coderesembleruleoid.oid
         where codeclassify0.lcstatus = #{lcstatus}
-        <if test="parentcodeclassifyoid != null and parentcodeclassifyoid != ''">
-            and codeclassify0.parentcodeclassifyoid = #{parentcodeclassifyoid}
-        </if>
-        <if test="parentcodeclassifyoid == null or parentcodeclassifyoid == ''">
-            and codeclassify0.parentcodeclassifyoid is null
-            and codeclassify0.id = #{id}
-        </if>
+        and codeclassify0.parentcodeclassifyoid = (
+            SELECT
+                OID
+            FROM
+                PL_CODE_CLASSIFY
+            WHERE
+                parentcodeclassifyoid IS NULL
+                AND id = #{id}
+        )
+        or codeclassify0.parentcodeclassifyoid IS NULL
+        and codeclassify0.id = #{id}
         <if test="tenantId != null and tenantId != ''">
             and codeclassify0.tenant_id = #{tenantId}
         </if>
diff --git a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/ClassifyAuthController.java b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/ClassifyAuthController.java
index 44ae6dc..e195f4a 100644
--- a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/ClassifyAuthController.java
+++ b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/controller/ClassifyAuthController.java
@@ -1,10 +1,12 @@
 package com.vci.ubcs.system.controller;
 
+import com.vci.ubcs.system.dto.ClassifyAuthDTO;
 import com.vci.ubcs.system.entity.ClassifyAuth;
 import com.vci.ubcs.system.service.IClassifyAuthService;
 import com.vci.ubcs.system.vo.ClassifyAuthVO;
 import io.swagger.annotations.Api;
 import lombok.AllArgsConstructor;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.tenant.annotation.NonDS;
 import org.springblade.core.tool.api.R;
 import org.springframework.web.bind.annotation.*;
@@ -31,12 +33,12 @@
 
 	/**
 	 * 鍒嗙被鎺堟潈淇濆瓨鎺ュ彛
-	 * @param classifyAuthList
+	 * @param classifyAuthListDTO
 	 * @return
 	 */
 	@PostMapping("/saveOrUpdate")
-	public R saveOrUpdate(@RequestBody List<ClassifyAuth> classifyAuthList) {
-		return classifyAuthService.submit(classifyAuthList);
+	public R saveOrUpdate(@RequestBody @Valid ClassifyAuthDTO classifyAuthListDTO) throws ServiceException {
+		return classifyAuthService.submit(classifyAuthListDTO);
 	}
 
 	/**
diff --git a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/IClassifyAuthService.java b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/IClassifyAuthService.java
index 71b0907..3d5bc9b 100644
--- a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/IClassifyAuthService.java
+++ b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/IClassifyAuthService.java
@@ -1,9 +1,11 @@
 package com.vci.ubcs.system.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.vci.ubcs.system.dto.ClassifyAuthDTO;
 import com.vci.ubcs.system.entity.ClassifyAuth;
 import com.vci.ubcs.system.entity.Menu;
 import com.vci.ubcs.system.vo.ClassifyAuthVO;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.tool.api.R;
 
 import java.util.List;
@@ -18,10 +20,10 @@
 
 	/**
 	 * 鍒嗙被鎺堟潈淇濆瓨鎺ュ彛
-	 * @param classifyAuthList
+	 * @param classifyAuthListDTO
 	 * @return
 	 */
-	R submit(List<ClassifyAuth> classifyAuthList);
+	R submit(ClassifyAuthDTO classifyAuthListDTO) throws ServiceException;
 
 	/**
 	 * 鑾峰彇鍒嗙被鎺堟潈闆嗗悎
diff --git a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java
index 124a39c..7bdaf05 100644
--- a/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-system/src/main/java/com/vci/ubcs/system/service/impl/ClassifyAuthServiceImpl.java
@@ -2,10 +2,12 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.vci.ubcs.code.feign.ICodeClassifyClient;
 import com.vci.ubcs.starter.web.util.VciBaseUtil;
+import com.vci.ubcs.system.dto.ClassifyAuthDTO;
 import com.vci.ubcs.system.entity.ClassifyAuth;
 import com.vci.ubcs.system.entity.Menu;
 import com.vci.ubcs.system.mapper.ClassifyAuthMapper;
@@ -44,17 +46,28 @@
 
 	/**
 	 * 鍒嗙被鎺堟潈淇濆瓨鎺ュ彛
-	 * @param classifyAuthList
+	 * @param classifyAuthListDTO
 	 * @return
 	 */
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public R submit(List<ClassifyAuth> classifyAuthList) {
-		if(classifyAuthList.isEmpty()){
+	public R submit(ClassifyAuthDTO classifyAuthListDTO) throws ServiceException{
+		// 鏄竻绌烘巿鏉冨垪琛�
+		if(classifyAuthListDTO.getIsCLear()){
+			if(Func.isEmpty(classifyAuthListDTO.getClassifyId())){
+				return R.fail("娓呯┖鎺堟潈鍒楄〃鏃讹紝鏈幏鍙栫殑鍒嗙被id");
+			}
+			this.classifyAuthMapper.delete(Wrappers.<ClassifyAuth>update()
+				.lambda().eq(ClassifyAuth::getClassifyId, classifyAuthListDTO.getClassifyId())
+			);
+			return R.success("鎺堟潈鍒楄〃娓呯┖鎴愬姛");
+		}
+
+		if(!classifyAuthListDTO.getIsCLear() && classifyAuthListDTO.getClassifyAuthList().isEmpty()){
 			R.fail("鎺堟潈鍒楄〃涓嶈兘涓虹┖锛�");
 		}
 		// 鍒ら噸锛屾煡鐪嬫槸鍚﹀瓨鍦ㄥ悓涓�涓猚lassid涓嬮厤缃簡鐩稿悓鐨勮鑹�
-		Map<String, Long> roleidCounts = classifyAuthList.stream()
+		Map<String, Long> roleidCounts = classifyAuthListDTO.getClassifyAuthList().stream()
 			.collect(Collectors.groupingBy(ClassifyAuth::getRoleId, Collectors.counting()));
 
 		// 妫�鏌ユ槸鍚︽湁roleid鍑虹幇娆℃暟澶т簬1鐨勬儏鍐�
@@ -65,17 +78,17 @@
 		}
 
 		// 濡傛灉浼犺繃鏉ョ殑闆嗗悎涓鍒嗙被id涓嬪垹闄や簡閮ㄥ垎瑙掕壊鐨勬巿鏉冿紝灏遍渶瑕佸皢璇ュ簱涓璫lassifyId涓嬩笉瀛樺湪鐨勬暟鎹垹鎺�
-		List<String> roleIds = classifyAuthList.stream().map(ClassifyAuth::getRoleId).collect(Collectors.toList());
+		List<String> roleIds = classifyAuthListDTO.getClassifyAuthList().stream().map(ClassifyAuth::getRoleId).collect(Collectors.toList());
 		// 鍒犻櫎
 		LambdaUpdateWrapper<ClassifyAuth> updateWrapper = Wrappers.<ClassifyAuth>update()
-			.lambda().eq(ClassifyAuth::getClassifyId, classifyAuthList.get(0).getClassifyId())
+			.lambda().eq(ClassifyAuth::getClassifyId, classifyAuthListDTO.getClassifyAuthList().get(0).getClassifyId())
 			.notIn(ClassifyAuth::getRoleId, roleIds);
 		try {
 			this.classifyAuthMapper.delete(updateWrapper);
 		}catch (Exception e){
 			throw new ServiceException("鍒嗙被鎺堟潈杩囩▼涓嚭鐜伴敊璇紝閿欒鍘熷洜锛�"+e.getMessage());
 		}
-		return R.status(saveOrUpdateBatch(classifyAuthList));
+		return R.status(saveOrUpdateBatch(classifyAuthListDTO.getClassifyAuthList()));
 	}
 
 	/**

--
Gitblit v1.9.3