From b86a9e50b3267d56dfcbcbd8bc7f74880b096851 Mon Sep 17 00:00:00 2001 From: "yan.y" Date: Wed, 3 Apr 2024 17:23:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/api/auth.go | 18 +++++++++++++----- business/api/car.go | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 business/api/car.go diff --git a/business/api/auth.go b/business/api/auth.go index 85d36bf..b35dd9b 100644 --- a/business/api/auth.go +++ b/business/api/auth.go @@ -13,7 +13,9 @@ import ( ) type LoginRequest struct { - Code string + 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, diff --git a/business/api/car.go b/business/api/car.go new file mode 100644 index 0000000..778f64e --- /dev/null +++ b/business/api/car.go @@ -0,0 +1 @@ +package api