2024-06-19 18:32:34 +08:00
|
|
|
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)
|
2024-06-24 11:44:38 +08:00
|
|
|
Code, YouChuResponse := client.Login(req.Code)
|
|
|
|
if Code != errorcode.Success {
|
2024-06-19 18:32:34 +08:00
|
|
|
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
|
|
|
|
}
|