Add get user list controller
This commit is contained in:
@@ -43,7 +43,7 @@ class InitConfig(
|
|||||||
}
|
}
|
||||||
val userInfo = UserInfo().apply {
|
val userInfo = UserInfo().apply {
|
||||||
userId = 0
|
userId = 0
|
||||||
nickName = AdminProperties.nickName
|
nickname = AdminProperties.nickname
|
||||||
email = AdminProperties.email
|
email = AdminProperties.email
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
import top.fatweb.api.converter.permission.UserConverter
|
import top.fatweb.api.converter.permission.UserConverter
|
||||||
import top.fatweb.api.entity.common.ResponseResult
|
import top.fatweb.api.entity.common.ResponseResult
|
||||||
import top.fatweb.api.service.permission.IUserService
|
import top.fatweb.api.service.permission.IUserService
|
||||||
import top.fatweb.api.vo.permission.UserWithInfoVo
|
import top.fatweb.api.vo.permission.UserWithPowerInfoVo
|
||||||
|
import top.fatweb.api.vo.permission.UserWithRoleInfoVo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -22,10 +23,16 @@ class UserController(
|
|||||||
private val userService: IUserService
|
private val userService: IUserService
|
||||||
) {
|
) {
|
||||||
@GetMapping("info")
|
@GetMapping("info")
|
||||||
fun getInfo(): ResponseResult<UserWithInfoVo> {
|
fun getInfo(): ResponseResult<UserWithPowerInfoVo> {
|
||||||
userService.getInfo()?.let {
|
userService.getInfo()?.let {
|
||||||
return ResponseResult.databaseSuccess(data = UserConverter.userToUserInfoVo(it))
|
return ResponseResult.databaseSuccess(data = UserConverter.userToUserWithPowerInfoVo(it))
|
||||||
} ?: let { return ResponseResult.databaseFail() }
|
} ?: let { return ResponseResult.databaseFail() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
fun get(): ResponseResult<List<UserWithRoleInfoVo>> {
|
||||||
|
return ResponseResult.databaseSuccess(
|
||||||
|
data = userService.getList().map { UserConverter.userToUserWithRoleInfoVo(it) })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ object UserConverter {
|
|||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
fun userToUserInfoVo(user: User) = UserWithInfoVo(
|
fun userToUserWithPowerInfoVo(user: User) = UserWithPowerInfoVo(
|
||||||
id = user.id,
|
id = user.id,
|
||||||
username = user.username,
|
username = user.username,
|
||||||
locking = user.locking?.let { it == 1 },
|
locking = user.locking?.let { it == 1 },
|
||||||
@@ -30,7 +30,7 @@ object UserConverter {
|
|||||||
userInfo = user.userInfo?.let { UserInfoVo(
|
userInfo = user.userInfo?.let { UserInfoVo(
|
||||||
id = it.id,
|
id = it.id,
|
||||||
userId = it.userId,
|
userId = it.userId,
|
||||||
nickName = it.nickName,
|
nickname = it.nickname,
|
||||||
avatar = it.avatar,
|
avatar = it.avatar,
|
||||||
email = it.email,
|
email = it.email,
|
||||||
createTime = it.createTime,
|
createTime = it.createTime,
|
||||||
@@ -71,4 +71,42 @@ object UserConverter {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun userToUserWithRoleInfoVo(user: User) = UserWithRoleInfoVo(
|
||||||
|
id = user.id,
|
||||||
|
username = user.username,
|
||||||
|
locking = user.locking?.let { it == 1 },
|
||||||
|
expiration = user.expiration,
|
||||||
|
credentialsExpiration = user.credentialsExpiration,
|
||||||
|
enable = user.enable?.let { it == 1 },
|
||||||
|
currentLoginTime = user.currentLoginTime,
|
||||||
|
currentLoginIp = user.currentLoginIp,
|
||||||
|
lastLoginTime = user.lastLoginTime,
|
||||||
|
lastLoginIp = user.lastLoginIp,
|
||||||
|
createTime = user.createTime,
|
||||||
|
updateTime = user.updateTime,
|
||||||
|
userInfo = user.userInfo?.let { UserInfoVo(
|
||||||
|
id = it.id,
|
||||||
|
userId = it.userId,
|
||||||
|
nickname = it.nickname,
|
||||||
|
avatar = it.avatar,
|
||||||
|
email = it.email,
|
||||||
|
createTime = it.createTime,
|
||||||
|
updateTime = it.updateTime
|
||||||
|
) },
|
||||||
|
roles = user.roles?.map {
|
||||||
|
RoleVo(
|
||||||
|
id = it.id,
|
||||||
|
name = it.name,
|
||||||
|
enable = it.enable == 1
|
||||||
|
)
|
||||||
|
},
|
||||||
|
groups = user.groups?.map {
|
||||||
|
GroupVo(
|
||||||
|
id = it.id,
|
||||||
|
name = it.name,
|
||||||
|
enable = it.enable == 1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@@ -24,8 +24,8 @@ class UserInfo : Serializable {
|
|||||||
/**
|
/**
|
||||||
* 昵称
|
* 昵称
|
||||||
*/
|
*/
|
||||||
@TableField("nick_name")
|
@TableField("nickname")
|
||||||
var nickName: String? = null
|
var nickname: String? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 头像
|
* 头像
|
||||||
@@ -60,6 +60,6 @@ class UserInfo : Serializable {
|
|||||||
var version: Int? = null
|
var version: Int? = null
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "UserInfo(id=$id, userId=$userId, nickName=$nickName, avatar=$avatar, email=$email, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version)"
|
return "UserInfo(id=$id, userId=$userId, nickname=$nickname, avatar=$avatar, email=$email, createTime=$createTime, updateTime=$updateTime, deleted=$deleted, version=$version)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,7 @@ import top.fatweb.api.entity.permission.User
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
interface UserMapper : BaseMapper<User> {
|
interface UserMapper : BaseMapper<User> {
|
||||||
fun getOneWithPowerByUsername(@Param("username")username: String): User?
|
fun getOneWithPowerInfoByUsername(@Param("username")username: String): User?
|
||||||
|
|
||||||
|
fun getListWithRoleInfo(): List<User>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ import org.springframework.stereotype.Component
|
|||||||
object AdminProperties {
|
object AdminProperties {
|
||||||
var username = "admin"
|
var username = "admin"
|
||||||
var password: String? = null
|
var password: String? = null
|
||||||
var nickName = "Administrator"
|
var nickname = "Administrator"
|
||||||
var email = "admin@fatweb.top"
|
var email = "admin@fatweb.top"
|
||||||
}
|
}
|
||||||
@@ -15,4 +15,6 @@ interface IUserService : IService<User> {
|
|||||||
fun getUserWithPower(username: String): User?
|
fun getUserWithPower(username: String): User?
|
||||||
|
|
||||||
fun getInfo(): User?
|
fun getInfo(): User?
|
||||||
|
|
||||||
|
fun getList(): List<User>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class UserServiceImpl(
|
|||||||
private val operationService: IOperationService
|
private val operationService: IOperationService
|
||||||
) : ServiceImpl<UserMapper, User>(), IUserService {
|
) : ServiceImpl<UserMapper, User>(), IUserService {
|
||||||
override fun getUserWithPower(username: String): User? {
|
override fun getUserWithPower(username: String): User? {
|
||||||
val user = baseMapper.getOneWithPowerByUsername(username)
|
val user = baseMapper.getOneWithPowerInfoByUsername(username)
|
||||||
user ?: let { return null }
|
user ?: let { return null }
|
||||||
|
|
||||||
if (user.id == 0L) {
|
if (user.id == 0L) {
|
||||||
@@ -38,4 +38,5 @@ class UserServiceImpl(
|
|||||||
|
|
||||||
override fun getInfo() = WebUtil.getLoginUsername()?.let { getUserWithPower(it) } ?: let { null }
|
override fun getInfo() = WebUtil.getLoginUsername()?.let { getUserWithPower(it) } ?: let { null }
|
||||||
|
|
||||||
|
override fun getList() = baseMapper.getListWithRoleInfo()
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/main/kotlin/top/fatweb/api/vo/permission/GroupVo.kt
Normal file
17
src/main/kotlin/top/fatweb/api/vo/permission/GroupVo.kt
Normal file
@@ -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 GroupVo(
|
||||||
|
@JsonSerialize(using = ToStringSerializer::class)
|
||||||
|
val id: Long?,
|
||||||
|
|
||||||
|
@Schema(description = "用户组名", example = "Group")
|
||||||
|
val name: String?,
|
||||||
|
|
||||||
|
@Schema(description = "启用", example = "true")
|
||||||
|
val enable: Boolean?
|
||||||
|
)
|
||||||
17
src/main/kotlin/top/fatweb/api/vo/permission/RoleVo.kt
Normal file
17
src/main/kotlin/top/fatweb/api/vo/permission/RoleVo.kt
Normal file
@@ -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 RoleVo(
|
||||||
|
@JsonSerialize(using = ToStringSerializer::class)
|
||||||
|
val id: Long?,
|
||||||
|
|
||||||
|
@Schema(description = "角色名", example = "Role")
|
||||||
|
val name: String?,
|
||||||
|
|
||||||
|
@Schema(description = "启用", example = "true")
|
||||||
|
val enable: Boolean?
|
||||||
|
)
|
||||||
@@ -2,7 +2,7 @@ package top.fatweb.api.vo.permission
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema
|
import io.swagger.v3.oas.annotations.media.Schema
|
||||||
|
|
||||||
@Schema(description = "Token")
|
@Schema(description = "Token 返回参数")
|
||||||
data class TokenVo(
|
data class TokenVo(
|
||||||
@Schema(
|
@Schema(
|
||||||
description = "Token",
|
description = "Token",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ data class UserInfoVo(
|
|||||||
val userId: Long?,
|
val userId: Long?,
|
||||||
|
|
||||||
@Schema(description = "昵称", example = "User")
|
@Schema(description = "昵称", example = "User")
|
||||||
val nickName: String?,
|
val nickname: String?,
|
||||||
|
|
||||||
@Schema(description = "头像")
|
@Schema(description = "头像")
|
||||||
val avatar: String?,
|
val avatar: String?,
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema
|
import io.swagger.v3.oas.annotations.media.Schema
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
@Schema(description = "获取用户信息返回参数")
|
@Schema(description = "用户权限信息返回参数")
|
||||||
data class UserWithInfoVo(
|
data class UserWithPowerInfoVo(
|
||||||
@JsonSerialize(using = ToStringSerializer::class)
|
@JsonSerialize(using = ToStringSerializer::class)
|
||||||
val id: Long?,
|
val id: Long?,
|
||||||
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
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 java.time.LocalDateTime
|
||||||
|
|
||||||
|
@Schema(description = "用户角色信息返回参数")
|
||||||
|
data class UserWithRoleInfoVo(
|
||||||
|
@JsonSerialize(using = ToStringSerializer::class)
|
||||||
|
val id: Long?,
|
||||||
|
|
||||||
|
@Schema(description = "用户名", example = "User")
|
||||||
|
val username: String?,
|
||||||
|
|
||||||
|
@Schema(description = "是否锁定", example = "false")
|
||||||
|
val locking: Boolean?,
|
||||||
|
|
||||||
|
@Schema(description = "过期时间", example = "1900-01-01T00:00:00.000Z")
|
||||||
|
val expiration: LocalDateTime?,
|
||||||
|
|
||||||
|
@Schema(description = "认证过期时间", example = "1900-01-01T00:00:00.000Z")
|
||||||
|
val credentialsExpiration: LocalDateTime?,
|
||||||
|
|
||||||
|
@Schema(description = "是否启用", example = "true")
|
||||||
|
val enable: Boolean?,
|
||||||
|
|
||||||
|
@Schema(description = "当前登录时间", example = "1900-01-01T00:00:00.000Z")
|
||||||
|
val currentLoginTime: LocalDateTime?,
|
||||||
|
|
||||||
|
@Schema(description = "当前登录 IP", example = "1.1.1.1")
|
||||||
|
val currentLoginIp: String?,
|
||||||
|
|
||||||
|
@Schema(description = "最后登录时间", example = "1900-01-01T00:00:00.000Z")
|
||||||
|
val lastLoginTime: LocalDateTime?,
|
||||||
|
|
||||||
|
@Schema(description = "最后登录 IP", example = "1.1.1.1")
|
||||||
|
val lastLoginIp: String?,
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", example = "1900-01-01T00:00:00.000Z")
|
||||||
|
val createTime: LocalDateTime?,
|
||||||
|
|
||||||
|
@Schema(description = "修改时间", example = "1900-01-01T00:00:00.000Z")
|
||||||
|
val updateTime: LocalDateTime?,
|
||||||
|
|
||||||
|
@Schema(description = "用户资料")
|
||||||
|
val userInfo: UserInfoVo?,
|
||||||
|
|
||||||
|
@Schema(description = "角色列表")
|
||||||
|
val roles: List<RoleVo>?,
|
||||||
|
|
||||||
|
@Schema(description = "用户组列表")
|
||||||
|
val groups: List<GroupVo>?
|
||||||
|
)
|
||||||
@@ -2,7 +2,7 @@ app:
|
|||||||
admin:
|
admin:
|
||||||
# username: admin # Username of administrator
|
# username: admin # Username of administrator
|
||||||
# password: admin # Default password of administrator
|
# password: admin # Default password of administrator
|
||||||
# nick-name: Administrator # Nickname of administrator
|
# nickname: Administrator # Nickname of administrator
|
||||||
# email: admin@fatweb.top # Email of administrator
|
# email: admin@fatweb.top # Email of administrator
|
||||||
security:
|
security:
|
||||||
# header-string: "Authorization" # The key of head to get token
|
# header-string: "Authorization" # The key of head to get token
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ create table if not exists t_user_info
|
|||||||
(
|
(
|
||||||
id bigint not null primary key,
|
id bigint not null primary key,
|
||||||
user_id bigint not null comment '用户ID',
|
user_id bigint not null comment '用户ID',
|
||||||
nick_name varchar(50) null comment '昵称',
|
nickname varchar(50) null comment '昵称',
|
||||||
avatar varchar(500) null comment '头像',
|
avatar text null comment '头像',
|
||||||
email varchar(100) null comment '邮箱',
|
email varchar(100) null comment '邮箱',
|
||||||
create_time datetime not null default (utc_timestamp()) comment '创建时间',
|
create_time datetime not null default (utc_timestamp()) comment '创建时间',
|
||||||
update_time datetime not null default (utc_timestamp()) comment '修改时间',
|
update_time datetime not null default (utc_timestamp()) comment '修改时间',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?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.permission.UserMapper">
|
<mapper namespace="top.fatweb.api.mapper.permission.UserMapper">
|
||||||
<select id="getOneWithPowerByUsername" resultMap="userWithPowerMap">
|
<select id="getOneWithPowerInfoByUsername" resultMap="userWithPowerInfoMap">
|
||||||
select t_user.id as user_id,
|
select t_user.id as user_id,
|
||||||
t_user.username as user_username,
|
t_user.username as user_username,
|
||||||
t_user.password as user_password,
|
t_user.password as user_password,
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
t_user.version as user_version,
|
t_user.version as user_version,
|
||||||
tui.id as user_info_id,
|
tui.id as user_info_id,
|
||||||
tui.user_id as user_info_user_id,
|
tui.user_id as user_info_user_id,
|
||||||
tui.nick_name as user_info_nick_name,
|
tui.nickname as user_info_nickname,
|
||||||
tui.avatar as user_info_avatar,
|
tui.avatar as user_info_avatar,
|
||||||
tui.email as user_info_email,
|
tui.email as user_info_email,
|
||||||
tui.create_time as user_info_create_time,
|
tui.create_time as user_info_create_time,
|
||||||
@@ -62,6 +62,52 @@
|
|||||||
and t_user.username = #{username};
|
and t_user.username = #{username};
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getListWithRoleInfo" resultMap="userWithRoleInfoMap">
|
||||||
|
select t_user.id as user_id,
|
||||||
|
t_user.username as user_username,
|
||||||
|
t_user.password as user_password,
|
||||||
|
t_user.locking as user_locking,
|
||||||
|
t_user.expiration as user_expiration,
|
||||||
|
t_user.credentials_expiration as user_credentials_expiration,
|
||||||
|
t_user.enable as user_enable,
|
||||||
|
t_user.current_login_time as user_current_login_time,
|
||||||
|
t_user.current_login_ip as user_current_login_ip,
|
||||||
|
t_user.last_login_time as user_last_login_time,
|
||||||
|
t_user.last_login_ip as user_last_login_ip,
|
||||||
|
t_user.create_time as user_create_time,
|
||||||
|
t_user.update_time as user_update_time,
|
||||||
|
t_user.deleted as user_deleted,
|
||||||
|
t_user.version as user_version,
|
||||||
|
tui.id as user_info_id,
|
||||||
|
tui.user_id as user_info_user_id,
|
||||||
|
tui.nickname as user_info_nickname,
|
||||||
|
tui.avatar as user_info_avatar,
|
||||||
|
tui.email as user_info_email,
|
||||||
|
tui.create_time as user_info_create_time,
|
||||||
|
tui.update_time as user_info_update_time,
|
||||||
|
tui.deleted as user_info_deleted,
|
||||||
|
tui.version as user_info_version,
|
||||||
|
tr.id as role_id,
|
||||||
|
tr.name as role_name,
|
||||||
|
tr.enable as role_enable,
|
||||||
|
tr.deleted as role_deleted,
|
||||||
|
tr.version as role_version,
|
||||||
|
tg.id as group_id,
|
||||||
|
tg.name as group_name,
|
||||||
|
tg.enable as group_enable,
|
||||||
|
tg.deleted as group_deleted,
|
||||||
|
tg.version as group_version
|
||||||
|
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
|
||||||
|
left join (select * from t_group where deleted = 0 and enable = 1) as tg on tg.id = tug.group_id
|
||||||
|
left join (select * from t_role_group where deleted = 0) as trg on tg.id = trg.group_id
|
||||||
|
left join (select * from t_user_role where deleted = 0) as tur on t_user.id = tur.user_id
|
||||||
|
left join (select * from t_role where deleted = 0 and enable = 1) as tr
|
||||||
|
on tr.id = trg.role_id or tr.id = tur.role_id
|
||||||
|
where t_user.deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
<resultMap id="userBaseMap" type="user">
|
<resultMap id="userBaseMap" type="user">
|
||||||
<id property="id" column="user_id"/>
|
<id property="id" column="user_id"/>
|
||||||
<result property="username" column="user_username"/>
|
<result property="username" column="user_username"/>
|
||||||
@@ -82,7 +128,7 @@
|
|||||||
<resultMap id="userInfoMap" type="userInfo">
|
<resultMap id="userInfoMap" type="userInfo">
|
||||||
<id property="id" column="user_info_id"/>
|
<id property="id" column="user_info_id"/>
|
||||||
<result property="userId" column="user_info_user_id"/>
|
<result property="userId" column="user_info_user_id"/>
|
||||||
<result property="nickName" column="user_info_nick_name"/>
|
<result property="nickname" column="user_info_nickname"/>
|
||||||
<result property="avatar" column="user_info_avatar"/>
|
<result property="avatar" column="user_info_avatar"/>
|
||||||
<result property="email" column="user_info_email"/>
|
<result property="email" column="user_info_email"/>
|
||||||
<result property="createTime" column="user_info_create_time"/>
|
<result property="createTime" column="user_info_create_time"/>
|
||||||
@@ -91,7 +137,7 @@
|
|||||||
<result property="version" column="user_info_version"/>
|
<result property="version" column="user_info_version"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="userWithPowerMap" type="user" extends="userBaseMap">
|
<resultMap id="userWithPowerInfoMap" type="user" extends="userBaseMap">
|
||||||
<result property="password" column="user_password"/>
|
<result property="password" column="user_password"/>
|
||||||
<association property="userInfo" resultMap="userInfoMap"/>
|
<association property="userInfo" resultMap="userInfoMap"/>
|
||||||
<collection property="modules" ofType="module">
|
<collection property="modules" ofType="module">
|
||||||
@@ -122,4 +168,22 @@
|
|||||||
<result property="elementId" column="operation_element_id"/>
|
<result property="elementId" column="operation_element_id"/>
|
||||||
</collection>
|
</collection>
|
||||||
</resultMap>
|
</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>
|
||||||
|
</resultMap>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package top.fatweb.api
|
package top.fatweb.api
|
||||||
|
|
||||||
|
import com.talanlabs.avatargenerator.GitHubAvatar
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.extension.ExtendWith
|
import org.junit.jupiter.api.extension.ExtendWith
|
||||||
@@ -9,6 +10,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension
|
|||||||
import top.fatweb.api.properties.SecurityProperties
|
import top.fatweb.api.properties.SecurityProperties
|
||||||
import top.fatweb.api.util.ByteUtil
|
import top.fatweb.api.util.ByteUtil
|
||||||
import top.fatweb.api.util.JwtUtil
|
import top.fatweb.api.util.JwtUtil
|
||||||
|
import kotlin.io.encoding.Base64
|
||||||
|
import kotlin.io.encoding.ExperimentalEncodingApi
|
||||||
|
|
||||||
|
|
||||||
@ExtendWith(SpringExtension::class)
|
@ExtendWith(SpringExtension::class)
|
||||||
class FatWebApiApplicationTests {
|
class FatWebApiApplicationTests {
|
||||||
@@ -39,4 +43,12 @@ class FatWebApiApplicationTests {
|
|||||||
assertEquals("512KiB", ByteUtil.formatByteSize(512 * 1024))
|
assertEquals("512KiB", ByteUtil.formatByteSize(512 * 1024))
|
||||||
assertEquals("1.5MiB", ByteUtil.formatByteSize(1 * 1024 * 1024 + 512 * 1024))
|
assertEquals("1.5MiB", ByteUtil.formatByteSize(1 * 1024 * 1024 + 512 * 1024))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalEncodingApi::class)
|
||||||
|
@Test
|
||||||
|
fun name() {
|
||||||
|
val avatar = GitHubAvatar.newAvatarBuilder(396, 5).build()
|
||||||
|
val bytes = avatar.createAsPngBytes(1232132134543L)
|
||||||
|
logger.info(Base64.encode(bytes))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user