From 73fffa3c77d86d09b0af45a10b6b524a6361f648 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 18 Sep 2024 21:01:53 +0800 Subject: [PATCH] update --- app/hdl/hdl_login.go | 29 +++++++++++++++++++++++++++++ app/md/md_login.go | 1 + go.mod | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 391e491..b8955f2 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -210,12 +210,41 @@ func Register(c *gin.Context) { } insertAffected, err = db.Db.Insert(&MediumDivisionStrategyModel) if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } if insertAffected <= 0 { e.OutErr(c, e.ERR_DB_ORM, "新增 记录失败") return } + + //5、判断是否为渠道代理邀请 + if req.AgentId != "" { + agentDb := implement.NewAgentDb(engine) + agent, err1 := agentDb.GetAgent(utils.StrToInt(req.AgentId)) + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + if agent != nil { + //5.1 新增agent_with_medium记录 + agentWithMediumDb := implement2.NewAgentWithMediumDb(engine) + insertAffected, err = agentWithMediumDb.AgentWithMediumInsert(&model.AgentWithMedium{ + AgentId: utils.StrToInt(req.AgentId), + MediumId: utils.StrToInt(mediumId), + CreateAt: now.Format("2006-01-02 15:04:05"), + UpdateAt: now.Format("2006-01-02 15:04:05"), + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if insertAffected <= 0 { + e.OutErr(c, e.ERR_DB_ORM, "新增 agent_with_medium 记录失败") + return + } + } + } 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..7294c59 100644 --- a/app/md/md_login.go +++ b/app/md/md_login.go @@ -16,6 +16,7 @@ type LoginPhoneReq struct { } type RegisterReq struct { UserName string `json:"username" binding:"required" example:"登录账号"` + AgentId string `json:"agent_id" example:"代理id"` Captcha string `json:"captcha" binding:"required" example:"验证码"` PassWord string `json:"password" binding:"required" example:"登录密码"` } diff --git a/go.mod b/go.mod index af06264..c76ba41 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module applet go 1.18 -//replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models +replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models // require (