jiangshuai
2023-10-23 40202aef72d93a6fb3acabf719d121ea88534dd7
1.获取调拨类型列表
7个文件已修改
91 ■■■■■ 已修改文件
controllers/operation_type.go 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation_type.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/operation_type.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/operation_type.go
@@ -166,3 +166,45 @@
    }
    util.ResponseFormat(c, code.UpdateSuccess, "删除成功")
}
// ListTransfer
// @Tags      业务类型
// @Summary   调拨类型列表
// @Produce   application/json
// @Param     object  query    request.ListTransfer true  "查询参数"
// @Success   200   {object}  util.ResponseList  "成功"
// @Router    /api-wms/v1/operationType/operationType [get]
func (slf OperationTypeController) ListTransfer(c *gin.Context) {
    var params request.GetOperationTypeList
    if err := c.ShouldBindQuery(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, err.Error())
        return
    }
    list, total, err := models.NewOperationTypeSearch().SetPage(params.Page, params.PageSize).SetBaseOperationType(constvar.BaseOperationTypeInternal).SetKeyword(params.Keyword).SetOrder("id desc").SetPreload(true).Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestError, "查找失败")
        return
    }
    var idList []int
    for _, v := range list {
        idList = append(idList, v.Id)
    }
    statistics, err := models.NewOperationTypeSearch().ListByStatusAndCount(idList)
    if err != nil {
        util.ResponseFormat(c, code.RequestError, err.Error())
        return
    }
    mapStatistics := make(map[string]*models.OperationTypeByStatus, 0)
    for _, v := range statistics {
        mapStatistics[strconv.Itoa(v.Id)+string(v.Status)] = v
    }
    for k, v := range list {
        if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Ready)]; ok {
            list[k].ReadyCount = value.Count
        }
        if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Finish)]; ok {
            list[k].FinishCount = value.Count
        }
    }
    util.ResponseFormatListWithPage(c, code.Success, list, cast.ToInt(total), params.Page, params.PageSize)
}
docs/docs.go
@@ -1069,23 +1069,11 @@
                "tags": [
                    "业务类型"
                ],
                "summary": "查询作业类型列表",
                "summary": "调拨类型列表",
                "parameters": [
                    {
                        "type": "string",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    }
                ],
@@ -3724,8 +3712,6 @@
    Description:      "",
    InfoInstanceName: "swagger",
    SwaggerTemplate:  docTemplate,
    LeftDelim:        "{{",
    RightDelim:       "}}",
}
func init() {
docs/swagger.json
@@ -1057,23 +1057,11 @@
                "tags": [
                    "业务类型"
                ],
                "summary": "查询作业类型列表",
                "summary": "调拨类型列表",
                "parameters": [
                    {
                        "type": "string",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
                        "name": "page",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "每页大小",
                        "name": "pageSize",
                        "in": "query"
                    }
                ],
docs/swagger.yaml
@@ -1927,14 +1927,6 @@
      - in: query
        name: keyword
        type: string
      - description: 页码
        in: query
        name: page
        type: integer
      - description: 每页大小
        in: query
        name: pageSize
        type: integer
      produces:
      - application/json
      responses:
@@ -1942,7 +1934,7 @@
          description: 成功
          schema:
            $ref: '#/definitions/util.ResponseList'
      summary: 查询作业类型列表
      summary: 调拨类型列表
      tags:
      - 业务类型
    post:
models/operation_type.go
@@ -135,6 +135,10 @@
        db = db.Where("warehouse_id = ?", slf.WarehouseId)
    }
    if int(slf.BaseOperationType) != 0 {
        db = db.Where("base_operation_type = ?", slf.BaseOperationType)
    }
    return db
}
request/operation_type.go
@@ -31,3 +31,7 @@
    ID uint `gorm:"comment:主键ID;primaryKey;" json:"id"`
    AddOperationType
}
type ListTransfer struct {
    Keyword string `json:"keyword"`
}
router/router.go
@@ -68,6 +68,7 @@
    operationTypeAPI := r.Group(urlPrefix + "/operationType")
    {
        operationTypeAPI.GET("operationType", operationTypeController.List)          // 获取作业类型列表
        operationTypeAPI.GET("listTransfer", operationTypeController.ListTransfer)   // 获取作业类型列表
        operationTypeAPI.POST("operationType", operationTypeController.Add)          // 新增作业类型
        operationTypeAPI.PUT("operationType/:id", operationTypeController.Update)    // 修改作业类型
        operationTypeAPI.DELETE("operationType/:id", operationTypeController.Delete) // 删除作业类型