新增逻辑

This commit is contained in:
yan.y 2024-04-03 17:23:22 +08:00
parent 43c26825b2
commit b86a9e50b3
2 changed files with 14 additions and 5 deletions

View File

@ -14,6 +14,8 @@ import (
type LoginRequest struct {
Code string
NickName string
HeadImgUrl string
}
type LoginResponse struct {
@ -52,15 +54,21 @@ func (p DefParty) login() web_iris.Party {
LoginError.DefFail(ctx, loginRequest, info.ErrMsg)
return
}
if len(loginRequest.NickName) == 0 {
loginRequest.NickName = defaultNickName
}
if len(loginRequest.HeadImgUrl) == 0 {
loginRequest.HeadImgUrl = defaultHeadImgUrl
}
var userInfo models.User
database.Instance().Model(&models.User{}).Where("open_id = ? or union_id = ?", "1", "2").Find(&userInfo)
if userInfo.Id == 0 {
newUser := models.User{
NickName: defaultNickName,
HeadImgUrl: defaultHeadImgUrl,
NickName: loginRequest.NickName,
HeadImgUrl: loginRequest.HeadImgUrl,
Amount: 0,
OpenId: NextId.Generate().String(),
UnionId: NextId.Generate().String(),
OpenId: info.Openid,
UnionId: info.Unionid,
UserType: 0,
Mobile: "",
Role: 0,

1
business/api/car.go Normal file
View File

@ -0,0 +1 @@
package api