Browse Source

权限菜单批量删除

侯茂昌 1 năm trước cách đây
mục cha
commit
d8ca281d41

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java

@@ -14,7 +14,7 @@ public class RuoYiApplication
 {
     public static void main(String[] args)
     {
-        // System.setProperty("spring.devtools.restart.enabled", "false");
+        //System.setProperty("spring.devtools.restart.enabled", "false");
         SpringApplication.run(RuoYiApplication.class, args);
         System.out.println("(♥◠‿◠)ノ゙  若依启动成功   ლ(´ڡ`ლ)゙  \n" +
                 " .-------.       ____     __        \n" +

+ 5 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java

@@ -47,11 +47,11 @@ public class CaptchaController
     {
         AjaxResult ajax = AjaxResult.success();
         boolean captchaEnabled = configService.selectCaptchaEnabled();
-        ajax.put("captchaEnabled", captchaEnabled);
-        if (!captchaEnabled)
-        {
-            return ajax;
-        }
+        //ajax.put("captchaEnabled", captchaEnabled);
+        //if (!captchaEnabled)
+        //{
+        //    return ajax;
+        //}
 
         // 保存验证码信息
         String uuid = IdUtils.simpleUUID();

+ 17 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java

@@ -6,14 +6,7 @@ import com.ruoyi.common.annotation.Anonymous;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.controller.BaseController;
@@ -129,6 +122,22 @@ public class SysMenuController extends BaseController {
         return toAjax(menuService.deleteMenuById(menuId));
     }
 
+    /**
+     * 批量删除菜单
+     */
+    @Log(title = "菜单管理", businessType = BusinessType.DELETE)
+    @DeleteMapping("/removeBatch")
+    public AjaxResult removeBatch(@RequestParam("menuIds") List<String> menuIds) {
+        if(menuService.hasChildByMenuIdBatchRemove(menuIds)){
+            return warn("当前选择的菜单中、存在子菜单,不允许删除");
+        }
+        if(menuService.checkMenuExistRoleBatchRemove(menuIds)){
+            return warn("当前选择的菜单中、菜单已分配,不允许删除");
+        }
+        return toAjax(menuService.batchDeleteMenuByIds(menuIds));
+    }
+
+
     /**
      * 动态表格获取菜单
      */

+ 18 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java

@@ -105,6 +105,14 @@ public interface SysMenuMapper {
      */
     public int hasChildByMenuId(Long menuId);
 
+    /**
+     * 批量删除判断是否存在菜单子节点
+     *
+     * @param menuIds 菜单ID
+     * @return 结果
+     */
+    public int hasChildByMenuIdBatchRemove(List<Long> menuIds);
+
     /**
      * 新增菜单信息
      *
@@ -129,6 +137,14 @@ public interface SysMenuMapper {
      */
     public int deleteMenuById(Long menuId);
 
+    /**
+     * 批量删除菜单管理信息
+     *
+     * @param menuIds 菜单ID
+     * @return 结果
+     */
+    int batchDeleteMenuById(List menuIds);
+
     /**
      * 校验菜单名称是否唯一
      *
@@ -155,4 +171,6 @@ public interface SysMenuMapper {
      * 根据菜单编号查询
      */
     List<SysMenu> selectMenusByIds(List<Long> ids);
+
+
 }

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java

@@ -18,6 +18,14 @@ public interface SysRoleMenuMapper
      */
     public int checkMenuExistRole(Long menuId);
 
+    /**
+     * 批量删除查询菜单使用数量
+     *
+     * @param menuIds 菜单ID集合
+     * @return 结果
+     */
+    public int checkMenuExistRoleBatchRemove(List menuIds);
+
     /**
      * 通过角色ID删除角色和菜单关联
      * 

+ 25 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java

@@ -102,6 +102,15 @@ public interface ISysMenuService
      */
     public boolean hasChildByMenuId(Long menuId);
 
+    /**
+     * 批量删除判断是否存在菜单子节点
+     *
+     * @param menuIds 菜单ID集合
+     * @return 结果 true 存在 false 不存在
+     */
+    public boolean hasChildByMenuIdBatchRemove(List menuIds);
+
+
     /**
      * 查询菜单是否存在角色
      * 
@@ -110,6 +119,14 @@ public interface ISysMenuService
      */
     public boolean checkMenuExistRole(Long menuId);
 
+    /**
+     * 批量删除查询菜单是否存在角色
+     *
+     * @param menuIds 菜单ID 集合
+     * @return 结果 true 存在 false 不存在
+     */
+    public boolean checkMenuExistRoleBatchRemove(List menuIds);
+
     /**
      * 新增保存菜单信息
      * 
@@ -134,6 +151,14 @@ public interface ISysMenuService
      */
     public int deleteMenuById(Long menuId);
 
+    /**
+     * 批量删除菜单管理信息
+     *
+     * @param menuIds 菜单ID
+     * @return 结果
+     */
+    public int batchDeleteMenuByIds(List menuIds);
+
     /**
      * 校验菜单名称是否唯一
      * 

+ 34 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java

@@ -266,6 +266,18 @@ public class SysMenuServiceImpl implements ISysMenuService {
         return result > 0;
     }
 
+    /**
+     * 批量删除是否存在菜单子节点
+     *
+     * @param menuIds 菜单ID
+     * @return 结果
+     */
+    @Override
+    public boolean hasChildByMenuIdBatchRemove(List menuIds) {
+        int result = menuMapper.hasChildByMenuIdBatchRemove(menuIds);
+        return result > 0;
+    }
+
     /**
      * 查询菜单使用数量
      *
@@ -278,6 +290,18 @@ public class SysMenuServiceImpl implements ISysMenuService {
         return result > 0;
     }
 
+    /**
+     * 批量删除查询菜单使用数量
+     *
+     * @param menuIds 菜单ID 集合
+     * @return 结果
+     */
+    @Override
+    public boolean checkMenuExistRoleBatchRemove(List menuIds) {
+        int result = roleMenuMapper.checkMenuExistRoleBatchRemove(menuIds);
+        return result > 0;
+    }
+
     /**
      * 新增保存菜单信息
      *
@@ -310,6 +334,16 @@ public class SysMenuServiceImpl implements ISysMenuService {
     public int deleteMenuById(Long menuId) {
         return menuMapper.deleteMenuById(menuId);
     }
+    /**
+     * 批量删除菜单管理信息
+     *
+     * @param menuIds 菜单ID
+     * @return 结果
+     */
+    @Override
+    public int batchDeleteMenuByIds(List menuIds) {
+        return menuMapper.batchDeleteMenuById(menuIds);
+    }
 
     /**
      * 校验菜单名称是否唯一

+ 12 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTenantServiceImpl.java

@@ -236,7 +236,7 @@ public class SysTenantServiceImpl implements ISysTenantService
     @Override
     public AjaxResult activationOperation(String tenantId, String activationCode) throws Exception {
         String activeCode="active:code:"+activationCode;//魔法值后期抽出来
-        String strCode = stringRedisTemplate.opsForValue().get(activationCode);
+        String strCode = stringRedisTemplate.opsForValue().get(activeCode);
         if(StringUtils.isNotEmpty(strCode)){
             return AjaxResult.error("当前激活码已经被使用过了不能重复使用");
         }
@@ -330,6 +330,16 @@ public class SysTenantServiceImpl implements ISysTenantService
     }
 
 
-
+    public static void main(String[] args) {
+        //校验充值天数是否正确
+        SymmetricCrypto symmetricCrypto = new SymmetricCrypto(SymmetricAlgorithm.DES, "sgEsnN6QWq8W7j5H01020304".getBytes());
+        String a = symmetricCrypto.decryptStr("facb3dad9a590c24584416fd0e9690e6ad8116cefdd53d5f");
+        System.out.println(a);
+        //判断如果用户过期了
+        LocalDateTime activeDateTime = LocalDateTimeUtil.offset(LocalDateTime.now(), -100, ChronoUnit.DAYS);
+        String activeDateTimeStr = DateUtils.toLocalDateTimeStr(activeDateTime);
+        String newActiveDateTimeStr= symmetricCrypto.encryptHex(activeDateTimeStr);
+        System.out.println(newActiveDateTimeStr);
+    }
 
 }

+ 16 - 1
ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -170,8 +170,16 @@
 	</select>
 	
 	<select id="hasChildByMenuId" resultType="Integer">
-	    select count(1) from sys_menu where parent_id = #{menuId}  
+	    select count(1) from sys_menu where parent_id = #{menuId}
 	</select>
+
+	<select id="hasChildByMenuIdBatchRemove" resultType="Integer" parameterType="java.util.List">
+		select count(1) from sys_menu where parent_id in
+		<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
+			#{item, jdbcType=VARCHAR}
+		</foreach>
+	</select>
+
 <!--	<include refid="selectMenuVo"/>-->
 	<select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult">
         SELECT sys.menu_id,
@@ -266,6 +274,13 @@
 	    delete from sys_menu where menu_id = #{menuId}
 	</delete>
 
+	<delete id="batchDeleteMenuById">
+		delete from sys_menu where menu_id in
+		<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
+			#{item, jdbcType=VARCHAR}
+		</foreach>
+	</delete>
+
 	<select id="getMenuList" resultMap="SysMenuResult">
 		SELECT
 			m.menu_id,

+ 7 - 0
ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml

@@ -13,6 +13,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	    select count(1) from sys_role_menu where menu_id = #{menuId}
 	</select>
 
+	<select id="checkMenuExistRoleBatchRemove" resultType="Integer" parameterType="java.util.List">
+		select count(1) from sys_role_menu where menu_id in
+		<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
+			#{item, jdbcType=VARCHAR}
+		</foreach>
+	</select>
+
 	<delete id="deleteRoleMenuByRoleId" parameterType="Long">
 		delete from sys_role_menu where role_id=#{roleId}
 	</delete>

+ 5 - 0
ruoyi-ui/src/views/system/bpmnPro/components/Toolbar/tools/Save.vue

@@ -175,8 +175,12 @@ export default {
       if (!data.bpmProcessConfigurationList.length) return;
       data.bpmProcessConfigurationList.forEach((item) => {
         item.createBy = this.$store.state.user.name;
+        item.createById = this.$store.state.user.userId;
         item.nodeProcessKey = obj.getElementsByTagName("bpmn:process")[0].id;
         item.createTime = moment().format("YYYY-MM-DD HH:mm:ss");
+        item.updateBy = this.$store.state.user.name;
+        item.updateById = this.$store.state.user.userId;
+        item.updateTime = moment().format("YYYY-MM-DD HH:mm:ss");
       });
       try {
         let res = await addConfiguration(data);
@@ -190,6 +194,7 @@ export default {
       if (!theData.bpmProcessConfigurationList.length) return;
       theData.bpmProcessConfigurationList.forEach((item) => {
         item.updateBy = this.$store.state.user.name;
+        item.updateById = this.$store.state.user.userId;
         item.nodeProcessKey = obj.getElementsByTagName("bpmn:process")[0].id;
         item.updateTime = moment().format("YYYY-MM-DD HH:mm:ss");
       });

+ 0 - 1
ruoyi-ui/src/views/system/tenant/code/index.vue

@@ -218,7 +218,6 @@ export default {
       });
       clipboard.on('success', () => {
         this.activationCodeForm=false;
-        console.log('');
         this.$message({showClose: true, message: '文本已成功复制到剪贴板', type: 'success'});
         clipboard.destroy(); //清除 Clipboard 实例
       });

+ 0 - 5
ruoyi-ui/src/views/system/tenant/index.vue

@@ -745,19 +745,14 @@ export default {
     /**打开激活码弹窗*/
     openTenantExpirationTime(row) {
       this.reset();
-      console.log(this)
       const tenantId = row.tenantId || this.ids;
-      console.log(tenantId)
       this.tenantExpirationTimeFrom.tenantId= row.tenantId
       this.tenantExpirationTimeOpen=true;
       this.title="激活租户";
     },
     /**激活租户操作*/
     activationOperationMethod(){
-      console.log("激活租户");
-      console.log(this.tenantExpirationTimeFrom.tenantExpirationTime);
       this.$refs["form"].validate((valid) => {
-        console.log(valid)
         if (valid) {
           activationOperation(this.tenantExpirationTimeFrom).then((response) => {
             this.$modal.msgSuccess("激活成功");