From 45cf93e1bf853b60c505cc486f538e0108c55796 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Tue, 27 Aug 2024 10:21:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86app=E7=99=BB=E5=BD=95=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controller/Login.go | 15 +++++++++++++-- api/requests/Login.go | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/api/controller/Login.go b/api/controller/Login.go index b186564..3d9286f 100644 --- a/api/controller/Login.go +++ b/api/controller/Login.go @@ -37,6 +37,13 @@ func (r *Login) Login(c *gin.Context) { return } + if req.Source == 1 { + if req.Mobile != "" { + responses.FailWithMessage("登陆失败", c) + return + } + } + // 开始事务 tx := global.Db.Begin() defer func() { @@ -59,11 +66,15 @@ func (r *Login) Login(c *gin.Context) { if req.Mobile != "" { maps["mobile"] = req.Mobile } + + if req.Uuid != "" { + maps["app_iden"] = req.Uuid + } user, _ := userDao.GetUser(maps) // 新用户处理方式 if user == nil { // 检测验证码 - if req.Mobile != "" { + if req.Source == 1 { if config.C.Env != "dev" { code, _ := global.Redis.Get(c, "login_code_count_"+req.Mobile).Result() if code == "" { @@ -94,7 +105,7 @@ func (r *Login) Login(c *gin.Context) { // 新增用户 user = &model.User{ UserName: req.Nickname, - AppIden: "", + AppIden: req.Uuid, Mobile: req.Mobile, RegisterSource: req.Source, OpenId: req.OpenId, diff --git a/api/requests/Login.go b/api/requests/Login.go index 7ebeae0..d303021 100644 --- a/api/requests/Login.go +++ b/api/requests/Login.go @@ -8,9 +8,10 @@ type LoginRequest struct { type Login struct { Mobile string `json:"mobile" form:"mobile" label:"手机号"` Code string `json:"code" form:"code" label:"验证码"` - Source int `json:"source" form:"source" label:"来源" validate:"required"` // (1:app 2:公众号 + Source int `json:"source" form:"source" label:"来源" validate:"required"` // (1:app 2:公众号) OpenId string `json:"openid" form:"openid" label:"openid"` Nickname string `json:"nickname" form:"nickname" label:"用户昵称"` HeadImgUrl string `json:"headimgurl" form:"headimgurl" label:"头像"` UnionId string `json:"unionid" form:"unionid" label:"unionid"` + Uuid string `json:"uuid" form:"uuid" label:"app唯一标识"` }