YouChuKoffee/app/services/UserService.go

32 lines
862 B
Go
Raw Normal View History

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)
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
}