Przeglądaj źródła

add 用户信息返回

tags/V2.2.0
chenjiandong 2 lat temu
rodzic
commit
ec9a8c9f68
5 zmienionych plików z 16 dodań i 5 usunięć
  1. +1
    -1
      tuoheng_oidc_server/src/main/java/com/tuoheng/model/dto/JwtUser.java
  2. +3
    -1
      tuoheng_oidc_server/src/main/java/com/tuoheng/model/dto/UserBaseInfoDto.java
  3. +1
    -1
      tuoheng_oidc_server/src/main/java/com/tuoheng/service/impl/OidcUserInfoServiceImpl.java
  4. +1
    -1
      tuoheng_oidc_server/src/main/resources/application-test.yml
  5. +10
    -1
      tuoheng_oidc_server/src/main/resources/mapper/UserMapper.xml

+ 1
- 1
tuoheng_oidc_server/src/main/java/com/tuoheng/model/dto/JwtUser.java Wyświetl plik

@@ -27,7 +27,7 @@ public class JwtUser implements UserDetails {
id = user.getUserId();
username = user.getUserName();
password = user.getPassword();
authorities = Collections.singleton(new SimpleGrantedAuthority(user.getAuthority()));
authorities = Collections.singleton(new SimpleGrantedAuthority(user.getAuthorityList().toString()));
}

@Override

+ 3
- 1
tuoheng_oidc_server/src/main/java/com/tuoheng/model/dto/UserBaseInfoDto.java Wyświetl plik

@@ -2,6 +2,8 @@ package com.tuoheng.model.dto;

import lombok.Data;

import java.util.List;

/**
* @author chenjiandong
* @description: TODO
@@ -16,6 +18,6 @@ public class UserBaseInfoDto {

private String password;

private String authority;
private List<String> authorityList;

}

+ 1
- 1
tuoheng_oidc_server/src/main/java/com/tuoheng/service/impl/OidcUserInfoServiceImpl.java Wyświetl plik

@@ -31,7 +31,7 @@ public class OidcUserInfoServiceImpl implements OidcUserInfoService {
if (scopes.contains(OidcScopes.PROFILE)) {
builder.claim("userId", userBaseInfoDto.getUserId())
.claim("userName", userBaseInfoDto.getUserName())
.claim("authority", userBaseInfoDto.getAuthority());
.claim("authority", userBaseInfoDto.getAuthorityList());
}
/*if (scopes.contains(OidcScopes.EMAIL)) {
builder.email(name + "@163.com").emailVerified(true);

+ 1
- 1
tuoheng_oidc_server/src/main/resources/application-test.yml Wyświetl plik

@@ -11,7 +11,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名
url: jdbc:mysql://192.168.11.242:3306/tuoheng_dsp?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
url: jdbc:mysql://192.168.11.242:3306/tuoheng_oidc?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false
username: root
password: idontcare
druid:

+ 10
- 1
tuoheng_oidc_server/src/main/resources/mapper/UserMapper.xml Wyświetl plik

@@ -2,13 +2,22 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.UserMapper">

<resultMap type="com.tuoheng.model.dto.UserBaseInfoDto" id="UserBaseInfoMap">
<id column="userId" jdbcType="INTEGER" property="userId" />
<result column="userName" jdbcType="VARCHAR" property="userName" />
<result column="password" jdbcType="VARCHAR" property="password" />
<collection property="authorityList" ofType="java.lang.String" javaType="java.util.List">
<result column="authority" jdbcType="VARCHAR"/>
</collection>
</resultMap>

<insert id="insertUser" parameterType="com.tuoheng.model.po.UserPo" keyProperty="id" useGeneratedKeys="true">
insert into users (username, password)
values (#{username}, #{password})
</insert>


<select id="getUserBaseInfo" resultType="com.tuoheng.model.dto.UserBaseInfoDto">
<select id="getUserBaseInfo" resultMap="UserBaseInfoMap">
select a.id as userId, a.username as userName, a.password , b.authority
from users a
inner join authorities b on a.id = b.user_id

Ładowanie…
Anuluj
Zapisz