Add group role tables

This commit is contained in:
2023-10-25 11:02:40 +08:00
parent 087e6ae8c3
commit 979d1d8fb8
75 changed files with 1172 additions and 30 deletions

View File

@@ -7,7 +7,7 @@ import org.slf4j.LoggerFactory
import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.stereotype.Component import org.springframework.stereotype.Component
import top.fatweb.api.entity.permission.User import top.fatweb.api.entity.permission.User
import top.fatweb.api.service.IUserService import top.fatweb.api.service.permission.IUserService
import kotlin.random.Random import kotlin.random.Random
@Component @Component

View File

@@ -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
/**
* <p>
* 页面元素
* </p>
*
* @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)"
}
}

View File

@@ -0,0 +1,46 @@
package top.fatweb.api.entity.permission
import com.baomidou.mybatisplus.annotation.*
import java.io.Serializable
/**
* <p>
* 用户组
* </p>
*
* @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<Role>? = null
override fun toString(): String {
return "Group(id=$id, name=$name, enable=$enable, deleted=$deleted, version=$version, roles=$roles)"
}
}

View File

@@ -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
/**
* <p>
* 菜单
* </p>
*
* @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)"
}
}

View File

@@ -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
/**
* <p>
* 功能
* </p>
*
* @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)"
}
}

View File

@@ -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
/**
* <p>
* 权限
* </p>
*
* @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)"
}
}

View File

@@ -0,0 +1,43 @@
package top.fatweb.api.entity.permission
import com.baomidou.mybatisplus.annotation.*
import java.io.Serializable
/**
* <p>
* 中间表-权限-角色
* </p>
*
* @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)"
}
}

View File

@@ -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
/**
* <p>
* 权限类型
* </p>
*
* @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)"
}
}

View File

@@ -0,0 +1,55 @@
package top.fatweb.api.entity.permission
import com.baomidou.mybatisplus.annotation.*
import java.io.Serializable
/**
* <p>
* 角色
* </p>
*
* @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<Menu>? = null
@TableField(exist = false)
var elements: List<Element>? = null
@TableField(exist = false)
var operations: List<Operation>? = null
@TableField(exist = false)
var powers: List<Power>? = 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)"
}
}

View File

@@ -0,0 +1,43 @@
package top.fatweb.api.entity.permission
import com.baomidou.mybatisplus.annotation.*
import java.io.Serializable
/**
* <p>
* 中间表-角色-用户组
* </p>
*
* @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)"
}
}

View File

@@ -92,7 +92,22 @@ class User() : Serializable {
@Version @Version
var version: Int? = null var version: Int? = null
@TableField(exist = false)
var roles: List<Role>? = null
@TableField(exist = false)
var groups: List<Group>? = null
@TableField(exist = false)
var menus: List<Menu>? = null
@TableField(exist = false)
var elements: List<Element>? = null
@TableField(exist = false)
var operations: List<Operation>? = null
override fun toString(): String { 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)"
} }
} }

View File

@@ -0,0 +1,43 @@
package top.fatweb.api.entity.permission
import com.baomidou.mybatisplus.annotation.*
import java.io.Serializable
/**
* <p>
* 中间表-用户-用户组
* </p>
*
* @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)"
}
}

View File

@@ -0,0 +1,43 @@
package top.fatweb.api.entity.permission
import com.baomidou.mybatisplus.annotation.*
import java.io.Serializable
/**
* <p>
* 中间表-用户-角色
* </p>
*
* @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)"
}
}

View File

@@ -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
/**
* <p>
* 页面元素 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface ElementMapper : BaseMapper<Element>

View File

@@ -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
/**
* <p>
* 用户组 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface GroupMapper : BaseMapper<Group>

View File

@@ -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
/**
* <p>
* 菜单 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface MenuMapper : BaseMapper<Menu>

View File

@@ -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
/**
* <p>
* 功能 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface OperationMapper : BaseMapper<Operation>

View File

@@ -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
/**
* <p>
* 权限 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface PowerMapper : BaseMapper<Power>

View File

@@ -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
/**
* <p>
* 中间表-权限-角色 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface PowerRoleMapper : BaseMapper<PowerRole>

View File

@@ -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
/**
* <p>
* 权限类型 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface PowerTypeMapper : BaseMapper<PowerType>

View File

@@ -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
/**
* <p>
* 中间表-角色-用户组 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface RoleGroupMapper : BaseMapper<RoleGroup>

View File

@@ -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
/**
* <p>
* 角色 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface RoleMapper : BaseMapper<Role>

View File

@@ -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
/**
* <p>
* 中间表-用户-用户组 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface UserGroupMapper : BaseMapper<UserGroup>

View File

@@ -1,4 +1,4 @@
package top.fatweb.api.mapper package top.fatweb.api.mapper.permission
import com.baomidou.mybatisplus.core.mapper.BaseMapper import com.baomidou.mybatisplus.core.mapper.BaseMapper
import org.apache.ibatis.annotations.Mapper import org.apache.ibatis.annotations.Mapper

View File

@@ -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
/**
* <p>
* 中间表-用户-角色 Mapper 接口
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Mapper
interface UserRoleMapper : BaseMapper<UserRole>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.Element
/**
* <p>
* 页面元素 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IElementService : IService<Element>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.Group
/**
* <p>
* 用户组 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IGroupService : IService<Group>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.Menu
/**
* <p>
* 菜单 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IMenuService : IService<Menu>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.Operation
/**
* <p>
* 功能 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IOperationService : IService<Operation>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.PowerRole
/**
* <p>
* 中间表-权限-角色 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IPowerRoleService : IService<PowerRole>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.Power
/**
* <p>
* 权限 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IPowerService : IService<Power>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.PowerType
/**
* <p>
* 权限类型 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IPowerTypeService : IService<PowerType>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.RoleGroup
/**
* <p>
* 中间表-角色-用户组 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IRoleGroupService : IService<RoleGroup>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.Role
/**
* <p>
* 角色 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IRoleService : IService<Role>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.UserGroup
/**
* <p>
* 中间表-用户-用户组 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IUserGroupService : IService<UserGroup>

View File

@@ -0,0 +1,14 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.UserRole
/**
* <p>
* 中间表-用户-角色 服务类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
interface IUserRoleService : IService<UserRole>

View File

@@ -1,4 +1,4 @@
package top.fatweb.api.service package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.User import top.fatweb.api.entity.permission.User

View File

@@ -11,8 +11,8 @@ import top.fatweb.api.constant.SecurityConstants
import top.fatweb.api.entity.permission.LoginUser import top.fatweb.api.entity.permission.LoginUser
import top.fatweb.api.entity.permission.User import top.fatweb.api.entity.permission.User
import top.fatweb.api.exception.TokenHasExpiredException 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.IAuthenticationService
import top.fatweb.api.service.permission.IUserService
import top.fatweb.api.util.JwtUtil import top.fatweb.api.util.JwtUtil
import top.fatweb.api.util.RedisUtil import top.fatweb.api.util.RedisUtil
import top.fatweb.api.util.WebUtil import top.fatweb.api.util.WebUtil

View File

@@ -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
/**
* <p>
* 页面元素 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class ElementServiceImpl : ServiceImpl<ElementMapper, Element>(), IElementService

View File

@@ -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
/**
* <p>
* 用户组 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class GroupServiceImpl : ServiceImpl<GroupMapper, Group>(), IGroupService

View File

@@ -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
/**
* <p>
* 菜单 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class MenuServiceImpl : ServiceImpl<MenuMapper, Menu>(), IMenuService

View File

@@ -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
/**
* <p>
* 功能 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class OperationServiceImpl : ServiceImpl<OperationMapper, Operation>(), IOperationService

View File

@@ -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
/**
* <p>
* 中间表-权限-角色 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class PowerRoleServiceImpl : ServiceImpl<PowerRoleMapper, PowerRole>(), IPowerRoleService

View File

@@ -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
/**
* <p>
* 权限 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class PowerServiceImpl : ServiceImpl<PowerMapper, Power>(), IPowerService

View File

@@ -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
/**
* <p>
* 权限类型 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class PowerTypeServiceImpl : ServiceImpl<PowerTypeMapper, PowerType>(), IPowerTypeService

View File

@@ -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
/**
* <p>
* 中间表-角色-用户组 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class RoleGroupServiceImpl : ServiceImpl<RoleGroupMapper, RoleGroup>(), IRoleGroupService

View File

@@ -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
/**
* <p>
* 角色 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class RoleServiceImpl : ServiceImpl<RoleMapper, Role>(), IRoleService

View File

@@ -6,7 +6,7 @@ import org.springframework.security.core.userdetails.UserDetailsService
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import top.fatweb.api.entity.permission.LoginUser import top.fatweb.api.entity.permission.LoginUser
import top.fatweb.api.entity.permission.User import top.fatweb.api.entity.permission.User
import top.fatweb.api.service.IUserService import top.fatweb.api.service.permission.IUserService
@Service @Service
class UserDetailsServiceImpl(val userService: IUserService) : UserDetailsService { class UserDetailsServiceImpl(val userService: IUserService) : UserDetailsService {

View File

@@ -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
/**
* <p>
* 中间表-用户-用户组 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class UserGroupServiceImpl : ServiceImpl<UserGroupMapper, UserGroup>(), IUserGroupService

View File

@@ -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
/**
* <p>
* 中间表-用户-角色 服务实现类
* </p>
*
* @author FatttSnake
* @since 2023-10-25
*/
@Service
class UserRoleServiceImpl : ServiceImpl<UserRoleMapper, UserRole>(), IUserRoleService

View File

@@ -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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import top.fatweb.api.entity.permission.User import top.fatweb.api.entity.permission.User
import top.fatweb.api.mapper.UserMapper import top.fatweb.api.mapper.permission.UserMapper
import top.fatweb.api.service.IUserService import top.fatweb.api.service.permission.IUserService
/** /**
* <p> * <p>

View File

@@ -41,9 +41,9 @@ on duplicate key update name = values(name),
insert into t_element(id, name, power_id, menu_id) insert into t_element(id, name, power_id, menu_id)
values (1010100, '公用', id, 1010000), values (1010100, '公用', id, 1010000),
(101010100, '基础', id, 101010000), (101010100, '角色基础', id, 101010000),
(102010100, '基础', id, 102010000), (102010100, '用户组基础', id, 102010000),
(103010100, '基础', id, 103010000) (103010100, '用户基础', id, 103010000)
on duplicate key update name = values(name), on duplicate key update name = values(name),
power_id=values(power_id), power_id=values(power_id),
menu_id = values(menu_id); menu_id = values(menu_id);

View File

@@ -2,6 +2,6 @@ drop table if exists t_power;
create table if not exists t_power create table if not exists t_power
( (
`id` bigint not null primary key, id bigint not null primary key,
`type_id` bigint not null comment '权限类型' type_id bigint not null comment '权限类型'
) comment '权限'; ) comment '权限';

View File

@@ -2,9 +2,9 @@ drop table if exists t_menu;
create table if not exists t_menu create table if not exists t_menu
( (
`id` bigint not null primary key, id bigint not null primary key,
`name` varchar(30) not null comment ' 菜单名', name varchar(30) not null comment ' 菜单名',
`url` varchar(100) null comment 'URL', url varchar(100) null comment 'URL',
`power_id` bigint not null comment '权限ID', power_id bigint not null comment '权限ID',
`parent_id` bigint null comment '父ID' parent_id bigint null comment '父ID'
) comment '菜单'; ) comment '菜单';

View File

@@ -2,8 +2,8 @@ drop table if exists t_element;
create table if not exists t_element create table if not exists t_element
( (
`id` bigint not null primary key, id bigint not null primary key,
`name` varchar(100) not null comment '元素名', name varchar(100) not null comment '元素名',
`power_id` bigint not null comment '权限ID', power_id bigint not null comment '权限ID',
`menu_id` bigint not null comment '菜单ID' menu_id bigint not null comment '菜单ID'
) comment '页面元素'; ) comment '页面元素';

View File

@@ -2,10 +2,10 @@ drop table if exists t_operation;
create table if not exists t_operation create table if not exists t_operation
( (
`id` bigint not null primary key, id bigint not null primary key,
`name` varchar(50) not null comment '功能名', name varchar(50) not null comment '功能名',
`code` varchar(50) null comment '功能编码', code varchar(50) null comment '功能编码',
`power_id` bigint not null comment '权限ID', power_id bigint not null comment '权限ID',
`parent_id` bigint null comment '父ID', parent_id bigint null comment '父ID',
`element_id` bigint not null comment '页面元素ID' element_id bigint not null comment '页面元素ID'
) comment '功能'; ) comment '功能';

View File

@@ -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 '用户组';

View File

@@ -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 '中间表-用户-用户组';

View File

@@ -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 '角色';

View File

@@ -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 '中间表-角色-用户组';

View File

@@ -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 '中间表-用户-角色';

View File

@@ -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 '中间表-权限-角色';

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.ElementMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.GroupMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.MenuMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.OperationMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.PowerMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.PowerRoleMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.PowerTypeMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.RoleGroupMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.RoleMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.UserGroupMapper">
</mapper>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.UserMapper"> <mapper namespace="top.fatweb.api.mapper.permission.UserMapper">
</mapper> </mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.UserRoleMapper">
</mapper>