Add get role controller. Optimize code.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package top.fatweb.api.controller.permission
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import io.swagger.v3.oas.annotations.tags.Tag
|
||||
import jakarta.validation.Valid
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import top.fatweb.api.converter.permission.GroupConverter
|
||||
import top.fatweb.api.entity.common.ResponseCode
|
||||
import top.fatweb.api.entity.common.ResponseResult
|
||||
import top.fatweb.api.param.authentication.GroupGetParam
|
||||
import top.fatweb.api.service.permission.IGroupService
|
||||
import top.fatweb.api.vo.PageVo
|
||||
import top.fatweb.api.vo.permission.GroupVo
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户组表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author FatttSnake
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Tag(name = "用户组管理", description = "用户组管理相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/system/group")
|
||||
class GroupController(
|
||||
val groupService: IGroupService
|
||||
) {
|
||||
@Operation(summary = "获取用户组列表")
|
||||
@GetMapping
|
||||
fun get(@Valid groupGetParam: GroupGetParam?): ResponseResult<PageVo<GroupVo>> {
|
||||
return ResponseResult.success(
|
||||
ResponseCode.DATABASE_SELECT_SUCCESS, data = GroupConverter.groupPageToGroupPageVo(
|
||||
groupService.getPage(groupGetParam)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package top.fatweb.api.controller.permission
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import io.swagger.v3.oas.annotations.tags.Tag
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import top.fatweb.api.converter.permission.RoleConverter
|
||||
import top.fatweb.api.entity.common.ResponseCode
|
||||
import top.fatweb.api.entity.common.ResponseResult
|
||||
import top.fatweb.api.param.authentication.RoleAddParam
|
||||
import top.fatweb.api.param.authentication.RoleGetParam
|
||||
import top.fatweb.api.service.permission.IRoleService
|
||||
import top.fatweb.api.vo.PageVo
|
||||
import top.fatweb.api.vo.permission.RoleVo
|
||||
|
||||
/**
|
||||
* 角色表 前端控制器
|
||||
*
|
||||
* @author FatttSnake
|
||||
* @since 2023-11-09
|
||||
*/
|
||||
@Tag(name = "角色管理", description = "角色管理相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/system/role")
|
||||
class RoleController(
|
||||
private val roleService: IRoleService
|
||||
) {
|
||||
@Operation(summary = "获取角色列表")
|
||||
@GetMapping
|
||||
fun get(roleGetParam: RoleGetParam?): ResponseResult<PageVo<RoleVo>> {
|
||||
return ResponseResult.success(
|
||||
ResponseCode.DATABASE_SELECT_SUCCESS, data = RoleConverter.rolePageToRolePageVo(
|
||||
roleService.getPage(roleGetParam)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Operation(summary = "添加角色")
|
||||
@PostMapping
|
||||
fun add(roleAddParam: RoleAddParam): ResponseResult<RoleVo> {
|
||||
return roleService.add(roleAddParam)
|
||||
?.let { ResponseResult.success(ResponseCode.DATABASE_INSERT_SUCCESS, data = it) }
|
||||
?: let { ResponseResult.fail(ResponseCode.DATABASE_INSERT_FAILED) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package top.fatweb.api.converter.permission
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import top.fatweb.api.entity.permission.Group
|
||||
import top.fatweb.api.vo.PageVo
|
||||
import top.fatweb.api.vo.permission.GroupVo
|
||||
|
||||
object GroupConverter {
|
||||
fun groupPageToGroupPageVo(groupPage: IPage<Group>): PageVo<GroupVo> = PageVo(
|
||||
groupPage.total,
|
||||
groupPage.pages,
|
||||
groupPage.size,
|
||||
groupPage.current,
|
||||
groupPage.records.map {
|
||||
GroupVo(
|
||||
id = it.id,
|
||||
name = it.name,
|
||||
enable = it.enable == 1
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package top.fatweb.api.converter.permission
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import top.fatweb.api.entity.permission.Power
|
||||
import top.fatweb.api.entity.permission.Role
|
||||
import top.fatweb.api.param.authentication.RoleAddParam
|
||||
import top.fatweb.api.vo.PageVo
|
||||
import top.fatweb.api.vo.permission.RoleVo
|
||||
|
||||
object RoleConverter {
|
||||
fun rolePageToRolePageVo(rolePage: IPage<Role>): PageVo<RoleVo> = PageVo(
|
||||
rolePage.total,
|
||||
rolePage.pages,
|
||||
rolePage.size,
|
||||
rolePage.current,
|
||||
rolePage.records.map {
|
||||
RoleVo(
|
||||
id = it.id,
|
||||
name = it.name,
|
||||
enable = it.enable == 1
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
fun roleAddParamToRole(roleAddParam: RoleAddParam): Role = Role().apply {
|
||||
name = roleAddParam.name
|
||||
enable = if (roleAddParam.enable) 1 else 0
|
||||
powers = roleAddParam.powerIds?.map { Power().apply { id = it } }
|
||||
}
|
||||
|
||||
fun roleToRoleVo(role: Role): RoleVo = RoleVo(
|
||||
id = role.id,
|
||||
name = role.name,
|
||||
enable = role.enable == 1
|
||||
)
|
||||
}
|
||||
@@ -37,6 +37,9 @@ class Role : Serializable {
|
||||
@Version
|
||||
var version: Int? = null
|
||||
|
||||
@TableField(exist = false)
|
||||
var modules: List<Module>? = null
|
||||
|
||||
@TableField(exist = false)
|
||||
var menus: List<Menu>? = null
|
||||
|
||||
@@ -50,6 +53,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, menus=$menus, elements=$elements, operations=$operations, powers=$powers)"
|
||||
return "Role(id=$id, name=$name, enable=$enable, deleted=$deleted, version=$version, modules=$modules, menus=$menus, elements=$elements, operations=$operations, powers=$powers)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package top.fatweb.api.mapper.permission
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import org.apache.ibatis.annotations.Mapper
|
||||
import top.fatweb.api.entity.permission.Group
|
||||
|
||||
@@ -13,4 +14,6 @@ import top.fatweb.api.entity.permission.Group
|
||||
* @since 2023-10-25
|
||||
*/
|
||||
@Mapper
|
||||
interface GroupMapper : BaseMapper<Group>
|
||||
interface GroupMapper : BaseMapper<Group> {
|
||||
fun selectPage(page: IPage<Group>): IPage<Group>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package top.fatweb.api.mapper.permission
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import org.apache.ibatis.annotations.Mapper
|
||||
import top.fatweb.api.entity.permission.Role
|
||||
|
||||
@@ -13,4 +14,6 @@ import top.fatweb.api.entity.permission.Role
|
||||
* @since 2023-10-25
|
||||
*/
|
||||
@Mapper
|
||||
interface RoleMapper : BaseMapper<Role>
|
||||
interface RoleMapper : BaseMapper<Role> {
|
||||
fun selectPage(page: IPage<Role>): IPage<Role>
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package top.fatweb.api.param
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import jakarta.validation.constraints.Min
|
||||
|
||||
open class PageParam {
|
||||
open class PageSortParam {
|
||||
@Schema(description = "分页页码", example = "1", defaultValue = "1")
|
||||
@field:Min(1, message = "Pagination page number must be a positive integer")
|
||||
var currentPage: Long = 1
|
||||
@@ -11,4 +11,10 @@ open class PageParam {
|
||||
@Schema(description = "分页大小", example = "20", defaultValue = "20")
|
||||
@field:Min(1, message = "The number of data per page must be a positive integer")
|
||||
var pageSize: Long = 20
|
||||
|
||||
@Schema(description = "排序字段", example = "id")
|
||||
val sortField: String? = null
|
||||
|
||||
@Schema(description = "排序方式", example = "desc", allowableValues = ["desc", "asc"])
|
||||
val sortOrder: String? = null
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package top.fatweb.api.param.authentication
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import top.fatweb.api.param.PageSortParam
|
||||
|
||||
data class GroupGetParam(
|
||||
@Schema(description = "查询用户组名称")
|
||||
val searchName: String? = null,
|
||||
|
||||
@Schema(description = "查询使用正则表达式")
|
||||
val searchRegex: Boolean = false,
|
||||
) : PageSortParam()
|
||||
@@ -0,0 +1,16 @@
|
||||
package top.fatweb.api.param.authentication
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import jakarta.validation.constraints.NotBlank
|
||||
|
||||
data class RoleAddParam(
|
||||
@Schema(description = "角色名称")
|
||||
@field:NotBlank
|
||||
val name: String,
|
||||
|
||||
@Schema(description = "启用")
|
||||
val enable: Boolean = true,
|
||||
|
||||
@Schema(description = "权限 ID 列表")
|
||||
val powerIds: List<Long>? = null
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package top.fatweb.api.param.authentication
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import top.fatweb.api.param.PageSortParam
|
||||
|
||||
data class RoleGetParam(
|
||||
@Schema(description = "查询角色名称")
|
||||
val searchName: String? = null,
|
||||
|
||||
@Schema(description = "查询使用正则表达式")
|
||||
val searchRegex: Boolean = false,
|
||||
) : PageSortParam()
|
||||
@@ -2,17 +2,11 @@ package top.fatweb.api.param.system
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import org.springframework.format.annotation.DateTimeFormat
|
||||
import top.fatweb.api.param.PageParam
|
||||
import top.fatweb.api.param.PageSortParam
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Schema(description = "获取系统日志请求参数")
|
||||
data class SysLogGetParam(
|
||||
@Schema(description = "排序字段", example = "id")
|
||||
val sortField: String? = null,
|
||||
|
||||
@Schema(description = "排序方式", example = "desc", allowableValues = ["desc", "asc"])
|
||||
val sortOrder: String? = null,
|
||||
|
||||
@Schema(description = "类型过滤(多个使用逗号分隔)", example = "INFO", allowableValues = ["INFO", "ERROR"])
|
||||
val logType: String? = null,
|
||||
|
||||
@@ -36,4 +30,4 @@ data class SysLogGetParam(
|
||||
@Schema(description = "查询结束时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
|
||||
val searchEndTime: LocalDateTime? = null
|
||||
) : PageParam()
|
||||
) : PageSortParam()
|
||||
@@ -1,7 +1,9 @@
|
||||
package top.fatweb.api.service.permission
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import com.baomidou.mybatisplus.extension.service.IService
|
||||
import top.fatweb.api.entity.permission.Group
|
||||
import top.fatweb.api.param.authentication.GroupGetParam
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,4 +13,6 @@ import top.fatweb.api.entity.permission.Group
|
||||
* @author FatttSnake
|
||||
* @since 2023-10-25
|
||||
*/
|
||||
interface IGroupService : IService<Group>
|
||||
interface IGroupService : IService<Group> {
|
||||
fun getPage(groupGetParam: GroupGetParam?): IPage<Group>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package top.fatweb.api.service.permission
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import com.baomidou.mybatisplus.extension.service.IService
|
||||
import top.fatweb.api.entity.permission.Role
|
||||
import top.fatweb.api.param.authentication.RoleAddParam
|
||||
import top.fatweb.api.param.authentication.RoleGetParam
|
||||
import top.fatweb.api.vo.permission.RoleVo
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -11,4 +15,8 @@ import top.fatweb.api.entity.permission.Role
|
||||
* @author FatttSnake
|
||||
* @since 2023-10-25
|
||||
*/
|
||||
interface IRoleService : IService<Role>
|
||||
interface IRoleService : IService<Role> {
|
||||
fun getPage(roleGetParam: RoleGetParam?): IPage<Role>
|
||||
|
||||
fun add(roleAddParam: RoleAddParam): RoleVo?
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package top.fatweb.api.service.permission.impl
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||
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.param.authentication.GroupGetParam
|
||||
import top.fatweb.api.service.permission.IGroupService
|
||||
import top.fatweb.api.util.PageUtil
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -15,4 +19,12 @@ import top.fatweb.api.service.permission.IGroupService
|
||||
* @since 2023-10-25
|
||||
*/
|
||||
@Service
|
||||
class GroupServiceImpl : ServiceImpl<GroupMapper, Group>(), IGroupService
|
||||
class GroupServiceImpl : ServiceImpl<GroupMapper, Group>(), IGroupService {
|
||||
override fun getPage(groupGetParam: GroupGetParam?): IPage<Group> {
|
||||
val groupPage = Page<Group>(groupGetParam?.currentPage ?: 1, groupGetParam?.pageSize ?: 20)
|
||||
|
||||
PageUtil.setPageSort(groupGetParam, groupPage)
|
||||
|
||||
return baseMapper.selectPage(groupPage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
package top.fatweb.api.service.permission.impl
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import top.fatweb.api.converter.permission.RoleConverter
|
||||
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.authentication.RoleAddParam
|
||||
import top.fatweb.api.param.authentication.RoleGetParam
|
||||
import top.fatweb.api.service.permission.IPowerRoleService
|
||||
import top.fatweb.api.service.permission.IRoleService
|
||||
import top.fatweb.api.util.PageUtil
|
||||
import top.fatweb.api.vo.permission.RoleVo
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -15,4 +25,35 @@ import top.fatweb.api.service.permission.IRoleService
|
||||
* @since 2023-10-25
|
||||
*/
|
||||
@Service
|
||||
class RoleServiceImpl : ServiceImpl<RoleMapper, Role>(), IRoleService
|
||||
class RoleServiceImpl(
|
||||
private val powerRoleService: IPowerRoleService
|
||||
) : ServiceImpl<RoleMapper, Role>(), IRoleService {
|
||||
override fun getPage(roleGetParam: RoleGetParam?): IPage<Role> {
|
||||
val rolePage = Page<Role>(roleGetParam?.currentPage ?: 1, roleGetParam?.pageSize ?: 20)
|
||||
|
||||
PageUtil.setPageSort(roleGetParam, rolePage)
|
||||
|
||||
return baseMapper.selectPage(rolePage)
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
override fun add(roleAddParam: RoleAddParam): RoleVo? {
|
||||
val role = RoleConverter.roleAddParamToRole(roleAddParam)
|
||||
if (baseMapper.insert(role) == 1) {
|
||||
if (powerRoleService.saveBatch(
|
||||
roleAddParam.powerIds?.map {
|
||||
PowerRole().apply {
|
||||
roleId = role.id
|
||||
powerId = it
|
||||
}
|
||||
}
|
||||
)
|
||||
) {
|
||||
return RoleConverter.roleToRoleVo(role)
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import top.fatweb.api.entity.system.SysLog
|
||||
import top.fatweb.api.mapper.system.SysLogMapper
|
||||
import top.fatweb.api.param.system.SysLogGetParam
|
||||
import top.fatweb.api.service.system.ISysLogService
|
||||
import top.fatweb.api.util.StrUtil
|
||||
import top.fatweb.api.util.PageUtil
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -24,20 +24,7 @@ class SysLogServiceImpl : ServiceImpl<SysLogMapper, SysLog>(), ISysLogService {
|
||||
override fun getPage(sysLogGetParam: SysLogGetParam?): IPage<SysLog> {
|
||||
val sysLogPage = Page<SysLog>(sysLogGetParam?.currentPage ?: 1, sysLogGetParam?.pageSize ?: 20)
|
||||
|
||||
if (sysLogGetParam?.sortField == null && sysLogGetParam?.sortOrder == null) {
|
||||
sysLogPage.addOrder(OrderItem.desc("start_time"))
|
||||
} else {
|
||||
sysLogPage.addOrder(
|
||||
if (sysLogGetParam.sortOrder?.startsWith(
|
||||
"desc", true
|
||||
) == true
|
||||
) OrderItem.desc(StrUtil.upperToUnderLetter(sysLogGetParam.sortField)) else OrderItem.asc(
|
||||
StrUtil.upperToUnderLetter(
|
||||
sysLogGetParam.sortField
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
PageUtil.setPageSort(sysLogGetParam, sysLogPage, OrderItem.desc("start_time"))
|
||||
|
||||
return baseMapper.selectPage(
|
||||
sysLogPage,
|
||||
|
||||
24
src/main/kotlin/top/fatweb/api/util/PageUtil.kt
Normal file
24
src/main/kotlin/top/fatweb/api/util/PageUtil.kt
Normal file
@@ -0,0 +1,24 @@
|
||||
package top.fatweb.api.util
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||
import top.fatweb.api.param.PageSortParam
|
||||
|
||||
object PageUtil {
|
||||
fun <T: Page<*>> setPageSort(pageSortParam: PageSortParam?, page: T, defaultOrder: OrderItem? = null) {
|
||||
if (pageSortParam?.sortField != null || pageSortParam?.sortOrder != null) {
|
||||
page.addOrder(
|
||||
if (pageSortParam.sortOrder?.startsWith(
|
||||
"desc", true
|
||||
) == true
|
||||
) OrderItem.desc(StrUtil.upperToUnderLetter(pageSortParam.sortField)) else OrderItem.asc(
|
||||
StrUtil.upperToUnderLetter(
|
||||
pageSortParam.sortField
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
defaultOrder?.let { page.addOrder(defaultOrder) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
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
|
||||
|
||||
@Schema(description = "角色返回参数")
|
||||
data class RoleWithPowerVo(
|
||||
@JsonSerialize(using = ToStringSerializer::class)
|
||||
val id: Long?,
|
||||
|
||||
@Schema(description = "角色名", example = "Role")
|
||||
val name: String?,
|
||||
|
||||
@Schema(description = "启用", example = "true")
|
||||
val enable: Boolean?
|
||||
)
|
||||
@@ -6,7 +6,35 @@ insert into t_power_type (id, name)
|
||||
on duplicate key update name = new_value.name;
|
||||
|
||||
insert into t_power (id, type_id)
|
||||
values (1000000, 1) as new_value
|
||||
values (1000000, 1),
|
||||
(1990000, 2),
|
||||
(1010000, 2),
|
||||
(1020000, 2),
|
||||
(1030000, 2),
|
||||
(1010100, 3),
|
||||
(1010200, 3),
|
||||
(1010300, 3),
|
||||
(1020100, 3),
|
||||
(1020200, 3),
|
||||
(1020300, 3),
|
||||
(1020400, 3),
|
||||
(1030100, 3),
|
||||
(1030200, 3),
|
||||
(1030300, 3),
|
||||
(1030400, 3),
|
||||
(1010101, 4),
|
||||
(1010102, 4),
|
||||
(1010201, 4),
|
||||
(1010301, 4),
|
||||
(1020101, 4),
|
||||
(1020201, 4),
|
||||
(1020301, 4),
|
||||
(1020401, 4),
|
||||
(1030101, 4),
|
||||
(1030201, 4),
|
||||
(1030301, 4),
|
||||
(1030401, 4)
|
||||
as new_value
|
||||
on duplicate key update type_id = new_value.type_id;
|
||||
|
||||
insert into t_module (id, name, power_id)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<?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="powerId" column="element_power_id"/>
|
||||
<result property="parentId" column="element_parent_id"/>
|
||||
<result property="menuId" column="element_menu_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
<?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">
|
||||
<select id="selectPage">
|
||||
|
||||
</select>
|
||||
|
||||
<resultMap id="groupMap" type="group">
|
||||
<id property="id" column="group_id"/>
|
||||
<result property="name" column="group_name"/>
|
||||
<result property="enable" column="group_enable"/>
|
||||
<result property="deleted" column="group_deleted"/>
|
||||
<result property="version" column="group_version"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<?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">
|
||||
|
||||
<resultMap id="menuMap" type="menu">
|
||||
<id property="id" column="menu_id"/>
|
||||
<result property="name" column="menu_name"/>
|
||||
<result property="url" column="menu_url"/>
|
||||
<result property="powerId" column="menu_power_id"/>
|
||||
<result property="parentId" column="menu_parent_id"/>
|
||||
<result property="moduleId" column="menu_module_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?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.ModuleMapper">
|
||||
|
||||
<resultMap id="moduleMap" type="module">
|
||||
<id property="id" column="module_id"/>
|
||||
<result property="name" column="module_name"/>
|
||||
<result property="powerId" column="module_power_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<?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">
|
||||
|
||||
<resultMap id="operationMap" type="operation">
|
||||
<id property="id" column="operation_id"/>
|
||||
<result property="name" column="operation_name"/>
|
||||
<result property="code" column="operation_code"/>
|
||||
<result property="powerId" column="operation_power_id"/>
|
||||
<result property="elementId" column="operation_element_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,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">
|
||||
<mapper namespace="top.fatweb.api.mapper.permission.PowerMapper">
|
||||
|
||||
<resultMap id="powerMap" type="power">
|
||||
<id property="id" column="power_id"/>
|
||||
<result property="typeId" column="power_type_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,52 @@
|
||||
<?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">
|
||||
<select id="selectPage" resultMap="roleWithPowerMap">
|
||||
select distinct t_role.id as role_id,
|
||||
t_role.name as role_name,
|
||||
t_role.enable as role_enable,
|
||||
t_role.deleted as role_deleted,
|
||||
t_role.version as role_version,
|
||||
tm.id as module_id,
|
||||
tm.name as module_name,
|
||||
tm.power_id as module_power_id,
|
||||
tmn.id as menu_id,
|
||||
tmn.name as menu_name,
|
||||
tmn.url as menu_url,
|
||||
tmn.power_id as menu_power_id,
|
||||
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.power_id as element_power_id,
|
||||
te.parent_id as element_parent_id,
|
||||
te.menu_id as element_menu_id,
|
||||
t.id as operation_id,
|
||||
t.name as operation_name,
|
||||
t.code as operation_code,
|
||||
t.power_id as operation_power_id,
|
||||
t.element_id as operation_element_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.power_id
|
||||
left join t_menu tmn on tp.id = tmn.power_id
|
||||
left join t_element te on tp.id = te.power_id
|
||||
left join t_operation t on tp.id = t.power_id
|
||||
</select>
|
||||
|
||||
<resultMap id="roleMap" type="role">
|
||||
<id property="id" column="role_id"/>
|
||||
<result property="name" column="role_name"/>
|
||||
<result property="enable" column="role_enable"/>
|
||||
<result property="deleted" column="role_deleted"/>
|
||||
<result property="version" column="role_version"/>
|
||||
</resultMap>
|
||||
|
||||
<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="operations" resultMap="top.fatweb.api.mapper.permission.OperationMapper.operationMap"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
<?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.UserInfoMapper">
|
||||
|
||||
<resultMap id="userInfoMap" type="userInfo">
|
||||
<id property="id" column="user_info_id"/>
|
||||
<result property="userId" column="user_info_user_id"/>
|
||||
<result property="nickname" column="user_info_nickname"/>
|
||||
<result property="avatar" column="user_info_avatar"/>
|
||||
<result property="email" column="user_info_email"/>
|
||||
<result property="createTime" column="user_info_create_time"/>
|
||||
<result property="updateTime" column="user_info_update_time"/>
|
||||
<result property="deleted" column="user_info_deleted"/>
|
||||
<result property="version" column="user_info_version"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
@@ -125,65 +125,18 @@
|
||||
<result property="version" column="user_version"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="userInfoMap" type="userInfo">
|
||||
<id property="id" column="user_info_id"/>
|
||||
<result property="userId" column="user_info_user_id"/>
|
||||
<result property="nickname" column="user_info_nickname"/>
|
||||
<result property="avatar" column="user_info_avatar"/>
|
||||
<result property="email" column="user_info_email"/>
|
||||
<result property="createTime" column="user_info_create_time"/>
|
||||
<result property="updateTime" column="user_info_update_time"/>
|
||||
<result property="deleted" column="user_info_deleted"/>
|
||||
<result property="version" column="user_info_version"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="userWithPowerInfoMap" type="user" extends="userBaseMap">
|
||||
<result property="password" column="user_password"/>
|
||||
<association property="userInfo" resultMap="userInfoMap"/>
|
||||
<collection property="modules" ofType="module">
|
||||
<id property="id" column="module_id"/>
|
||||
<result property="name" column="module_name"/>
|
||||
<result property="powerId" column="module_power_id"/>
|
||||
</collection>
|
||||
<collection property="menus" ofType="menu">
|
||||
<id property="id" column="menu_id"/>
|
||||
<result property="name" column="menu_name"/>
|
||||
<result property="url" column="menu_url"/>
|
||||
<result property="powerId" column="menu_power_id"/>
|
||||
<result property="parentId" column="menu_parent_id"/>
|
||||
<result property="moduleId" column="menu_module_id"/>
|
||||
</collection>
|
||||
<collection property="elements" ofType="element">
|
||||
<id property="id" column="element_id"/>
|
||||
<result property="name" column="element_name"/>
|
||||
<result property="powerId" column="element_power_id"/>
|
||||
<result property="parentId" column="element_parent_id"/>
|
||||
<result property="menuId" column="element_menu_id"/>
|
||||
</collection>
|
||||
<collection property="operations" ofType="operation">
|
||||
<id property="id" column="operation_id"/>
|
||||
<result property="name" column="operation_name"/>
|
||||
<result property="code" column="operation_code"/>
|
||||
<result property="powerId" column="operation_power_id"/>
|
||||
<result property="elementId" column="operation_element_id"/>
|
||||
</collection>
|
||||
<association property="userInfo" resultMap="top.fatweb.api.mapper.permission.UserInfoMapper.userInfoMap"/>
|
||||
<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="operations" resultMap="top.fatweb.api.mapper.permission.OperationMapper.operationMap"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="userWithRoleInfoMap" type="user" extends="userBaseMap">
|
||||
<association property="userInfo" resultMap="userInfoMap"/>
|
||||
<collection property="roles" ofType="role">
|
||||
<id property="id" column="role_id"/>
|
||||
<result property="name" column="role_name"/>
|
||||
<result property="enable" column="role_enable"/>
|
||||
<result property="deleted" column="role_deleted"/>
|
||||
<result property="version" column="role_version"/>
|
||||
</collection>
|
||||
<collection property="groups" ofType="group">
|
||||
<id property="id" column="group_id"/>
|
||||
<result property="name" column="group_name"/>
|
||||
<result property="enable" column="group_enable"/>
|
||||
<result property="deleted" column="group_deleted"/>
|
||||
<result property="version" column="group_version"/>
|
||||
</collection>
|
||||
<association property="userInfo" resultMap="top.fatweb.api.mapper.permission.UserInfoMapper.userInfoMap"/>
|
||||
<collection property="roles" resultMap="top.fatweb.api.mapper.permission.RoleMapper.roleMap"/>
|
||||
<collection property="groups" resultMap="top.fatweb.api.mapper.permission.GroupMapper.groupMap"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user