From 8f1bb68cbe84346c2a1b17fdb64b86958e803e15 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 19 Sep 2024 11:10:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_login.go | 15 +++++++++++++++ app/md/md_login.go | 1 + 2 files changed, 16 insertions(+) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 391e491..fb12ba0 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -216,6 +216,21 @@ func Register(c *gin.Context) { e.OutErr(c, e.ERR_DB_ORM, "新增 记录失败") return } + if utils.StrToInt(req.AgentId) > 0 { + NewAgentWithMediumDb := implement2.NewAgentWithMediumDb(db.Db) + data := NewAgentWithMediumDb.GetAgentWithMediumByMediumIdAndAgentId(utils.StrToInt(mediumId), utils.StrToInt(req.AgentId)) + if data != nil { + e.OutErr(c, 400, e.NewErr(400, "已绑定过该渠道代理")) + return + } + var tmp = model.AgentWithMedium{ + AgentId: utils.StrToInt(req.AgentId), + MediumId: utils.StrToInt(mediumId), + CreateAt: time.Now().Format("2006-01-02 15:04:05"), + UpdateAt: time.Now().Format("2006-01-02 15:04:05"), + } + db.Db.InsertOne(&tmp) + } ip := utils.GetIP(c.Request) key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(mediumModel.Id)) token, err := svc.HandleLoginToken(key, &mediumModel) diff --git a/app/md/md_login.go b/app/md/md_login.go index c8ee437..cb0806d 100644 --- a/app/md/md_login.go +++ b/app/md/md_login.go @@ -18,4 +18,5 @@ type RegisterReq struct { UserName string `json:"username" binding:"required" example:"登录账号"` Captcha string `json:"captcha" binding:"required" example:"验证码"` PassWord string `json:"password" binding:"required" example:"登录密码"` + AgentId string `json:"agent_id" example:"代理id"` }