package xiangyu import ( "eta_gn/eta_bridge/models/eta" "eta_gn/eta_bridge/models/response" "eta_gn/eta_bridge/services" "eta_gn/eta_bridge/services/xiangyu" "fmt" "time" ) // LoginEta // @Description: 获取eta的session // @author: Roc // @datetime 2024-01-23 17:44:15 // @param code string // @return resp response.LoginResp // @return err error // @return errMsg string func LoginEta(code string) (resp response.LoginResp, err error, errMsg string) { // 获取xiangyu token tokenResp, err := xiangyu.GetToken(code) if err != nil { return } //// 获取eta用户信息 //adminInfo, err := eta.GetSysUserByOutId(tokenResp.Uid) //if err != nil { // return //} // 获取用户信息 userInfoResp, err := xiangyu.GetUserInfo(tokenResp.AccessToken) if err != nil { return } // 获取eta用户信息 adminInfo, err := eta.GetSysUserByAdminName(userInfoResp.LoginName) if err != nil { return } // 生成登录session resp, session, err, errMsg := services.CreateEtaSession(adminInfo) if err != nil { return } // 记录两方session的绑定信息 thirdSession := &eta.SysThirdSession{ ID: 0, SysUserID: uint64(session.SysUserId), UserName: session.UserName, AccessToken: session.AccessToken, ThirdAccessToken: tokenResp.AccessToken, //ThirdRefreshToken: tokenResp.RefreshToken, ThirdExpiredTime: time.Now().Add(time.Duration(tokenResp.ExpiresIn-100) * time.Second), CreatedTime: time.Now(), LastUpdatedTime: time.Now(), } eta.AddSysThirdSession(thirdSession) return } func GetToken(code string) (err error) { fmt.Println(xiangyu.GetToken(code)) return } func GetUserInfo(token string) (err error) { fmt.Println(xiangyu.GetUserInfo(token)) return } func CheckToken(token string) (err error) { fmt.Println(xiangyu.CheckToken(token)) return } func GetTokenInfo(token string) (err error) { fmt.Println(xiangyu.GetTokenInfo(token)) return } func RefreshToken(token string) (err error) { fmt.Println(xiangyu.RefreshToken(token)) return } func RevokeToken(token string) (err error) { fmt.Println(xiangyu.RevokeToken(token)) return }