master
黄海 5 years ago
parent 3047d95afa
commit a9573ee836

@ -5,6 +5,7 @@ import (
"dsSso/Const/DefaultConst"
"dsSso/Controller/ControllerRecaptcha"
"dsSso/Dao/DaoBaseGlobal"
"dsSso/Dao/DaoSysLoginPerson"
"dsSso/Model"
"dsSso/Service/ServiceJoinApp"
"dsSso/Service/ServiceLoginPerson"
@ -268,11 +269,19 @@ func accessToken(context *gin.Context) {
k := ConfigUtil.OAuth2RedisKeyPrefix + ":refresh_token_vs_person:" + refreshToken
RedisUtil.SET(k, personStr, time.Hour*24*30) //30天的有效期
personName, err := DaoSysLoginPerson.GetPersonName(identityId, personId)
if err != nil {
context.JSON(http.StatusOK, Model.Res{
Code: http.StatusNotImplemented,
Msg: "获取人员姓名信息失败!",
})
return
}
//返回json数据
context.JSON(http.StatusOK,
gin.H{
"access_token": accessToken, "expires_in": expiresIn, "refresh_token": refreshToken,
"token_type": tokenType, "identity_id": identityIdInt, "person_id": personId, "code": 200})
"token_type": tokenType, "identity_id": identityIdInt, "person_id": personId, "person_name": personName, "code": 200})
return
} else {
//刷新token

@ -269,3 +269,16 @@ func BindWxUser(identityId string, personId string, openid string) (bool, error)
func UnBindWxUser(identityId string, personId string) (bool, error) {
return BindWxUser(identityId, personId, "")
}
//通过人员身份ID和人员编号获取人员的信息
func GetPersonName(identityId string, personId string) (string, error) {
sql := `select person_name from t_sys_loginperson where identity_id=? and person_id=?`
list, err := db.SQL(sql, identityId, personId).Query().List()
if err != nil {
return "", err
}
if len(list) == 0 {
return "", err
}
return list[0]["person_name"].(string), nil
}

@ -663,7 +663,7 @@ type swaggerInfo struct {
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "2.0",
Host: "127.0.0.1:8000",
Host: "10.10.14.187:8000",
BasePath: "",
Schemes: []string{},
Title: "东师理想统一认证中心(OAuth2+Sso)",

@ -6,7 +6,7 @@
"contact": {},
"version": "2.0"
},
"host": "127.0.0.1:8000",
"host": "10.10.14.187:8000",
"paths": {
"/oauth2/AddClient": {
"post": {

@ -32,7 +32,7 @@ definitions:
description: 个数
type: object
type: object
host: 127.0.0.1:8000
host: 10.10.14.187:8000
info:
contact: {}
description: 参考自xxl-sso

@ -56,7 +56,7 @@ func startOAuth2Server() {
// @title 东师理想统一认证中心(OAuth2+Sso)
// @version 2.0
// @description 参考自xxl-sso
// @host 127.0.0.1:8000
// @host 10.10.14.187:8000
func main() {
// 发布模式
//gin.SetMode(gin.ReleaseMode)

@ -458,7 +458,7 @@ func insertRedisCache(accessKey string, secretKey string, redirectUri string) er
if err != nil {
return err
}
defer resp.Body.Close()
_, _ = ioutil.ReadAll(resp.Body)
return nil

Loading…
Cancel
Save