liujiandao
2023-10-24 6aa75c2a266a2522ae713b13dc702b5ad0a08f87
编码规则需求功能开发
49个文件已修改
1165 ■■■■■ 已修改文件
api/v1/client.go 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/code.go 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/contract.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/followRecord.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/masterOrder.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/quotation.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/saleChance.go 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesDetails.go 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesLeads.go 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesRefund.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/salesReturn.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceContract.go 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceFollowup.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceOrder.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/subOrder.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/const.go 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 132 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 132 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/client.go 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/contract.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/followRecord.go 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/masterOrder.go 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/quotation.go 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/client.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/contract.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/followRecord.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/masterOrder.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/quotation.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/saleChance.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/salesDetails.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/salesLeads.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/salesRefund.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/salesReturn.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/serviceContract.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/serviceFollowup.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/serviceOrder.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/subOrder.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/saleChance.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesDetails.go 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesLeads.go 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesRefund.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/salesReturn.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceContract.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceFollowup.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceOrder.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/subOrder.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/util.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewClientSearch(nil).SetId(client.Id).UpdateByMap(m)
    }
    ctx.Ok()
api/v1/code.go
@@ -2,6 +2,8 @@
import (
    "aps_crm/conf"
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/model/request"
    "aps_crm/model/response"
    "aps_crm/pkg/contextx"
@@ -71,3 +73,64 @@
        Count: list.Total,
    })
}
// GetAutoCode
//
// @Tags        编码
// @Summary    获取自动编码
// @Produce    application/json
// @Param        object    body        code.CodeStandard    true    "参数"
// @Success    200    {object}    response.ListResponse
//
//    @Router        /api/code/getAutoCode [post]
func (ca *CodeApi) GetAutoCode(c *gin.Context) {
    var params code.CodeStandard
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    var (
        id  = 0
        err error
    )
    switch constvar.CodeStandardType(params.Type) {
    case constvar.CodeStandardTypeSaleKey:
        id, err = model.NewSaleChanceSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeSaleLead:
        id, err = model.NewSalesLeadsSearch(nil).MaxAutoIncr()
    case constvar.CodeStandardTypeCustom:
        id, err = model.NewClientSearch(nil).MaxAutoIncr()
    case constvar.CodeStandardTypeFollowRecord:
        id, err = model.NewFollowRecordSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeQuotation:
        id, err = model.NewQuotationSearch(nil).MaxAutoIncr()
    case constvar.CodeStandardTypeSaleTotalOrder:
        id, err = model.NewMasterOrderSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeSaleSuborder:
        id, err = model.NewSubOrderSearch(nil).MaxAutoIncr()
    case constvar.CodeStandardTypeSaleDetail:
        id, err = model.NewSalesDetailsSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeSaleReturnGoods:
        id, err = model.NewSalesReturnSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeSaleRefund:
        id, err = model.NewSalesRefundSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeContract:
        id, err = model.NewContractSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeServerContract:
        id, err = model.NewServiceContractSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeCustomServer:
        id, err = model.NewServiceOrderSearch().MaxAutoIncr()
    case constvar.CodeStandardTypeServerFollow:
        id, err = model.NewServiceFollowupSearch().MaxAutoIncr()
    default:
        ctx.FailWithMsg(ecode.UnknownErr, "编码规则不存在")
        return
    }
    if err != nil {
        logx.Errorf("GetAutoCode err: %v", err.Error())
        ctx.FailWithMsg(ecode.UnknownErr, "获取最大值失败")
        return
    }
    autoCode := model.GetAutoCode(id, &params)
    ctx.OkWithDetailed(autoCode)
}
api/v1/contract.go
@@ -35,6 +35,16 @@
        return
    }
    count, err := model.NewContractSearch().SetNumber(params.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if contract.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -46,14 +56,6 @@
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(contract.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewContractSearch().SetId(contract.Id).UpdateByMap(m)
    }
    ctx.Ok()
api/v1/followRecord.go
@@ -36,6 +36,16 @@
        return
    }
    count, err := model.NewFollowRecordSearch().SetNumber(followRecord.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if followRecord.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -47,13 +57,6 @@
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.FollowRecord.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(followRecord.Id, &params.FollowRecord.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewFollowRecordSearch().SetId(followRecord.Id).UpdateMap(m)
    }
    ctx.Ok()
api/v1/masterOrder.go
@@ -34,6 +34,16 @@
        return
    }
    count, err := model.NewMasterOrderSearch().SetNumber(params.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if masterOrder.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -45,14 +55,6 @@
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(masterOrder.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewMasterOrderSearch().SetId(masterOrder.Id).UpdateByMap(m)
    }
    ctx.Ok()
api/v1/quotation.go
@@ -34,6 +34,16 @@
        return
    }
    count, err := model.NewQuotationSearch(nil).SetNumber(params.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if quotation.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -45,14 +55,6 @@
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(quotation.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewQuotationSearch(nil).SetId(quotation.Id).Updates(m)
    }
    ctx.Ok()
api/v1/saleChance.go
@@ -33,7 +33,7 @@
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method != 1 {
        count, err := model.NewSaleChanceSearch().SetNumber(saleChance.Number).Count()
        if err != nil {
            ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
@@ -42,7 +42,6 @@
        if count > 0 {
            ctx.FailWithMsg(ecode.UnknownErr, "销售机会编码已存在")
            return
        }
    }
    if saleChance.MemberId == 0 {
@@ -56,14 +55,6 @@
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(saleChance.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewSaleChanceSearch().SetId(saleChance.Id).UpdateByMap(m)
    }
    ctx.Ok()
api/v1/salesDetails.go
@@ -35,6 +35,16 @@
        return
    }
    count, err := model.NewSalesDetailsSearch().SetNumber(params.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if salesDetails.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -46,14 +56,6 @@
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(salesDetails.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewSalesDetailsSearch().SetId(salesDetails.Id).UpdateByMap(m)
    }
    ctx.OkWithDetailed(salesDetails)
@@ -156,6 +158,7 @@
    salesDetailsModel.LogisticNumber = salesDetails.LogisticNumber
    salesDetailsModel.LogisticCost = salesDetails.LogisticCost
    salesDetailsModel.CodeStandID = salesDetails.CodeStandID
    salesDetailsModel.DeliverType = salesDetails.DeliverType
    return ecode.OK, salesDetailsModel
}
api/v1/salesLeads.go
@@ -40,18 +40,20 @@
        ctx.Fail(errCode)
        return
    }
    count, err := model.NewSalesLeadsSearch(nil).SetNumber(params.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    errCode = salesLeadsService.AddSalesLeads(&salesLeads)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(salesLeads.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewSalesLeadsSearch(nil).SetId(salesLeads.Id).UpdateMap(m)
    }
    ctx.Ok()
api/v1/salesRefund.go
@@ -36,6 +36,16 @@
        return
    }
    count, err := model.NewSalesRefundSearch().SetNumber(salesRefund.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if salesRefund.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -47,14 +57,6 @@
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.SalesRefund.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(salesRefund.Id, &params.SalesRefund.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewSalesRefundSearch().SetId(salesRefund.Id).UpdateByMap(m)
    }
    ctx.Ok()
api/v1/salesReturn.go
@@ -37,6 +37,16 @@
        return
    }
    count, err := model.NewSalesReturnSearch().SetNumber(salesReturn.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if salesReturn.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -48,14 +58,6 @@
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.SalesReturn.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(salesReturn.Id, &params.SalesReturn.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewSalesReturnSearch().SetId(salesReturn.Id).UpdateByMap(m)
    }
    ctx.Ok()
api/v1/serviceContract.go
@@ -35,6 +35,16 @@
        return
    }
    count, err := model.NewServiceContractSearch().SetNumber(params.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if params.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -48,40 +58,8 @@
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(serviceContract.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewServiceContractSearch().SetId(serviceContract.Id).UpdateByMap(m)
    }
    ctx.Ok()
}
//// Delete
////
////    @Tags        ServiceContract
////    @Summary    删除服务合同
////    @Produce    application/json
////    @Param        object    body        request.DeleteServiceContract true    "查询参数"
////    @Success    200    {object}    contextx.Response{}
////    @Router        /api/serviceContract/delete [delete]
//func (s *ServiceContractApi) Delete(c *gin.Context) {
//    var params request.DeleteServiceContract
//    ctx, ok := contextx.NewContext(c, &params)
//    if !ok {
//        return
//    }
//
//    errCode := serviceContractService.DeleteServiceContract(params.Ids)
//    if errCode != ecode.OK {
//        ctx.Fail(errCode)
//        return
//    }
//
//    ctx.Ok()
//}
// BatchDelete
// @Tags    ServiceContract
api/v1/serviceFollowup.go
@@ -40,17 +40,20 @@
        return
    }
    count, err := model.NewServiceFollowupSearch().SetNumber(serviceFollowup.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    errCode = serviceFollowupService.AddServiceFollowup(&serviceFollowup)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(serviceFollowup.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).UpdateByMap(m)
    }
    ctx.Ok()
api/v1/serviceOrder.go
@@ -42,17 +42,20 @@
        return
    }
    count, err := model.NewServiceOrderSearch().SetNumber(serviceOrder.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    errCode := service.NewServiceOrderService().AddServiceOrder(serviceOrder)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(serviceOrder.Id, &params.CodeRule)
        m := map[string]interface{}{
            "service_number": autoCode,
        }
        _ = model.NewServiceOrderSearch().SetId(serviceOrder.Id).UpdateByMap(m)
    }
    ctx.Ok()
api/v1/subOrder.go
@@ -34,6 +34,16 @@
        return
    }
    count, err := model.NewSubOrderSearch(nil).SetNumber(params.Number).Count()
    if err != nil {
        ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败")
        return
    }
    if count > 0 {
        ctx.FailWithMsg(ecode.UnknownErr, "编码已存在")
        return
    }
    if subOrder.MemberId == 0 {
        userInfo := utils.GetUserInfo(c)
        if userInfo.UserType == constvar.UserTypeSub {
@@ -47,13 +57,6 @@
        return
    }
    if params.CodeRule.Method == 1 {
        autoCode := model.GetAutoCode(subOrder.Id, &params.CodeRule)
        m := map[string]interface{}{
            "number": autoCode,
        }
        _ = model.NewSubOrderSearch(nil).SetId(subOrder.Id).UpdateByMap(m)
    }
    ctx.Ok()
}
constvar/const.go
@@ -139,7 +139,6 @@
const (
    CodeStandardTypeSaleLead       CodeStandardType = "销售线索编码"
    CodeStandardTypeCustom         CodeStandardType = "客户编码"
    CodeStandardTypeContact        CodeStandardType = "联系人编码"
    CodeStandardTypeFollowRecord   CodeStandardType = "跟进记录编码"
    CodeStandardTypeSaleKey        CodeStandardType = "销售机会编码"
    CodeStandardTypeQuotation      CodeStandardType = "报价编码"
@@ -149,12 +148,15 @@
    CodeStandardTypeContract       CodeStandardType = "合同编码"
    CodeStandardTypeServerContract CodeStandardType = "服务合同编码"
    CodeStandardTypeServerFollow   CodeStandardType = "服务回访编码"
    CodeStandardTypeCustomServer    CodeStandardType = "客户服务编码"
    CodeStandardTypeSaleInvoice     CodeStandardType = "销售发票编码"
    CodeStandardTypeSaleDetail      CodeStandardType = "销售明细编码"
    CodeStandardTypeSaleReturnGoods CodeStandardType = "销售退货编码"
)
func (t CodeStandardType) Valid() bool {
    if t != CodeStandardTypeSaleLead &&
        t != CodeStandardTypeCustom &&
        t != CodeStandardTypeContact &&
        t != CodeStandardTypeFollowRecord &&
        t != CodeStandardTypeSaleKey &&
        t != CodeStandardTypeQuotation &&
@@ -163,6 +165,10 @@
        t != CodeStandardTypeSaleRefund &&
        t != CodeStandardTypeContract &&
        t != CodeStandardTypeServerContract &&
        t != CodeStandardTypeCustomServer &&
        t != CodeStandardTypeSaleInvoice &&
        t != CodeStandardTypeSaleDetail &&
        t != CodeStandardTypeSaleReturnGoods &&
        t != CodeStandardTypeServerFollow {
        return false
    }
docs/docs.go
@@ -1199,6 +1199,36 @@
                }
            }
        },
        "/api/code/getAutoCode": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "编码"
                ],
                "summary": "获取自动编码",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/code.CodeStandard"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/response.ListResponse"
                        }
                    }
                }
            }
        },
        "/api/code/getCodeList": {
            "get": {
                "produces": [
@@ -12048,8 +12078,16 @@
                "solutions": {
                    "type": "string"
                },
                "status_id": {
                "status": {
                    "description": "状态",
                    "allOf": [
                        {
                    "$ref": "#/definitions/model.Status"
                        }
                    ]
                },
                "status_id": {
                    "type": "integer"
                },
                "threats": {
                    "type": "string"
@@ -12133,6 +12171,9 @@
                },
                "creatorName": {
                    "type": "string"
                },
                "deliverType": {
                    "type": "integer"
                },
                "deliveryDate": {
                    "type": "string"
@@ -13296,9 +13337,6 @@
                    "description": "客户类型ID",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -13502,9 +13540,6 @@
            "properties": {
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -13773,9 +13808,6 @@
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -13895,9 +13927,6 @@
            "properties": {
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -14133,9 +14162,6 @@
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -14266,15 +14292,16 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
                },
                "conditions": {
                    "type": "string"
                },
                "deliverType": {
                    "description": "交付类型:1.一次发货,2.多次发货",
                    "type": "integer"
                },
                "deliveryDate": {
                    "type": "string"
@@ -14325,9 +14352,6 @@
            "properties": {
                "city_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -14452,9 +14476,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -14563,9 +14584,6 @@
                    "description": "客户类型ID",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -14660,9 +14678,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -14727,9 +14742,6 @@
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -14885,9 +14897,6 @@
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -15265,9 +15274,6 @@
                },
                "client_status_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "type": "string"
@@ -15846,15 +15852,16 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
                },
                "conditions": {
                    "type": "string"
                },
                "deliverType": {
                    "description": "交付类型:1.一次发货,2.多次发货",
                    "type": "integer"
                },
                "deliveryDate": {
                    "type": "string"
@@ -15914,9 +15921,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -15965,9 +15969,6 @@
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -16167,9 +16168,6 @@
                "client_type_id": {
                    "description": "客户类型ID",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -16459,9 +16457,6 @@
            "properties": {
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -16865,9 +16860,6 @@
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -17048,9 +17040,6 @@
            "properties": {
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -17413,9 +17402,6 @@
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -17589,9 +17575,6 @@
            "properties": {
                "city_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -17846,9 +17829,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -17978,9 +17958,6 @@
                    "description": "客户类型ID",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -18076,9 +18053,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -18146,9 +18120,6 @@
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -18343,9 +18314,6 @@
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
docs/swagger.json
@@ -1187,6 +1187,36 @@
                }
            }
        },
        "/api/code/getAutoCode": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "编码"
                ],
                "summary": "获取自动编码",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/code.CodeStandard"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/response.ListResponse"
                        }
                    }
                }
            }
        },
        "/api/code/getCodeList": {
            "get": {
                "produces": [
@@ -12036,8 +12066,16 @@
                "solutions": {
                    "type": "string"
                },
                "status_id": {
                "status": {
                    "description": "状态",
                    "allOf": [
                        {
                    "$ref": "#/definitions/model.Status"
                        }
                    ]
                },
                "status_id": {
                    "type": "integer"
                },
                "threats": {
                    "type": "string"
@@ -12121,6 +12159,9 @@
                },
                "creatorName": {
                    "type": "string"
                },
                "deliverType": {
                    "type": "integer"
                },
                "deliveryDate": {
                    "type": "string"
@@ -13284,9 +13325,6 @@
                    "description": "客户类型ID",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -13490,9 +13528,6 @@
            "properties": {
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -13761,9 +13796,6 @@
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -13883,9 +13915,6 @@
            "properties": {
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -14121,9 +14150,6 @@
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -14254,15 +14280,16 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
                },
                "conditions": {
                    "type": "string"
                },
                "deliverType": {
                    "description": "交付类型:1.一次发货,2.多次发货",
                    "type": "integer"
                },
                "deliveryDate": {
                    "type": "string"
@@ -14313,9 +14340,6 @@
            "properties": {
                "city_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -14440,9 +14464,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -14551,9 +14572,6 @@
                    "description": "客户类型ID",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -14648,9 +14666,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -14715,9 +14730,6 @@
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -14873,9 +14885,6 @@
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -15253,9 +15262,6 @@
                },
                "client_status_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "type": "string"
@@ -15834,15 +15840,16 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
                },
                "conditions": {
                    "type": "string"
                },
                "deliverType": {
                    "description": "交付类型:1.一次发货,2.多次发货",
                    "type": "integer"
                },
                "deliveryDate": {
                    "type": "string"
@@ -15902,9 +15909,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -15953,9 +15957,6 @@
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -16155,9 +16156,6 @@
                "client_type_id": {
                    "description": "客户类型ID",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -16447,9 +16445,6 @@
            "properties": {
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -16853,9 +16848,6 @@
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -17036,9 +17028,6 @@
            "properties": {
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -17401,9 +17390,6 @@
                "client_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -17577,9 +17563,6 @@
            "properties": {
                "city_id": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -17834,9 +17817,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -17966,9 +17946,6 @@
                    "description": "客户类型ID",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -18064,9 +18041,6 @@
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
                    "type": "string"
@@ -18134,9 +18108,6 @@
                "clientId": {
                    "description": "客户id",
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
@@ -18331,9 +18302,6 @@
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "codeRule": {
                    "$ref": "#/definitions/code.CodeStandard"
                },
                "codeStandID": {
                    "description": "编码id",
docs/swagger.yaml
@@ -1373,8 +1373,12 @@
        type: integer
      solutions:
        type: string
      status:
        allOf:
        - $ref: '#/definitions/model.Status'
        description: 状态
      status_id:
        $ref: '#/definitions/model.Status'
        type: integer
      threats:
        type: string
      whether_established:
@@ -1431,6 +1435,8 @@
        type: integer
      creatorName:
        type: string
      deliverType:
        type: integer
      deliveryDate:
        type: string
      id:
@@ -2212,8 +2218,6 @@
      client_type_id:
        description: 客户类型ID
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -2360,8 +2364,6 @@
    properties:
      client_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -2538,8 +2540,6 @@
    properties:
      client_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -2618,8 +2618,6 @@
    properties:
      client_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -2773,8 +2771,6 @@
        type: integer
      client_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -2861,13 +2857,14 @@
        type: string
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
      conditions:
        type: string
      deliverType:
        description: 交付类型:1.一次发货,2.多次发货
        type: integer
      deliveryDate:
        type: string
      logisticCompany:
@@ -2901,8 +2898,6 @@
    properties:
      city_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -2984,8 +2979,6 @@
    properties:
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -3061,8 +3054,6 @@
      client_type_id:
        description: 客户类型ID
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -3131,8 +3122,6 @@
    properties:
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -3178,8 +3167,6 @@
      clientId:
        description: 客户id
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -3289,8 +3276,6 @@
    properties:
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -3546,8 +3531,6 @@
        type: integer
      client_status_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        type: string
      contact_id:
@@ -3966,13 +3949,14 @@
        type: string
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
      conditions:
        type: string
      deliverType:
        description: 交付类型:1.一次发货,2.多次发货
        type: integer
      deliveryDate:
        type: string
      logisticCompany:
@@ -4009,8 +3993,6 @@
        type: integer
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -4046,8 +4028,6 @@
    properties:
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -4183,8 +4163,6 @@
      client_type_id:
        description: 客户类型ID
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -4387,8 +4365,6 @@
    properties:
      client_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -4657,8 +4633,6 @@
    properties:
      client_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -4778,8 +4752,6 @@
    properties:
      client_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -5016,8 +4988,6 @@
        type: integer
      client_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -5135,8 +5105,6 @@
    properties:
      city_id:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -5305,8 +5273,6 @@
    properties:
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -5396,8 +5362,6 @@
      client_type_id:
        description: 客户类型ID
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -5466,8 +5430,6 @@
    properties:
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -5515,8 +5477,6 @@
      clientId:
        description: 客户id
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -5652,8 +5612,6 @@
    properties:
      clientId:
        type: integer
      codeRule:
        $ref: '#/definitions/code.CodeStandard'
      codeStandID:
        description: 编码id
        type: string
@@ -7025,6 +6983,25 @@
      summary: 更新客户类型
      tags:
      - ClientType
  /api/code/getAutoCode:
    post:
      parameters:
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/code.CodeStandard'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.ListResponse'
      summary: 获取自动编码
      tags:
      - 编码
  /api/code/getCodeList:
    get:
      parameters:
model/client.go
@@ -3,6 +3,7 @@
import (
    "aps_crm/constvar"
    "aps_crm/pkg/mysqlx"
    "fmt"
    "gorm.io/gorm"
    "time"
)
@@ -196,6 +197,30 @@
    return db.Updates(data).Error
}
func (slf *ClientSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *ClientSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *ClientSearch) SetPage(page, size int) *ClientSearch {
    slf.PageNum, slf.PageSize = page, size
    return slf
model/contract.go
@@ -2,6 +2,7 @@
import (
    "aps_crm/pkg/mysqlx"
    "fmt"
    "gorm.io/gorm"
)
@@ -50,6 +51,9 @@
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    if len(slf.SearchMap) > 0 {
@@ -123,6 +127,30 @@
    return records, total, err
}
func (slf *ContractSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *ContractSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *ContractSearch) SetId(id int) *ContractSearch {
    slf.Id = id
    return slf
@@ -146,6 +174,12 @@
    slf.Orm = slf.Orm.Where("id in (?)", ids)
    return slf
}
func (slf *ContractSearch) SetNumber(number string) *ContractSearch {
    slf.Number = number
    return slf
}
func (slf *ContractSearch) UpdateByMap(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
model/followRecord.go
@@ -2,6 +2,7 @@
import (
    "aps_crm/pkg/mysqlx"
    "fmt"
    "gorm.io/gorm"
)
@@ -61,6 +62,9 @@
    }
    if slf.ClientId != 0 {
        db = db.Where("client_id = ?", slf.ClientId)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    if len(slf.SearchMap) > 0 {
@@ -130,12 +134,6 @@
    return records, total, err
}
func (slf *FollowRecordSearch) Count() (int64, error) {
    var count int64
    err := slf.build().Count(&count).Error
    return count, err
}
func (slf *FollowRecordSearch) Page(page, pageSize int) ([]*FollowRecord, int64, error) {
    var records = make([]*FollowRecord, 0)
    var count int64
@@ -160,6 +158,30 @@
func (slf *FollowRecordSearch) Delete() error {
    var db = slf.build()
    return db.Delete(&slf.FollowRecord).Error
}
func (slf *FollowRecordSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *FollowRecordSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *FollowRecordSearch) SetId(id int) *FollowRecordSearch {
@@ -199,3 +221,8 @@
    slf.Orm = tx
    return slf
}
func (slf *FollowRecordSearch) SetNumber(number string) *FollowRecordSearch {
    slf.Number = number
    return slf
}
model/masterOrder.go
@@ -2,6 +2,7 @@
import (
    "aps_crm/pkg/mysqlx"
    "fmt"
    "gorm.io/gorm"
)
@@ -47,6 +48,9 @@
    var db = slf.Orm.Model(&MasterOrder{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    if len(slf.SearchMap) > 0 {
@@ -112,6 +116,30 @@
    return records, total, err
}
func (slf *MasterOrderSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *MasterOrderSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *MasterOrderSearch) SetId(id int) *MasterOrderSearch {
    slf.Id = id
    return slf
@@ -136,6 +164,11 @@
    return slf
}
func (slf *MasterOrderSearch) SetNumber(number string) *MasterOrderSearch {
    slf.Number = number
    return slf
}
func (slf *MasterOrderSearch) UpdateByMap(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
model/quotation.go
@@ -2,6 +2,7 @@
import (
    "aps_crm/pkg/mysqlx"
    "fmt"
    "gorm.io/gorm"
)
@@ -58,6 +59,9 @@
    var db = slf.Orm.Model(&Quotation{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    if len(slf.SearchMap) > 0 {
@@ -128,6 +132,30 @@
    return records, total, err
}
func (slf *QuotationSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *QuotationSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *QuotationSearch) SetId(id int) *QuotationSearch {
    slf.Id = id
    return slf
@@ -152,6 +180,11 @@
    slf.SearchMap = searchMap
    return slf
}
func (slf *QuotationSearch) SetNumber(number string) *QuotationSearch {
    slf.Number = number
    return slf
}
func (slf *QuotationSearch) SetIds(ids []int) *QuotationSearch {
    slf.Orm = slf.Orm.Where("id in (?)", ids)
    return slf
model/request/client.go
@@ -1,7 +1,5 @@
package request
import "aps_crm/proto/code"
type AddClient struct {
    Client
}
@@ -23,7 +21,6 @@
    SalesLeadsId      int               `json:"sales_leads_id"` // 销售线索ID
    ContactId         int               `json:"contact_id"`     // 联系人ID
    CodeStandID       string            `json:"codeStandID"`    //编码id
    CodeRule          code.CodeStandard `json:"codeRule"`
    Address
    Business
}
model/request/contract.go
@@ -1,7 +1,5 @@
package request
import "aps_crm/proto/code"
type AddContract struct {
    Contract
}
@@ -15,7 +13,6 @@
    StatusId     int               `json:"status_id"`
    File         string            `json:"file"`
    CodeStandID  string            `json:"codeStandID"` //编码id
    CodeRule     code.CodeStandard `json:"codeRule"`
}
type UpdateContract struct {
model/request/followRecord.go
@@ -1,7 +1,5 @@
package request
import "aps_crm/proto/code"
type AddFollowRecord struct {
    FollowRecord FollowRecord `json:"follow_record" binding:"required"`
}
@@ -22,7 +20,6 @@
    Purpose              string            `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:跟进目的"`
    Content              string            `json:"content" gorm:"column:content;type:varchar(255);comment:跟进内容"`
    CodeStandID          string            `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"`
    CodeRule             code.CodeStandard `json:"codeRule"`
}
type UpdateFollowRecord struct {
model/request/masterOrder.go
@@ -1,7 +1,5 @@
package request
import "aps_crm/proto/code"
type AddMasterOrder struct {
    MasterOrder
}
@@ -14,7 +12,6 @@
    EndTime     string            `json:"end_time"`
    Money       float64           `json:"money"`
    CodeStandID string            `json:"codeStandID"` //编码id
    CodeRule    code.CodeStandard `json:"codeRule"`
}
type UpdateMasterOrder struct {
model/request/quotation.go
@@ -2,7 +2,6 @@
import (
    "aps_crm/model"
    "aps_crm/proto/code"
)
type AddQuotation struct {
@@ -21,7 +20,6 @@
    Conditions        string            `json:"conditions"`
    File              string            `json:"file"`
    CodeStandID       string            `json:"codeStandID"` //编码id
    CodeRule          code.CodeStandard `json:"codeRule"`
    Products          []model.Product   `json:"products"`
}
model/request/saleChance.go
@@ -2,7 +2,6 @@
import (
    "aps_crm/model"
    "aps_crm/proto/code"
)
type AddSaleChance struct {
@@ -40,7 +39,6 @@
    Remark             string            `json:"remark"`
    DetailAddress      string            `json:"detail_address"`
    CodeStandID        string            `json:"codeStandID"` //编码id
    CodeRule           code.CodeStandard `json:"codeRule"`
    Products           []*model.Product  `json:"products" gorm:"many2many:SaleChance_Product;"`
    Address
}
model/request/salesDetails.go
@@ -3,7 +3,6 @@
import (
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/proto/code"
)
type AddSalesDetails struct {
@@ -29,7 +28,7 @@
    LogisticNumber      string            `json:"logisticNumber" gorm:"column:logistic_number;type:varchar(255);comment:物流单号"`
    LogisticCost        float64           `json:"logisticCost" gorm:"column:logistic_cost;type:decimal(10,2);comment:物流费用"`
    CodeStandID         string            `json:"codeStandID"` //编码id
    CodeRule            code.CodeStandard `json:"codeRule"`
    DeliverType         int              `json:"deliverType"` //交付类型:1.一次发货,2.多次发货
}
type UpdateSalesDetails struct {
model/request/salesLeads.go
@@ -2,7 +2,6 @@
import (
    "aps_crm/constvar"
    "aps_crm/proto/code"
)
type AddSalesLeads struct {
@@ -20,7 +19,6 @@
    Desc            string            `json:"desc"`             // 备注
    DetailAddress   string            `json:"detail_address"`   // 详细地址
    CodeStandID     string            `json:"codeStandID"`      //编码id
    CodeRule        code.CodeStandard `json:"codeRule"`
    Address
}
model/request/salesRefund.go
@@ -3,7 +3,6 @@
import (
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/proto/code"
)
type AddSalesRefundRequest struct {
@@ -23,7 +22,6 @@
    Reason        string                    `json:"reason"`
    Products      []*model.Product          `json:"products"`
    CodeStandID   string                    `json:"codeStandID"` //编码id
    CodeRule      code.CodeStandard         `json:"codeRule"`
}
type UpdateSalesRefundRequest struct {
model/request/salesReturn.go
@@ -3,7 +3,6 @@
import (
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/proto/code"
)
type AddSalesReturnRequest struct {
@@ -24,7 +23,6 @@
    Reason              string                         `json:"reason" gorm:"column:reason;type:varchar(255);comment:退货原因"`                     //退货原因
    Products            []*model.Product               `json:"products" gorm:"many2many:salesReturn_product;"`                                 //退货产品
    CodeStandID         string                         `json:"codeStandID"`                                                                    //编码id
    CodeRule            code.CodeStandard              `json:"codeRule"`
}
type UpdateSalesReturnRequest struct {
model/request/serviceContract.go
@@ -3,7 +3,6 @@
import (
    "aps_crm/constvar"
    "aps_crm/model"
    "aps_crm/proto/code"
)
type AddServiceContract struct {
@@ -30,7 +29,6 @@
    ServiceContractTypeId   int               `json:"serviceContractTypeId"`
    ServiceContractStatusId int               `json:"serviceContractStatusId"`
    CodeStandID             string            `json:"codeStandID"` //编码id
    CodeRule                code.CodeStandard `json:"codeRule"`
}
type UpdateServiceContract struct {
model/request/serviceFollowup.go
@@ -2,7 +2,6 @@
import (
    "aps_crm/constvar"
    "aps_crm/proto/code"
)
type AddServiceFollowup struct {
@@ -24,7 +23,6 @@
    Remark         string            `json:"remark"`
    File           string            `json:"file"`
    CodeStandID    string            `json:"codeStandID"` //编码id
    CodeRule       code.CodeStandard `json:"codeRule"`
}
type UpdateServiceFollowup struct {
model/request/serviceOrder.go
@@ -2,7 +2,6 @@
import (
    "aps_crm/constvar"
    "aps_crm/proto/code"
)
type AddServiceOrder struct {
@@ -34,7 +33,6 @@
    SolutionRemark       string            `gorm:"solution_remark" json:"solutionRemark"`                                                                  // 内部备注
    Remark               string            `gorm:"remark" json:"remark"`                                                                                   // 备注
    CodeStandID          string            `json:"codeStandID"`                                                                                            //编码id
    CodeRule             code.CodeStandard `json:"codeRule"`
}
type UpdateServiceOrder struct {
model/request/subOrder.go
@@ -2,7 +2,6 @@
import (
    "aps_crm/model"
    "aps_crm/proto/code"
)
type AddSubOrder struct {
@@ -16,7 +15,6 @@
    MemberId      int               `json:"memberId"`
    Product       []model.Product   `json:"product"`
    CodeStandID   string            `json:"codeStandID"` //编码id
    CodeRule      code.CodeStandard `json:"codeRule"`
}
type UpdateSubOrder struct {
model/saleChance.go
@@ -2,6 +2,7 @@
import (
    "aps_crm/pkg/mysqlx"
    "fmt"
    "gorm.io/gorm"
)
@@ -213,3 +214,20 @@
    var db = slf.build()
    return db.Updates(data).Error
}
func (slf *SaleChanceSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
model/salesDetails.go
@@ -40,6 +40,7 @@
        AmountUnInvoiced    decimal.Decimal   `gorm:"column:amount_not_invoiced;type:decimal(12,2);comment:未开票金额" json:"amountUnInvoiced"` // 未开票金额
        AmountTotal         decimal.Decimal   `gorm:"column:amount_total;type:decimal(12,2);comment:价税合计" json:"amountTotal"`              // 价税合计
        CodeStandID         string            `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"`
        DeliverType         int               `json:"deliverType" gorm:"column:deliver_type;type:int;comment:交付类型(1.一次发货,2.多次发货)"`
        CrmModel
    }
@@ -133,6 +134,30 @@
    return db.Updates(record).Error
}
func (slf *SalesDetailsSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *SalesDetailsSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *SalesDetailsSearch) SetId(id int) *SalesDetailsSearch {
    slf.Id = id
    return slf
model/salesLeads.go
@@ -3,6 +3,7 @@
import (
    "aps_crm/constvar"
    "aps_crm/pkg/mysqlx"
    "fmt"
    "gorm.io/gorm"
)
@@ -61,6 +62,9 @@
    }
    if slf.Name != "" {
        db = db.Where("name = ?", slf.Name)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    if len(slf.SearchMap) > 0 {
@@ -141,6 +145,30 @@
    return records, total, err
}
func (slf *SalesLeadsSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *SalesLeadsSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *SalesLeadsSearch) SetId(id int) *SalesLeadsSearch {
    slf.Id = id
    return slf
@@ -176,6 +204,11 @@
    return slf
}
func (slf *SalesLeadsSearch) SetNumber(number string) *SalesLeadsSearch {
    slf.Number = number
    return slf
}
func (slf *SalesLeadsSearch) SetSearchMap(data map[string]interface{}) *SalesLeadsSearch {
    slf.SearchMap = data
    return slf
model/salesRefund.go
@@ -116,6 +116,9 @@
    if len(slf.MemberIds) > 0 {
        db = db.Where("sales_refund.member_id in ?", slf.MemberIds)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    return db
}
@@ -169,6 +172,30 @@
    return records, total, err
}
func (slf *SalesRefundSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *SalesRefundSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *SalesRefundSearch) SetId(id int) *SalesRefundSearch {
    slf.Id = id
    return slf
@@ -214,6 +241,11 @@
    return slf
}
func (slf *SalesRefundSearch) SetNumber(number string) *SalesRefundSearch {
    slf.Number = number
    return slf
}
func (slf *SalesRefundSearch) UpdateByMap(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
model/salesReturn.go
@@ -114,6 +114,9 @@
    if len(slf.MemberIds) > 0 {
        db = db.Where("sales_return.member_id in ?", slf.MemberIds)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    return db
}
@@ -168,6 +171,30 @@
    return records, err
}
func (slf *SalesReturnSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *SalesReturnSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *SalesReturnSearch) SetId(id int) *SalesReturnSearch {
    slf.Id = id
    return slf
@@ -217,6 +244,11 @@
    return slf
}
func (slf *SalesReturnSearch) SetNumber(number string) *SalesReturnSearch {
    slf.Number = number
    return slf
}
func (slf *SalesReturnSearch) UpdateByMap(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
model/serviceContract.go
@@ -145,6 +145,9 @@
    if slf.ContactId != 0 {
        db = db.Where("contact_id = ?", slf.ContactId)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    return db
}
@@ -180,10 +183,39 @@
        db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
    }
    err := db.Order("id desc").Order("id desc").Find(&records).Error
    err := db.Order("id desc").Find(&records).Error
    return records, total, err
}
func (slf *ServiceContractSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *ServiceContractSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *ServiceContractSearch) SetNumber(number string) *ServiceContractSearch {
    slf.Number = number
    return slf
}
func (slf *ServiceContractSearch) SetId(id int) *ServiceContractSearch {
    slf.Id = id
    return slf
model/serviceFollowup.go
@@ -101,6 +101,9 @@
    if len(slf.MemberIds) > 0 {
        db = db.Where("service_followup.member_id in ?", slf.MemberIds)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    return db
}
@@ -142,6 +145,35 @@
    return records, total, err
}
func (slf *ServiceFollowupSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *ServiceFollowupSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *ServiceFollowupSearch) SetNumber(number string) *ServiceFollowupSearch {
    slf.Number = number
    return slf
}
func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch {
    slf.Id = id
    return slf
model/serviceOrder.go
@@ -134,6 +134,9 @@
    if len(slf.ServiceManIds) > 0 {
        db = db.Where("service_man_id in ?", slf.ServiceManIds)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    return db
}
@@ -216,6 +219,11 @@
    return slf
}
func (slf *ServiceOrderSearch) SetNumber(number string) *ServiceOrderSearch {
    slf.Number = number
    return slf
}
func (slf *ServiceOrderSearch) First() (*ServiceOrder, error) {
    var db = slf.build()
    var record = new(ServiceOrder)
@@ -260,3 +268,27 @@
    var db = slf.build()
    return db.Updates(data).Error
}
func (slf *ServiceOrderSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *ServiceOrderSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
model/subOrder.go
@@ -2,6 +2,7 @@
import (
    "aps_crm/pkg/mysqlx"
    "fmt"
    "gorm.io/gorm"
)
@@ -49,6 +50,9 @@
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.Number != "" {
        db = db.Where("number = ?", slf.Number)
    }
    if len(slf.SearchMap) > 0 {
@@ -120,6 +124,30 @@
    return records, total, err
}
func (slf *SubOrderSearch) Count() (int64, error) {
    var db = slf.build()
    var total int64
    err := db.Count(&total).Error
    return total, err
}
func (slf *SubOrderSearch) MaxAutoIncr() (int, error) {
    type Result struct {
        Max int
    }
    var (
        result Result
        db     = slf.build()
    )
    err := db.Select("MAX(id) as max").Scan(&result).Error
    if err != nil {
        return result.Max, fmt.Errorf("max err: %v", err)
    }
    return result.Max, nil
}
func (slf *SubOrderSearch) SetId(id int) *SubOrderSearch {
    slf.Id = id
    return slf
@@ -143,6 +171,12 @@
    slf.Orm = slf.Orm.Where("id in (?)", ids)
    return slf
}
func (slf *SubOrderSearch) SetNumber(number string) *SubOrderSearch {
    slf.Number = number
    return slf
}
func (slf *SubOrderSearch) UpdateByMap(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
model/util.go
@@ -38,7 +38,7 @@
    } else { // 固定值
        prefixValue = codeStandard.AutoRule.PrefixValue
    }
    strMaxAutoIncr := strconv.Itoa(id)
    strMaxAutoIncr := strconv.Itoa(id + 1)
    count := int(codeStandard.AutoRule.AutoLength) - len(strMaxAutoIncr)
    for i := 0; i < count; i++ {
        strMaxAutoIncr = "0" + strMaxAutoIncr
router/index.go
@@ -198,6 +198,7 @@
    codeApi := v1.CodeApi{}
    {
        codeGroup.GET("getCodeList", codeApi.GetCodeList) //获取编码列表
        codeGroup.POST("getAutoCode", codeApi.GetAutoCode) //获取编码列表
    }
    return Router
}