36 lines
774 B
Go
36 lines
774 B
Go
package services
|
|
|
|
import (
|
|
"qteam/app/constants/errorcode"
|
|
"qteam/app/http/entities/front"
|
|
"qteam/app/models/usersmodel"
|
|
"qteam/app/utils"
|
|
)
|
|
|
|
func XyYouKuLogin(req *front.LoginRequest) (code int, token string) {
|
|
var err error
|
|
var user usersmodel.Users
|
|
info := DecryptXyData(req.Data)
|
|
if info.Mobile == "" {
|
|
code = errorcode.ParamError
|
|
return
|
|
}
|
|
var addUser = false
|
|
info.Mobile = "15583730896"
|
|
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()
|
|
_, err = usersmodel.GetInstance().GetDb().Insert(&user)
|
|
}
|
|
if err != nil {
|
|
code = handErr(err)
|
|
}
|
|
token = utils.GeneratorJwtToken(user)
|
|
return
|
|
}
|