From a7066b64e1feacc0f0954c5e1fb6984816cccd40 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期五, 25 八月 2023 11:14:47 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- constvar/receipt.go | 10 +- model/request/receipt.go | 9 - docs/swagger.yaml | 53 +++++----- api/v1/receipt.go | 12 +- docs/docs.go | 69 ++++++------- docs/swagger.json | 69 ++++++------- service/receipt.go | 8 + model/receipt.go | 21 ++++ 8 files changed, 131 insertions(+), 120 deletions(-) diff --git a/api/v1/receipt.go b/api/v1/receipt.go index e507d08..3367e14 100644 --- a/api/v1/receipt.go +++ b/api/v1/receipt.go @@ -71,10 +71,10 @@ if !ok { return } - if params.Id == 0 { - ctx.Fail(ecode.ParamsErr) - } - params.Receipt.Id = params.Id + if params.Id == 0 { + ctx.Fail(ecode.ParamsErr) + } + params.Receipt.Id = params.Id errCode := service.NewReceiptService().UpdateReceipt(¶ms.Receipt) if errCode != ecode.OK { @@ -99,14 +99,14 @@ return } - receipt, total, errCode := service.NewReceiptService().GetReceiptList() + receipt, total, errCode := service.NewReceiptService().GetReceiptList(params) if errCode != ecode.OK { ctx.Fail(errCode) return } ctx.OkWithDetailed(response.ListResponse{ - Data: receipt, + Data: receipt, Count: total, }) } diff --git a/constvar/receipt.go b/constvar/receipt.go index d0d04a8..fbef2df 100644 --- a/constvar/receipt.go +++ b/constvar/receipt.go @@ -15,9 +15,9 @@ type ReceiptSourceType int //鏉ユ簮绫诲瀷锛�1閿�鍞槑缁嗗崟2鏈嶅姟鍚堝悓3閿�鍞彂绁�4鏀舵璁″垝5鍑哄簱鍗曪級 const ( - ReceiptSourceTypeSalesDetails ReceiptSourceType = 1 - ReceiptSourceTypeServiceContract ReceiptSourceType = 2 - ReceiptSourceTypeInvoice ReceiptSourceType = 3 - ReceiptSourceTypeCollectionPlan ReceiptSourceType = 4 - ReceiptSourceTypeChuKuDan ReceiptSourceType = 5 + ReceiptSourceTypeSalesDetails ReceiptSourceType = 1 //閿�鍞槑缁嗗崟 + ReceiptSourceTypeServiceContract ReceiptSourceType = 2 //鏈嶅姟鍚堝悓 + ReceiptSourceTypeInvoice ReceiptSourceType = 3 //閿�鍞彂绁� + ReceiptSourceTypeCollectionPlan ReceiptSourceType = 4 //鏀舵璁″垝 + ReceiptSourceTypeChuKuDan ReceiptSourceType = 5 //鍑哄簱鍗昳t ) diff --git a/docs/docs.go b/docs/docs.go index 8d2e5b7..1337cad 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -5520,22 +5520,6 @@ "summary": "鑾峰彇鏀舵鍗曞垪琛�", "parameters": [ { - "type": "string", - "name": "keyword", - "in": "query" - }, - { - "enum": [ - "" - ], - "type": "string", - "x-enum-varnames": [ - "ReceiptKeywordCustomerName" - ], - "name": "keywordType", - "in": "query" - }, - { "type": "integer", "description": "椤电爜", "name": "page", @@ -5548,14 +5532,34 @@ "in": "query" }, { + "type": "integer", + "name": "sourceId", + "in": "query" + }, + { "enum": [ - "" + 1, + 2, + 3, + 4, + 5 ], - "type": "string", + "type": "integer", + "x-enum-comments": { + "ReceiptSourceTypeChuKuDan": "鍑哄簱鍗昳t", + "ReceiptSourceTypeCollectionPlan": "鏀舵璁″垝", + "ReceiptSourceTypeInvoice": "閿�鍞彂绁�", + "ReceiptSourceTypeSalesDetails": "閿�鍞槑缁嗗崟", + "ReceiptSourceTypeServiceContract": "鏈嶅姟鍚堝悓" + }, "x-enum-varnames": [ - "ReceiptQueryClassExpireLessThen60Days" + "ReceiptSourceTypeSalesDetails", + "ReceiptSourceTypeServiceContract", + "ReceiptSourceTypeInvoice", + "ReceiptSourceTypeCollectionPlan", + "ReceiptSourceTypeChuKuDan" ], - "name": "queryClass", + "name": "sourceType", "in": "query" } ], @@ -10391,24 +10395,6 @@ "PaymentTypeQueryClassExpireLessThen60Days" ] }, - "constvar.ReceiptKeywordType": { - "type": "string", - "enum": [ - "" - ], - "x-enum-varnames": [ - "ReceiptKeywordCustomerName" - ] - }, - "constvar.ReceiptQueryClass": { - "type": "string", - "enum": [ - "" - ], - "x-enum-varnames": [ - "ReceiptQueryClassExpireLessThen60Days" - ] - }, "constvar.ReceiptSourceType": { "type": "integer", "enum": [ @@ -10418,6 +10404,13 @@ 4, 5 ], + "x-enum-comments": { + "ReceiptSourceTypeChuKuDan": "鍑哄簱鍗昳t", + "ReceiptSourceTypeCollectionPlan": "鏀舵璁″垝", + "ReceiptSourceTypeInvoice": "閿�鍞彂绁�", + "ReceiptSourceTypeSalesDetails": "閿�鍞槑缁嗗崟", + "ReceiptSourceTypeServiceContract": "鏈嶅姟鍚堝悓" + }, "x-enum-varnames": [ "ReceiptSourceTypeSalesDetails", "ReceiptSourceTypeServiceContract", diff --git a/docs/swagger.json b/docs/swagger.json index f8501aa..2729e72 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -5508,22 +5508,6 @@ "summary": "鑾峰彇鏀舵鍗曞垪琛�", "parameters": [ { - "type": "string", - "name": "keyword", - "in": "query" - }, - { - "enum": [ - "" - ], - "type": "string", - "x-enum-varnames": [ - "ReceiptKeywordCustomerName" - ], - "name": "keywordType", - "in": "query" - }, - { "type": "integer", "description": "椤电爜", "name": "page", @@ -5536,14 +5520,34 @@ "in": "query" }, { + "type": "integer", + "name": "sourceId", + "in": "query" + }, + { "enum": [ - "" + 1, + 2, + 3, + 4, + 5 ], - "type": "string", + "type": "integer", + "x-enum-comments": { + "ReceiptSourceTypeChuKuDan": "鍑哄簱鍗昳t", + "ReceiptSourceTypeCollectionPlan": "鏀舵璁″垝", + "ReceiptSourceTypeInvoice": "閿�鍞彂绁�", + "ReceiptSourceTypeSalesDetails": "閿�鍞槑缁嗗崟", + "ReceiptSourceTypeServiceContract": "鏈嶅姟鍚堝悓" + }, "x-enum-varnames": [ - "ReceiptQueryClassExpireLessThen60Days" + "ReceiptSourceTypeSalesDetails", + "ReceiptSourceTypeServiceContract", + "ReceiptSourceTypeInvoice", + "ReceiptSourceTypeCollectionPlan", + "ReceiptSourceTypeChuKuDan" ], - "name": "queryClass", + "name": "sourceType", "in": "query" } ], @@ -10379,24 +10383,6 @@ "PaymentTypeQueryClassExpireLessThen60Days" ] }, - "constvar.ReceiptKeywordType": { - "type": "string", - "enum": [ - "" - ], - "x-enum-varnames": [ - "ReceiptKeywordCustomerName" - ] - }, - "constvar.ReceiptQueryClass": { - "type": "string", - "enum": [ - "" - ], - "x-enum-varnames": [ - "ReceiptQueryClassExpireLessThen60Days" - ] - }, "constvar.ReceiptSourceType": { "type": "integer", "enum": [ @@ -10406,6 +10392,13 @@ 4, 5 ], + "x-enum-comments": { + "ReceiptSourceTypeChuKuDan": "鍑哄簱鍗昳t", + "ReceiptSourceTypeCollectionPlan": "鏀舵璁″垝", + "ReceiptSourceTypeInvoice": "閿�鍞彂绁�", + "ReceiptSourceTypeSalesDetails": "閿�鍞槑缁嗗崟", + "ReceiptSourceTypeServiceContract": "鏈嶅姟鍚堝悓" + }, "x-enum-varnames": [ "ReceiptSourceTypeSalesDetails", "ReceiptSourceTypeServiceContract", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index ac2abf1..fbb345d 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -116,18 +116,6 @@ type: string x-enum-varnames: - PaymentTypeQueryClassExpireLessThen60Days - constvar.ReceiptKeywordType: - enum: - - "" - type: string - x-enum-varnames: - - ReceiptKeywordCustomerName - constvar.ReceiptQueryClass: - enum: - - "" - type: string - x-enum-varnames: - - ReceiptQueryClassExpireLessThen60Days constvar.ReceiptSourceType: enum: - 1 @@ -136,6 +124,12 @@ - 4 - 5 type: integer + x-enum-comments: + ReceiptSourceTypeChuKuDan: 鍑哄簱鍗昳t + ReceiptSourceTypeCollectionPlan: 鏀舵璁″垝 + ReceiptSourceTypeInvoice: 閿�鍞彂绁� + ReceiptSourceTypeSalesDetails: 閿�鍞槑缁嗗崟 + ReceiptSourceTypeServiceContract: 鏈嶅姟鍚堝悓 x-enum-varnames: - ReceiptSourceTypeSalesDetails - ReceiptSourceTypeServiceContract @@ -9450,16 +9444,6 @@ /api/receipt/list: get: parameters: - - in: query - name: keyword - type: string - - enum: - - "" - in: query - name: keywordType - type: string - x-enum-varnames: - - ReceiptKeywordCustomerName - description: 椤电爜 in: query name: page @@ -9468,13 +9452,30 @@ in: query name: pageSize type: integer + - in: query + name: sourceId + type: integer - enum: - - "" + - 1 + - 2 + - 3 + - 4 + - 5 in: query - name: queryClass - type: string + name: sourceType + type: integer + x-enum-comments: + ReceiptSourceTypeChuKuDan: 鍑哄簱鍗昳t + ReceiptSourceTypeCollectionPlan: 鏀舵璁″垝 + ReceiptSourceTypeInvoice: 閿�鍞彂绁� + ReceiptSourceTypeSalesDetails: 閿�鍞槑缁嗗崟 + ReceiptSourceTypeServiceContract: 鏈嶅姟鍚堝悓 x-enum-varnames: - - ReceiptQueryClassExpireLessThen60Days + - ReceiptSourceTypeSalesDetails + - ReceiptSourceTypeServiceContract + - ReceiptSourceTypeInvoice + - ReceiptSourceTypeCollectionPlan + - ReceiptSourceTypeChuKuDan produces: - application/json responses: diff --git a/model/receipt.go b/model/receipt.go index 9ec62f4..5eb54df 100644 --- a/model/receipt.go +++ b/model/receipt.go @@ -53,11 +53,32 @@ } } +func (slf *ReceiptSearch) SetSourceType(sourceType constvar.ReceiptSourceType) *ReceiptSearch { + slf.SourceType = sourceType + return slf +} + +func (slf *ReceiptSearch) SetSourceId(sourceId int) *ReceiptSearch { + slf.SourceId = sourceId + return slf +} + +func (slf *ReceiptSearch) SetPage(page, size int) *ReceiptSearch { + slf.PageNum, slf.PageSize = page, size + return slf +} + func (slf *ReceiptSearch) build() *gorm.DB { var db = slf.Orm.Model(&Receipt{}) if slf.Id != 0 { db = db.Where("id = ?", slf.Id) } + if slf.SourceType != 0 { + db = db.Where("source_type = ?", slf.SourceType) + } + if slf.SourceId != 0 { + db = db.Where("source_id = ?", slf.SourceId) + } return db } diff --git a/model/request/receipt.go b/model/request/receipt.go index 677d508..10225b2 100644 --- a/model/request/receipt.go +++ b/model/request/receipt.go @@ -1,8 +1,8 @@ package request import ( - "aps_crm/constvar" - "aps_crm/model" + "aps_crm/constvar" + "aps_crm/model" ) type AddReceipt struct { @@ -16,7 +16,6 @@ type GetReceiptList struct { PageInfo - QueryClass constvar.ReceiptQueryClass `json:"queryClass" form:"queryClass"` - KeywordType constvar.ReceiptKeywordType `json:"keywordType" form:"keywordType"` - Keyword string `json:"keyword" form:"keyword"` + SourceType constvar.ReceiptSourceType `json:"sourceType" form:"sourceType"` + SourceId int `json:"sourceId" form:"sourceId"` } diff --git a/service/receipt.go b/service/receipt.go index feec40f..210b4b7 100644 --- a/service/receipt.go +++ b/service/receipt.go @@ -130,8 +130,12 @@ return ecode.OK } -func (ReceiptService) GetReceiptList() ([]*model.Receipt, int64, int) { - list, total, err := model.NewReceiptSearch().Find() +func (ReceiptService) GetReceiptList(params request.GetReceiptList) ([]*model.Receipt, int64, int) { + list, total, err := model.NewReceiptSearch(). + SetPage(params.Page, params.PageSize). + SetSourceType(params.SourceType). + SetSourceId(params.SourceId). + Find() if err != nil { return nil, 0, ecode.DBErr } -- Gitblit v1.8.0