From edf6810f2ff9ac32230f58f62a753454b8e24269 Mon Sep 17 00:00:00 2001 From: zhansan <1061428287@qq.com> Date: 星期一, 18 九月 2023 20:05:38 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS --- constvar/const.go | 27 + controllers/product_controller.go | 78 ++++ models/product.go | 74 ++-- request/product_request.go | 6 docs/swagger.yaml | 208 ++++++++++++ docs/docs.go | 303 +++++++++++++++++ docs/swagger.json | 301 +++++++++++++++++ router/router.go | 8 8 files changed, 968 insertions(+), 37 deletions(-) diff --git a/constvar/const.go b/constvar/const.go index 8e45297..640baa6 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 0f27c63..ef21891 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -324,6 +324,81 @@ } } }, + "/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/product/getProductList": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "鑾峰彇浜у搧璇︽儏", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetProductList" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Product" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/warehouse/operationType": { "get": { "produces": [ @@ -632,6 +707,30 @@ "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": [ @@ -681,6 +780,45 @@ "OperationStatus_Waiting", "OperationStatus_Ready", "OperationStatus_Finish" + ] + }, + "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": { @@ -947,6 +1085,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": [ @@ -1190,6 +1475,22 @@ } } }, + "request.GetProductList": { + "type": "object", + "properties": { + "keyWord": { + "type": "string" + }, + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + } + } + }, "request.OperationDetails": { "type": "object", "properties": { @@ -1413,6 +1714,8 @@ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index 8d67b82..a8d4229 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -312,6 +312,81 @@ } } }, + "/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/product/getProductList": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "鑾峰彇浜у搧璇︽儏", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetProductList" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Product" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/warehouse/operationType": { "get": { "produces": [ @@ -620,6 +695,30 @@ "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": [ @@ -669,6 +768,45 @@ "OperationStatus_Waiting", "OperationStatus_Ready", "OperationStatus_Finish" + ] + }, + "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": { @@ -935,6 +1073,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": [ @@ -1178,6 +1463,22 @@ } } }, + "request.GetProductList": { + "type": "object", + "properties": { + "keyWord": { + "type": "string" + }, + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + } + } + }, "request.OperationDetails": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 7f4c9c9..1131974 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -13,6 +13,26 @@ - 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 @@ -56,6 +76,37 @@ - OperationStatus_Waiting - OperationStatus_Ready - OperationStatus_Finish + 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 @@ -231,6 +282,107 @@ 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: active: @@ -397,6 +549,17 @@ type: array required: - code + type: object + request.GetProductList: + properties: + keyWord: + type: string + page: + description: 椤电爜 + type: integer + pageSize: + description: 姣忛〉澶у皬 + type: integer type: object request.OperationDetails: properties: @@ -736,6 +899,51 @@ 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/product/getProductList: + post: + parameters: + - description: 鏌ヨ鍙傛暟 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.GetProductList' + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/util.ResponseList' + - properties: + data: + items: + $ref: '#/definitions/models.Product' + type: array + type: object + summary: 鑾峰彇浜у搧璇︽儏 + tags: + - 浜у搧 /api-wms/v1/warehouse/operationType: get: parameters: 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 6da897f..0df3ac9 100644 --- a/router/router.go +++ b/router/router.go @@ -69,5 +69,13 @@ operationAPI.POST("operation", operationController.Add) } + //浜у搧 + 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