Browse Source

add 用户信息返回

tags/V2.2.0
chenjiandong 2 years ago
parent
commit
ec9a8c9f68
5 changed files with 16 additions and 5 deletions
  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 View File

id = user.getUserId(); id = user.getUserId();
username = user.getUserName(); username = user.getUserName();
password = user.getPassword(); password = user.getPassword();
authorities = Collections.singleton(new SimpleGrantedAuthority(user.getAuthority()));
authorities = Collections.singleton(new SimpleGrantedAuthority(user.getAuthorityList().toString()));
} }


@Override @Override

+ 3
- 1
tuoheng_oidc_server/src/main/java/com/tuoheng/model/dto/UserBaseInfoDto.java View File



import lombok.Data; import lombok.Data;


import java.util.List;

/** /**
* @author chenjiandong * @author chenjiandong
* @description: TODO * @description: TODO


private String password; private String password;


private String authority;
private List<String> authorityList;


} }

+ 1
- 1
tuoheng_oidc_server/src/main/java/com/tuoheng/service/impl/OidcUserInfoServiceImpl.java View File

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

+ 1
- 1
tuoheng_oidc_server/src/main/resources/application-test.yml View File

type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
# 填写你数据库的url、登录名、密码和数据库名 # 填写你数据库的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 username: root
password: idontcare password: idontcare
druid: druid:

+ 10
- 1
tuoheng_oidc_server/src/main/resources/mapper/UserMapper.xml View File

<!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="com.tuoheng.mapper.UserMapper"> <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 id="insertUser" parameterType="com.tuoheng.model.po.UserPo" keyProperty="id" useGeneratedKeys="true">
insert into users (username, password) insert into users (username, password)
values (#{username}, #{password}) values (#{username}, #{password})
</insert> </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 select a.id as userId, a.username as userName, a.password , b.authority
from users a from users a
inner join authorities b on a.id = b.user_id inner join authorities b on a.id = b.user_id

Loading…
Cancel
Save