From 979d1d8fb89b5357f038e1631b4bd28e3eb544d4 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 25 Oct 2023 11:02:40 +0800 Subject: [PATCH] Add group role tables --- .../top/fatweb/api/config/InitConfig.kt | 2 +- .../fatweb/api/entity/permission/Element.kt | 43 +++++++++++++++ .../top/fatweb/api/entity/permission/Group.kt | 46 ++++++++++++++++ .../top/fatweb/api/entity/permission/Menu.kt | 49 +++++++++++++++++ .../fatweb/api/entity/permission/Operation.kt | 55 +++++++++++++++++++ .../top/fatweb/api/entity/permission/Power.kt | 31 +++++++++++ .../fatweb/api/entity/permission/PowerRole.kt | 43 +++++++++++++++ .../fatweb/api/entity/permission/PowerType.kt | 31 +++++++++++ .../top/fatweb/api/entity/permission/Role.kt | 55 +++++++++++++++++++ .../fatweb/api/entity/permission/RoleGroup.kt | 43 +++++++++++++++ .../top/fatweb/api/entity/permission/User.kt | 17 +++++- .../fatweb/api/entity/permission/UserGroup.kt | 43 +++++++++++++++ .../fatweb/api/entity/permission/UserRole.kt | 43 +++++++++++++++ .../api/mapper/permission/ElementMapper.kt | 16 ++++++ .../api/mapper/permission/GroupMapper.kt | 16 ++++++ .../api/mapper/permission/MenuMapper.kt | 16 ++++++ .../api/mapper/permission/OperationMapper.kt | 16 ++++++ .../api/mapper/permission/PowerMapper.kt | 16 ++++++ .../api/mapper/permission/PowerRoleMapper.kt | 16 ++++++ .../api/mapper/permission/PowerTypeMapper.kt | 16 ++++++ .../api/mapper/permission/RoleGroupMapper.kt | 16 ++++++ .../api/mapper/permission/RoleMapper.kt | 16 ++++++ .../api/mapper/permission/UserGroupMapper.kt | 16 ++++++ .../api/mapper/{ => permission}/UserMapper.kt | 2 +- .../api/mapper/permission/UserRoleMapper.kt | 16 ++++++ .../api/service/permission/IElementService.kt | 14 +++++ .../api/service/permission/IGroupService.kt | 14 +++++ .../api/service/permission/IMenuService.kt | 14 +++++ .../service/permission/IOperationService.kt | 14 +++++ .../service/permission/IPowerRoleService.kt | 14 +++++ .../api/service/permission/IPowerService.kt | 14 +++++ .../service/permission/IPowerTypeService.kt | 14 +++++ .../service/permission/IRoleGroupService.kt | 14 +++++ .../api/service/permission/IRoleService.kt | 14 +++++ .../service/permission/IUserGroupService.kt | 14 +++++ .../service/permission/IUserRoleService.kt | 14 +++++ .../service/{ => permission}/IUserService.kt | 2 +- .../impl/AuthenticationServiceImpl.kt | 2 +- .../permission/impl/ElementServiceImpl.kt | 18 ++++++ .../permission/impl/GroupServiceImpl.kt | 18 ++++++ .../permission/impl/MenuServiceImpl.kt | 18 ++++++ .../permission/impl/OperationServiceImpl.kt | 18 ++++++ .../permission/impl/PowerRoleServiceImpl.kt | 18 ++++++ .../permission/impl/PowerServiceImpl.kt | 18 ++++++ .../permission/impl/PowerTypeServiceImpl.kt | 18 ++++++ .../permission/impl/RoleGroupServiceImpl.kt | 18 ++++++ .../permission/impl/RoleServiceImpl.kt | 18 ++++++ .../permission/impl/UserDetailsServiceImpl.kt | 2 +- .../permission/impl/UserGroupServiceImpl.kt | 18 ++++++ .../permission/impl/UserRoleServiceImpl.kt | 18 ++++++ .../{ => permission}/impl/UserServiceImpl.kt | 6 +- .../resources/db/migration/R__Basic_data.sql | 6 +- .../V1_0_0_231024__Add_table_'t_power'.sql | 4 +- .../V1_0_0_231025__Add_table_'t_menu'.sql | 10 ++-- .../V1_0_0_231026__Add_table_'t_element'.sql | 8 +-- ...V1_0_0_231027__Add_table_'t_operation'.sql | 12 ++-- .../V1_0_0_231028__Add_table_'t_group'.sql | 11 ++++ ...1_0_0_231029__Add_table_'t_user_group'.sql | 10 ++++ .../V1_0_0_231030__Add_table_'t_role'.sql | 11 ++++ ...1_0_0_231031__Add_table_'t_role_group'.sql | 10 ++++ ...V1_0_0_231101__Add_table_'t_user_role'.sql | 10 ++++ ...1_0_0_231102__Add_table_'t_power_role'.sql | 10 ++++ .../mapper/permission/ElementMapper.xml | 5 ++ .../mapper/permission/GroupMapper.xml | 5 ++ .../mapper/permission/MenuMapper.xml | 5 ++ .../mapper/permission/OperationMapper.xml | 5 ++ .../mapper/permission/PowerMapper.xml | 5 ++ .../mapper/permission/PowerRoleMapper.xml | 5 ++ .../mapper/permission/PowerTypeMapper.xml | 5 ++ .../mapper/permission/RoleGroupMapper.xml | 5 ++ .../mapper/permission/RoleMapper.xml | 5 ++ .../mapper/permission/UserGroupMapper.xml | 5 ++ .../mapper/{ => permission}/UserMapper.xml | 2 +- .../mapper/permission/UserRoleMapper.xml | 5 ++ .../mapper/{ => system}/SysLogMapper.xml | 0 75 files changed, 1172 insertions(+), 30 deletions(-) create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/Element.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/Group.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/Menu.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/Operation.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/Power.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/PowerRole.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/PowerType.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/Role.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/RoleGroup.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/UserGroup.kt create mode 100644 src/main/kotlin/top/fatweb/api/entity/permission/UserRole.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/ElementMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/GroupMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/MenuMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/OperationMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/PowerMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/PowerRoleMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/PowerTypeMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/RoleGroupMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/RoleMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/UserGroupMapper.kt rename src/main/kotlin/top/fatweb/api/mapper/{ => permission}/UserMapper.kt (87%) create mode 100644 src/main/kotlin/top/fatweb/api/mapper/permission/UserRoleMapper.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IElementService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IGroupService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IMenuService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IOperationService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IPowerRoleService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IPowerService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IPowerTypeService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IRoleGroupService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IRoleService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IUserGroupService.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/IUserRoleService.kt rename src/main/kotlin/top/fatweb/api/service/{ => permission}/IUserService.kt (84%) create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/ElementServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/GroupServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/MenuServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/OperationServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/PowerRoleServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/PowerServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/PowerTypeServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/RoleGroupServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/RoleServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/UserGroupServiceImpl.kt create mode 100644 src/main/kotlin/top/fatweb/api/service/permission/impl/UserRoleServiceImpl.kt rename src/main/kotlin/top/fatweb/api/service/{ => permission}/impl/UserServiceImpl.kt (68%) create mode 100644 src/main/resources/db/migration/V1_0_0_231028__Add_table_'t_group'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231029__Add_table_'t_user_group'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231030__Add_table_'t_role'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231031__Add_table_'t_role_group'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231101__Add_table_'t_user_role'.sql create mode 100644 src/main/resources/db/migration/V1_0_0_231102__Add_table_'t_power_role'.sql create mode 100644 src/main/resources/mapper/permission/ElementMapper.xml create mode 100644 src/main/resources/mapper/permission/GroupMapper.xml create mode 100644 src/main/resources/mapper/permission/MenuMapper.xml create mode 100644 src/main/resources/mapper/permission/OperationMapper.xml create mode 100644 src/main/resources/mapper/permission/PowerMapper.xml create mode 100644 src/main/resources/mapper/permission/PowerRoleMapper.xml create mode 100644 src/main/resources/mapper/permission/PowerTypeMapper.xml create mode 100644 src/main/resources/mapper/permission/RoleGroupMapper.xml create mode 100644 src/main/resources/mapper/permission/RoleMapper.xml create mode 100644 src/main/resources/mapper/permission/UserGroupMapper.xml rename src/main/resources/mapper/{ => permission}/UserMapper.xml (70%) create mode 100644 src/main/resources/mapper/permission/UserRoleMapper.xml rename src/main/resources/mapper/{ => system}/SysLogMapper.xml (100%) diff --git a/src/main/kotlin/top/fatweb/api/config/InitConfig.kt b/src/main/kotlin/top/fatweb/api/config/InitConfig.kt index 14b6858..abb56fc 100644 --- a/src/main/kotlin/top/fatweb/api/config/InitConfig.kt +++ b/src/main/kotlin/top/fatweb/api/config/InitConfig.kt @@ -7,7 +7,7 @@ import org.slf4j.LoggerFactory import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.stereotype.Component import top.fatweb.api.entity.permission.User -import top.fatweb.api.service.IUserService +import top.fatweb.api.service.permission.IUserService import kotlin.random.Random @Component diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/Element.kt b/src/main/kotlin/top/fatweb/api/entity/permission/Element.kt new file mode 100644 index 0000000..a285141 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/Element.kt @@ -0,0 +1,43 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.TableField +import com.baomidou.mybatisplus.annotation.TableId +import com.baomidou.mybatisplus.annotation.TableName +import java.io.Serializable + +/** + *

+ * 页面元素 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_element") +class Element : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 元素名 + */ + @TableField("name") + var name: String? = null + + /** + * 权限ID + */ + @TableField("power_id") + var powerId: Long? = null + + /** + * 菜单ID + */ + @TableField("menu_id") + var menuId: Long? = null + + override fun toString(): String { + return "Element(id=$id, name=$name, powerId=$powerId, menuId=$menuId)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/Group.kt b/src/main/kotlin/top/fatweb/api/entity/permission/Group.kt new file mode 100644 index 0000000..3a1fc11 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/Group.kt @@ -0,0 +1,46 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.* +import java.io.Serializable + +/** + *

+ * 用户组 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_group") +class Group : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 用户组名 + */ + @TableField("name") + var name: String? = null + + /** + * 启用 + */ + @TableField("enable") + var enable: Int? = null + + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + @TableField("version") + @Version + var version: Int? = null + + @TableField(exist = false) + var roles: List? = null + + override fun toString(): String { + return "Group(id=$id, name=$name, enable=$enable, deleted=$deleted, version=$version, roles=$roles)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/Menu.kt b/src/main/kotlin/top/fatweb/api/entity/permission/Menu.kt new file mode 100644 index 0000000..a2559e7 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/Menu.kt @@ -0,0 +1,49 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.TableField +import com.baomidou.mybatisplus.annotation.TableId +import com.baomidou.mybatisplus.annotation.TableName +import java.io.Serializable + +/** + *

+ * 菜单 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_menu") +class Menu : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 菜单名 + */ + @TableField("name") + var name: String? = null + + /** + * URL + */ + @TableField("url") + var url: String? = null + + /** + * 权限ID + */ + @TableField("power_id") + var powerId: Long? = null + + /** + * 父ID + */ + @TableField("parent_id") + var parentId: Long? = null + + override fun toString(): String { + return "Menu(id=$id, name=$name, url=$url, powerId=$powerId, parentId=$parentId)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/Operation.kt b/src/main/kotlin/top/fatweb/api/entity/permission/Operation.kt new file mode 100644 index 0000000..f9a713a --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/Operation.kt @@ -0,0 +1,55 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.TableField +import com.baomidou.mybatisplus.annotation.TableId +import com.baomidou.mybatisplus.annotation.TableName +import java.io.Serializable + +/** + *

+ * 功能 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_operation") +class Operation : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 功能名 + */ + @TableField("name") + var name: String? = null + + /** + * 功能编码 + */ + @TableField("code") + var code: String? = null + + /** + * 权限ID + */ + @TableField("power_id") + var powerId: Long? = null + + /** + * 父ID + */ + @TableField("parent_id") + var parentId: Long? = null + + /** + * 页面元素ID + */ + @TableField("element_id") + var elementId: Long? = null + + override fun toString(): String { + return "Operation(id=$id, name=$name, code=$code, powerId=$powerId, parentId=$parentId, elementId=$elementId)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/Power.kt b/src/main/kotlin/top/fatweb/api/entity/permission/Power.kt new file mode 100644 index 0000000..4e52fdd --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/Power.kt @@ -0,0 +1,31 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.TableField +import com.baomidou.mybatisplus.annotation.TableId +import com.baomidou.mybatisplus.annotation.TableName +import java.io.Serializable + +/** + *

+ * 权限 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_power") +class Power : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 权限类型 + */ + @TableField("type_id") + var typeId: Long? = null + + override fun toString(): String { + return "Power(id=$id, typeId=$typeId)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/PowerRole.kt b/src/main/kotlin/top/fatweb/api/entity/permission/PowerRole.kt new file mode 100644 index 0000000..43c87af --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/PowerRole.kt @@ -0,0 +1,43 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.* +import java.io.Serializable + +/** + *

+ * 中间表-权限-角色 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_power_role") +class PowerRole : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 权限 + */ + @TableField("power_id") + var powerId: Long? = null + + /** + * 角色 + */ + @TableField("role_id") + var roleId: Long? = null + + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + @TableField("version") + @Version + var version: Int? = null + + override fun toString(): String { + return "PowerRole(id=$id, powerId=$powerId, roleId=$roleId, deleted=$deleted, version=$version)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/PowerType.kt b/src/main/kotlin/top/fatweb/api/entity/permission/PowerType.kt new file mode 100644 index 0000000..1f69a83 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/PowerType.kt @@ -0,0 +1,31 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.TableField +import com.baomidou.mybatisplus.annotation.TableId +import com.baomidou.mybatisplus.annotation.TableName +import java.io.Serializable + +/** + *

+ * 权限类型 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_power_type") +class PowerType : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 权限类型名 + */ + @TableField("name") + var name: String? = null + + override fun toString(): String { + return "PowerType(id=$id, name=$name)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/Role.kt b/src/main/kotlin/top/fatweb/api/entity/permission/Role.kt new file mode 100644 index 0000000..c55a604 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/Role.kt @@ -0,0 +1,55 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.* +import java.io.Serializable + +/** + *

+ * 角色 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_role") +class Role : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 角色名 + */ + @TableField("name") + var name: String? = null + + /** + * 启用 + */ + @TableField("enable") + var enable: Int? = null + + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + @TableField("version") + @Version + var version: Int? = null + + @TableField(exist = false) + var menus: List? = null + + @TableField(exist = false) + var elements: List? = null + + @TableField(exist = false) + var operations: List? = null + + @TableField(exist = false) + var powers: List? = null + + override fun toString(): String { + return "Role(id=$id, name=$name, enable=$enable, deleted=$deleted, version=$version, menus=$menus, elements=$elements, operations=$operations, powers=$powers)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/RoleGroup.kt b/src/main/kotlin/top/fatweb/api/entity/permission/RoleGroup.kt new file mode 100644 index 0000000..2d780b5 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/RoleGroup.kt @@ -0,0 +1,43 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.* +import java.io.Serializable + +/** + *

+ * 中间表-角色-用户组 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_role_group") +class RoleGroup : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 角色 + */ + @TableField("role_id") + var roleId: Long? = null + + /** + * 群组 + */ + @TableField("group_id") + var groupId: Long? = null + + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + @TableField("version") + @Version + var version: Int? = null + + override fun toString(): String { + return "RoleGroup(id=$id, roleId=$roleId, groupId=$groupId, deleted=$deleted, version=$version)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/User.kt b/src/main/kotlin/top/fatweb/api/entity/permission/User.kt index 8277f73..2956bf0 100644 --- a/src/main/kotlin/top/fatweb/api/entity/permission/User.kt +++ b/src/main/kotlin/top/fatweb/api/entity/permission/User.kt @@ -92,7 +92,22 @@ class User() : Serializable { @Version var version: Int? = null + @TableField(exist = false) + var roles: List? = null + + @TableField(exist = false) + var groups: List? = null + + @TableField(exist = false) + var menus: List? = null + + @TableField(exist = false) + var elements: List? = null + + @TableField(exist = false) + var operations: List? = null + override fun toString(): String { - return "User(id=$id, username=$username, password=$password, locking=$locking, expiration=$expiration, credentialsExpiration=$credentialsExpiration, enable=$enable, lastLoginTime=$lastLoginTime, lastLoginIp=$lastLoginIp, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version)" + return "User(id=$id, username=$username, password=$password, locking=$locking, expiration=$expiration, credentialsExpiration=$credentialsExpiration, enable=$enable, lastLoginTime=$lastLoginTime, lastLoginIp=$lastLoginIp, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, roles=$roles, groups=$groups, menus=$menus, elements=$elements, operations=$operations)" } } diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/UserGroup.kt b/src/main/kotlin/top/fatweb/api/entity/permission/UserGroup.kt new file mode 100644 index 0000000..ad2264f --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/UserGroup.kt @@ -0,0 +1,43 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.* +import java.io.Serializable + +/** + *

+ * 中间表-用户-用户组 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_user_group") +class UserGroup : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 用户 + */ + @TableField("user_id") + var userId: Long? = null + + /** + * 用户组 + */ + @TableField("group_id") + var groupId: Long? = null + + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + @TableField("version") + @Version + var version: Int? = null + + override fun toString(): String { + return "UserGroup(id=$id, userId=$userId, groupId=$groupId, deleted=$deleted, version=$version)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/UserRole.kt b/src/main/kotlin/top/fatweb/api/entity/permission/UserRole.kt new file mode 100644 index 0000000..ffd6c49 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/entity/permission/UserRole.kt @@ -0,0 +1,43 @@ +package top.fatweb.api.entity.permission + +import com.baomidou.mybatisplus.annotation.* +import java.io.Serializable + +/** + *

+ * 中间表-用户-角色 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@TableName("t_user_role") +class UserRole : Serializable { + + @TableId("id") + var id: Long? = null + + /** + * 用户 + */ + @TableField("user_id") + var userId: Long? = null + + /** + * 角色 + */ + @TableField("role_id") + var roleId: Long? = null + + @TableField("deleted") + @TableLogic + var deleted: Long? = null + + @TableField("version") + @Version + var version: Int? = null + + override fun toString(): String { + return "UserRole(id=$id, userId=$userId, roleId=$roleId, deleted=$deleted, version=$version)" + } +} diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/ElementMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/ElementMapper.kt new file mode 100644 index 0000000..62d9ac3 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/ElementMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.Element + +/** + *

+ * 页面元素 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface ElementMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/GroupMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/GroupMapper.kt new file mode 100644 index 0000000..cba8e5f --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/GroupMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.Group + +/** + *

+ * 用户组 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface GroupMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/MenuMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/MenuMapper.kt new file mode 100644 index 0000000..c952d58 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/MenuMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.Menu + +/** + *

+ * 菜单 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface MenuMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/OperationMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/OperationMapper.kt new file mode 100644 index 0000000..169bb7d --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/OperationMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.Operation + +/** + *

+ * 功能 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface OperationMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/PowerMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/PowerMapper.kt new file mode 100644 index 0000000..fbeb8cd --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/PowerMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.Power + +/** + *

+ * 权限 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface PowerMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/PowerRoleMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/PowerRoleMapper.kt new file mode 100644 index 0000000..565416d --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/PowerRoleMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.PowerRole + +/** + *

+ * 中间表-权限-角色 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface PowerRoleMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/PowerTypeMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/PowerTypeMapper.kt new file mode 100644 index 0000000..6616e89 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/PowerTypeMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.PowerType + +/** + *

+ * 权限类型 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface PowerTypeMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/RoleGroupMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/RoleGroupMapper.kt new file mode 100644 index 0000000..6d8e73a --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/RoleGroupMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.RoleGroup + +/** + *

+ * 中间表-角色-用户组 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface RoleGroupMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/RoleMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/RoleMapper.kt new file mode 100644 index 0000000..36881ad --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/RoleMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.Role + +/** + *

+ * 角色 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface RoleMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/UserGroupMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/UserGroupMapper.kt new file mode 100644 index 0000000..5dac8dd --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/UserGroupMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.UserGroup + +/** + *

+ * 中间表-用户-用户组 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface UserGroupMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/UserMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/UserMapper.kt similarity index 87% rename from src/main/kotlin/top/fatweb/api/mapper/UserMapper.kt rename to src/main/kotlin/top/fatweb/api/mapper/permission/UserMapper.kt index 8b37df3..2dc6d5f 100644 --- a/src/main/kotlin/top/fatweb/api/mapper/UserMapper.kt +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/UserMapper.kt @@ -1,4 +1,4 @@ -package top.fatweb.api.mapper +package top.fatweb.api.mapper.permission import com.baomidou.mybatisplus.core.mapper.BaseMapper import org.apache.ibatis.annotations.Mapper diff --git a/src/main/kotlin/top/fatweb/api/mapper/permission/UserRoleMapper.kt b/src/main/kotlin/top/fatweb/api/mapper/permission/UserRoleMapper.kt new file mode 100644 index 0000000..d6f5478 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/mapper/permission/UserRoleMapper.kt @@ -0,0 +1,16 @@ +package top.fatweb.api.mapper.permission + +import com.baomidou.mybatisplus.core.mapper.BaseMapper +import org.apache.ibatis.annotations.Mapper +import top.fatweb.api.entity.permission.UserRole + +/** + *

+ * 中间表-用户-角色 Mapper 接口 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Mapper +interface UserRoleMapper : BaseMapper diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IElementService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IElementService.kt new file mode 100644 index 0000000..eaacea3 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IElementService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.Element + +/** + *

+ * 页面元素 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IElementService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IGroupService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IGroupService.kt new file mode 100644 index 0000000..94f8aa0 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IGroupService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.Group + +/** + *

+ * 用户组 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IGroupService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IMenuService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IMenuService.kt new file mode 100644 index 0000000..6267758 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IMenuService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.Menu + +/** + *

+ * 菜单 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IMenuService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IOperationService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IOperationService.kt new file mode 100644 index 0000000..0bac5b1 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IOperationService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.Operation + +/** + *

+ * 功能 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IOperationService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IPowerRoleService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IPowerRoleService.kt new file mode 100644 index 0000000..8b8e0e3 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IPowerRoleService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.PowerRole + +/** + *

+ * 中间表-权限-角色 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IPowerRoleService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IPowerService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IPowerService.kt new file mode 100644 index 0000000..03b0d45 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IPowerService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.Power + +/** + *

+ * 权限 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IPowerService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IPowerTypeService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IPowerTypeService.kt new file mode 100644 index 0000000..ecc0491 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IPowerTypeService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.PowerType + +/** + *

+ * 权限类型 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IPowerTypeService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IRoleGroupService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IRoleGroupService.kt new file mode 100644 index 0000000..30ce26b --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IRoleGroupService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.RoleGroup + +/** + *

+ * 中间表-角色-用户组 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IRoleGroupService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IRoleService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IRoleService.kt new file mode 100644 index 0000000..f9c46a0 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IRoleService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.Role + +/** + *

+ * 角色 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IRoleService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IUserGroupService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IUserGroupService.kt new file mode 100644 index 0000000..0356954 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IUserGroupService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.UserGroup + +/** + *

+ * 中间表-用户-用户组 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IUserGroupService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IUserRoleService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IUserRoleService.kt new file mode 100644 index 0000000..be86fef --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/IUserRoleService.kt @@ -0,0 +1,14 @@ +package top.fatweb.api.service.permission + +import com.baomidou.mybatisplus.extension.service.IService +import top.fatweb.api.entity.permission.UserRole + +/** + *

+ * 中间表-用户-角色 服务类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +interface IUserRoleService : IService diff --git a/src/main/kotlin/top/fatweb/api/service/IUserService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IUserService.kt similarity index 84% rename from src/main/kotlin/top/fatweb/api/service/IUserService.kt rename to src/main/kotlin/top/fatweb/api/service/permission/IUserService.kt index 7bc58e9..1e546ea 100644 --- a/src/main/kotlin/top/fatweb/api/service/IUserService.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/IUserService.kt @@ -1,4 +1,4 @@ -package top.fatweb.api.service +package top.fatweb.api.service.permission import com.baomidou.mybatisplus.extension.service.IService import top.fatweb.api.entity.permission.User diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/AuthenticationServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/AuthenticationServiceImpl.kt index eb8c765..e7947ec 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/impl/AuthenticationServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/AuthenticationServiceImpl.kt @@ -11,8 +11,8 @@ import top.fatweb.api.constant.SecurityConstants import top.fatweb.api.entity.permission.LoginUser import top.fatweb.api.entity.permission.User import top.fatweb.api.exception.TokenHasExpiredException -import top.fatweb.api.service.IUserService import top.fatweb.api.service.permission.IAuthenticationService +import top.fatweb.api.service.permission.IUserService import top.fatweb.api.util.JwtUtil import top.fatweb.api.util.RedisUtil import top.fatweb.api.util.WebUtil diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/ElementServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/ElementServiceImpl.kt new file mode 100644 index 0000000..70bb88f --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/ElementServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.Element +import top.fatweb.api.mapper.permission.ElementMapper +import top.fatweb.api.service.permission.IElementService + +/** + *

+ * 页面元素 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class ElementServiceImpl : ServiceImpl(), IElementService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/GroupServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/GroupServiceImpl.kt new file mode 100644 index 0000000..92c06ae --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/GroupServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.Group +import top.fatweb.api.mapper.permission.GroupMapper +import top.fatweb.api.service.permission.IGroupService + +/** + *

+ * 用户组 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class GroupServiceImpl : ServiceImpl(), IGroupService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/MenuServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/MenuServiceImpl.kt new file mode 100644 index 0000000..d431903 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/MenuServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.Menu +import top.fatweb.api.mapper.permission.MenuMapper +import top.fatweb.api.service.permission.IMenuService + +/** + *

+ * 菜单 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class MenuServiceImpl : ServiceImpl(), IMenuService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/OperationServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/OperationServiceImpl.kt new file mode 100644 index 0000000..44076ad --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/OperationServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.Operation +import top.fatweb.api.mapper.permission.OperationMapper +import top.fatweb.api.service.permission.IOperationService + +/** + *

+ * 功能 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class OperationServiceImpl : ServiceImpl(), IOperationService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerRoleServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerRoleServiceImpl.kt new file mode 100644 index 0000000..1dafe8b --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerRoleServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.PowerRole +import top.fatweb.api.mapper.permission.PowerRoleMapper +import top.fatweb.api.service.permission.IPowerRoleService + +/** + *

+ * 中间表-权限-角色 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class PowerRoleServiceImpl : ServiceImpl(), IPowerRoleService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerServiceImpl.kt new file mode 100644 index 0000000..70fdc17 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.Power +import top.fatweb.api.mapper.permission.PowerMapper +import top.fatweb.api.service.permission.IPowerService + +/** + *

+ * 权限 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class PowerServiceImpl : ServiceImpl(), IPowerService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerTypeServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerTypeServiceImpl.kt new file mode 100644 index 0000000..481a0aa --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/PowerTypeServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.PowerType +import top.fatweb.api.mapper.permission.PowerTypeMapper +import top.fatweb.api.service.permission.IPowerTypeService + +/** + *

+ * 权限类型 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class PowerTypeServiceImpl : ServiceImpl(), IPowerTypeService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleGroupServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleGroupServiceImpl.kt new file mode 100644 index 0000000..002c299 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleGroupServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.RoleGroup +import top.fatweb.api.mapper.permission.RoleGroupMapper +import top.fatweb.api.service.permission.IRoleGroupService + +/** + *

+ * 中间表-角色-用户组 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class RoleGroupServiceImpl : ServiceImpl(), IRoleGroupService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleServiceImpl.kt new file mode 100644 index 0000000..c75703d --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.Role +import top.fatweb.api.mapper.permission.RoleMapper +import top.fatweb.api.service.permission.IRoleService + +/** + *

+ * 角色 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class RoleServiceImpl : ServiceImpl(), IRoleService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/UserDetailsServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserDetailsServiceImpl.kt index 6b78e76..db65f6b 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/impl/UserDetailsServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserDetailsServiceImpl.kt @@ -6,7 +6,7 @@ import org.springframework.security.core.userdetails.UserDetailsService import org.springframework.stereotype.Service import top.fatweb.api.entity.permission.LoginUser import top.fatweb.api.entity.permission.User -import top.fatweb.api.service.IUserService +import top.fatweb.api.service.permission.IUserService @Service class UserDetailsServiceImpl(val userService: IUserService) : UserDetailsService { diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/UserGroupServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserGroupServiceImpl.kt new file mode 100644 index 0000000..7bcfd5d --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserGroupServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.UserGroup +import top.fatweb.api.mapper.permission.UserGroupMapper +import top.fatweb.api.service.permission.IUserGroupService + +/** + *

+ * 中间表-用户-用户组 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class UserGroupServiceImpl : ServiceImpl(), IUserGroupService diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/UserRoleServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserRoleServiceImpl.kt new file mode 100644 index 0000000..e89f64d --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserRoleServiceImpl.kt @@ -0,0 +1,18 @@ +package top.fatweb.api.service.permission.impl + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl +import org.springframework.stereotype.Service +import top.fatweb.api.entity.permission.UserRole +import top.fatweb.api.mapper.permission.UserRoleMapper +import top.fatweb.api.service.permission.IUserRoleService + +/** + *

+ * 中间表-用户-角色 服务实现类 + *

+ * + * @author FatttSnake + * @since 2023-10-25 + */ +@Service +class UserRoleServiceImpl : ServiceImpl(), IUserRoleService diff --git a/src/main/kotlin/top/fatweb/api/service/impl/UserServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserServiceImpl.kt similarity index 68% rename from src/main/kotlin/top/fatweb/api/service/impl/UserServiceImpl.kt rename to src/main/kotlin/top/fatweb/api/service/permission/impl/UserServiceImpl.kt index e522f6b..2b213b2 100644 --- a/src/main/kotlin/top/fatweb/api/service/impl/UserServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserServiceImpl.kt @@ -1,10 +1,10 @@ -package top.fatweb.api.service.impl +package top.fatweb.api.service.permission.impl import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl import org.springframework.stereotype.Service import top.fatweb.api.entity.permission.User -import top.fatweb.api.mapper.UserMapper -import top.fatweb.api.service.IUserService +import top.fatweb.api.mapper.permission.UserMapper +import top.fatweb.api.service.permission.IUserService /** *

diff --git a/src/main/resources/db/migration/R__Basic_data.sql b/src/main/resources/db/migration/R__Basic_data.sql index 6dfc7db..e9d4747 100644 --- a/src/main/resources/db/migration/R__Basic_data.sql +++ b/src/main/resources/db/migration/R__Basic_data.sql @@ -41,9 +41,9 @@ on duplicate key update name = values(name), insert into t_element(id, name, power_id, menu_id) values (1010100, '公用', id, 1010000), - (101010100, '基础', id, 101010000), - (102010100, '基础', id, 102010000), - (103010100, '基础', id, 103010000) + (101010100, '角色基础', id, 101010000), + (102010100, '用户组基础', id, 102010000), + (103010100, '用户基础', id, 103010000) on duplicate key update name = values(name), power_id=values(power_id), menu_id = values(menu_id); diff --git a/src/main/resources/db/migration/V1_0_0_231024__Add_table_'t_power'.sql b/src/main/resources/db/migration/V1_0_0_231024__Add_table_'t_power'.sql index bd32054..b7ba089 100644 --- a/src/main/resources/db/migration/V1_0_0_231024__Add_table_'t_power'.sql +++ b/src/main/resources/db/migration/V1_0_0_231024__Add_table_'t_power'.sql @@ -2,6 +2,6 @@ drop table if exists t_power; create table if not exists t_power ( - `id` bigint not null primary key, - `type_id` bigint not null comment '权限类型' + id bigint not null primary key, + type_id bigint not null comment '权限类型' ) comment '权限'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231025__Add_table_'t_menu'.sql b/src/main/resources/db/migration/V1_0_0_231025__Add_table_'t_menu'.sql index d85e070..7d7e26f 100644 --- a/src/main/resources/db/migration/V1_0_0_231025__Add_table_'t_menu'.sql +++ b/src/main/resources/db/migration/V1_0_0_231025__Add_table_'t_menu'.sql @@ -2,9 +2,9 @@ drop table if exists t_menu; create table if not exists t_menu ( - `id` bigint not null primary key, - `name` varchar(30) not null comment ' 菜单名', - `url` varchar(100) null comment 'URL', - `power_id` bigint not null comment '权限ID', - `parent_id` bigint null comment '父ID' + id bigint not null primary key, + name varchar(30) not null comment ' 菜单名', + url varchar(100) null comment 'URL', + power_id bigint not null comment '权限ID', + parent_id bigint null comment '父ID' ) comment '菜单'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231026__Add_table_'t_element'.sql b/src/main/resources/db/migration/V1_0_0_231026__Add_table_'t_element'.sql index 1175c69..27bc46c 100644 --- a/src/main/resources/db/migration/V1_0_0_231026__Add_table_'t_element'.sql +++ b/src/main/resources/db/migration/V1_0_0_231026__Add_table_'t_element'.sql @@ -2,8 +2,8 @@ drop table if exists t_element; create table if not exists t_element ( - `id` bigint not null primary key, - `name` varchar(100) not null comment '元素名', - `power_id` bigint not null comment '权限ID', - `menu_id` bigint not null comment '菜单ID' + id bigint not null primary key, + name varchar(100) not null comment '元素名', + power_id bigint not null comment '权限ID', + menu_id bigint not null comment '菜单ID' ) comment '页面元素'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231027__Add_table_'t_operation'.sql b/src/main/resources/db/migration/V1_0_0_231027__Add_table_'t_operation'.sql index dc73326..b239e1b 100644 --- a/src/main/resources/db/migration/V1_0_0_231027__Add_table_'t_operation'.sql +++ b/src/main/resources/db/migration/V1_0_0_231027__Add_table_'t_operation'.sql @@ -2,10 +2,10 @@ drop table if exists t_operation; create table if not exists t_operation ( - `id` bigint not null primary key, - `name` varchar(50) not null comment '功能名', - `code` varchar(50) null comment '功能编码', - `power_id` bigint not null comment '权限ID', - `parent_id` bigint null comment '父ID', - `element_id` bigint not null comment '页面元素ID' + id bigint not null primary key, + name varchar(50) not null comment '功能名', + code varchar(50) null comment '功能编码', + power_id bigint not null comment '权限ID', + parent_id bigint null comment '父ID', + element_id bigint not null comment '页面元素ID' ) comment '功能'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231028__Add_table_'t_group'.sql b/src/main/resources/db/migration/V1_0_0_231028__Add_table_'t_group'.sql new file mode 100644 index 0000000..9a4d162 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231028__Add_table_'t_group'.sql @@ -0,0 +1,11 @@ +drop table if exists t_group; + +create table if not exists t_group +( + id bigint not null primary key, + name varchar(30) not null comment '用户组名', + enable int not null comment '启用', + deleted bigint not null default 0, + version int not null default 0, + constraint t_group_unique unique (name, deleted) +) comment '用户组'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231029__Add_table_'t_user_group'.sql b/src/main/resources/db/migration/V1_0_0_231029__Add_table_'t_user_group'.sql new file mode 100644 index 0000000..27ede64 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231029__Add_table_'t_user_group'.sql @@ -0,0 +1,10 @@ +drop table if exists t_user_group; + +create table if not exists t_user_group +( + id bigint not null primary key, + user_id bigint not null comment '用户', + group_id bigint not null comment '用户组', + deleted bigint not null default 0, + version int not null default 0 +) comment '中间表-用户-用户组'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231030__Add_table_'t_role'.sql b/src/main/resources/db/migration/V1_0_0_231030__Add_table_'t_role'.sql new file mode 100644 index 0000000..7ace525 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231030__Add_table_'t_role'.sql @@ -0,0 +1,11 @@ +drop table if exists t_role; + +create table if not exists t_role +( + id bigint not null primary key, + name varchar(20) not null comment '角色名', + enable int not null comment '启用', + deleted bigint not null default 0, + version int not null default 0, + constraint t_role_unique unique (name, deleted) +) comment '角色'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231031__Add_table_'t_role_group'.sql b/src/main/resources/db/migration/V1_0_0_231031__Add_table_'t_role_group'.sql new file mode 100644 index 0000000..9492e35 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231031__Add_table_'t_role_group'.sql @@ -0,0 +1,10 @@ +drop table if exists t_role_group; + +create table if not exists t_role_group +( + id bigint not null primary key, + role_id bigint not null comment '角色', + group_id bigint not null comment '群组', + deleted bigint not null default 0, + version int not null default 0 +) comment '中间表-角色-用户组'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231101__Add_table_'t_user_role'.sql b/src/main/resources/db/migration/V1_0_0_231101__Add_table_'t_user_role'.sql new file mode 100644 index 0000000..27d674d --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231101__Add_table_'t_user_role'.sql @@ -0,0 +1,10 @@ +drop table if exists t_user_role; + +create table if not exists t_user_role +( + id bigint not null primary key, + user_id bigint not null comment '用户', + role_id bigint not null comment '角色', + deleted bigint not null default 0, + version int not null default 0 +) comment '中间表-用户-角色'; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0_0_231102__Add_table_'t_power_role'.sql b/src/main/resources/db/migration/V1_0_0_231102__Add_table_'t_power_role'.sql new file mode 100644 index 0000000..854e78b --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0_231102__Add_table_'t_power_role'.sql @@ -0,0 +1,10 @@ +drop table if exists t_power_role; + +create table if not exists t_power_role +( + id bigint not null primary key, + power_id bigint not null comment '权限', + role_id bigint not null comment '角色', + deleted bigint not null default 0, + version int not null default 0 +) comment '中间表-权限-角色'; \ No newline at end of file diff --git a/src/main/resources/mapper/permission/ElementMapper.xml b/src/main/resources/mapper/permission/ElementMapper.xml new file mode 100644 index 0000000..f29cb9f --- /dev/null +++ b/src/main/resources/mapper/permission/ElementMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/GroupMapper.xml b/src/main/resources/mapper/permission/GroupMapper.xml new file mode 100644 index 0000000..861ee18 --- /dev/null +++ b/src/main/resources/mapper/permission/GroupMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/MenuMapper.xml b/src/main/resources/mapper/permission/MenuMapper.xml new file mode 100644 index 0000000..aaf1664 --- /dev/null +++ b/src/main/resources/mapper/permission/MenuMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/OperationMapper.xml b/src/main/resources/mapper/permission/OperationMapper.xml new file mode 100644 index 0000000..174b17b --- /dev/null +++ b/src/main/resources/mapper/permission/OperationMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/PowerMapper.xml b/src/main/resources/mapper/permission/PowerMapper.xml new file mode 100644 index 0000000..c9854f0 --- /dev/null +++ b/src/main/resources/mapper/permission/PowerMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/PowerRoleMapper.xml b/src/main/resources/mapper/permission/PowerRoleMapper.xml new file mode 100644 index 0000000..3004952 --- /dev/null +++ b/src/main/resources/mapper/permission/PowerRoleMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/PowerTypeMapper.xml b/src/main/resources/mapper/permission/PowerTypeMapper.xml new file mode 100644 index 0000000..8c3fe6e --- /dev/null +++ b/src/main/resources/mapper/permission/PowerTypeMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/RoleGroupMapper.xml b/src/main/resources/mapper/permission/RoleGroupMapper.xml new file mode 100644 index 0000000..678e1eb --- /dev/null +++ b/src/main/resources/mapper/permission/RoleGroupMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/RoleMapper.xml b/src/main/resources/mapper/permission/RoleMapper.xml new file mode 100644 index 0000000..b84d046 --- /dev/null +++ b/src/main/resources/mapper/permission/RoleMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/permission/UserGroupMapper.xml b/src/main/resources/mapper/permission/UserGroupMapper.xml new file mode 100644 index 0000000..9eaaad8 --- /dev/null +++ b/src/main/resources/mapper/permission/UserGroupMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/permission/UserMapper.xml similarity index 70% rename from src/main/resources/mapper/UserMapper.xml rename to src/main/resources/mapper/permission/UserMapper.xml index cecc32c..668c8e5 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/permission/UserMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/src/main/resources/mapper/permission/UserRoleMapper.xml b/src/main/resources/mapper/permission/UserRoleMapper.xml new file mode 100644 index 0000000..9884516 --- /dev/null +++ b/src/main/resources/mapper/permission/UserRoleMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/SysLogMapper.xml b/src/main/resources/mapper/system/SysLogMapper.xml similarity index 100% rename from src/main/resources/mapper/SysLogMapper.xml rename to src/main/resources/mapper/system/SysLogMapper.xml