32 lines
862 B
Go
32 lines
862 B
Go
|
package services
|
||
|
|
||
|
import (
|
||
|
"qteam/app/constants/common"
|
||
|
"qteam/app/constants/errorcode"
|
||
|
"qteam/app/http/entities/front"
|
||
|
"qteam/app/models/usersmodel"
|
||
|
"qteam/app/third/youchu"
|
||
|
"qteam/app/utils"
|
||
|
"qteam/config"
|
||
|
)
|
||
|
|
||
|
func YouChuLogin(req *front.UnionLoginRequest) (code int, login front.LoginResponse) {
|
||
|
client := youchu.NewYouChuClient(config.GetConf().YouChu)
|
||
|
YouChuResponse, err := client.Login(req.Code)
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
if YouChuResponse.RespCode == "000000" {
|
||
|
// 获取用户信息
|
||
|
var user usersmodel.Users
|
||
|
err := usersmodel.GetInstance().GetDb().Where("status = ?", common.STATUSABLED).Where("phone = ?", YouChuResponse.Phone).Find(&user)
|
||
|
code = handErr(err)
|
||
|
login.Token = utils.GeneratorJwtToken(utils.User{
|
||
|
Id: user.Id,
|
||
|
Phone: user.Phone,
|
||
|
})
|
||
|
return errorcode.Success, login
|
||
|
}
|
||
|
return errorcode.NotFound, login
|
||
|
}
|