From 40eb578f79a0f0dcf0bbfa2c267478d159f0f58c Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期一, 18 九月 2023 20:03:16 +0800 Subject: [PATCH] 产品表字段更改 --- constvar/const.go | 27 + controllers/product_controller.go | 78 ++++ go.sum | 7 go.mod | 7 models/product.go | 74 ++- request/product_request.go | 6 docs/swagger.yaml | 223 ++++++++++++ docs/docs.go | 310 +++++++++++++++++ docs/swagger.json | 310 +++++++++++++++++ router/router.go | 8 10 files changed, 1,004 insertions(+), 46 deletions(-) diff --git a/constvar/const.go b/constvar/const.go index dff496d..9a5246d 100644 --- a/constvar/const.go +++ b/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 diff --git a/controllers/product_controller.go b/controllers/product_controller.go new file mode 100644 index 0000000..7c78abc --- /dev/null +++ b/controllers/product_controller.go @@ -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(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") + 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(¶ms) + 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(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") + 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) { + +} diff --git a/docs/docs.go b/docs/docs.go index 2922b77..7a99fb9 100644 --- a/docs/docs.go +++ b/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": [ diff --git a/docs/swagger.json b/docs/swagger.json index 6700840..bfd55df 100644 --- a/docs/swagger.json +++ b/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": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index eb93df2..32ad891 100644 --- a/docs/swagger.yaml +++ b/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: diff --git a/go.mod b/go.mod index 2518648..84ea6f9 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index ffc0ea1..4aa9e74 100644 --- a/go.sum +++ b/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= diff --git a/models/product.go b/models/product.go index c97e2f1..b44ddbb 100644 --- a/models/product.go +++ b/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:鍙�変骇鍝乮d" 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:渚涘簲鍟唅d" 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:鍘熶骇鍦癷d" 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 { diff --git a/request/product_request.go b/request/product_request.go new file mode 100644 index 0000000..8af1cd0 --- /dev/null +++ b/request/product_request.go @@ -0,0 +1,6 @@ +package request + +type GetProductList struct { + PageInfo + KeyWord string `json:"keyWord"` +} diff --git a/router/router.go b/router/router.go index ac1f0c5..05a0153 100644 --- a/router/router.go +++ b/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 } -- Gitblit v1.8.0