24282 2 년 전
부모
커밋
b56a91a6bf

+ 47 - 22
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java

@@ -2,8 +2,6 @@ package com.ruoyi.common.core.domain.entity;
 
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.ruoyi.common.core.domain.BaseEntity;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
@@ -101,6 +99,16 @@ public class SysMenu extends BaseEntity {
     private String icon;
 
     /**
+     * 背景颜色
+     */
+    private String background;
+
+    /**
+     * 颜色
+     */
+    private String color;
+
+    /**
      * 子菜单
      */
     private List<SysMenu> children = new ArrayList<SysMenu>();
@@ -248,27 +256,44 @@ public class SysMenu extends BaseEntity {
         this.type = type;
     }
 
+    public String getBackground() {
+        return background;
+    }
+
+    public void setBackground(String background) {
+        this.background = background;
+    }
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String color) {
+        this.color = color;
+    }
+
     @Override
     public String toString() {
-        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
-                .append("menuId", getMenuId())
-                .append("menuName", getMenuName())
-                .append("parentId", getParentId())
-                .append("orderNum", getOrderNum())
-                .append("path", getPath())
-                .append("component", getComponent())
-                .append("isFrame", getIsFrame())
-                .append("IsCache", getIsCache())
-                .append("menuType", getMenuType())
-                .append("visible", getVisible())
-                .append("status ", getStatus())
-                .append("perms", getPerms())
-                .append("icon", getIcon())
-                .append("createBy", getCreateBy())
-                .append("createTime", getCreateTime())
-                .append("updateBy", getUpdateBy())
-                .append("updateTime", getUpdateTime())
-                .append("remark", getRemark())
-                .toString();
+        return "SysMenu{" +
+                "menuId=" + menuId +
+                ", type=" + type +
+                ", menuName='" + menuName + '\'' +
+                ", parentName='" + parentName + '\'' +
+                ", parentId=" + parentId +
+                ", orderNum=" + orderNum +
+                ", path='" + path + '\'' +
+                ", component='" + component + '\'' +
+                ", query='" + query + '\'' +
+                ", isFrame='" + isFrame + '\'' +
+                ", isCache='" + isCache + '\'' +
+                ", menuType='" + menuType + '\'' +
+                ", visible='" + visible + '\'' +
+                ", status='" + status + '\'' +
+                ", perms='" + perms + '\'' +
+                ", icon='" + icon + '\'' +
+                ", background='" + background + '\'' +
+                ", color='" + color + '\'' +
+                ", children=" + children +
+                '}';
     }
 }

+ 20 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RouterVo.java

@@ -57,6 +57,10 @@ public class RouterVo {
      */
     private MetaVo meta;
 
+    private String background;
+
+    private String color;
+
     /**
      * 子路由
      */
@@ -141,4 +145,20 @@ public class RouterVo {
     public void setType(Integer type) {
         this.type = type;
     }
+
+    public String getBackground() {
+        return background;
+    }
+
+    public void setBackground(String background) {
+        this.background = background;
+    }
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String color) {
+        this.color = color;
+    }
 }

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

@@ -146,6 +146,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
         List<RouterVo> routers = new LinkedList<RouterVo>();
         for (SysMenu menu : menus) {
             RouterVo router = new RouterVo();
+            router.setBackground(menu.getBackground());
+            router.setColor(menu.getColor());
             router.setType(menu.getType());
             router.setHidden("1".equals(menu.getVisible()));
             router.setName(getRouteName(menu));

+ 39 - 24
ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -5,27 +5,29 @@
 <mapper namespace="com.ruoyi.system.mapper.SysMenuMapper">
 
 	<resultMap type="SysMenu" id="SysMenuResult">
-		<id     property="menuId"         column="menu_id"        />
-		<result property="menuName"       column="menu_name"      />
-		<result property="parentName"     column="parent_name"    />
-		<result property="parentId"       column="parent_id"      />
-		<result property="orderNum"       column="order_num"      />
-		<result property="path"           column="path"           />
-		<result property="component"      column="component"      />
-		<result property="query"          column="query"          />
-		<result property="isFrame"        column="is_frame"       />
-		<result property="isCache"        column="is_cache"       />
-		<result property="menuType"       column="menu_type"      />
-		<result property="visible"        column="visible"        />
-		<result property="status"         column="status"         />
-		<result property="perms"          column="perms"          />
-		<result property="icon"           column="icon"           />
-		<result property="createBy"       column="create_by"      />
-		<result property="createTime"     column="create_time"    />
-		<result property="updateTime"     column="update_time"    />
-		<result property="updateBy"       column="update_by"      />
-		<result property="remark"         column="remark"         />
-		<result property="type"         column="type"         />
+		<id property="menuId" column="menu_id"/>
+		<result property="menuName" column="menu_name"/>
+		<result property="parentName" column="parent_name"/>
+		<result property="parentId" column="parent_id"/>
+		<result property="orderNum" column="order_num"/>
+		<result property="path" column="path"/>
+		<result property="component" column="component"/>
+		<result property="query" column="query"/>
+		<result property="isFrame" column="is_frame"/>
+		<result property="isCache" column="is_cache"/>
+		<result property="menuType" column="menu_type"/>
+		<result property="visible" column="visible"/>
+		<result property="status" column="status"/>
+		<result property="perms" column="perms"/>
+		<result property="icon" column="icon"/>
+		<result property="createBy" column="create_by"/>
+		<result property="createTime" column="create_time"/>
+		<result property="updateTime" column="update_time"/>
+		<result property="updateBy" column="update_by"/>
+		<result property="remark" column="remark"/>
+		<result property="type" column="type"/>
+		<result property="background" column="background"/>
+		<result property="color" column="color"/>
 	</resultMap>
 
 	<sql id="selectMenuVo">
@@ -44,6 +46,8 @@
                ifnull(perms, '') as perms,
                icon,
                type,
+			   background,
+			   color,
                create_time
         from sys_menu
     </sql>
@@ -80,7 +84,9 @@
                         m.icon,
                         m.order_num,
                         m.create_time,
-                        m.type
+                        m.type,
+						m.background,
+						m.color
         from sys_menu m
         where m.menu_type in ('M', 'C')
           and m.status = 0
@@ -89,7 +95,8 @@
 	
 	<select id="selectMenuListByUserId" parameterType="SysMenu" 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.type, m.create_time
+        ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num,m.type, m.create_time,
+		m.background, m.color
         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
@@ -123,7 +130,9 @@
 						m.icon,
 						m.order_num,
 						m.create_time,
-						m.type
+						m.type,
+						m.background,
+						m.color
 		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
@@ -203,6 +212,8 @@
 			<if test="icon !=null and icon != ''">icon = #{icon},</if>
 			<if test="remark != null and remark != ''">remark = #{remark},</if>
 			<if test="type != null and type != ''">type = #{type},</if>
+			<if test="background != null and background != ''">background = #{background},</if>
+			<if test="color != null and color != ''">color = #{color},</if>
 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
 			update_time = sysdate()
 		</set>
@@ -227,6 +238,8 @@
 		<if test="icon != null and icon != ''">icon,</if>
 		<if test="remark != null and remark != ''">remark,</if>
 		<if test="type != null and type != ''">type,</if>
+		<if test="background != null and background != ''">background,</if>
+		<if test="color != null and color != ''">color,</if>
 		<if test="createBy != null and createBy != ''">create_by,</if>
 		create_time
 		)values(
@@ -246,6 +259,8 @@
 		<if test="icon != null and icon != ''">#{icon},</if>
 		<if test="remark != null and remark != ''">#{remark},</if>
 		<if test="type != null and type != ''">#{type},</if>
+		<if test="background != null and background != ''">#{background},</if>
+		<if test="color != null and color != ''">#{color},</if>
 		<if test="createBy != null and createBy != ''">#{createBy},</if>
 		sysdate()
 		)