ソースを参照

add 用户信息返回

tags/V2.2.0
chenjiandong 1年前
コミット
ec9a8c9f68
5個のファイルの変更16行の追加5行の削除
  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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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

読み込み中…
キャンセル
保存