From 6aa75c2a266a2522ae713b13dc702b5ad0a08f87 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期二, 24 十月 2023 13:50:23 +0800 Subject: [PATCH] 编码规则需求功能开发 --- api/v1/client.go | 23 +++++++++-------------- 1 files changed, 9 insertions(+), 14 deletions(-) diff --git a/api/v1/client.go b/api/v1/client.go index 37016eb..bca5872 100644 --- a/api/v1/client.go +++ b/api/v1/client.go @@ -41,25 +41,20 @@ return } - //CreatorId, b := c.Get("claims") - //if !b { - // ctx.Fail(ecode.JWTParseErr) - // return - //} - // - //client.CreatorId = CreatorId.(int) + count, err := model.NewClientSearch(nil).SetNumber(params.Number).Count() + if err != nil { + ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜楠岃瘉澶辫触") + return + } + if count > 0 { + ctx.FailWithMsg(ecode.UnknownErr, "缂栫爜宸插瓨鍦�") + return + } errCode = clientService.AddClient(client, params.SalesLeadsId) if errCode != ecode.OK { ctx.Fail(errCode) return - } - if params.CodeRule.Method == 1 { - autoCode := model.GetAutoCode(client.Id, ¶ms.CodeRule) - m := map[string]interface{}{ - "number": autoCode, - } - _ = model.NewClientSearch(nil).SetId(client.Id).UpdateByMap(m) } ctx.Ok() -- Gitblit v1.8.0