feat(admin-server): 将管理员超级管理员标识改造为角色ID字段,更新相关字段映射及数据库表结构
This commit is contained in:
parent
9cdffe1f70
commit
9f40ce1f31
|
|
@ -55,7 +55,7 @@ public class AdminAuthController {
|
||||||
Map<String, Object> claims = new HashMap<>();
|
Map<String, Object> claims = new HashMap<>();
|
||||||
claims.put("id", admin.getId());
|
claims.put("id", admin.getId());
|
||||||
claims.put("username", admin.getUsername());
|
claims.put("username", admin.getUsername());
|
||||||
claims.put("isSuper", admin.getIsSuper());
|
claims.put("role_id", admin.getRoleId());
|
||||||
|
|
||||||
// Token 与 RefreshToken
|
// Token 与 RefreshToken
|
||||||
return getResult(claims);
|
return getResult(claims);
|
||||||
|
|
@ -107,14 +107,12 @@ public class AdminAuthController {
|
||||||
|
|
||||||
|
|
||||||
// 获取 Token 与 RefreshToken
|
// 获取 Token 与 RefreshToken
|
||||||
private Result<?> getResult(Map<String, Object> data) {
|
private Result<Map<String, String>> getResult(Map<String, Object> data) {
|
||||||
String newToken = jwtUtil.generateToken(data);
|
String newToken = jwtUtil.generateToken(data);
|
||||||
String newRefreshToken = jwtUtil.generateRefreshToken(data);
|
String newRefreshToken = jwtUtil.generateRefreshToken(data);
|
||||||
|
|
||||||
Map<String, String> tokenMap = new HashMap<>();
|
Map<String, String> tokenMap = new HashMap<>();
|
||||||
tokenMap.put("token", newToken);
|
tokenMap.put("token", newToken);
|
||||||
tokenMap.put("refreshToken", newRefreshToken);
|
tokenMap.put("refreshToken", newRefreshToken);
|
||||||
|
|
||||||
return Result.ok(tokenMap);
|
return Result.ok(tokenMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
package com.example.admin_server.model.query;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class RoleQuery {
|
|
||||||
@ApiModelProperty("页码")
|
|
||||||
private Integer pageNum = 1;
|
|
||||||
|
|
||||||
@ApiModelProperty("每页数量")
|
|
||||||
private Integer pageSize = 10;
|
|
||||||
|
|
||||||
@ApiModelProperty("角色名称关键词")
|
|
||||||
private String keyword;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -47,8 +47,8 @@ public class AdminVO implements Serializable {
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否为超级管理员:1是,0否")
|
@ApiModelProperty(value = "是否为超级管理员:1是,0否")
|
||||||
@TableField("is_super")
|
@TableField("role_id")
|
||||||
private Integer isSuper;
|
private Integer roleId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "上次登录IP")
|
@ApiModelProperty(value = "上次登录IP")
|
||||||
@TableField("last_login_ip")
|
@TableField("last_login_ip")
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ CREATE TABLE IF NOT EXISTS `admin` (
|
||||||
`phone` varchar(20) DEFAULT NULL COMMENT '手机号',
|
`phone` varchar(20) DEFAULT NULL COMMENT '手机号',
|
||||||
`avatar` varchar(255) DEFAULT NULL COMMENT '头像',
|
`avatar` varchar(255) DEFAULT NULL COMMENT '头像',
|
||||||
`status` tinyint(1) DEFAULT 1 COMMENT '状态:0禁用,1正常',
|
`status` tinyint(1) DEFAULT 1 COMMENT '状态:0禁用,1正常',
|
||||||
`roleId` int(11) DEFAULT 0 COMMENT '角色ID',
|
`role_id` int(11) DEFAULT 0 COMMENT '角色ID',
|
||||||
`last_login_ip` varchar(50) DEFAULT NULL COMMENT '上次登录IP',
|
`last_login_ip` varchar(50) DEFAULT NULL COMMENT '上次登录IP',
|
||||||
`last_login_time` datetime DEFAULT NULL COMMENT '上次登录时间',
|
`last_login_time` datetime DEFAULT NULL COMMENT '上次登录时间',
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
|
@ -68,6 +68,6 @@ CREATE TABLE IF NOT EXISTS `sys_menu` (
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='菜单表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='菜单表';
|
||||||
|
|
||||||
-- 初始化超级管理员账号
|
-- 初始化超级管理员账号
|
||||||
INSERT INTO `admin` (`username`, `password`, `nickname`, `is_super`, `status`)
|
INSERT INTO `admin` (`username`, `password`, `nickname`, `role_id`, `status`)
|
||||||
VALUES ('admin', 'e10adc3949ba59abbe56e057f20f883e', '超级管理员', 1, 1)
|
VALUES ('admin', 'e10adc3949ba59abbe56e057f20f883e', '超级管理员', 1, 1)
|
||||||
ON DUPLICATE KEY UPDATE `id` = `id`;
|
ON DUPLICATE KEY UPDATE `id` = `id`;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
<result column="phone" property="phone" />
|
<result column="phone" property="phone" />
|
||||||
<result column="avatar" property="avatar" />
|
<result column="avatar" property="avatar" />
|
||||||
<result column="status" property="status" />
|
<result column="status" property="status" />
|
||||||
<result column="is_super" property="isSuper" />
|
<result column="role_id" property="roleId" />
|
||||||
<result column="last_login_ip" property="lastLoginIp" />
|
<result column="last_login_ip" property="lastLoginIp" />
|
||||||
<result column="last_login_time" property="lastLoginTime" />
|
<result column="last_login_time" property="lastLoginTime" />
|
||||||
<result column="create_time" property="createTime" />
|
<result column="create_time" property="createTime" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue