liujiandao
2023-09-18 40eb578f79a0f0dcf0bbfa2c267478d159f0f58c
产品表字段更改
2个文件已添加
8个文件已修改
1050 ■■■■■ 已修改文件
constvar/const.go 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/product_controller.go 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 310 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 310 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 223 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.mod 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.sum 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/product.go 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/product_request.go 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/const.go
@@ -46,9 +46,30 @@
type ProductType int
const (
    ProductTypeRaw      = iota + 1 // 原材料
    ProductTypeSemi                // 半成品
    ProductTypeFinished            // 成品
    Consumables   ProductType = iota + 1 // 消耗品
    Server                               // 服务
    StoredProduct                        // 可储存的产品
)
// InvoicingStrategy 开票策略
type InvoicingStrategy int
const (
    IndentNumber       InvoicingStrategy = iota + 1 //订购数量
    DeliverNumber                                   //交付数量
    PrepaidPrice                                    //预付\固定价格
    Milestones                                      //基于里程碑
    BasedDeliverNumber                              //基于交付数量
)
// OrderCreation 订单创建
type OrderCreation int
const (
    Nothing       OrderCreation = iota + 1 //不操作
    Task                                   //任务
    Object                                 //项目
    TaskAndObject                          //任务和项目
)
type ProductStatus int
controllers/product_controller.go
New file
@@ -0,0 +1,78 @@
package controllers
import (
    "github.com/gin-gonic/gin"
    "wms/extend/code"
    "wms/extend/util"
    "wms/models"
    "wms/request"
)
type ProductController struct {
}
// AddProduct
// @Tags      产品
// @Summary   添加产品
// @Produce   application/json
// @Param     object  body  models.Product true  "产品信息"
// @Success   200 {object} util.Response "成功"
// @Router    /api-wms/v1/product/addProduct [post]
func (slf ProductController) AddProduct(c *gin.Context) {
    var params models.Product
    if err := c.BindJSON(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    if params.Name == "" {
        util.ResponseFormat(c, code.RequestParamError, "产品名称不能为空")
        return
    }
    if params.SalePrice.IntPart() <= 0 {
        util.ResponseFormat(c, code.RequestParamError, "产品售价不能小于等于零")
        return
    }
    err := models.NewProductSearch().Create(&params)
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "产品信息保存失败")
        return
    }
    util.ResponseFormat(c, code.Success, "保存成功")
}
// GetProductList
// @Tags      产品
// @Summary   获取产品列表
// @Produce   application/json
// @Param     object  body  request.GetProductList true  "查询参数"
// @Success   200 {object} util.ResponseList{data=[]models.Product}    "成功"
// @Router    /api-wms/v1/product/getProductList [post]
func (slf ProductController) GetProductList(c *gin.Context) {
    var params request.GetProductList
    if err := c.BindJSON(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    search := models.NewProductSearch()
    if params.PageInfo.Check() {
        search.SetPage(params.Page, params.PageSize)
    }
    products, total, err := search.SetKeyword(params.KeyWord).SetOrder("created_at desc").Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查找失败")
        return
    }
    util.ResponseFormatList(c, code.Success, products, int(total))
}
// GetProductDetails
// @Tags      产品
// @Summary   获取产品详情
// @Produce   application/json
// @Param     object  body  request.GetProductList true  "查询参数"
// @Success   200 {object} util.ResponseList{data=[]models.Product}    "成功"
// @Router    /api-wms/v1/product/getProductList [post]
func (slf ProductController) GetProductDetails(c *gin.Context) {
}
docs/docs.go
@@ -294,6 +294,36 @@
                }
            }
        },
        "/api-wms/v1/product/addProduct": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                ],
                "summary": "添加产品",
                "parameters": [
                    {
                        "description": "产品信息",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.Product"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/warehouse/operationType": {
            "get": {
                "produces": [
@@ -602,6 +632,99 @@
                "BaseOperationTypeInternal"
            ]
        },
        "constvar.InvoicingStrategy": {
            "type": "integer",
            "enum": [
                1,
                2,
                3,
                4,
                5
            ],
            "x-enum-comments": {
                "BasedDeliverNumber": "基于交付数量",
                "DeliverNumber": "交付数量",
                "IndentNumber": "订购数量",
                "Milestones": "基于里程碑",
                "PrepaidPrice": "预付\\固定价格"
            },
            "x-enum-varnames": [
                "IndentNumber",
                "DeliverNumber",
                "PrepaidPrice",
                "Milestones",
                "BasedDeliverNumber"
            ]
        },
        "constvar.LocationType": {
            "type": "integer",
            "enum": [
                1,
                2,
                3,
                4,
                5,
                6,
                7
            ],
            "x-enum-comments": {
                "LocationTypeCustomer": "客户位置",
                "LocationTypeInternal": "内部位置",
                "LocationTypeInventoryLoss": "库存损失",
                "LocationTypeProduction": "生产",
                "LocationTypeTransit": "中转位置",
                "LocationTypeVendor": "供应商位置",
                "LocationTypeView": "视图"
            },
            "x-enum-varnames": [
                "LocationTypeVendor",
                "LocationTypeView",
                "LocationTypeInternal",
                "LocationTypeCustomer",
                "LocationTypeInventoryLoss",
                "LocationTypeProduction",
                "LocationTypeTransit"
            ]
        },
        "constvar.OrderCreation": {
            "type": "integer",
            "enum": [
                1,
                2,
                3,
                4
            ],
            "x-enum-comments": {
                "Nothing": "不操作",
                "Object": "项目",
                "Task": "任务",
                "TaskAndObject": "任务和项目"
            },
            "x-enum-varnames": [
                "Nothing",
                "Task",
                "Object",
                "TaskAndObject"
            ]
        },
        "constvar.ProductType": {
            "type": "integer",
            "enum": [
                1,
                2,
                3
            ],
            "x-enum-comments": {
                "Consumables": "消耗品",
                "Server": "服务",
                "StoredProduct": "可储存的产品"
            },
            "x-enum-varnames": [
                "Consumables",
                "Server",
                "StoredProduct"
            ]
        },
        "constvar.ReservationMethod": {
            "type": "integer",
            "enum": [
@@ -697,15 +820,55 @@
        "models.Location": {
            "type": "object",
            "properties": {
                "company": {
                    "description": "公司",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.Company"
                        }
                    ]
                },
                "companyId": {
                    "description": "公司id",
                    "type": "integer"
                },
                "countFrequency": {
                    "description": "盘点频率(天)",
                    "type": "integer"
                },
                "createTime": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "isReturnLocation": {
                    "description": "是否退货位置",
                    "type": "boolean"
                },
                "isScrapLocation": {
                    "description": "是否报废位置",
                    "type": "boolean"
                },
                "name": {
                    "description": "位置名称",
                    "type": "string"
                },
                "parentId": {
                    "description": "上级id",
                    "type": "integer"
                },
                "replenishLocation": {
                    "description": "是否补充位置",
                    "type": "boolean"
                },
                "type": {
                    "description": "位置类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.LocationType"
                        }
                    ]
                },
                "updateTime": {
                    "type": "string"
@@ -826,6 +989,153 @@
                }
            }
        },
        "models.Product": {
            "type": "object",
            "properties": {
                "HSCode": {
                    "type": "string"
                },
                "barcode": {
                    "description": "条码",
                    "type": "string"
                },
                "buyExplain": {
                    "type": "string"
                },
                "canBePurchased": {
                    "description": "是否可采购",
                    "type": "boolean"
                },
                "canBeSell": {
                    "description": "是否销售",
                    "type": "boolean"
                },
                "categoryId": {
                    "description": "产品分类id",
                    "type": "integer"
                },
                "companyId": {
                    "type": "integer"
                },
                "companyName": {
                    "type": "string"
                },
                "controlStrategy": {
                    "$ref": "#/definitions/constvar.InvoicingStrategy"
                },
                "cost": {
                    "description": "成本",
                    "type": "number"
                },
                "createTime": {
                    "type": "string"
                },
                "currencyId": {
                    "type": "integer"
                },
                "currencyName": {
                    "type": "string"
                },
                "customerAdvanceTime": {
                    "type": "number"
                },
                "customerTaxes": {
                    "description": "客户税百分比",
                    "type": "number"
                },
                "deliveryAdvanceTime": {
                    "type": "number"
                },
                "id": {
                    "type": "integer"
                },
                "inStorageExplain": {
                    "type": "string"
                },
                "internalNotes": {
                    "description": "内部说明",
                    "type": "string"
                },
                "internalReference": {
                    "description": "内部参考",
                    "type": "string"
                },
                "internalTransferExplain": {
                    "type": "string"
                },
                "invoicingStrategy": {
                    "$ref": "#/definitions/constvar.InvoicingStrategy"
                },
                "name": {
                    "description": "产品名称",
                    "type": "string"
                },
                "objectTemplateId": {
                    "type": "string"
                },
                "orderCreation": {
                    "$ref": "#/definitions/constvar.OrderCreation"
                },
                "originCountryId": {
                    "type": "integer"
                },
                "originCountryName": {
                    "type": "string"
                },
                "outStorageExplain": {
                    "type": "string"
                },
                "price": {
                    "type": "number"
                },
                "principal": {
                    "description": "负责人",
                    "type": "string"
                },
                "productTagId": {
                    "description": "产品标签",
                    "type": "integer"
                },
                "productTagName": {
                    "type": "string"
                },
                "salePrice": {
                    "description": "销售价格",
                    "type": "number"
                },
                "selectProduct": {
                    "type": "integer"
                },
                "sellExplain": {
                    "type": "string"
                },
                "supplierId": {
                    "type": "integer"
                },
                "supplierName": {
                    "type": "string"
                },
                "type": {
                    "description": "产品类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.ProductType"
                        }
                    ]
                },
                "updateTime": {
                    "type": "string"
                },
                "volume": {
                    "description": "体积",
                    "type": "number"
                },
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
        "models.Warehouse": {
            "type": "object",
            "required": [
docs/swagger.json
@@ -282,6 +282,36 @@
                }
            }
        },
        "/api-wms/v1/product/addProduct": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                ],
                "summary": "添加产品",
                "parameters": [
                    {
                        "description": "产品信息",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.Product"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/warehouse/operationType": {
            "get": {
                "produces": [
@@ -590,6 +620,99 @@
                "BaseOperationTypeInternal"
            ]
        },
        "constvar.InvoicingStrategy": {
            "type": "integer",
            "enum": [
                1,
                2,
                3,
                4,
                5
            ],
            "x-enum-comments": {
                "BasedDeliverNumber": "基于交付数量",
                "DeliverNumber": "交付数量",
                "IndentNumber": "订购数量",
                "Milestones": "基于里程碑",
                "PrepaidPrice": "预付\\固定价格"
            },
            "x-enum-varnames": [
                "IndentNumber",
                "DeliverNumber",
                "PrepaidPrice",
                "Milestones",
                "BasedDeliverNumber"
            ]
        },
        "constvar.LocationType": {
            "type": "integer",
            "enum": [
                1,
                2,
                3,
                4,
                5,
                6,
                7
            ],
            "x-enum-comments": {
                "LocationTypeCustomer": "客户位置",
                "LocationTypeInternal": "内部位置",
                "LocationTypeInventoryLoss": "库存损失",
                "LocationTypeProduction": "生产",
                "LocationTypeTransit": "中转位置",
                "LocationTypeVendor": "供应商位置",
                "LocationTypeView": "视图"
            },
            "x-enum-varnames": [
                "LocationTypeVendor",
                "LocationTypeView",
                "LocationTypeInternal",
                "LocationTypeCustomer",
                "LocationTypeInventoryLoss",
                "LocationTypeProduction",
                "LocationTypeTransit"
            ]
        },
        "constvar.OrderCreation": {
            "type": "integer",
            "enum": [
                1,
                2,
                3,
                4
            ],
            "x-enum-comments": {
                "Nothing": "不操作",
                "Object": "项目",
                "Task": "任务",
                "TaskAndObject": "任务和项目"
            },
            "x-enum-varnames": [
                "Nothing",
                "Task",
                "Object",
                "TaskAndObject"
            ]
        },
        "constvar.ProductType": {
            "type": "integer",
            "enum": [
                1,
                2,
                3
            ],
            "x-enum-comments": {
                "Consumables": "消耗品",
                "Server": "服务",
                "StoredProduct": "可储存的产品"
            },
            "x-enum-varnames": [
                "Consumables",
                "Server",
                "StoredProduct"
            ]
        },
        "constvar.ReservationMethod": {
            "type": "integer",
            "enum": [
@@ -685,15 +808,55 @@
        "models.Location": {
            "type": "object",
            "properties": {
                "company": {
                    "description": "公司",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.Company"
                        }
                    ]
                },
                "companyId": {
                    "description": "公司id",
                    "type": "integer"
                },
                "countFrequency": {
                    "description": "盘点频率(天)",
                    "type": "integer"
                },
                "createTime": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "isReturnLocation": {
                    "description": "是否退货位置",
                    "type": "boolean"
                },
                "isScrapLocation": {
                    "description": "是否报废位置",
                    "type": "boolean"
                },
                "name": {
                    "description": "位置名称",
                    "type": "string"
                },
                "parentId": {
                    "description": "上级id",
                    "type": "integer"
                },
                "replenishLocation": {
                    "description": "是否补充位置",
                    "type": "boolean"
                },
                "type": {
                    "description": "位置类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.LocationType"
                        }
                    ]
                },
                "updateTime": {
                    "type": "string"
@@ -814,6 +977,153 @@
                }
            }
        },
        "models.Product": {
            "type": "object",
            "properties": {
                "HSCode": {
                    "type": "string"
                },
                "barcode": {
                    "description": "条码",
                    "type": "string"
                },
                "buyExplain": {
                    "type": "string"
                },
                "canBePurchased": {
                    "description": "是否可采购",
                    "type": "boolean"
                },
                "canBeSell": {
                    "description": "是否销售",
                    "type": "boolean"
                },
                "categoryId": {
                    "description": "产品分类id",
                    "type": "integer"
                },
                "companyId": {
                    "type": "integer"
                },
                "companyName": {
                    "type": "string"
                },
                "controlStrategy": {
                    "$ref": "#/definitions/constvar.InvoicingStrategy"
                },
                "cost": {
                    "description": "成本",
                    "type": "number"
                },
                "createTime": {
                    "type": "string"
                },
                "currencyId": {
                    "type": "integer"
                },
                "currencyName": {
                    "type": "string"
                },
                "customerAdvanceTime": {
                    "type": "number"
                },
                "customerTaxes": {
                    "description": "客户税百分比",
                    "type": "number"
                },
                "deliveryAdvanceTime": {
                    "type": "number"
                },
                "id": {
                    "type": "integer"
                },
                "inStorageExplain": {
                    "type": "string"
                },
                "internalNotes": {
                    "description": "内部说明",
                    "type": "string"
                },
                "internalReference": {
                    "description": "内部参考",
                    "type": "string"
                },
                "internalTransferExplain": {
                    "type": "string"
                },
                "invoicingStrategy": {
                    "$ref": "#/definitions/constvar.InvoicingStrategy"
                },
                "name": {
                    "description": "产品名称",
                    "type": "string"
                },
                "objectTemplateId": {
                    "type": "string"
                },
                "orderCreation": {
                    "$ref": "#/definitions/constvar.OrderCreation"
                },
                "originCountryId": {
                    "type": "integer"
                },
                "originCountryName": {
                    "type": "string"
                },
                "outStorageExplain": {
                    "type": "string"
                },
                "price": {
                    "type": "number"
                },
                "principal": {
                    "description": "负责人",
                    "type": "string"
                },
                "productTagId": {
                    "description": "产品标签",
                    "type": "integer"
                },
                "productTagName": {
                    "type": "string"
                },
                "salePrice": {
                    "description": "销售价格",
                    "type": "number"
                },
                "selectProduct": {
                    "type": "integer"
                },
                "sellExplain": {
                    "type": "string"
                },
                "supplierId": {
                    "type": "integer"
                },
                "supplierName": {
                    "type": "string"
                },
                "type": {
                    "description": "产品类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.ProductType"
                        }
                    ]
                },
                "updateTime": {
                    "type": "string"
                },
                "volume": {
                    "description": "体积",
                    "type": "number"
                },
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
        "models.Warehouse": {
            "type": "object",
            "required": [
docs/swagger.yaml
@@ -13,6 +13,83 @@
    - BaseOperationTypeIncoming
    - BaseOperationTypeOutgoing
    - BaseOperationTypeInternal
  constvar.InvoicingStrategy:
    enum:
    - 1
    - 2
    - 3
    - 4
    - 5
    type: integer
    x-enum-comments:
      BasedDeliverNumber: 基于交付数量
      DeliverNumber: 交付数量
      IndentNumber: 订购数量
      Milestones: 基于里程碑
      PrepaidPrice: 预付\固定价格
    x-enum-varnames:
    - IndentNumber
    - DeliverNumber
    - PrepaidPrice
    - Milestones
    - BasedDeliverNumber
  constvar.LocationType:
    enum:
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    type: integer
    x-enum-comments:
      LocationTypeCustomer: 客户位置
      LocationTypeInternal: 内部位置
      LocationTypeInventoryLoss: 库存损失
      LocationTypeProduction: 生产
      LocationTypeTransit: 中转位置
      LocationTypeVendor: 供应商位置
      LocationTypeView: 视图
    x-enum-varnames:
    - LocationTypeVendor
    - LocationTypeView
    - LocationTypeInternal
    - LocationTypeCustomer
    - LocationTypeInventoryLoss
    - LocationTypeProduction
    - LocationTypeTransit
  constvar.OrderCreation:
    enum:
    - 1
    - 2
    - 3
    - 4
    type: integer
    x-enum-comments:
      Nothing: 不操作
      Object: 项目
      Task: 任务
      TaskAndObject: 任务和项目
    x-enum-varnames:
    - Nothing
    - Task
    - Object
    - TaskAndObject
  constvar.ProductType:
    enum:
    - 1
    - 2
    - 3
    type: integer
    x-enum-comments:
      Consumables: 消耗品
      Server: 服务
      StoredProduct: 可储存的产品
    x-enum-varnames:
    - Consumables
    - Server
    - StoredProduct
  constvar.ReservationMethod:
    enum:
    - 1
@@ -82,13 +159,39 @@
    type: object
  models.Location:
    properties:
      company:
        allOf:
        - $ref: '#/definitions/models.Company'
        description: 公司
      companyId:
        description: 公司id
        type: integer
      countFrequency:
        description: 盘点频率(天)
        type: integer
      createTime:
        type: string
      id:
        type: integer
      isReturnLocation:
        description: 是否退货位置
        type: boolean
      isScrapLocation:
        description: 是否报废位置
        type: boolean
      name:
        description: 位置名称
        type: string
      parentId:
        description: 上级id
        type: integer
      replenishLocation:
        description: 是否补充位置
        type: boolean
      type:
        allOf:
        - $ref: '#/definitions/constvar.LocationType'
        description: 位置类型
      updateTime:
        type: string
    type: object
@@ -161,6 +264,107 @@
      warehouseId:
        description: 仓库id
        type: integer
    type: object
  models.Product:
    properties:
      HSCode:
        type: string
      barcode:
        description: 条码
        type: string
      buyExplain:
        type: string
      canBePurchased:
        description: 是否可采购
        type: boolean
      canBeSell:
        description: 是否销售
        type: boolean
      categoryId:
        description: 产品分类id
        type: integer
      companyId:
        type: integer
      companyName:
        type: string
      controlStrategy:
        $ref: '#/definitions/constvar.InvoicingStrategy'
      cost:
        description: 成本
        type: number
      createTime:
        type: string
      currencyId:
        type: integer
      currencyName:
        type: string
      customerAdvanceTime:
        type: number
      customerTaxes:
        description: 客户税百分比
        type: number
      deliveryAdvanceTime:
        type: number
      id:
        type: integer
      inStorageExplain:
        type: string
      internalNotes:
        description: 内部说明
        type: string
      internalReference:
        description: 内部参考
        type: string
      internalTransferExplain:
        type: string
      invoicingStrategy:
        $ref: '#/definitions/constvar.InvoicingStrategy'
      name:
        description: 产品名称
        type: string
      objectTemplateId:
        type: string
      orderCreation:
        $ref: '#/definitions/constvar.OrderCreation'
      originCountryId:
        type: integer
      originCountryName:
        type: string
      outStorageExplain:
        type: string
      price:
        type: number
      principal:
        description: 负责人
        type: string
      productTagId:
        description: 产品标签
        type: integer
      productTagName:
        type: string
      salePrice:
        description: 销售价格
        type: number
      selectProduct:
        type: integer
      sellExplain:
        type: string
      supplierId:
        type: integer
      supplierName:
        type: string
      type:
        allOf:
        - $ref: '#/definitions/constvar.ProductType'
        description: 产品类型
      updateTime:
        type: string
      volume:
        description: 体积
        type: number
      weight:
        description: 重量
        type: number
    type: object
  models.Warehouse:
    properties:
@@ -598,6 +802,25 @@
      summary: 编辑公司
      tags:
      - 公司
  /api-wms/v1/product/addProduct:
    post:
      parameters:
      - description: 产品信息
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/models.Product'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 添加产品
      tags:
      - 产品
  /api-wms/v1/warehouse/operationType:
    get:
      parameters:
go.mod
@@ -7,13 +7,15 @@
    github.com/dgrijalva/jwt-go v3.2.0+incompatible
    github.com/gin-gonic/gin v1.9.0
    github.com/nsqio/go-nsq v1.1.0
    github.com/shopspring/decimal v1.3.1
    github.com/spf13/cast v1.5.0
    github.com/spf13/viper v1.15.0
    github.com/swaggo/files v1.0.1
    github.com/swaggo/gin-swagger v1.6.0
    github.com/swaggo/swag v1.16.1
    go.uber.org/zap v1.24.0
    golang.org/x/crypto v0.11.0
    google.golang.org/grpc v1.54.0
    google.golang.org/genproto v0.0.0-20230323212658-478b75c54725
    gopkg.in/natefinch/lumberjack.v2 v2.2.1
    gorm.io/driver/mysql v1.5.0
    gorm.io/gorm v1.25.0
@@ -36,7 +38,6 @@
    github.com/go-playground/validator/v10 v10.14.1 // indirect
    github.com/go-sql-driver/mysql v1.7.0 // indirect
    github.com/goccy/go-json v0.10.2 // indirect
    github.com/golang/protobuf v1.5.3 // indirect
    github.com/golang/snappy v0.0.1 // indirect
    github.com/hashicorp/hcl v1.0.0 // indirect
    github.com/jinzhu/inflection v1.0.0 // indirect
@@ -53,7 +54,6 @@
    github.com/modern-go/reflect2 v1.0.2 // indirect
    github.com/pelletier/go-toml/v2 v2.0.9 // indirect
    github.com/spf13/afero v1.9.3 // indirect
    github.com/spf13/cast v1.5.0 // indirect
    github.com/spf13/jwalterweatherman v1.1.0 // indirect
    github.com/spf13/pflag v1.0.5 // indirect
    github.com/subosito/gotenv v1.4.2 // indirect
@@ -66,7 +66,6 @@
    golang.org/x/sys v0.10.0 // indirect
    golang.org/x/text v0.11.0 // indirect
    golang.org/x/tools v0.11.0 // indirect
    google.golang.org/genproto v0.0.0-20230323212658-478b75c54725 // indirect
    google.golang.org/protobuf v1.31.0 // indirect
    gopkg.in/ini.v1 v1.67.0 // indirect
    gopkg.in/yaml.v3 v3.0.1 // indirect
go.sum
@@ -135,8 +135,6 @@
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@@ -232,6 +230,8 @@
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk=
github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
@@ -593,8 +593,6 @@
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag=
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -606,7 +604,6 @@
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
models/product.go
@@ -2,7 +2,7 @@
import (
    "fmt"
    "google.golang.org/genproto/googleapis/type/decimal"
    "github.com/shopspring/decimal"
    "gorm.io/gorm"
    "wms/constvar"
    "wms/pkg/mysqlx"
@@ -12,39 +12,45 @@
    // Product 产品
    Product struct {
        WmsModel
        Id         int                  `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        Name       string               `json:"name" gorm:"index;type:varchar(255);not null;comment:产品名称"` //产品名称
        Type       constvar.ProductType `gorm:"type:tinyint;comment:产品类型" json:"type"`                     //产品类型
        CategoryId int                  `gorm:"type:int(11);comment:产品分类" json:"categoryId"`               //产品分类id
        Category   string               `gorm:"type:int(11);comment:产品分类" json:"category"`                 //产品分类
        Specs      string               `gorm:"type:varchar(191);comment:产品规格" json:"specs"`               //产品规格
        Model      string               `gorm:"type:varchar(191);comment:产品型号" json:"model"`               //产品型号
        //MinInventory      decimal.Decimal         `gorm:"type:decimal(20,2);comment:最小库存" json:"minInventory"` //最大库存
        //MaxInventory      decimal.Decimal         `gorm:"type:decimal(20,2);comment:最大库存" json:"maxInventory"` //最小库存
        //Amount            decimal.Decimal         `gorm:"type:decimal(20,2);comment:数量" json:"amount"`
        //LockAmount        decimal.Decimal         `gorm:"type:decimal(20,2);default:0;comment:锁定数量" json:"lockAmount"`
        Unit         string                 `gorm:"type:varchar(100);comment:单位" json:"unit"`           //单位
        PurchaseUnit string                 `gorm:"type:varchar(100);comment:采购单位" json:"purchaseUnit"` //采购单位
        Note         string                 `gorm:"type:varchar(1024);comment:备注" json:"note"`
        Status       constvar.ProductStatus `gorm:"type:int(11);comment:状态" json:"status"`
        Purchases    []*PurchaseInfo        `gorm:"-" json:"purchases"` //采购信息
        PurchasesStr string                 `gorm:"column:purchase;type:varchar(4096);comment:购买信息" json:"-"`
        //PurchaseType     constvar.PurchaseType `gorm:"type:int(11);comment:采购类型" json:"purchaseType"`            ///采购类型
        CanBePurchased   bool            `gorm:"type:int(11);not null;comment:是否可采购" json:"purchaseType"`           //是否可采购
        IsSale           bool            `gorm:"type:tinyint(1);comment:是否销售" json:"isSale"`                        //是否销售
        SalePrice        decimal.Decimal `gorm:"type:decimal(35,18);comment:销售单价" json:"salePrice"`                 //销售价格
        CustomerTaxes    decimal.Decimal `gorm:"type:decimal(20,2);not null;comment:客户税" json:"customerTaxes"`      //客户税百分比
        Cost             decimal.Decimal `gorm:"type:decimal(20,2);not null;comment:成本" json:"cost"`                //成本
        OptionalProducts []int           `gorm:"type:varchar(255);not null;comment:相似产品id" json:"optionalProducts"` //相识产品
        Principal        string          `gorm:"type:varchar(255);not null;comment:负责人" json:"principal"`           //负责人
        Weight           string          `gorm:"type:decimal(20,2);not null;comment:重量" json:"weight"`              //重量
        Volume           string          `gorm:"type:decimal(20,2);not null;comment:体积" json:"volume"`              //体积
        InternalReference string `gorm:"type:varchar(255);not null;comment:内部参考" json:"internalReference"` //内部参考
        Barcode           string `gorm:"type:varchar(255);not null;comment:条码" json:"barcode"`             //条码
        Tags              string `gorm:"type:varchar(255);not null;comment:产品标签" json:"tags"`              //产品标签
        InternalNotes     string `gorm:"type:varchar(512);not null;comment:内部说明" json:"internalNotes"`     //内部说明
        Id                      int                        `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
        Name                    string                     `gorm:"index;type:varchar(255);not null;comment:产品名称" json:"name"` //产品名称
        Type                    constvar.ProductType       `gorm:"type:int(11);comment:产品类型" json:"type"`                     //产品类型
        InvoicingStrategy       constvar.InvoicingStrategy `gorm:"type:int(11);comment:开票策略" json:"invoicingStrategy"`
        OrderCreation           constvar.OrderCreation     `gorm:"type:int(11);comment:订单创建" json:"orderCreation"`
        ObjectTemplateId        string                     `gorm:"type:varchar(191);comment:项目模版id" json:"objectTemplateId"`
        SalePrice               decimal.Decimal            `gorm:"type:decimal(35,18);comment:销售单价" json:"salePrice"`       //销售价格
        CustomerTaxes           decimal.Decimal            `gorm:"type:decimal(20,2);comment:客户税" json:"customerTaxes"`     //客户税百分比
        Cost                    decimal.Decimal            `gorm:"type:decimal(20,2);comment:成本" json:"cost"`               //成本
        CategoryId              int                        `gorm:"type:int(11);comment:产品类型id" json:"categoryId"`           //产品分类id
        InternalReference       string                     `gorm:"type:varchar(255);comment:内部参考" json:"internalReference"` //内部参考
        Barcode                 string                     `gorm:"type:varchar(255);comment:条码" json:"barcode"`             //条码
        ProductTagId            int                        `gorm:"type:int(11);comment:产品标签id" json:"productTagId"`         //产品标签
        ProductTagName          string                     `gorm:"type:varchar(255);comment:产品标签名称" json:"productTagName"`
        CompanyId               int                        `gorm:"type:int(11);comment:公司id" json:"companyId"`
        CompanyName             string                     `gorm:"type:varchar(255);comment:公司名称" json:"companyName"`
        InternalNotes           string                     `gorm:"type:varchar(512);comment:内部说明" json:"internalNotes"` //内部说明
        CanBeSell               bool                       `gorm:"type:tinyint(1);comment:是否可销售" json:"canBeSell"`      //是否销售
        SelectProduct           int                        `gorm:"type:int(11);comment:可选产品id" json:"selectProduct"`
        SellExplain             string                     `gorm:"type:varchar(512);comment:销售说明" json:"sellExplain"`
        CanBePurchased          bool                       `gorm:"type:int(11);comment:是否可采购" json:"canBePurchased"` //是否可采购
        SupplierId              int                        `gorm:"type:int(11);comment:供应商id" json:"supplierId"`
        SupplierName            string                     `gorm:"type:varchar(255);comment:供应商名称" json:"supplierName"`
        Price                   decimal.Decimal            `gorm:"type:decimal(20,2);comment:价格" json:"price"`
        CurrencyId              int                        `gorm:"type:int(11);comment:币种id" json:"currencyId"`
        CurrencyName            string                     `gorm:"type:varchar(255);comment:币种名称" json:"currencyName"`
        DeliveryAdvanceTime     decimal.Decimal            `gorm:"type:decimal(20,5);comment:提前交货时间" json:"deliveryAdvanceTime"`
        ControlStrategy         constvar.InvoicingStrategy `gorm:"type:int(11);comment:控制策略" json:"controlStrategy"`
        BuyExplain              string                     `gorm:"type:varchar(512);comment:采购说明" json:"buyExplain"`
        Principal               string                     `gorm:"type:varchar(255);comment:负责人" json:"principal"` //负责人
        Weight                  decimal.Decimal            `gorm:"type:decimal(20,2);comment:重量" json:"weight"`    //重量
        Volume                  decimal.Decimal            `gorm:"type:decimal(20,2);comment:体积" json:"volume"`    //体积
        CustomerAdvanceTime     decimal.Decimal            `gorm:"type:decimal(20,5);comment:客户前置时间" json:"customerAdvanceTime"`
        HSCode                  string                     `gorm:"type:varchar(255);comment:HS编码" json:"HSCode"`
        OriginCountryId         int                        `gorm:"type:int(11);comment:原产地id" json:"originCountryId"`
        OriginCountryName       string                     `gorm:"type:varchar(255);comment:原产地名称" json:"originCountryName"`
        InStorageExplain        string                     `gorm:"type:varchar(512);comment:入库说明" json:"inStorageExplain"`
        OutStorageExplain       string                     `gorm:"type:varchar(512);comment:出库说明" json:"outStorageExplain"`
        InternalTransferExplain string                     `gorm:"type:varchar(512);comment:内部调拨说明" json:"internalTransferExplain"`
    }
    ProductSearch struct {
request/product_request.go
New file
@@ -0,0 +1,6 @@
package request
type GetProductList struct {
    PageInfo
    KeyWord string `json:"keyWord"`
}
router/router.go
@@ -61,5 +61,13 @@
        operationTypeAPI.DELETE("operationType/:id", operationTypeController.Delete) // 删除作业类型
    }
    //产品
    productController := new(controllers.ProductController)
    productAPI := r.Group(urlPrefix + "/product")
    {
        productAPI.POST("addProduct", productController.AddProduct)         // 新增产品
        productAPI.POST("getProductList", productController.GetProductList) // 获取产品列表
    }
    return r
}