Jelajahi Sumber

Merge branch 'master' of http://192.168.101.10:13000/boman/boman-framwork

sr 4 tahun lalu
induk
melakukan
a796364ca3
19 mengubah file dengan 261 tambahan dan 16 penghapusan
  1. 7 0
      boman-api/boman-api-system/src/main/java/com/boman/system/api/domain/SysMenu.java
  2. 27 0
      boman-api/boman-api-web-core/pom.xml
  3. 25 0
      boman-api/boman-api-web-core/src/main/java/com/boman/web/core/api/RemoteObjService.java
  4. 1 0
      boman-api/pom.xml
  5. 6 0
      boman-modules/boman-system/pom.xml
  6. 7 2
      boman-modules/boman-system/src/main/java/com/boman/system/controller/SysMenuController.java
  7. 32 0
      boman-modules/boman-system/src/main/java/com/boman/system/controller/SysRoleMenuController.java
  8. 9 0
      boman-modules/boman-system/src/main/java/com/boman/system/domain/SysRoleData.java
  9. 11 0
      boman-modules/boman-system/src/main/java/com/boman/system/domain/SysRoleMenu.java
  10. 8 0
      boman-modules/boman-system/src/main/java/com/boman/system/service/ISysMenuService.java
  11. 23 0
      boman-modules/boman-system/src/main/java/com/boman/system/service/impl/ISysRoleMenuService.java
  12. 37 8
      boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysMenuServiceImpl.java
  13. 45 0
      boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysRoleMenuServiceImpl.java
  14. 1 1
      boman-modules/boman-system/src/main/resources/mapper/system/SysMenuMapper.xml
  15. 3 2
      boman-modules/boman-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml
  16. 12 0
      boman-web-core/src/main/java/com/boman/web/core/controller/CommonController.java
  17. 0 3
      boman-web-core/src/main/java/com/boman/web/core/controller/ObjController.java
  18. 5 0
      boman-web-core/src/main/java/com/boman/web/core/service/common/CommonServiceImpl.java
  19. 2 0
      boman-web-core/src/main/java/com/boman/web/core/service/common/ICommonService.java

+ 7 - 0
boman-api/boman-api-system/src/main/java/com/boman/system/api/domain/SysMenu.java

@@ -19,6 +19,13 @@ public class SysMenu extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
 
+    /** 目录*/
+    public static final String DICTIONARY = "M";
+    /** 菜单*/
+    public static final String MENU = "C";
+    /** 按钮*/
+    public static final String BUTTON = "F";
+
     /** 菜单ID */
     private Long id;
 

+ 27 - 0
boman-api/boman-api-web-core/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<parent>
+    <groupId>com.boman</groupId>
+    <artifactId>boman-api</artifactId>
+    <version>2.5.0-SNAPSHOT</version>
+</parent>
+<modelVersion>4.0.0</modelVersion>
+
+<artifactId>boman-api-web-core</artifactId>
+
+<description>
+    boman-api-web-core系统接口模块
+</description>
+
+<dependencies>
+    <dependency>
+        <groupId>com.boman</groupId>
+        <artifactId>boman-domain</artifactId>
+        <version>2.5.0-SNAPSHOT</version>
+    </dependency>
+
+</dependencies>
+
+</project>

+ 25 - 0
boman-api/boman-api-web-core/src/main/java/com/boman/web/core/api/RemoteObjService.java

@@ -0,0 +1,25 @@
+package com.boman.web.core.api;
+
+import com.boman.common.core.constant.ServiceNameConstants;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+
+/**
+ * @author shiqian
+ * @date 2021年04月07日 10:31
+ **/
+@FeignClient(contextId = "remoteObjService", value = ServiceNameConstants.SYSTEM_SERVICE)
+public interface RemoteObjService {
+
+    /**
+     * 功能描述: 根据id查找
+     *
+     * @param tableName tableName
+     * @param pkName    pkName
+     * @return com.boman.common.core.web.domain.AjaxResult
+     */
+    @GetMapping("common/tableName/{tableName}/pkName/{pkName}")
+    Long getMaxId(@PathVariable("tableName") String tableName, @PathVariable("pkName") String pkName);
+}
+

+ 1 - 0
boman-api/pom.xml

@@ -12,6 +12,7 @@
         <module>boman-api-system</module>
         <module>boman-api-gen</module>
         <module>boman-domain</module>
+        <module>boman-api-web-core</module>
     </modules>
 
     <artifactId>boman-api</artifactId>

+ 6 - 0
boman-modules/boman-system/pom.xml

@@ -90,6 +90,12 @@
             <version>1.18.4</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.boman</groupId>
+            <artifactId>boman-api-web-core</artifactId>
+            <version>2.5.0-SNAPSHOT</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 7 - 2
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysMenuController.java

@@ -72,8 +72,8 @@ public class SysMenuController extends BaseController
     /**
      * 加载对应角色菜单列表树, 不包含叶子结点 不包含叶子结点 不包含叶子结点 重要的事情说三遍
      */
-    @GetMapping(value = "/roleMenuTreeselect/{roleId}")
-    public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
+    @GetMapping(value = "/treeMenuNotAddLeafNode/{roleId}")
+    public AjaxResult treeMenuNotAddLeafNode(@PathVariable("roleId") Long roleId)
     {
         Long userId = SecurityUtils.getUserId();
         List<SysMenu> menus = menuService.selectMenuList(userId);
@@ -83,6 +83,11 @@ public class SysMenuController extends BaseController
         return ajax;
     }
 
+    @GetMapping(value = "/allLeafNodeById/{menuId}")
+    public AjaxResult allLeafNodeById(@PathVariable("menuId") Long menuId) {
+        return AjaxResult.success(menuService.allLeafNodeById(menuId));
+    }
+
     /**
      * 新增菜单
      */

+ 32 - 0
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysRoleMenuController.java

@@ -0,0 +1,32 @@
+package com.boman.system.controller;
+
+import com.boman.common.core.web.domain.AjaxResult;
+import com.boman.system.domain.SysRoleMenu;
+import com.boman.system.service.impl.ISysRoleMenuService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @author shiqian
+ * @date 2021年04月27日 14:31
+ **/
+@RestController
+@RequestMapping("/role/menu")
+public class SysRoleMenuController {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(SysRoleMenuController.class);
+
+    @Resource
+    private ISysRoleMenuService service;
+    @PostMapping
+    public AjaxResult list(@RequestBody List<SysRoleMenu> roleMenuList) {
+        return AjaxResult.success(service.saveList(roleMenuList));
+    }
+}

+ 9 - 0
boman-modules/boman-system/src/main/java/com/boman/system/domain/SysRoleData.java

@@ -13,6 +13,15 @@ public class SysRoleData extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
 
+    /**
+     * 1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)5 :仅本人数据
+     */
+    public static final String ALL_DATA = "1";
+    public static final String DIY_DATA = "2";
+    public static final String SELF_DEPT_DATA = "3";
+    public static final String ALL_DEPT_DATA = "4";
+    public static final String MYSELF_DATA = "5";
+
     /** 角色权限id */
     private Long id;
 

+ 11 - 0
boman-modules/boman-system/src/main/java/com/boman/system/domain/SysRoleMenu.java

@@ -10,12 +10,23 @@ import org.apache.commons.lang3.builder.ToStringStyle;
  */
 public class SysRoleMenu
 {
+    /** id */
+    private Long id;
+
     /** 角色ID */
     private Long roleId;
     
     /** 菜单ID */
     private Long menuId;
 
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
     public Long getRoleId()
     {
         return roleId;

+ 8 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/ISysMenuService.java

@@ -49,6 +49,14 @@ public interface ISysMenuService
      */
     public List<SysMenu> selectMenuTreeById(Long id);
 
+    /**
+     * 根据用户ID查询菜单树信息
+     *
+     * @param menuId menuId
+     * @return 菜单列表
+     */
+    List<SysMenu> allLeafNodeById(Long menuId);
+
     /**
      * 根据角色ID查询菜单树信息
      * 

+ 23 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/ISysRoleMenuService.java

@@ -0,0 +1,23 @@
+package com.boman.system.service.impl;
+
+import com.boman.system.domain.SysRoleMenu;
+
+import java.util.List;
+
+/**
+ * 参数配置 服务层
+ *
+ * @author ruoyi
+ */
+public interface ISysRoleMenuService {
+
+    /**
+     * 功能描述: 批量保存roleMenu
+     *
+     * @param roleMenuList roleMenuList
+     * @return boolean
+     */
+    int saveList(List<SysRoleMenu> roleMenuList);
+
+
+}

+ 37 - 8
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysMenuServiceImpl.java

@@ -1,17 +1,12 @@
 package com.boman.system.service.impl;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.core.web.domain.AjaxResult;
 import com.boman.system.api.domain.SysMenu;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.boman.common.core.constant.UserConstants;
@@ -123,6 +118,40 @@ public class SysMenuServiceImpl implements ISysMenuService
         return getChildPerms(menus, 0);
     }
 
+    /**
+     * 根据用户ID查询菜单树信息
+     *
+     * @param menuId menuId
+     * @return 菜单列表
+     */
+    @Override
+    public List<SysMenu> allLeafNodeById(Long menuId) {
+        List<SysMenu> tempList = Lists.newArrayListWithCapacity(16);
+        SysMenu menu = selectMenuById(menuId);
+        List<SysMenu> menus = menuMapper.selectMenuList(new SysMenu());
+        List<SysMenu> sysMenus = recursionList(menus, menu, tempList);
+        return ObjectUtils.filter(sysMenus, menu1 -> SysMenu.BUTTON.equals(menu1.getMenuType()));
+    }
+
+    private List<SysMenu> recursionList(List<SysMenu> menus, SysMenu menu, List<SysMenu> tempList) {
+        int child = 0;
+        // 得到子节点列表
+        List<SysMenu> childList = getChildList(menus, menu);
+        for (SysMenu tChild : childList) {
+            if (hasChild(menus, tChild)) {
+                recursionList(menus, tChild, tempList);
+            } else {
+                child++;
+            }
+        }
+
+        if (child == childList.size() && childList.size() != 0) {
+            tempList.addAll(childList);
+        }
+
+        return tempList;
+    }
+
     /**
      * 根据角色ID查询菜单树信息
      * 
@@ -521,6 +550,6 @@ public class SysMenuServiceImpl implements ISysMenuService
      */
     private boolean hasChild(List<SysMenu> list, SysMenu t)
     {
-        return getChildList(list, t).size() > 0 ? true : false;
+        return getChildList(list, t).size() > 0;
     }
 }

+ 45 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysRoleMenuServiceImpl.java

@@ -0,0 +1,45 @@
+package com.boman.system.service.impl;
+
+import com.boman.system.domain.SysRoleMenu;
+import com.boman.system.mapper.SysRoleMenuMapper;
+import com.boman.web.core.api.RemoteObjService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+import static com.boman.common.core.utils.obj.ObjectUtils.isEmpty;
+
+/**
+ * @author shiqian
+ * @date 2021年04月27日 14:34
+ **/
+public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(SysRoleMenuServiceImpl.class);
+
+    @Resource
+    private SysRoleMenuMapper mapper;
+    @Resource
+    private RemoteObjService remoteObjService;
+    /**
+     * 功能描述: 批量保存roleMenu
+     *
+     * @param roleMenuList roleMenuList
+     * @return int
+     */
+    @Override
+    public int saveList(List<SysRoleMenu> roleMenuList) {
+        if (isEmpty(roleMenuList)) {
+            return 0;
+        }
+
+        for (SysRoleMenu sysRoleMenu : roleMenuList) {
+            Long maxId = remoteObjService.getMaxId("sys_role_menu", "id");
+            sysRoleMenu.setId(maxId);
+        }
+
+        return mapper.batchRoleMenu(roleMenuList);
+    }
+}

+ 1 - 1
boman-modules/boman-system/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -83,7 +83,7 @@
 			 left join sys_user_role ur on rm.role_id = ur.role_id
 			 left join sys_role ro on ur.role_id = ro.id
 			 left join sys_user u on ur.user_id = u.id
-		where u.id = #id} and m.menu_type in ('M', 'C') and m.status = 0  AND ro.status = 0
+		where u.id = #{id} and m.menu_type in ('M', 'C') and m.status = 0  AND ro.status = 0
 		order by m.parent_id, m.order_num
 	</select>
 	

+ 3 - 2
boman-modules/boman-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml

@@ -5,6 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.boman.system.mapper.SysRoleMenuMapper">
 
 	<resultMap type="SysRoleMenu" id="SysRoleMenuResult">
+		<result property="id"     column="id"      />
 		<result property="roleId"     column="role_id"      />
 		<result property="menuId"     column="menu_id"      />
 	</resultMap>
@@ -25,9 +26,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  	</delete>
 	
 	<insert id="batchRoleMenu">
-		insert into sys_role_menu(role_id, menu_id) values
+		insert into sys_role_menu(id, role_id, menu_id) values
 		<foreach item="item" index="index" collection="list" separator=",">
-			(#{item.roleId},#{item.menuId})
+			(#{item.id},#{item.roleId},#{item.menuId})
 		</foreach>
 	</insert>
 	

+ 12 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/CommonController.java

@@ -42,4 +42,16 @@ public class CommonController {
         return AjaxResult.success(commonService.getByMap(dto.getTable(), dto.getFixedData()));
     }
 
+    /**
+     * 功能描述: getMaxId
+     *
+     * @param tableName tableName
+     * @param pkName        pkName
+     * @return com.boman.common.core.web.domain.AjaxResult
+     */
+    @GetMapping("tableName/{tableName}/pkName/{pkName}")
+    public Long getMaxId(@PathVariable("tableName") String tableName, @PathVariable("pkName") String pkName) {
+        return commonService.getMaxId(tableName, pkName);
+    }
+
 }

+ 0 - 3
boman-web-core/src/main/java/com/boman/web/core/controller/ObjController.java

@@ -138,7 +138,6 @@ public class ObjController {
     /**
      * 功能描述: 获取表单查询字段、按钮、表头
      * 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
-     * 刷新的入口为 {@link MyController#loadTable(GenTable)}
      *
      *                    eg:{
      *                          "table": "sys_config"
@@ -156,7 +155,6 @@ public class ObjController {
     /**
      * 功能描述: 获取表单查询字段
      * 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
-     * 刷新的入口为 {@link MyController#loadTable(GenTable)}
      *
      *                    eg:{
      *                          "table": "sys_config"
@@ -193,7 +191,6 @@ public class ObjController {
     /**
      * 功能描述: 获取表单按钮
      * 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
-     * 刷新的入口为 {@link MyController#loadTable(GenTable)}
      *
      *                    eg:{
      *                          "table": "sys_config"

+ 5 - 0
boman-web-core/src/main/java/com/boman/web/core/service/common/CommonServiceImpl.java

@@ -58,4 +58,9 @@ public class CommonServiceImpl implements ICommonService {
         requireNonNull(tableName, "tableName is empty");
         return selectService.getByMap(tableName, condition);
     }
+
+    @Override
+    public Long getMaxId(String tableName, String pkName) {
+        return IdUtils.getMaxId(tableName, pkName);
+    }
 }

+ 2 - 0
boman-web-core/src/main/java/com/boman/web/core/service/common/ICommonService.java

@@ -28,4 +28,6 @@ public interface ICommonService {
      * @return java.util.List<com.alibaba.fastjson.JSONObject>
      */
     List<JSONObject> getByMap(String tableName, JSONObject condition);
+
+    Long getMaxId(String tableName, String pkName);
 }