2024-06-11 18:47:02 +08:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
|
|
|
"qteam/app/constants/errorcode"
|
|
|
|
"qteam/app/http/entities/front"
|
|
|
|
"qteam/app/models/usersmodel"
|
2024-06-12 19:11:00 +08:00
|
|
|
"qteam/app/utils"
|
2024-06-11 18:47:02 +08:00
|
|
|
)
|
|
|
|
|
2024-06-12 19:11:00 +08:00
|
|
|
func XyYouKuLogin(req *front.LoginRequest) (code int, token string) {
|
2024-06-11 18:47:02 +08:00
|
|
|
var err error
|
2024-06-12 19:11:00 +08:00
|
|
|
var user usersmodel.Users
|
2024-06-11 18:47:02 +08:00
|
|
|
info := DecryptXyData(req.Data)
|
|
|
|
if info.Mobile == "" {
|
|
|
|
code = errorcode.ParamError
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var addUser = false
|
2024-06-12 19:11:00 +08:00
|
|
|
info.Mobile = "15583730896"
|
2024-06-11 18:47:02 +08:00
|
|
|
var session = usersmodel.GetInstance().GetDb().Where("phone = ?", info.Mobile)
|
|
|
|
_, err = session.Get(&user)
|
|
|
|
code = errorcode.Success
|
|
|
|
if user.Id < 1 {
|
|
|
|
addUser = true
|
|
|
|
}
|
|
|
|
if addUser {
|
|
|
|
user = info.RequestToDb()
|
2024-06-13 18:45:49 +08:00
|
|
|
//user.XinYeUserId = info.UserId
|
|
|
|
user.XinYeUserId = 10054
|
2024-06-11 18:47:02 +08:00
|
|
|
_, err = usersmodel.GetInstance().GetDb().Insert(&user)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
code = handErr(err)
|
|
|
|
}
|
2024-06-12 19:11:00 +08:00
|
|
|
token = utils.GeneratorJwtToken(user)
|
|
|
|
return
|
2024-06-11 18:47:02 +08:00
|
|
|
}
|