本地认证或LDAP认证支持携带‘姓名’、‘部门’、‘邮箱’等用户元信息

This commit is contained in:
huyueeer
2021-08-06 11:40:24 +08:00
parent b77345222c
commit b5fb24b360
6 changed files with 87 additions and 6 deletions

View File

@@ -16,6 +16,9 @@ CREATE TABLE `account` (
`status` int(16) NOT NULL DEFAULT '0' COMMENT '0标识使用中-1标识已废弃',
`gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modify` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`department` varchar(128) DEFAULT '' COMMENT '部门名',
`display_name` varchar(128) DEFAULT '' COMMENT '用户姓名',
`mail` varchar(128) DEFAULT '' COMMENT '邮箱',
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='账号表';

View File

@@ -21,6 +21,15 @@ public class AccountDTO {
@ApiModelProperty(value = "角色")
private Integer role;
@ApiModelProperty(value = "用户姓名")
private String displayName;
@ApiModelProperty(value = "部门")
private String department;
@ApiModelProperty(value = "邮箱")
private String mail;
public String getUsername() {
return username;
}
@@ -45,12 +54,39 @@ public class AccountDTO {
this.role = role;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
@Override
public String toString() {
return "AccountDTO{" +
"username='" + username + '\'' +
", password='" + password + '\'' +
", role=" + role +
", displayName='" + displayName + '\'' +
", department='" + department + '\'' +
", mail='" + mail + '\'' +
'}';
}

View File

@@ -21,6 +21,12 @@ public class AccountDO {
private Integer role;
private String displayName;
private String department;
private String mail;
public String getUsername() {
return username;
}
@@ -45,16 +51,43 @@ public class AccountDO {
this.role = role;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
@Override
public String toString() {
return "AccountDO{" +
"username='" + username + '\'' +
", password='" + password + '\'' +
", role=" + role +
", id=" + id +
"id=" + id +
", status=" + status +
", gmtCreate=" + gmtCreate +
", gmtModify=" + gmtModify +
", username='" + username + '\'' +
", password='" + password + '\'' +
", role=" + role +
", displayName='" + displayName + '\'' +
", department='" + department + '\'' +
", mail='" + mail + '\'' +
'}';
}
}

View File

@@ -10,14 +10,17 @@
<result property="role" column="role" />
<result property="gmtCreate" column="gmt_create" />
<result property="gmtModify" column="gmt_modify" />
<result property="displayName" column="display_name" />
<result property="department" column="department" />
<result property="mail" column="mail" />
</resultMap>
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO">
<![CDATA[
REPLACE account
(username, password, role)
(username, password, role, display_name, department, mail)
VALUES
(#{username}, #{password}, #{role})
(#{username}, #{password}, #{role}, #{displayName}, #{department}, #{mail})
]]>
</insert>

View File

@@ -68,6 +68,9 @@ public class BaseSessionSignOn extends AbstractSingleSignOn {
accountDO.setUsername(dto.getUsername());
accountDO.setRole(AccountRoleEnum.getUserRoleEnum(authUserRegistrationRole).getRole());
accountDO.setPassword(dto.getPassword());
accountDO.setDisplayName(ldapAttrsInfo.get("displayName").toString());
accountDO.setDepartment(ldapAttrsInfo.get("department").toString());
accountDO.setMail(ldapAttrsInfo.get("mail").toString());
accountService.createAccount(accountDO);
}

View File

@@ -18,6 +18,9 @@ public class AccountConverter {
accountDO.setUsername(dto.getUsername());
accountDO.setPassword(dto.getPassword());
accountDO.setRole(dto.getRole());
accountDO.setDepartment(dto.getDepartment());
accountDO.setMail(dto.getMail());
accountDO.setDisplayName(dto.getDisplayName());
return accountDO;
}