Rename table t_element to t_func

This commit is contained in:
2023-11-30 23:03:42 +08:00
parent 4fcbceb149
commit cdb6339787
31 changed files with 132 additions and 132 deletions

View File

@@ -1,19 +0,0 @@
package top.fatweb.api.converter.permission
import top.fatweb.api.entity.permission.Element
import top.fatweb.api.vo.permission.base.ElementVo
/**
* Element converter
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
object ElementConverter {
fun elementToElementVo(element: Element) = ElementVo(
id = element.id,
name = element.name,
parentId = element.parentId,
menuId = element.menuId
)
}

View File

@@ -0,0 +1,19 @@
package top.fatweb.api.converter.permission
import top.fatweb.api.entity.permission.Func
import top.fatweb.api.vo.permission.base.FuncVo
/**
* Function converter
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
object FuncConverter {
fun funcToFuncVo(func: Func) = FuncVo(
id = func.id,
name = func.name,
parentId = func.parentId,
menuId = func.menuId
)
}

View File

@@ -14,6 +14,6 @@ object OperationConverter {
id = operation.id,
name = operation.name,
code = operation.code,
elementId = operation.elementId
funcId = operation.funcId
)
}

View File

@@ -13,7 +13,7 @@ object PowerConverter {
fun powerSetToPowerSetVo(powerSet: PowerSet) = PowerSetVo(
moduleList = powerSet.moduleList?.map { ModuleConverter.moduleToModuleVo(it) },
menuList = powerSet.menuList?.map { MenuConverter.menuToMenuVo(it) },
elementList = powerSet.elementList?.map { ElementConverter.elementToElementVo(it) },
funcList = powerSet.funcList?.map { FuncConverter.funcToFuncVo(it) },
operationList = powerSet.operationList?.map { OperationConverter.operationToOperationVo(it) }
)
}

View File

@@ -33,7 +33,7 @@ object RoleConverter {
updateTime = role.updateTime,
modules = role.modules?.map { ModuleConverter.moduleToModuleVo(it) },
menus = role.menus?.map { MenuConverter.menuToMenuVo(it) },
elements = role.elements?.map { ElementConverter.elementToElementVo(it) },
funcs = role.funcs?.map { FuncConverter.funcToFuncVo(it) },
operations = role.operations?.map { OperationConverter.operationToOperationVo(it) }
)

View File

@@ -50,8 +50,8 @@ object UserConverter {
menus = user.menus?.map {
MenuConverter.menuToMenuVo(it)
},
elements = user.elements?.map {
ElementConverter.elementToElementVo(it)
funcs = user.funcs?.map {
FuncConverter.funcToFuncVo(it)
},
operations = user.operations?.map {
OperationConverter.operationToOperationVo(it)

View File

@@ -6,19 +6,19 @@ import com.baomidou.mybatisplus.annotation.TableName
import java.io.Serializable
/**
* Element entity
* Function entity
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@TableName("t_element")
class Element : Serializable {
@TableName("t_func")
class Func : Serializable {
@TableId("id")
var id: Long? = null
/**
* 元素
* 功能
*/
@TableField("name")
var name: String? = null
@@ -36,6 +36,6 @@ class Element : Serializable {
var menuId: Long? = null
override fun toString(): String {
return "Element(id=$id, name=$name, parentId=$parentId, menuId=$menuId)"
return "Func(id=$id, name=$name, parentId=$parentId, menuId=$menuId)"
}
}

View File

@@ -18,24 +18,24 @@ class Operation : Serializable {
var id: Long? = null
/**
* 功能
* 操作
*/
@TableField("name")
var name: String? = null
/**
* 功能编码
* 操作编码
*/
@TableField("code")
var code: String? = null
/**
* 页面元素ID
* 功能ID
*/
@TableField("element_id")
var elementId: Long? = null
@TableField("func_id")
var funcId: Long? = null
override fun toString(): String {
return "Operation(id=$id, name=$name, code=$code, elementId=$elementId)"
return "Operation(id=$id, name=$name, code=$code, funcId=$funcId)"
}
}

View File

@@ -13,7 +13,7 @@ class PowerSet : Serializable {
var menuList: List<Menu>? = null
var elementList: List<Element>? = null
var funcList: List<Func>? = null
var operationList: List<Operation>? = null
}

View File

@@ -55,7 +55,7 @@ class Role : Serializable {
var menus: List<Menu>? = null
@TableField(exist = false)
var elements: List<Element>? = null
var funcs: List<Func>? = null
@TableField(exist = false)
var operations: List<Operation>? = null
@@ -64,6 +64,6 @@ class Role : Serializable {
var powers: List<Power>? = null
override fun toString(): String {
return "Role(id=$id, name=$name, enable=$enable, deleted=$deleted, version=$version, modules=$modules, menus=$menus, elements=$elements, operations=$operations, powers=$powers)"
return "Role(id=$id, name=$name, enable=$enable, deleted=$deleted, version=$version, modules=$modules, menus=$menus, funcs=$funcs, operations=$operations, powers=$powers)"
}
}

View File

@@ -118,12 +118,12 @@ class User() : Serializable {
var menus: List<Menu>? = null
@TableField(exist = false)
var elements: List<Element>? = null
var funcs: List<Func>? = null
@TableField(exist = false)
var operations: List<Operation>? = null
override fun toString(): String {
return "User(id=$id, username=$username, password=$password, locking=$locking, expiration=$expiration, credentialsExpiration=$credentialsExpiration, enable=$enable, currentLoginTime=$currentLoginTime, currentLoginIp=$currentLoginIp, lastLoginTime=$lastLoginTime, lastLoginIp=$lastLoginIp, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, userInfo=$userInfo, roles=$roles, groups=$groups, modules=$modules, menus=$menus, elements=$elements, operations=$operations)"
return "User(id=$id, username=$username, password=$password, locking=$locking, expiration=$expiration, credentialsExpiration=$credentialsExpiration, enable=$enable, currentLoginTime=$currentLoginTime, currentLoginIp=$currentLoginIp, lastLoginTime=$lastLoginTime, lastLoginIp=$lastLoginIp, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version, userInfo=$userInfo, roles=$roles, groups=$groups, modules=$modules, menus=$menus, funcs=$funcs, operations=$operations)"
}
}

View File

@@ -2,13 +2,13 @@ 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
import top.fatweb.api.entity.permission.Func
/**
* Element mapper
* Function mapper
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Mapper
interface ElementMapper : BaseMapper<Element>
interface FuncMapper : BaseMapper<Func>

View File

@@ -1,12 +1,12 @@
package top.fatweb.api.service.permission
import com.baomidou.mybatisplus.extension.service.IService
import top.fatweb.api.entity.permission.Element
import top.fatweb.api.entity.permission.Func
/**
* Element service interface
* Function service interface
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
interface IElementService : IService<Element>
interface IFuncService : IService<Func>

View File

@@ -1,16 +0,0 @@
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
/**
* Element service implement
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Service
class ElementServiceImpl : ServiceImpl<ElementMapper, Element>(), IElementService

View File

@@ -0,0 +1,16 @@
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.Func
import top.fatweb.api.mapper.permission.FuncMapper
import top.fatweb.api.service.permission.IFuncService
/**
* Function service implement
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Service
class FuncServiceImpl : ServiceImpl<FuncMapper, Func>(), IFuncService

View File

@@ -18,13 +18,13 @@ import top.fatweb.api.service.permission.*
class PowerServiceImpl(
private val moduleService: IModuleService,
private val menuService: IMenuService,
private val elementService: IElementService,
private val funcService: IFuncService,
private val operationService: IOperationService
) : ServiceImpl<PowerMapper, Power>(), IPowerService {
override fun getList() = PowerConverter.powerSetToPowerSetVo(PowerSet().apply {
moduleList = moduleService.list()
menuList = menuService.list()
elementList = elementService.list()
funcList = funcService.list()
operationList = operationService.list()
})
}

View File

@@ -10,7 +10,7 @@ import top.fatweb.api.entity.permission.PowerRole
import top.fatweb.api.entity.permission.Role
import top.fatweb.api.mapper.permission.RoleMapper
import top.fatweb.api.param.permission.role.*
import top.fatweb.api.service.permission.IElementService
import top.fatweb.api.service.permission.IFuncService
import top.fatweb.api.service.permission.IMenuService
import top.fatweb.api.service.permission.IPowerRoleService
import top.fatweb.api.service.permission.IRoleService
@@ -28,7 +28,7 @@ import top.fatweb.api.vo.permission.RoleWithPowerVo
@Service
class RoleServiceImpl(
private val powerRoleService: IPowerRoleService,
private val elementService: IElementService,
private val funcService: IFuncService,
private val menuService: IMenuService
) : ServiceImpl<RoleMapper, Role>(), IRoleService {
override fun getPage(roleGetParam: RoleGetParam?): PageVo<RoleWithPowerVo> {
@@ -150,7 +150,7 @@ class RoleServiceImpl(
private fun getElementParent(id: Long, parentIds: HashSet<Long>) {
parentIds.add(id)
elementService.getById(id)?.parentId?.let {
funcService.getById(id)?.parentId?.let {
getElementParent(it, parentIds)
}
}

View File

@@ -38,7 +38,7 @@ class UserServiceImpl(
private val userInfoService: IUserInfoService,
private val moduleService: IModuleService,
private val menuService: IMenuService,
private val elementService: IElementService,
private val funcService: IFuncService,
private val operationService: IOperationService,
private val userRoleService: IUserRoleService,
private val userGroupService: IUserGroupService
@@ -50,7 +50,7 @@ class UserServiceImpl(
if (user.id == 0L) {
user.modules = moduleService.list()
user.menus = menuService.list()
user.elements = elementService.list()
user.funcs = funcService.list()
user.operations = operationService.list()
}

View File

@@ -1,7 +1,7 @@
package top.fatweb.api.vo.permission
import io.swagger.v3.oas.annotations.media.Schema
import top.fatweb.api.vo.permission.base.ElementVo
import top.fatweb.api.vo.permission.base.FuncVo
import top.fatweb.api.vo.permission.base.MenuVo
import top.fatweb.api.vo.permission.base.ModuleVo
import top.fatweb.api.vo.permission.base.OperationVo
@@ -20,9 +20,9 @@ data class PowerSetVo(
@Schema(description = "菜单列表")
val menuList: List<MenuVo>?,
@Schema(description = "页面元素列表")
val elementList: List<ElementVo>?,
@Schema(description = "功能列表")
val funcList: List<FuncVo>?,
@Schema(description = "操作列表")
val operationList: List<OperationVo>?
)

View File

@@ -3,7 +3,7 @@ package top.fatweb.api.vo.permission
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
import io.swagger.v3.oas.annotations.media.Schema
import top.fatweb.api.vo.permission.base.ElementVo
import top.fatweb.api.vo.permission.base.FuncVo
import top.fatweb.api.vo.permission.base.MenuVo
import top.fatweb.api.vo.permission.base.ModuleVo
import top.fatweb.api.vo.permission.base.OperationVo
@@ -38,9 +38,9 @@ data class RoleWithPowerVo(
@Schema(description = "菜单列表")
val menus: List<MenuVo>?,
@Schema(description = "页面元素列表")
val elements: List<ElementVo>?,
@Schema(description = "功能列表")
val funcs: List<FuncVo>?,
@Schema(description = "操作列表")
val operations: List<OperationVo>?
)

View File

@@ -59,9 +59,9 @@ data class UserWithPowerInfoVo(
@Schema(description = "菜单列表")
val menus: List<MenuVo>?,
@Schema(description = "页面元素列表")
val elements: List<ElementVo>?,
@Schema(description = "功能列表")
val funcs: List<FuncVo>?,
@Schema(description = "操作列表")
val operations: List<OperationVo>?
)

View File

@@ -3,16 +3,16 @@ package top.fatweb.api.vo.permission.base
import io.swagger.v3.oas.annotations.media.Schema
/**
* Element value object
* Function value object
*
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "页面元素返回参数")
data class ElementVo(
@Schema(description = "功能返回参数")
data class FuncVo(
val id: Long?,
@Schema(description = "元素", example = "AddButton")
@Schema(description = "功能", example = "AddButton")
val name: String?,
@Schema(description = "父 ID")

View File

@@ -8,16 +8,16 @@ import io.swagger.v3.oas.annotations.media.Schema
* @author FatttSnake, fatttsnake@gmail.com
* @since 1.0.0
*/
@Schema(description = "功能返回参数")
@Schema(description = "操作返回参数")
data class OperationVo(
val id: Long?,
@Schema(description = "功能", example = "Add User")
@Schema(description = "操作", example = "Add User")
val name: String?,
@Schema(description = "功能编码", example = "system:user:add")
@Schema(description = "操作编码", example = "system:user:add")
val code: String?,
@Schema(description = "页面元素 ID")
val elementId: Long?
@Schema(description = "功能 ID")
val funcId: Long?
)

View File

@@ -1,7 +1,7 @@
insert into t_power_type (id, name)
values (1, 'module'),
(2, 'menu'),
(3, 'element'),
(3, 'func'),
(4, 'operation') as new_value
on duplicate key update name = new_value.name;
@@ -68,7 +68,7 @@ on duplicate key update name =new_value.name,
url =new_value.url,
parent_id =new_value.parent_id;
insert into t_element(id, name, menu_id, parent_id)
insert into t_func(id, name, menu_id, parent_id)
values (1010100, '查询', 1010000, null),
(1010200, '增加', 1010000, null),
(1010300, '修改', 1010000, null),
@@ -87,7 +87,7 @@ on duplicate key update name = new_value.name,
menu_id = new_value.menu_id,
parent_id = new_value.parent_id;
insert into t_operation(id, name, code, element_id)
insert into t_operation(id, name, code, func_id)
values (1010101, '单个', 'system:user:query:one', 1010100),
(1010102, '全部', 'system:user:query:all', 1010100),
(1010103, '列表', 'system:user:query:list', 1010100),
@@ -116,4 +116,4 @@ insert into t_operation(id, name, code, element_id)
(1510101, '列表', 'system:log:query:all', 1510100) as new_value
on duplicate key update name=new_value.name,
code=new_value.code,
element_id=new_value.element_id;
func_id=new_value.func_id;

View File

@@ -1,9 +1,9 @@
drop table if exists t_element;
drop table if exists t_func;
create table if not exists t_element
create table if not exists t_func
(
id bigint not null primary key,
name varchar(100) not null comment '元素',
name varchar(100) not null comment '功能',
parent_id bigint null comment '父ID',
menu_id bigint not null comment '菜单ID'
) comment '页面元素';
) comment '功能';

View File

@@ -3,7 +3,7 @@ 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 '功能编码',
element_id bigint not null comment '页面元素ID'
) comment '功能';
name varchar(50) not null comment '操作',
code varchar(50) null comment '操作编码',
func_id bigint not null comment '功能ID'
) comment '操作';

View File

@@ -1,10 +0,0 @@
<?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">
<resultMap id="elementMap" type="element">
<id property="id" column="element_id"/>
<result property="name" column="element_name"/>
<result property="parentId" column="element_parent_id"/>
<result property="menuId" column="element_menu_id"/>
</resultMap>
</mapper>

View File

@@ -0,0 +1,10 @@
<?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.FuncMapper">
<resultMap id="funcMap" type="func">
<id property="id" column="func_id"/>
<result property="name" column="func_name"/>
<result property="parentId" column="func_parent_id"/>
<result property="menuId" column="func_menu_id"/>
</resultMap>
</mapper>

View File

@@ -5,6 +5,6 @@
<id property="id" column="operation_id"/>
<result property="name" column="operation_name"/>
<result property="code" column="operation_code"/>
<result property="elementId" column="operation_element_id"/>
<result property="funcId" column="operation_func_id"/>
</resultMap>
</mapper>

View File

@@ -34,20 +34,20 @@
tmn.url as menu_url,
tmn.parent_id as menu_parent_id,
tmn.module_id as menu_module_id,
te.id as element_id,
te.name as element_name,
te.parent_id as element_parent_id,
te.menu_id as element_menu_id,
tf.id as func_id,
tf.name as func_name,
tf.parent_id as func_parent_id,
tf.menu_id as func_menu_id,
t.id as operation_id,
t.name as operation_name,
t.code as operation_code,
t.element_id as operation_element_id
t.func_id as operation_func_id
from (select * from t_role where deleted = 0) as t_role
left join (select * from t_power_role where deleted = 0) as tpr on t_role.id = tpr.role_id
left join t_power tp on tp.id = tpr.power_id
left join t_module tm on tp.id = tm.id
left join t_menu tmn on tp.id = tmn.id
left join t_element te on tp.id = te.id
left join t_func tf on tp.id = tf.id
left join t_operation t on tp.id = t.id
<where>
<foreach collection="roleIds" item="item" index="index" open="and t_role.id in (" separator="," close=")"
@@ -72,20 +72,20 @@
tmn.url as menu_url,
tmn.parent_id as menu_parent_id,
tmn.module_id as menu_module_id,
te.id as element_id,
te.name as element_name,
te.parent_id as element_parent_id,
te.menu_id as element_menu_id,
tf.id as func_id,
tf.name as func_name,
tf.parent_id as func_parent_id,
tf.menu_id as func_menu_id,
t.id as operation_id,
t.name as operation_name,
t.code as operation_code,
t.element_id as operation_element_id
t.func_id as operation_func_id
from (select * from t_role where deleted = 0) as t_role
left join (select * from t_power_role where deleted = 0) as tpr on t_role.id = tpr.role_id
left join t_power tp on tp.id = tpr.power_id
left join t_module tm on tp.id = tm.id
left join t_menu tmn on tp.id = tmn.id
left join t_element te on tp.id = te.id
left join t_func tf on tp.id = tf.id
left join t_operation t on tp.id = t.id
where t_role.id = #{id}
</select>
@@ -103,7 +103,7 @@
<resultMap id="roleWithPowerMap" type="role" extends="roleMap">
<collection property="modules" resultMap="top.fatweb.api.mapper.permission.ModuleMapper.moduleMap"/>
<collection property="menus" resultMap="top.fatweb.api.mapper.permission.MenuMapper.menuMap"/>
<collection property="elements" resultMap="top.fatweb.api.mapper.permission.ElementMapper.elementMap"/>
<collection property="funcs" resultMap="top.fatweb.api.mapper.permission.FuncMapper.funcMap"/>
<collection property="operations" resultMap="top.fatweb.api.mapper.permission.OperationMapper.operationMap"/>
</resultMap>
</mapper>

View File

@@ -32,14 +32,14 @@
tm.name as menu_name,
tm.url as menu_url,
tm.parent_id as menu_parent_id,
te.id as element_id,
te.name as element_name,
te.parent_id as element_parent_id,
te.menu_id as element_menu_id,
tf.id as func_id,
tf.name as func_name,
tf.parent_id as func_parent_id,
tf.menu_id as func_menu_id,
t.id as operation_id,
t.name as operation_name,
t.code as operation_code,
t.element_id as operation_element_id
t.func_id as operation_func_id
from t_user
left join (select * from t_user_info where deleted = 0) as tui on t_user.id = tui.user_id
left join (select * from t_user_group where deleted = 0) as tug on t_user.id = tug.user_id
@@ -52,7 +52,7 @@
left join t_power as tp on tp.id = tpr.power_id
left join t_module as tmo on tp.id = tmo.id
left join t_menu as tm on tp.id = tm.id
left join t_element as te on tp.id = te.id
left join t_func as tf on tp.id = tf.id
left join t_operation as t on tp.id = t.id
where t_user.deleted = 0
and t_user.username = #{username};
@@ -276,7 +276,7 @@
<result property="password" column="user_password"/>
<collection property="modules" resultMap="top.fatweb.api.mapper.permission.ModuleMapper.moduleMap"/>
<collection property="menus" resultMap="top.fatweb.api.mapper.permission.MenuMapper.menuMap"/>
<collection property="elements" resultMap="top.fatweb.api.mapper.permission.ElementMapper.elementMap"/>
<collection property="funcs" resultMap="top.fatweb.api.mapper.permission.FuncMapper.funcMap"/>
<collection property="operations" resultMap="top.fatweb.api.mapper.permission.OperationMapper.operationMap"/>
</resultMap>