From 34e1e9dbc7a750048c0825b8f91b07ed526ae577 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期五, 22 九月 2023 15:41:48 +0800 Subject: [PATCH] 1.根据产品获取出入库历史记录 --- controllers/product_controller.go | 30 +++ request/product_request.go | 5 docs/swagger.yaml | 118 +++++++++++++ docs/docs.go | 186 ++++++++++++++++++++ docs/swagger.json | 184 ++++++++++++++++++++ router/router.go | 2 6 files changed, 523 insertions(+), 2 deletions(-) diff --git a/controllers/product_controller.go b/controllers/product_controller.go index 0f57587..ab40488 100644 --- a/controllers/product_controller.go +++ b/controllers/product_controller.go @@ -274,3 +274,33 @@ } util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛") } + +// ListOperation +// @Tags 浜у搧 +// @Summary 浜у搧鍘嗗彶鍑哄叆搴撲俊鎭� +// @Produce application/json +// @Param object body request.QueryOperationList true "鏌ヨ鍙傛暟" +// @Success 200 {object} util.ResponseList{data=[]models.Operation} "鎴愬姛" +// @Router /api-wms/v1/product/listOperaton [post] +func (slf ProductController) ListOperation(c *gin.Context) { + var params request.QueryOperationList + if err := c.BindJSON(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error()) + return + } + if !params.PageInfo.Check() { + util.ResponseFormat(c, code.RequestParamError, "椤电爜淇℃伅閿欒") + return + } + + search := models.NewOperationSearch().SetPage(params.Page, params.PageSize).SetPreload(true).SetOrder("created_at desc") + search.SetOrm(search.Orm.InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation_details.product_id=?", params.ProductId)) + + list, total, err := search.Find() + if err != nil { + util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error()) + return + } + + util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize) +} diff --git a/docs/docs.go b/docs/docs.go index 81492dd..3bd0a03 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1052,6 +1052,51 @@ } } }, + "/api-wms/v1/product/listOperaton": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "浜у搧鍘嗗彶鍑哄叆搴撲俊鎭�", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.QueryOperationList" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Operation" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/product/updateProduct": { "post": { "produces": [ @@ -1609,6 +1654,10 @@ "description": "鏄惁鎶ュ簾浣嶇疆", "type": "boolean" }, + "jointName": { + "description": "鎷兼帴鍚嶇О", + "type": "string" + }, "name": { "description": "浣嶇疆鍚嶇О", "type": "string" @@ -1835,6 +1884,125 @@ "weight": { "description": "閲嶉噺", "type": "number" + } + } + }, + "models.Operation": { + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "companyID": { + "type": "integer" + }, + "companyName": { + "type": "string" + }, + "contacterID": { + "type": "integer" + }, + "contacterName": { + "type": "string" + }, + "createTime": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/models.OperationDetails" + } + }, + "fromLocation": { + "description": "婧愪綅缃�", + "allOf": [ + { + "$ref": "#/definitions/models.Location" + } + ] + }, + "fromLocationId": { + "description": "婧愪綅缃甶d", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "number": { + "description": "鍗曞彿", + "type": "string" + }, + "operationDate": { + "type": "string" + }, + "operationTypeId": { + "description": "浣滀笟绫诲瀷id", + "type": "integer" + }, + "operationTypeName": { + "description": "浣滀笟绫诲瀷鍚嶇О", + "type": "string" + }, + "sourceNumber": { + "description": "婧愬崟鍙�", + "type": "string" + }, + "status": { + "description": "鐘舵��", + "allOf": [ + { + "$ref": "#/definitions/constvar.OperationStatus" + } + ] + }, + "toLocation": { + "description": "鐩爣浣嶇疆", + "allOf": [ + { + "$ref": "#/definitions/models.Location" + } + ] + }, + "toLocationId": { + "description": "鐩爣浣嶇疆id", + "type": "integer" + }, + "updateTime": { + "type": "string" + } + } + }, + "models.OperationDetails": { + "type": "object", + "properties": { + "amount": { + "description": "鏁伴噺", + "type": "number" + }, + "createTime": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "operationId": { + "description": "鎿嶄綔id", + "type": "integer" + }, + "productId": { + "description": "浜у搧id", + "type": "string" + }, + "productName": { + "description": "浜у搧鍚嶇О", + "type": "string" + }, + "unit": { + "type": "string" + }, + "updateTime": { + "type": "string" } } }, @@ -2352,6 +2520,22 @@ } } }, + "request.QueryOperationList": { + "type": "object", + "properties": { + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + }, + "productId": { + "type": "string" + } + } + }, "request.UpdateCompany": { "type": "object", "properties": { @@ -2576,8 +2760,6 @@ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index 54bcd5b..053866d 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1040,6 +1040,51 @@ } } }, + "/api-wms/v1/product/listOperaton": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "浜у搧鍘嗗彶鍑哄叆搴撲俊鎭�", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.QueryOperationList" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Operation" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/product/updateProduct": { "post": { "produces": [ @@ -1597,6 +1642,10 @@ "description": "鏄惁鎶ュ簾浣嶇疆", "type": "boolean" }, + "jointName": { + "description": "鎷兼帴鍚嶇О", + "type": "string" + }, "name": { "description": "浣嶇疆鍚嶇О", "type": "string" @@ -1823,6 +1872,125 @@ "weight": { "description": "閲嶉噺", "type": "number" + } + } + }, + "models.Operation": { + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "companyID": { + "type": "integer" + }, + "companyName": { + "type": "string" + }, + "contacterID": { + "type": "integer" + }, + "contacterName": { + "type": "string" + }, + "createTime": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/models.OperationDetails" + } + }, + "fromLocation": { + "description": "婧愪綅缃�", + "allOf": [ + { + "$ref": "#/definitions/models.Location" + } + ] + }, + "fromLocationId": { + "description": "婧愪綅缃甶d", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "number": { + "description": "鍗曞彿", + "type": "string" + }, + "operationDate": { + "type": "string" + }, + "operationTypeId": { + "description": "浣滀笟绫诲瀷id", + "type": "integer" + }, + "operationTypeName": { + "description": "浣滀笟绫诲瀷鍚嶇О", + "type": "string" + }, + "sourceNumber": { + "description": "婧愬崟鍙�", + "type": "string" + }, + "status": { + "description": "鐘舵��", + "allOf": [ + { + "$ref": "#/definitions/constvar.OperationStatus" + } + ] + }, + "toLocation": { + "description": "鐩爣浣嶇疆", + "allOf": [ + { + "$ref": "#/definitions/models.Location" + } + ] + }, + "toLocationId": { + "description": "鐩爣浣嶇疆id", + "type": "integer" + }, + "updateTime": { + "type": "string" + } + } + }, + "models.OperationDetails": { + "type": "object", + "properties": { + "amount": { + "description": "鏁伴噺", + "type": "number" + }, + "createTime": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "operationId": { + "description": "鎿嶄綔id", + "type": "integer" + }, + "productId": { + "description": "浜у搧id", + "type": "string" + }, + "productName": { + "description": "浜у搧鍚嶇О", + "type": "string" + }, + "unit": { + "type": "string" + }, + "updateTime": { + "type": "string" } } }, @@ -2340,6 +2508,22 @@ } } }, + "request.QueryOperationList": { + "type": "object", + "properties": { + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + }, + "productId": { + "type": "string" + } + } + }, "request.UpdateCompany": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index ef9f62c..42553ef 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -241,6 +241,9 @@ isScrapLocation: description: 鏄惁鎶ュ簾浣嶇疆 type: boolean + jointName: + description: 鎷兼帴鍚嶇О + type: string name: description: 浣嶇疆鍚嶇О type: string @@ -414,6 +417,84 @@ weight: description: 閲嶉噺 type: number + type: object + models.Operation: + properties: + comment: + type: string + companyID: + type: integer + companyName: + type: string + contacterID: + type: integer + contacterName: + type: string + createTime: + type: string + details: + items: + $ref: '#/definitions/models.OperationDetails' + type: array + fromLocation: + allOf: + - $ref: '#/definitions/models.Location' + description: 婧愪綅缃� + fromLocationId: + description: 婧愪綅缃甶d + type: integer + id: + type: integer + number: + description: 鍗曞彿 + type: string + operationDate: + type: string + operationTypeId: + description: 浣滀笟绫诲瀷id + type: integer + operationTypeName: + description: 浣滀笟绫诲瀷鍚嶇О + type: string + sourceNumber: + description: 婧愬崟鍙� + type: string + status: + allOf: + - $ref: '#/definitions/constvar.OperationStatus' + description: 鐘舵�� + toLocation: + allOf: + - $ref: '#/definitions/models.Location' + description: 鐩爣浣嶇疆 + toLocationId: + description: 鐩爣浣嶇疆id + type: integer + updateTime: + type: string + type: object + models.OperationDetails: + properties: + amount: + description: 鏁伴噺 + type: number + createTime: + type: string + id: + type: integer + operationId: + description: 鎿嶄綔id + type: integer + productId: + description: 浜у搧id + type: string + productName: + description: 浜у搧鍚嶇О + type: string + unit: + type: string + updateTime: + type: string type: object models.OperationType: properties: @@ -759,6 +840,17 @@ description: 浜у搧鍚嶇О type: string unit: + type: string + type: object + request.QueryOperationList: + properties: + page: + description: 椤电爜 + type: integer + pageSize: + description: 姣忛〉澶у皬 + type: integer + productId: type: string type: object request.UpdateCompany: @@ -1546,6 +1638,32 @@ summary: 鑾峰彇浜у搧鍒楄〃 tags: - 浜у搧 + /api-wms/v1/product/listOperaton: + post: + parameters: + - description: 鏌ヨ鍙傛暟 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.QueryOperationList' + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/util.ResponseList' + - properties: + data: + items: + $ref: '#/definitions/models.Operation' + type: array + type: object + summary: 浜у搧鍘嗗彶鍑哄叆搴撲俊鎭� + tags: + - 浜у搧 /api-wms/v1/product/updateProduct: post: parameters: diff --git a/request/product_request.go b/request/product_request.go index 8af1cd0..c4b8cae 100644 --- a/request/product_request.go +++ b/request/product_request.go @@ -4,3 +4,8 @@ PageInfo KeyWord string `json:"keyWord"` } + +type QueryOperationList struct { + PageInfo + ProductId string `json:"productId"` +} diff --git a/router/router.go b/router/router.go index ac257be..c8905ca 100644 --- a/router/router.go +++ b/router/router.go @@ -99,6 +99,8 @@ productAPI.GET("getProductCategoryDetails/:id", productController.GetProductCategoryDetails) //鑾峰彇浜у搧绫诲瀷璇︽儏 productAPI.POST("updateProductCategory", productController.UpdateProductCategory) //淇敼浜у搧绫诲瀷 productAPI.DELETE("deleteProductCategory/:id", productController.DeleteProductCategory) //鍒犻櫎浜у搧绫诲瀷 + + productAPI.POST("listOperaton", productController.ListOperation) //鏌ョ湅浜у搧鐨勫巻鍙插嚭鍏ュ簱淇℃伅 } return r -- Gitblit v1.8.0