| | |
| | | |
| | | import ( |
| | | "aps_crm/conf" |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | |
| | | 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, ¶ms) |
| | | 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, ¶ms) |
| | | ctx.OkWithDetailed(autoCode) |
| | | } |