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"` }