jiangshuai
2023-09-22 f89bbcf77dae0465e829ca6f7548cd36ef57aaa6
1.调拨接口
7个文件已修改
370 ■■■■ 已修改文件
controllers/operation.go 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 104 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 104 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 71 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation.go 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/operation.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
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(&params); err != nil {
    if err := c.BindJSON(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+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(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+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)
}
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": {
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": {
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: 入库/出库信息
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)
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"`
}
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)
    }
    //产品