Selaa lähdekoodia

删除增加删除标识,页面防止连续提交

xusl 2 vuotta sitten
vanhempi
commit
20eab50b99

+ 18 - 18
backend/pom.xml

@@ -201,24 +201,24 @@
                 <version>2.2.1.RELEASE</version>
             </plugin>
         </plugins>
-        <resources>
-            <resource>
-                <directory>src/main/java</directory>
-                <includes>
-                    <include>**/*.properties</include>
-                    <include>**/*.xml</include>
-                </includes>
-                <filtering>false</filtering>
-            </resource>
-            <resource>
-                <directory>src/main/resources</directory>
-                <includes>
-                    <include>**/*.properties</include>
-                    <include>**/*.xml</include>
-                </includes>
-                <filtering>false</filtering>
-            </resource>
-        </resources>
+<!--        <resources>-->
+<!--            <resource>-->
+<!--                <directory>src/main/java</directory>-->
+<!--                <includes>-->
+<!--                    <include>**/*.properties</include>-->
+<!--                    <include>**/*.xml</include>-->
+<!--                </includes>-->
+<!--                <filtering>false</filtering>-->
+<!--            </resource>-->
+<!--            <resource>-->
+<!--                <directory>src/main/resources</directory>-->
+<!--                <includes>-->
+<!--                    <include>**/*.properties</include>-->
+<!--                    <include>**/*.xml</include>-->
+<!--                </includes>-->
+<!--                <filtering>false</filtering>-->
+<!--            </resource>-->
+<!--        </resources>-->
     </build>
     <!--上传配置 必须 -->
     <distributionManagement>

+ 0 - 3
backend/src/main/java/com/jiayue/ssi/config/MybatisPlusConfig.java

@@ -1,14 +1,11 @@
 package com.jiayue.ssi.config;
 
 import com.baomidou.mybatisplus.annotation.DbType;
-import com.baomidou.mybatisplus.core.injector.ISqlInjector;
 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-import java.util.Properties;
-
 /**
  * 注册mp分页
  *

+ 4 - 0
backend/src/main/java/com/jiayue/ssi/constant/Constants.java

@@ -2,6 +2,9 @@ package com.jiayue.ssi.constant;
 
 import io.jsonwebtoken.Claims;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * 通用常量信息
  *
@@ -139,4 +142,5 @@ public class Constants
      */
     public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
             "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config" };
+
 }

+ 32 - 0
backend/src/main/java/com/jiayue/ssi/controller/SysMenuController.java

@@ -125,4 +125,36 @@ public class SysMenuController {
             return ResponseVO.error(null);
         }
     }
+    /**
+     * 删除菜单信息
+     */
+    @DeleteMapping
+    @InterfaceLimit
+    public ResponseVO delete(String menuId) {
+        if (org.apache.commons.lang3.StringUtils.isEmpty(menuId)) {
+            return ResponseVO.fail("删除菜单的id不能为空!");
+        }
+        if (sysMenuService.hasChildByMenuId(Long.parseLong(menuId)))
+        {
+            return ResponseVO.fail("存在子菜单,不允许删除");
+        }
+        ////////////////角色创建后再补这个逻辑
+//        if (sysMenuService.checkMenuExistRole(menuId))
+//        {
+//            return ResponseVO.fail("菜单已分配,不允许删除");
+//        }
+        try {
+            int bo = sysMenuService.deleteMenuById(Long.parseLong(menuId));
+            if (bo == 1) {
+                return ResponseVO.success("删除成功");
+            } else {
+                log.error("删除失败");
+                return ResponseVO.fail("删除失败");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("删除异常");
+            return ResponseVO.error(e);
+        }
+    }
 }

+ 3 - 3
backend/src/main/java/com/jiayue/ssi/entity/SysMenu.java

@@ -23,7 +23,7 @@ public class SysMenu extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
     /** 菜单ID */
-    private Integer menuId;
+    private Long menuId;
 
     /** 菜单名称 */
     private String menuName;
@@ -74,12 +74,12 @@ public class SysMenu extends BaseEntity {
     /** 子菜单 */
     private List<SysMenu> children = new ArrayList<SysMenu>();
 
-    public Integer getMenuId()
+    public Long getMenuId()
     {
         return menuId;
     }
 
-    public void setMenuId(Integer menuId)
+    public void setMenuId(Long menuId)
     {
         this.menuId = menuId;
     }

+ 7 - 4
backend/src/main/java/com/jiayue/ssi/handler/CustomAuthenticationSuccessHandler.java

@@ -44,10 +44,13 @@ public class CustomAuthenticationSuccessHandler extends SavedRequestAwareAuthent
         // 删除缓存邮箱口令
         LocalCache.remove(CacheConstants.MAIL_CODE_KEY + username);
         SysUser sysUser = (SysUser) authentication.getPrincipal();
-        sysUser.setErrNum(0);
-        sysUser.setLockTime(0L);
-        sysUser.setStatus("0");
-        sysUserService.updateUser(sysUser);
+        if (sysUser.getErrNum()>0){
+            sysUser.setErrNum(0);
+            sysUser.setLockTime(0L);
+            sysUser.setStatus("0");
+            sysUserService.updateUser(sysUser);
+        }
+
 
         SecurityContextHolder.getContext().setAuthentication(authentication);
         String token = jwtTokenUtil.generateToken(sysUser);

+ 0 - 2
backend/src/main/java/com/jiayue/ssi/handler/MyMetaObjectHandler.java

@@ -30,8 +30,6 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
         String username = SecurityContextUtil.getSysUser().getUsername();
         this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
         this.strictInsertFill(metaObject, "createBy", String.class, username);
-        this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
-        this.strictInsertFill(metaObject, "updateBy", String.class, username);
     }
 
     /**

+ 2 - 1
backend/src/main/java/com/jiayue/ssi/mapper/SysMenuMapper.java

@@ -115,10 +115,11 @@ public interface SysMenuMapper  extends BaseMapper<SysMenu> {
     /**
      * 删除菜单管理信息
      *
+     * @param updateBy 修改人
      * @param menuId 菜单ID
      * @return 结果
      */
-    public int deleteMenuById(Long menuId);
+    public int deleteMenuById(String updateBy,Long menuId);
 
     /**
      * 校验菜单名称是否唯一

+ 14 - 0
backend/src/main/java/com/jiayue/ssi/service/SysMenuService.java

@@ -62,4 +62,18 @@ public interface SysMenuService  extends IService<SysMenu> {
      * @return 结果
      */
     int updateMenu(SysMenu menu);
+    /**
+     * 是否存在菜单子节点
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    boolean hasChildByMenuId(Long menuId);
+    /**
+     * 删除菜单管理信息
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    int deleteMenuById(Long menuId);
 }

+ 36 - 2
backend/src/main/java/com/jiayue/ssi/service/impl/SysMenuServiceImpl.java

@@ -294,7 +294,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
      */
     @Override
     public int insertMenu(SysMenu menu) {
-        menu.setCreateBy(SecurityContextUtil.getSysUser().getCreateBy());
+        menu.setCreateBy(SecurityContextUtil.getSysUser().getUsername());
         return menuMapper.insertMenu(menu);
     }
 
@@ -318,7 +318,41 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
      */
     @Override
     public SysMenu selectMenuById(Long menuId) {
-
         return menuMapper.selectMenuById(menuId);
     }
+
+    /**
+     * 是否存在菜单子节点
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    @Override
+    public boolean hasChildByMenuId(Long menuId) {
+        int result = menuMapper.hasChildByMenuId(menuId);
+        return result > 0;
+    }
+    // /**
+    // * 查询菜单使用数量
+    // *
+    // * @param menuId 菜单ID
+    // * @return 结果
+    // */
+    // @Override
+    // public boolean checkMenuExistRole(Long menuId)
+    // {
+    // int result = roleMenuMapper.checkMenuExistRole(menuId);
+    // return result > 0;
+    // }
+
+    /**
+     * 删除菜单管理信息
+     *
+     * @param menuId 菜单ID
+     * @return 结果
+     */
+    @Override
+    public int deleteMenuById(Long menuId) {
+        return menuMapper.deleteMenuById(SecurityContextUtil.getSysUser().getUsername(),menuId);
+    }
 }

+ 21 - 15
backend/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -25,6 +25,7 @@
 		<result property="updateTime"     column="update_time"    />
 		<result property="updateBy"       column="update_by"      />
 		<result property="remark"         column="remark"         />
+		<result property="delFlag"         column="del_flag"         />
 	</resultMap>
 
 	<sql id="selectMenuVo">
@@ -35,6 +36,7 @@
     <select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
 		<include refid="selectMenuVo"/>
 		<where>
+			del_flag=0
 			<if test="menuName != null and menuName != ''">
 				AND menu_name like concat('%', #{menuName}, '%')
 			</if>
@@ -50,7 +52,7 @@
 
 	<select id="selectMenuTreeAll" resultMap="SysMenuResult">
 		select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
-		from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
+		from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0 and del_flag=0
 		order by m.parent_id, m.order_num
 	</select>
 
@@ -60,7 +62,7 @@
 		left join sys_role_menu rm on m.menu_id = rm.menu_id
 		left join sys_user_role ur on rm.role_id = ur.role_id
 		left join sys_role ro on ur.role_id = ro.role_id
-		where ur.user_id = #{params.userId}
+		where m.del_flag=0 and ur.user_id = #{params.userId}
 		<if test="menuName != null and menuName != ''">
             AND m.menu_name like concat('%', #{menuName}, '%')
 		</if>
@@ -80,7 +82,7 @@
 			 left join sys_user_role ur on rm.role_id = ur.role_id
 			 left join sys_role ro on ur.role_id = ro.role_id
 			 left join sys_user u on ur.user_id = u.user_id
-		where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0  AND ro.status = 0
+		where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0  AND ro.status = 0 and m.del_flag=0 and u.del_flag=0
 		order by m.parent_id, m.order_num
 	</select>
 
@@ -88,7 +90,8 @@
 		select m.menu_id
 		from sys_menu m
             left join sys_role_menu rm on m.menu_id = rm.menu_id
-        where rm.role_id = #{roleId}
+        where m.del_flag=0
+              and rm.role_id = #{roleId}
             <if test="menuCheckStrictly">
               and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
             </if>
@@ -100,6 +103,7 @@
 		from sys_menu m
 			 left join sys_role_menu rm on m.menu_id = rm.menu_id
 			 left join sys_user_role ur on rm.role_id = ur.role_id
+		where m.del_flag=0
 	</select>
 
 	<select id="selectMenuPermsByUserId" parameterType="Long" resultType="String">
@@ -108,28 +112,28 @@
 			 left join sys_role_menu rm on m.menu_id = rm.menu_id
 			 left join sys_user_role ur on rm.role_id = ur.role_id
 			 left join sys_role r on r.role_id = ur.role_id
-		where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
+		where m.status = '0' and r.status = '0' and ur.user_id = #{userId} and del_flag=0
 	</select>
 
 	<select id="selectMenuPermsByRoleId" parameterType="Long" resultType="String">
 		select distinct m.perms
 		from sys_menu m
 			 left join sys_role_menu rm on m.menu_id = rm.menu_id
-		where m.status = '0' and rm.role_id = #{roleId}
+		where m.status = '0' and rm.role_id = #{roleId} and m.del_flag=0 and rm.del_flag=0
 	</select>
 
 	<select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
 		<include refid="selectMenuVo"/>
-		where menu_id = #{menuId}
+		where menu_id = #{menuId} and del_flag=0
 	</select>
 
-	<select id="hasChildByMenuId" resultType="Long">
-	    select count(1) from sys_menu where parent_id = #{menuId}
+	<select id="hasChildByMenuId" resultType="Integer">
+	    select count(1) from sys_menu where parent_id = #{menuId} and del_flag=0
 	</select>
 
 	<select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult">
 		<include refid="selectMenuVo"/>
-		where menu_name=#{menuName} and parent_id = #{parentId} limit 1
+		where menu_name=#{menuName} and parent_id = #{parentId} and del_flag=0 limit 1
 	</select>
 
 	<update id="updateMenu" parameterType="SysMenu">
@@ -152,7 +156,7 @@
 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
 			update_time = sysdate()
 		</set>
-		where menu_id = #{menuId}
+		where menu_id = #{menuId} and del_flag=0
 	</update>
 
 	<insert id="insertMenu" parameterType="SysMenu">
@@ -173,7 +177,8 @@
 		<if test="icon != null and icon != ''">icon,</if>
 		<if test="remark != null and remark != ''">remark,</if>
 		<if test="createBy != null and createBy != ''">create_by,</if>
-		create_time
+		create_time,
+		del_flag
 		)values(
 		<if test="menuId != null and menuId != 0">#{menuId},</if>
 		<if test="parentId != null and parentId != 0">#{parentId},</if>
@@ -191,12 +196,13 @@
 		<if test="icon != null and icon != ''">#{icon},</if>
 		<if test="remark != null and remark != ''">#{remark},</if>
 		<if test="createBy != null and createBy != ''">#{createBy},</if>
-		sysdate()
+		sysdate(),
+		0
 		)
 	</insert>
 
-	<delete id="deleteMenuById" parameterType="Long">
-	    delete from sys_menu where menu_id = #{menuId}
+	<delete id="deleteMenuById">
+	    update sys_menu set del_flag=1,update_by=#{updateBy},update_time=sysdate() where menu_id = #{menuId} and del_flag=0
 	</delete>
 
 </mapper>

+ 49 - 18
ui/src/views/sysManager/sysMenu/index.vue

@@ -274,7 +274,7 @@
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import IconSelect from "@/components/IconSelect";
-
+import { debounce } from 'lodash'
 export default {
   name: "Menu",
   dicts: ['sys_show_hide', 'sys_normal_disable'],
@@ -347,14 +347,15 @@ export default {
       this.form.icon = name
     },
     /** 查询菜单列表 */
-    getList() {
+    getList:debounce(function(){
       this.loading = true;
-
       this.$axios.get('/sysMenuController/list',{params: this.queryParams}).then((res) => {
         this.menuList = this.handleTree(res.data, "menuId")
-        this.loading = false
+      }).catch((error) => {
+        console.log(error)
       })
-    },
+      this.loading = false;
+    },1000),
     /** 转换菜单数据结构 */
     normalizer(node) {
       if (node.children && !node.children.length) {
@@ -403,10 +404,9 @@ export default {
     /** 重置按钮操作 */
     resetQuery() {
       this.resetForm("queryForm")
-      this.handleQuery()
     },
     /** 新增按钮操作 */
-    handleAdd(row) {
+    handleAdd:debounce(function(row){
       this.reset()
       this.getTreeselect();
       if (row != null && row.menuId) {
@@ -416,7 +416,7 @@ export default {
       }
       this.open = true
       this.title = "添加菜单"
-    },
+    },500),
     /** 展开/折叠操作 */
     toggleExpandAll() {
       this.refreshTable = false
@@ -426,7 +426,7 @@ export default {
       });
     },
     /** 修改按钮操作 */
-    handleUpdate(row) {
+    handleUpdate:debounce(function(row){
       this.reset()
       this.getTreeselect()
       var searchParams = {
@@ -440,9 +440,9 @@ export default {
       }).catch((error) => {
         // this.$message.error('获取数据出错' + error)
       })
-    },
+    },500),
     /** 提交按钮 */
-    submitForm: function() {
+    submitForm:debounce(function(){
       this.$refs["form"].validate(valid => {
         if (valid) {
           if (this.form.menuId != undefined) {
@@ -474,16 +474,47 @@ export default {
           }
         }
       });
-    },
+    },1000),
     /** 删除按钮操作 */
     handleDelete(row) {
-      this.$modal.confirm('是否确认删除名称为"' + row.menuName + '"的数据项?').then(function() {
-        return delMenu(row.menuId)
+      this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
       }).then(() => {
-        this.getList()
-        this.$modal.msgSuccess("删除成功");
-      }).catch(() => {})
-    }
+        this.doDelete(row)
+      }).catch(() => {
+      });
+    },
+    /**
+     * 删除提交
+     */
+    doDelete:debounce(function(row){
+      const param = {
+        menuId: row.menuId
+      }
+      this.$axios.delete('/sysMenuController', {data:param}).then((res) => {
+        if (res.code == 0) {
+          this.$message({
+            type: 'success',
+            message: '删除成功!'
+          });
+        } else {
+          this.$message({
+            type: 'error',
+            message: res.data
+          });
+        }
+        this.getList();
+      }).catch((error) => {
+        this.$message({
+          type: 'error',
+          message: '删除失败!'
+        });
+        console.log(error)
+        this.loading = false
+      })
+    },1000)
   }
 }
 </script>

+ 0 - 1
ui/src/views/sysManager/sysParameter/index.vue

@@ -186,7 +186,6 @@ export default {
       this.$refs.xTable.setActiveRow(row)
     },
     saveRowEvent:debounce(function(row){
-      console.log(row)
       this.saveLoding = true
       this.$refs.xTable.validate(valid => {
         if (valid) {

+ 35 - 21
ui/src/views/sysManager/userManager/index.vue

@@ -420,10 +420,14 @@ export default {
           } else {
             this.$message({
               type: 'error',
-              message: '创建密码失败!'
+              message: res.data
             });
           }
         }).catch((error) => {
+          this.$message({
+            type: 'error',
+            message: '创建密码失败!'
+          });
           console.log(error)
           this.loading = false
         })
@@ -445,29 +449,39 @@ export default {
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
-        const param = {
-          id: _selectData.id
-        }
-        this.$axios.post('/sysUserController/delUser', param).then((res) => {
-          if (res.code == 0) {
-            this.$message({
-              type: 'success',
-              message: '删除成功!'
-            });
-            this.getList();
-          } else {
-            this.$message({
-              type: 'error',
-              message: '删除失败!'
-            });
-          }
-        }).catch((error) => {
-          console.log(error)
-          this.loading = false
-        })
+        this.doDelete(_selectData)
       }).catch(() => {
       });
     },
+    /**
+     * 删除提交
+     */
+    doDelete:debounce(function(_selectData){
+      const param = {
+        id: _selectData.id
+      }
+      this.$axios.post('/sysUserController/delUser', param).then((res) => {
+        if (res.code == 0) {
+          this.$message({
+            type: 'success',
+            message: '删除成功!'
+          });
+          this.getList();
+        } else {
+          this.$message({
+            type: 'error',
+            message: res.data
+          });
+        }
+      }).catch((error) => {
+        this.$message({
+          type: 'error',
+          message: '删除失败!'
+        });
+        console.log(error)
+        this.loading = false
+      })
+    },1000),
     /** 修改按钮操作 */
     handleUpdate() {
       this.reset();