From f89bbcf77dae0465e829ca6f7548cd36ef57aaa6 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期五, 22 九月 2023 16:37:06 +0800
Subject: [PATCH] 1.调拨接口
---
controllers/operation.go | 53 ++++++
models/operation.go | 24 +++
docs/swagger.yaml | 71 ++++++++--
request/operation.go | 10 +
docs/docs.go | 104 +++++++++++---
docs/swagger.json | 104 +++++++++++---
router/router.go | 4
7 files changed, 302 insertions(+), 68 deletions(-)
diff --git a/controllers/operation.go b/controllers/operation.go
index 97f68b3..8eca517 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -128,13 +128,12 @@
// @Tags 鍏ュ簱/鍑哄簱
// @Summary 鍏ュ簱/鍑哄簱鍒楄〃
// @Produce application/json
-// @Accept json
-// @Param object query request.OperationList true "鍙傛暟"
-// @Success 200 {object} util.Response "鎴愬姛"
-// @Router /api-wms/v1/operation/operation [get]
+// @Param object body request.OperationList true "鏌ヨ鍙傛暟"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/operation/list [post]
func (slf OperationController) List(c *gin.Context) {
var params request.OperationList
- if err := c.ShouldBindQuery(¶ms); err != nil {
+ if err := c.BindJSON(¶ms); err != nil {
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error())
return
}
@@ -144,13 +143,19 @@
}
search := models.NewOperationSearch()
search.SetPage(params.Page, params.PageSize)
+ if params.Number != "" {
+ search.SetNumber(params.Number)
+ }
+ if params.SourceNumber != "" {
+ search.SetSourceNumber(params.SourceNumber)
+ }
list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find()
if err != nil {
util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
return
}
- util.ResponseFormatList(c, code.Success, list, int(total))
+ util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
}
@@ -344,3 +349,39 @@
}
util.ResponseFormat(c, code.Success, "鎿嶄綔鎴愬姛")
}
+
+// ListAll
+// @Tags 鍏ュ簱/鍑哄簱
+// @Summary 璋冩嫧
+// @Produce application/json
+// @Param object body request.OperationAllList true "鍙傛暟"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/operation/listAll [post]
+func (slf OperationController) ListAll(c *gin.Context) {
+ var params request.OperationAllList
+ 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()
+ search.SetPage(params.Page, params.PageSize)
+ search.SetPage(params.Page, params.PageSize)
+ if params.Number != "" {
+ search.SetNumber(params.Number)
+ }
+ if params.SourceNumber != "" {
+ search.SetSourceNumber(params.SourceNumber)
+ }
+ list, total, err := search.SetPreload(true).SetOrder("created_at desc").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 3bd0a03..3a58589 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -495,11 +495,8 @@
}
}
},
- "/api-wms/v1/operation/operation": {
- "get": {
- "consumes": [
- "application/json"
- ],
+ "/api-wms/v1/operation/list": {
+ "post": {
"produces": [
"application/json"
],
@@ -509,21 +506,13 @@
"summary": "鍏ュ簱/鍑哄簱鍒楄〃",
"parameters": [
{
- "type": "integer",
- "name": "operationTypeId",
- "in": "query"
- },
- {
- "type": "integer",
- "description": "椤电爜",
- "name": "page",
- "in": "query"
- },
- {
- "type": "integer",
- "description": "姣忛〉澶у皬",
- "name": "pageSize",
- "in": "query"
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.OperationList"
+ }
}
],
"responses": {
@@ -534,7 +523,39 @@
}
}
}
- },
+ }
+ },
+ "/api-wms/v1/operation/listAll": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "鍏ュ簱/鍑哄簱"
+ ],
+ "summary": "璋冩嫧",
+ "parameters": [
+ {
+ "description": "鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.OperationAllList"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/operation/operation": {
"post": {
"produces": [
"application/json"
@@ -2496,6 +2517,25 @@
}
}
},
+ "request.OperationAllList": {
+ "type": "object",
+ "properties": {
+ "number": {
+ "type": "string"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
+ },
+ "sourceNumber": {
+ "type": "string"
+ }
+ }
+ },
"request.OperationDetails": {
"type": "object",
"properties": {
@@ -2520,6 +2560,28 @@
}
}
},
+ "request.OperationList": {
+ "type": "object",
+ "properties": {
+ "number": {
+ "type": "string"
+ },
+ "operationTypeId": {
+ "type": "integer"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
+ },
+ "sourceNumber": {
+ "type": "string"
+ }
+ }
+ },
"request.QueryOperationList": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 053866d..0e384b5 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -483,11 +483,8 @@
}
}
},
- "/api-wms/v1/operation/operation": {
- "get": {
- "consumes": [
- "application/json"
- ],
+ "/api-wms/v1/operation/list": {
+ "post": {
"produces": [
"application/json"
],
@@ -497,21 +494,13 @@
"summary": "鍏ュ簱/鍑哄簱鍒楄〃",
"parameters": [
{
- "type": "integer",
- "name": "operationTypeId",
- "in": "query"
- },
- {
- "type": "integer",
- "description": "椤电爜",
- "name": "page",
- "in": "query"
- },
- {
- "type": "integer",
- "description": "姣忛〉澶у皬",
- "name": "pageSize",
- "in": "query"
+ "description": "鏌ヨ鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.OperationList"
+ }
}
],
"responses": {
@@ -522,7 +511,39 @@
}
}
}
- },
+ }
+ },
+ "/api-wms/v1/operation/listAll": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "鍏ュ簱/鍑哄簱"
+ ],
+ "summary": "璋冩嫧",
+ "parameters": [
+ {
+ "description": "鍙傛暟",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.OperationAllList"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/operation/operation": {
"post": {
"produces": [
"application/json"
@@ -2484,6 +2505,25 @@
}
}
},
+ "request.OperationAllList": {
+ "type": "object",
+ "properties": {
+ "number": {
+ "type": "string"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
+ },
+ "sourceNumber": {
+ "type": "string"
+ }
+ }
+ },
"request.OperationDetails": {
"type": "object",
"properties": {
@@ -2508,6 +2548,28 @@
}
}
},
+ "request.OperationList": {
+ "type": "object",
+ "properties": {
+ "number": {
+ "type": "string"
+ },
+ "operationTypeId": {
+ "type": "integer"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
+ },
+ "sourceNumber": {
+ "type": "string"
+ }
+ }
+ },
"request.QueryOperationList": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 42553ef..ff5c7d4 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -825,6 +825,19 @@
description: 姣忛〉澶у皬
type: integer
type: object
+ request.OperationAllList:
+ properties:
+ number:
+ type: string
+ page:
+ description: 椤电爜
+ type: integer
+ pageSize:
+ description: 姣忛〉澶у皬
+ type: integer
+ sourceNumber:
+ type: string
+ type: object
request.OperationDetails:
properties:
OperationId:
@@ -840,6 +853,21 @@
description: 浜у搧鍚嶇О
type: string
unit:
+ type: string
+ type: object
+ request.OperationList:
+ properties:
+ number:
+ type: string
+ operationTypeId:
+ type: integer
+ page:
+ description: 椤电爜
+ type: integer
+ pageSize:
+ description: 姣忛〉澶у皬
+ type: integer
+ sourceNumber:
type: string
type: object
request.QueryOperationList:
@@ -1295,22 +1323,15 @@
summary: 鏇存敼璁板綍鐘舵��
tags:
- 鍏ュ簱/鍑哄簱
- /api-wms/v1/operation/operation:
- get:
- consumes:
- - application/json
+ /api-wms/v1/operation/list:
+ post:
parameters:
- - in: query
- name: operationTypeId
- type: integer
- - description: 椤电爜
- in: query
- name: page
- type: integer
- - description: 姣忛〉澶у皬
- in: query
- name: pageSize
- type: integer
+ - description: 鏌ヨ鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.OperationList'
produces:
- application/json
responses:
@@ -1321,6 +1342,26 @@
summary: 鍏ュ簱/鍑哄簱鍒楄〃
tags:
- 鍏ュ簱/鍑哄簱
+ /api-wms/v1/operation/listAll:
+ post:
+ parameters:
+ - description: 鍙傛暟
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.OperationAllList'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 璋冩嫧
+ tags:
+ - 鍏ュ簱/鍑哄簱
+ /api-wms/v1/operation/operation:
post:
parameters:
- description: 鍏ュ簱/鍑哄簱淇℃伅
diff --git a/models/operation.go b/models/operation.go
index d1c7545..3142f3b 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -91,6 +91,16 @@
return slf
}
+func (slf *OperationSearch) SetNumber(number string) *OperationSearch {
+ slf.Number = number
+ return slf
+}
+
+func (slf *OperationSearch) SetSourceNumber(sourceNumber string) *OperationSearch {
+ slf.SourceNumber = sourceNumber
+ return slf
+}
+
func (slf *OperationSearch) build() *gorm.DB {
var db = slf.Orm.Model(&Operation{})
@@ -101,9 +111,17 @@
db = db.Order(slf.Order)
}
- //if slf.Keyword != "" {
- // db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword))
- //}
+ if slf.Keyword != "" {
+ db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword))
+ }
+
+ if slf.SourceNumber != "" {
+ db = db.Where("source_number like ?", fmt.Sprintf("%%%v%%", slf.SourceNumber))
+ }
+
+ if slf.Number != "" {
+ db = db.Where("number like ?", fmt.Sprintf("%%%v%%", slf.Number))
+ }
if slf.OperationTypeId != 0 {
db.Where("operation_type_id = ?", slf.OperationTypeId)
diff --git a/request/operation.go b/request/operation.go
index b3b0bc2..9e730f2 100644
--- a/request/operation.go
+++ b/request/operation.go
@@ -39,7 +39,9 @@
type OperationList struct {
PageInfo
- OperationTypeId int `json:"operationTypeId" form:"operationTypeId"`
+ OperationTypeId int `json:"operationTypeId" form:"operationTypeId"`
+ Number string `json:"number"`
+ SourceNumber string `json:"sourceNumber"`
}
type UpdateOperation struct {
@@ -65,3 +67,9 @@
//Weight decimal.Decimal `json:"weight" gorm:"type:decimal(20,2);comment:閲嶉噺(kg)"` //閲嶉噺(kg)-闈炲繀濉�
//TransferWeight decimal.Decimal `json:"transferWeight" gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺(kg)"` //鐗╂祦閲嶉噺(kg)-闈炲繀濉�
}
+
+type OperationAllList struct {
+ PageInfo
+ Number string `json:"number"`
+ SourceNumber string `json:"sourceNumber"`
+}
diff --git a/router/router.go b/router/router.go
index c8905ca..b03a86d 100644
--- a/router/router.go
+++ b/router/router.go
@@ -77,11 +77,13 @@
operationController := new(controllers.OperationController)
operationAPI := r.Group(urlPrefix + "/operation")
{
- operationAPI.GET("operation", operationController.List)
+ operationAPI.POST("list", operationController.List)
operationAPI.POST("operation", operationController.Add)
operationAPI.POST("update", operationController.Update)
operationAPI.DELETE("operation/:id", operationController.Delete)
operationAPI.PUT("finish/:id", operationController.Finish)
+ operationAPI.POST("listAll", operationController.ListAll)
+
}
//浜у搧
--
Gitblit v1.8.0