From b9347013f0458be44a6ac8b980660aec37252cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=96=87=E8=B1=AA?= <980287353@qq.com> Date: Tue, 13 Aug 2024 14:49:22 +0800 Subject: [PATCH] =?UTF-8?q?perf=EF=BC=9A=E6=9D=83=E9=99=90=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AAsource=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E6=A0=87=E8=AE=B0=E6=9D=83=E9=99=90=E6=9D=A5?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../role/pojos/dao/CoreRoleAuthority.java | 29 ++++++++++++++++++- .../role/service/CoreRoleService.java | 1 + .../role/service/RoleAuthorityHandler.java | 3 ++ .../db/migration/tiesheng_init_role.sql | 4 +++ .../mapper/CoreRoleAuthorityMapper.xml | 8 +++-- 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/springboot-role/src/main/java/com/tiesheng/role/pojos/dao/CoreRoleAuthority.java b/springboot-role/src/main/java/com/tiesheng/role/pojos/dao/CoreRoleAuthority.java index 40ca8ed..539606e 100644 --- a/springboot-role/src/main/java/com/tiesheng/role/pojos/dao/CoreRoleAuthority.java +++ b/springboot-role/src/main/java/com/tiesheng/role/pojos/dao/CoreRoleAuthority.java @@ -1,8 +1,11 @@ package com.tiesheng.role.pojos.dao; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.tiesheng.util.pojos.DaoBase; +import java.util.Date; /** * 角色-权限 @@ -81,6 +84,12 @@ public class CoreRoleAuthority extends DaoBase { @TableField(value = "version") private String version; + /** + * 权限来源:auto-自动生成,input-添加 + */ + @TableField(value = "`source`") + private String source; + /** * 扩展1 */ @@ -315,6 +324,24 @@ public class CoreRoleAuthority extends DaoBase { this.version = version; } + /** + * 获取权限来源:auto-自动生成,input-添加 + * + * @return source - 权限来源:auto-自动生成,input-添加 + */ + public String getSource() { + return source; + } + + /** + * 设置权限来源:auto-自动生成,input-添加 + * + * @param source 权限来源:auto-自动生成,input-添加 + */ + public void setSource(String source) { + this.source = source; + } + /** * 获取扩展1 * @@ -368,4 +395,4 @@ public class CoreRoleAuthority extends DaoBase { public void setExt3(String ext3) { this.ext3 = ext3; } -} +} \ No newline at end of file diff --git a/springboot-role/src/main/java/com/tiesheng/role/service/CoreRoleService.java b/springboot-role/src/main/java/com/tiesheng/role/service/CoreRoleService.java index f0fa406..57d30e7 100644 --- a/springboot-role/src/main/java/com/tiesheng/role/service/CoreRoleService.java +++ b/springboot-role/src/main/java/com/tiesheng/role/service/CoreRoleService.java @@ -263,6 +263,7 @@ public class CoreRoleService extends TsServiceBase() .ne("version", version) + .ne("source", "auto") ); } diff --git a/springboot-role/src/main/java/com/tiesheng/role/service/RoleAuthorityHandler.java b/springboot-role/src/main/java/com/tiesheng/role/service/RoleAuthorityHandler.java index b4c8d18..cbfe10c 100644 --- a/springboot-role/src/main/java/com/tiesheng/role/service/RoleAuthorityHandler.java +++ b/springboot-role/src/main/java/com/tiesheng/role/service/RoleAuthorityHandler.java @@ -57,6 +57,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler { groupAuthority.setPlatform(menuPlatform); groupAuthority.setParent(parentId); groupAuthority.setVersion(version); + groupAuthority.setSource("auto"); groupAuthority.setId(StrUtil.join("_", groupAuthority.getService(), groupAuthority.getNo())); list.add(groupAuthority); } @@ -72,6 +73,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler { menuAuthority.setParent(groupAuthority.getId()); menuAuthority.setPlatform(menuPlatform); menuAuthority.setVersion(version); + menuAuthority.setSource("auto"); menuAuthority.setId(StrUtil.join("_", menuAuthority.getService(), menuAuthority.getNo())); list.add(menuAuthority); @@ -85,6 +87,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler { point.setLevel(menuAuthority.getLevel() + 1); point.setParent(menuAuthority.getId()); point.setVersion(version); + point.setSource("auto"); point.setPlatform(StrUtil.emptyToDefault(authority.platform(), menuPlatform)); point.setId(StrUtil.join("_", point.getService(), point.getNo())); list.add(point); diff --git a/springboot-role/src/main/resources/db/migration/tiesheng_init_role.sql b/springboot-role/src/main/resources/db/migration/tiesheng_init_role.sql index 6063669..fd32d5e 100644 --- a/springboot-role/src/main/resources/db/migration/tiesheng_init_role.sql +++ b/springboot-role/src/main/resources/db/migration/tiesheng_init_role.sql @@ -99,4 +99,8 @@ create table core_role_user alter table core_role_authority add version varchar(50) null comment '版本号' after platform; +alter table core_role_authority + add source varchar(10) null comment '权限来源:auto-自动生成,input-添加' after version; + + SET FOREIGN_KEY_CHECKS = 1; diff --git a/springboot-role/src/main/resources/mapper/CoreRoleAuthorityMapper.xml b/springboot-role/src/main/resources/mapper/CoreRoleAuthorityMapper.xml index 2fe38b7..bf20664 100644 --- a/springboot-role/src/main/resources/mapper/CoreRoleAuthorityMapper.xml +++ b/springboot-role/src/main/resources/mapper/CoreRoleAuthorityMapper.xml @@ -20,6 +20,7 @@ + @@ -27,12 +28,12 @@ id, create_time, update_time, is_deleted, service, `no`, `name`, sort, `level`, parent, - remark, is_open, `type`, link, platform, version, ext1, ext2, ext3 + remark, is_open, `type`, link, platform, version, `source`, ext1, ext2, ext3 insert into core_role_authority(id, create_time, update_time, is_deleted, service, no, name, level, parent, - type, platform, is_open, version) + type, platform, is_open, version, source) values (#{item.id}, now(), now(), 0, @@ -42,7 +43,7 @@ #{item.level}, #{item.parent}, #{item.type}, - #{item.platform}, 1, #{item.version}) + #{item.platform}, 1, #{item.version}, #{item.source}) on duplicate key update update_time=now(), @@ -51,6 +52,7 @@ parent=values(parent), type=values(type), platform=values(platform), + source=values(source), version=values(version)