From 6becb6b281b34e17197a25af86acd35628e88811 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期三, 20 九月 2023 17:51:18 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS --- models/product_category.go | 10 models/warehouse.go | 42 models/material.go | 83 +- controllers/warehouse.go | 125 +++- docs/swagger.yaml | 304 +++++--- controllers/location.go | 4 docs/docs.go | 435 ++++++++----- docs/swagger.json | 435 ++++++++----- request/location.go | 2 router/router.go | 9 /dev/null | 294 --------- request/warehouse.go | 16 models/location.go | 56 + 13 files changed, 937 insertions(+), 878 deletions(-) diff --git a/controllers/location.go b/controllers/location.go index 128eb14..c4f3002 100644 --- a/controllers/location.go +++ b/controllers/location.go @@ -26,7 +26,7 @@ if params.Keyword != "" { search.SetKeyword(params.Keyword) } - if params.ParentId != 0 { + if params.ParentId != "" { search.SetParentId(params.ParentId) } if params.CompanyId != 0 { @@ -43,7 +43,7 @@ if params.Type == 0 { return errors.New("璇烽�夋嫨姝g‘鐨勪綅缃被鍨�") } - if params.ParentId < 0 { + if params.ParentId == "" { return errors.New("閿欒鍙傛暟ParentId") } if params.CompanyId < 0 { diff --git a/controllers/warehouse.go b/controllers/warehouse.go index f4a297a..5dc9857 100644 --- a/controllers/warehouse.go +++ b/controllers/warehouse.go @@ -6,6 +6,8 @@ "github.com/gin-gonic/gin" "github.com/spf13/cast" "gorm.io/gorm" + "strconv" + "wms/constvar" "wms/extend/code" "wms/extend/util" "wms/models" @@ -39,6 +41,19 @@ util.ResponseFormat(c, code.RequestParamError, err.Error()) return } + //鍒涘缓榛樿浣嶇疆 + location := &models.Location{ + Name: "榛樿浣嶇疆", + ParentId: params.Code, + Type: constvar.LocationTypeInternal, + ReplenishLocation: true, + } + locationId, err := models.NewLocationSearch().CreateReturnId(location) + if err != nil { + util.ResponseFormat(c, code.SaveFail, "浣嶇疆鍒涘缓澶辫触") + return + } + params.LocationId = locationId if err := models.NewWarehouseSearch().Create(¶ms); err != nil { logx.Errorf("warehouse create err: %v", err) util.ResponseFormat(c, code.SaveFail, "鎻掑叆澶辫触") @@ -48,39 +63,24 @@ util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛") } -// Update +// UpdateWarehouse // @Tags 浠撳簱 // @Summary 缂栬緫浠撳簱 // @Produce application/json -// @Param object body request.UpdateWarehouse true "浠撳簱淇℃伅" -// @Param id path string true "浠撳簱id" +// @Param object body models.Warehouse true "浠撳簱淇℃伅" // @Success 200 {object} util.Response "鎴愬姛" -// @Router /api-wms/v1/warehouse/warehouse/{id} [put] -func (slf WarehouseController) Update(c *gin.Context) { - id := cast.ToUint(c.Param("id")) - if id == 0 { - util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id") - return - } - var ( - reqParams request.UpdateWarehouse - params models.Warehouse - ) - if err := c.BindJSON(&reqParams); err != nil { +// @Router /api-wms/v1/warehouse/updateWarehouse [post] +func (slf WarehouseController) UpdateWarehouse(c *gin.Context) { + var params models.Warehouse + if err := c.BindJSON(¶ms); err != nil { util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("鍙傛暟瑙f瀽澶辫触: %v"+err.Error())) return } - if err := structx.AssignTo(reqParams, ¶ms); err != nil { - util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("鏁版嵁杞崲閿欒: %v", err.Error())) - return - } - params.ID = id if err := slf.ParamsCheck(params); err != nil { util.ResponseFormat(c, code.RequestParamError, err.Error()) return } - - err := models.NewWarehouseSearch().SetID(params.ID).Update(¶ms) + err := models.NewWarehouseSearch().SetID(params.Id).Update(¶ms) if err != nil { util.ResponseFormat(c, code.RequestParamError, "淇敼澶辫触") @@ -92,19 +92,31 @@ func (slf WarehouseController) ParamsCheck(params models.Warehouse) (err error) { var oldRecord *models.Warehouse - if params.ID != 0 { - oldRecord, err = models.NewWarehouseSearch().SetID(params.ID).First() + if params.Id != 0 { + oldRecord, err = models.NewWarehouseSearch().SetID(params.Id).First() if err == gorm.ErrRecordNotFound { return errors.New("璁板綍涓嶅瓨鍦�") } } - if oldRecord == nil || params.Code != oldRecord.Code { - _, err = models.NewWarehouseSearch().SetCode(params.Code).First() - if err != gorm.ErrRecordNotFound { + //鏇存柊浣嶇疆淇℃伅 + if oldRecord != nil && params.Code != oldRecord.Code { + m := make(map[string]interface{}) + m["parent_id"] = params.Code + err := models.NewLocationSearch().SetID(oldRecord.LocationId).UpdateByMap(m) + if err != nil { + return errors.New("鏇存柊浣嶇疆淇℃伅澶辫触") + } + } + if oldRecord == nil { + record, err := models.NewWarehouseSearch().SetCode(params.Code).First() + if record != nil && record.Code == params.Code { + fmt.Println(err) return errors.New("浠撳簱缂栧彿閲嶅") } } - + if params.Code == "" { + return errors.New("缂╁啓涓嶈兘涓虹┖") + } return nil } @@ -126,6 +138,24 @@ util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") return } + //鑾峰彇浣嶇疆淇℃伅 + codes := make([]string, 0) + for _, warehouse := range list { + codes = append(codes, warehouse.Code) + } + locations, err := models.NewLocationSearch().SetParents(codes).FindNotTotal() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "浣嶇疆淇℃伅鏌ユ壘澶辫触") + return + } + for _, warehouse := range list { + for _, location := range locations { + if warehouse.LocationId == location.Id { + warehouse.WarehouseLocation = warehouse.Code + "/" + location.Name + break + } + } + } util.ResponseFormatList(c, code.Success, list, cast.ToInt(total)) } @@ -138,16 +168,49 @@ // @Success 200 {object} util.Response "鎴愬姛" // @Router /api-wms/v1/warehouse/warehouse/{id} [delete] func (slf WarehouseController) Delete(c *gin.Context) { - id := cast.ToUint(c.Param("id")) + id, _ := strconv.Atoi(c.Param("id")) if id == 0 { util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id") return } - err := models.NewWarehouseSearch().SetID(id).Delete() + //鍒犻櫎浣嶇疆淇℃伅 + first, err := models.NewWarehouseSearch().SetID(id).First() if err != nil { - util.ResponseFormat(c, code.RequestParamError, "鍒犻櫎澶辫触") + util.ResponseFormat(c, code.RequestParamError, "鑾峰彇浠撳簱淇℃伅澶辫触") + return + } + err = models.NewLocationSearch().SetID(first.LocationId).Delete() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍒犻櫎浣嶇疆淇℃伅澶辫触") + return + } + err = models.NewWarehouseSearch().SetID(id).Delete() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍒犻櫎浠撳簱淇℃伅澶辫触") return } util.ResponseFormat(c, code.UpdateSuccess, "鍒犻櫎鎴愬姛") } + +// GetWarehouseDetails +// @Tags 浠撳簱 +// @Summary 鑾峰彇浠撳簱璇︽儏 +// @Produce application/json +// @Param id path string true "浠撳簱id" +// @Success 200 {object} util.Response{data=models.Warehouse} "鎴愬姛" +// @Router /api-wms/v1/warehouse/getWarehouseDetails/{id} [get] +func (slf WarehouseController) GetWarehouseDetails(c *gin.Context) { + id, _ := strconv.Atoi(c.Param("id")) + if id == 0 { + util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id") + return + } + + first, err := models.NewWarehouseSearch().SetID(id).First() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鑾峰彇浠撳簱淇℃伅澶辫触") + return + } + util.ResponseFormat(c, code.UpdateSuccess, first) +} diff --git a/docs/docs.go b/docs/docs.go index c19f52e..f67d02f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -426,6 +426,150 @@ } } }, + "/api-wms/v1/operationType/operationType": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "鏌ヨ浣滀笟绫诲瀷鍒楄〃", + "parameters": [ + { + "type": "string", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.OperationType" + } + } + } + } + ] + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "娣诲姞浣滀笟绫诲瀷", + "parameters": [ + { + "description": "浣滀笟绫诲瀷淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddOperationType" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/operationType/operationType/{id}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "缂栬緫浣滀笟绫诲瀷", + "parameters": [ + { + "description": "浣滀笟绫诲瀷淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateOperationType" + } + }, + { + "type": "string", + "description": "浣滀笟绫诲瀷id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "鍒犻櫎浣滀笟绫诲瀷", + "parameters": [ + { + "type": "string", + "description": "浣滀笟绫诲瀷id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, "/api-wms/v1/product/addProduct": { "post": { "produces": [ @@ -772,32 +916,22 @@ } } }, - "/api-wms/v1/warehouse/operationType": { + "/api-wms/v1/warehouse/getWarehouseDetails/{id}": { "get": { "produces": [ "application/json" ], "tags": [ - "浣滀笟绫诲瀷" + "浠撳簱" ], - "summary": "鏌ヨ浣滀笟绫诲瀷鍒楄〃", + "summary": "鑾峰彇浠撳簱璇︽儏", "parameters": [ { "type": "string", - "name": "keyword", - "in": "query" - }, - { - "type": "integer", - "description": "椤电爜", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "姣忛〉澶у皬", - "name": "pageSize", - "in": "query" + "description": "浠撳簱id", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -806,16 +940,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/util.ResponseList" + "$ref": "#/definitions/util.Response" }, { "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/models.OperationType" - } + "$ref": "#/definitions/models.Warehouse" } } } @@ -823,87 +954,26 @@ } } } - }, + } + }, + "/api-wms/v1/warehouse/updateWarehouse": { "post": { "produces": [ "application/json" ], "tags": [ - "浣滀笟绫诲瀷" + "浠撳簱" ], - "summary": "娣诲姞浣滀笟绫诲瀷", + "summary": "缂栬緫浠撳簱", "parameters": [ { - "description": "浣滀笟绫诲瀷淇℃伅", + "description": "浠撳簱淇℃伅", "name": "object", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/request.AddOperationType" + "$ref": "#/definitions/models.Warehouse" } - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "$ref": "#/definitions/util.Response" - } - } - } - } - }, - "/api-wms/v1/warehouse/operationType/{id}": { - "put": { - "produces": [ - "application/json" - ], - "tags": [ - "浣滀笟绫诲瀷" - ], - "summary": "缂栬緫浣滀笟绫诲瀷", - "parameters": [ - { - "description": "浣滀笟绫诲瀷淇℃伅", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.UpdateOperationType" - } - }, - { - "type": "string", - "description": "浣滀笟绫诲瀷id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "$ref": "#/definitions/util.Response" - } - } - } - }, - "delete": { - "produces": [ - "application/json" - ], - "tags": [ - "浣滀笟绫诲瀷" - ], - "summary": "鍒犻櫎浣滀笟绫诲瀷", - "parameters": [ - { - "type": "string", - "description": "浣滀笟绫诲瀷id", - "name": "id", - "in": "path", - "required": true } ], "responses": { @@ -998,41 +1068,6 @@ } }, "/api-wms/v1/warehouse/warehouse/{id}": { - "put": { - "produces": [ - "application/json" - ], - "tags": [ - "浠撳簱" - ], - "summary": "缂栬緫浠撳簱", - "parameters": [ - { - "description": "浠撳簱淇℃伅", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.UpdateWarehouse" - } - }, - { - "type": "string", - "description": "浠撳簱id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "$ref": "#/definitions/util.Response" - } - } - } - }, "delete": { "produces": [ "application/json" @@ -1235,6 +1270,24 @@ "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": [ @@ -1366,7 +1419,7 @@ }, "parentId": { "description": "涓婄骇id", - "type": "integer" + "type": "string" }, "replenishLocation": { "description": "鏄惁琛ュ厖浣嶇疆", @@ -1389,9 +1442,11 @@ "type": "object", "properties": { "HSCode": { + "description": "HS缂栫爜", "type": "string" }, "amount": { + "description": "鏁伴噺", "type": "number" }, "barcode": { @@ -1399,6 +1454,7 @@ "type": "string" }, "buyExplain": { + "description": "閲囪喘璇存槑", "type": "string" }, "canBePurchased": { @@ -1409,20 +1465,32 @@ "description": "浜у搧绫诲埆id", "type": "integer" }, + "categoryName": { + "description": "浜у搧绫诲埆鍚嶇О", + "type": "string" + }, "companyId": { + "description": "鍏徃id", "type": "integer" }, "companyName": { + "description": "鍏徃鍚嶇О", "type": "string" }, "controlStrategy": { - "$ref": "#/definitions/constvar.InvoicingStrategy" + "description": "鎺у埗绛栫暐", + "allOf": [ + { + "$ref": "#/definitions/constvar.InvoicingStrategy" + } + ] }, "cost": { "description": "鎴愭湰", "type": "number" }, "currencyName": { + "description": "甯佺鍚嶇О", "type": "string" }, "customerTaxes": { @@ -1430,12 +1498,14 @@ "type": "number" }, "deliveryAdvanceTime": { + "description": "浜よ揣鎻愬墠鏃堕棿(澶�)", "type": "integer" }, "id": { "type": "string" }, "inStorageExplain": { + "description": "鍏ュ簱璇存槑", "type": "string" }, "internalNotes": { @@ -1447,10 +1517,11 @@ "type": "string" }, "internalTransferExplain": { + "description": "鍐呴儴璋冩嫧璇存槑", "type": "string" }, "invoicingStrategy": { - "description": "wms娣诲姞瀛楁", + "description": "寮�绁ㄧ瓥鐣�", "allOf": [ { "$ref": "#/definitions/constvar.InvoicingStrategy" @@ -1462,6 +1533,7 @@ "type": "boolean" }, "maxInventory": { + "description": "鏈�澶у簱瀛�", "type": "number" }, "minInventory": { @@ -1481,18 +1553,27 @@ ] }, "name": { + "description": "鐗╂枡鍚嶇О", "type": "string" }, "orderCreation": { - "$ref": "#/definitions/constvar.OrderCreation" + "description": "璁㈠崟鍒涘缓", + "allOf": [ + { + "$ref": "#/definitions/constvar.OrderCreation" + } + ] }, "originCountryId": { + "description": "鍘熶骇鍦癷d", "type": "integer" }, "originCountryName": { + "description": "鍘熶骇鍦板悕绉�", "type": "string" }, "outStorageExplain": { + "description": "鍑哄簱璇存槑", "type": "string" }, "principal": { @@ -1500,26 +1581,43 @@ "type": "string" }, "productTagId": { - "description": "浜у搧鏍囩", + "description": "浜у搧鏍囩id", "type": "integer" }, "productTagName": { + "description": "浜у搧鏍囩鍚嶇О", "type": "string" }, + "productType": { + "description": "wms娣诲姞瀛楁", + "allOf": [ + { + "$ref": "#/definitions/constvar.ProductType" + } + ] + }, "purchasePrice": { + "description": "閲囪喘浠锋牸", "type": "number" }, "salePrice": { + "description": "閿�鍞崟浠�", "type": "number" }, "selectProduct": { + "description": "鍙�変骇鍝乮d", "type": "integer" }, "sellExplain": { + "description": "閿�鍞鏄�", "type": "string" }, "supplier": { "description": "FSource string ` + "`" + `gorm:\"type:varchar(191);comment:鐢熶骇杞﹂棿\" json:\"-\"` + "`" + `\nStatus constvar.MaterialStatus ` + "`" + `gorm:\"type:int(11);comment:鐘舵�乗" json:\"status\"` + "`" + `", + "type": "string" + }, + "templateID": { + "description": "Note string ` + "`" + `gorm:\"type:varchar(1024);comment:澶囨敞\" json:\"note\"` + "`" + `", "type": "string" }, "unit": { @@ -1689,6 +1787,7 @@ "type": "integer" }, "routeId": { + "description": "璺嚎id", "type": "integer" }, "routeName": { @@ -1706,6 +1805,10 @@ "active": { "description": "鏄惁鍚敤锛屼紶true灏辫", "type": "boolean" + }, + "address": { + "description": "鍦板潃", + "type": "string" }, "buyToResupply": { "description": "鏄惁璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�", @@ -1729,9 +1832,21 @@ "id": { "type": "integer" }, + "inboundTransportation": { + "description": "鍏ュ悜杩愯緭", + "type": "integer" + }, + "locationId": { + "description": "浣嶇疆id", + "type": "integer" + }, "name": { "description": "浠撳簱鍚嶇О", "type": "string" + }, + "outboundTransportation": { + "description": "鍑哄簱杩愯緭", + "type": "integer" }, "partnerId": { "description": "鍚堜綔浼欎即id", @@ -1752,6 +1867,10 @@ } }, "updateTime": { + "type": "string" + }, + "warehouseLocation": { + "description": "搴撳瓨浣嶇疆", "type": "string" } } @@ -1940,6 +2059,10 @@ "description": "鏄惁鍚敤锛屼紶true灏辫", "type": "boolean" }, + "address": { + "description": "鍦板潃", + "type": "string" + }, "buyToResupply": { "description": "璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�", "type": "boolean" @@ -1950,9 +2073,21 @@ "maxLength": 5, "minLength": 1 }, + "inboundTransportation": { + "description": "鍏ュ悜杩愯緭", + "type": "integer" + }, + "locationId": { + "description": "浣嶇疆id", + "type": "integer" + }, "name": { "description": "浠撳簱鍚嶇О", "type": "string" + }, + "outboundTransportation": { + "description": "鍑哄簱杩愯緭", + "type": "integer" }, "partnerId": { "description": "鍚堜綔浼欎即id", @@ -2181,46 +2316,6 @@ "warehouseId": { "description": "浠撳簱id", "type": "integer" - } - } - }, - "request.UpdateWarehouse": { - "type": "object", - "required": [ - "code" - ], - "properties": { - "active": { - "description": "鏄惁鍚敤锛屼紶true灏辫", - "type": "boolean" - }, - "buyToResupply": { - "description": "璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�", - "type": "boolean" - }, - "code": { - "description": "浠撳簱缂栫爜", - "type": "string", - "maxLength": 5, - "minLength": 1 - }, - "id": { - "type": "integer" - }, - "name": { - "description": "浠撳簱鍚嶇О", - "type": "string" - }, - "partnerId": { - "description": "鍚堜綔浼欎即id", - "type": "integer" - }, - "resupplyWhIds": { - "description": "琛ョ粰鏉ユ簮浠撳簱ID", - "type": "array", - "items": { - "type": "string" - } } } }, diff --git a/docs/swagger.json b/docs/swagger.json index a6aa289..db0828c 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -414,6 +414,150 @@ } } }, + "/api-wms/v1/operationType/operationType": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "鏌ヨ浣滀笟绫诲瀷鍒楄〃", + "parameters": [ + { + "type": "string", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.OperationType" + } + } + } + } + ] + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "娣诲姞浣滀笟绫诲瀷", + "parameters": [ + { + "description": "浣滀笟绫诲瀷淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddOperationType" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/operationType/operationType/{id}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "缂栬緫浣滀笟绫诲瀷", + "parameters": [ + { + "description": "浣滀笟绫诲瀷淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateOperationType" + } + }, + { + "type": "string", + "description": "浣滀笟绫诲瀷id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "鍒犻櫎浣滀笟绫诲瀷", + "parameters": [ + { + "type": "string", + "description": "浣滀笟绫诲瀷id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, "/api-wms/v1/product/addProduct": { "post": { "produces": [ @@ -760,32 +904,22 @@ } } }, - "/api-wms/v1/warehouse/operationType": { + "/api-wms/v1/warehouse/getWarehouseDetails/{id}": { "get": { "produces": [ "application/json" ], "tags": [ - "浣滀笟绫诲瀷" + "浠撳簱" ], - "summary": "鏌ヨ浣滀笟绫诲瀷鍒楄〃", + "summary": "鑾峰彇浠撳簱璇︽儏", "parameters": [ { "type": "string", - "name": "keyword", - "in": "query" - }, - { - "type": "integer", - "description": "椤电爜", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "姣忛〉澶у皬", - "name": "pageSize", - "in": "query" + "description": "浠撳簱id", + "name": "id", + "in": "path", + "required": true } ], "responses": { @@ -794,16 +928,13 @@ "schema": { "allOf": [ { - "$ref": "#/definitions/util.ResponseList" + "$ref": "#/definitions/util.Response" }, { "type": "object", "properties": { "data": { - "type": "array", - "items": { - "$ref": "#/definitions/models.OperationType" - } + "$ref": "#/definitions/models.Warehouse" } } } @@ -811,87 +942,26 @@ } } } - }, + } + }, + "/api-wms/v1/warehouse/updateWarehouse": { "post": { "produces": [ "application/json" ], "tags": [ - "浣滀笟绫诲瀷" + "浠撳簱" ], - "summary": "娣诲姞浣滀笟绫诲瀷", + "summary": "缂栬緫浠撳簱", "parameters": [ { - "description": "浣滀笟绫诲瀷淇℃伅", + "description": "浠撳簱淇℃伅", "name": "object", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/request.AddOperationType" + "$ref": "#/definitions/models.Warehouse" } - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "$ref": "#/definitions/util.Response" - } - } - } - } - }, - "/api-wms/v1/warehouse/operationType/{id}": { - "put": { - "produces": [ - "application/json" - ], - "tags": [ - "浣滀笟绫诲瀷" - ], - "summary": "缂栬緫浣滀笟绫诲瀷", - "parameters": [ - { - "description": "浣滀笟绫诲瀷淇℃伅", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.UpdateOperationType" - } - }, - { - "type": "string", - "description": "浣滀笟绫诲瀷id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "$ref": "#/definitions/util.Response" - } - } - } - }, - "delete": { - "produces": [ - "application/json" - ], - "tags": [ - "浣滀笟绫诲瀷" - ], - "summary": "鍒犻櫎浣滀笟绫诲瀷", - "parameters": [ - { - "type": "string", - "description": "浣滀笟绫诲瀷id", - "name": "id", - "in": "path", - "required": true } ], "responses": { @@ -986,41 +1056,6 @@ } }, "/api-wms/v1/warehouse/warehouse/{id}": { - "put": { - "produces": [ - "application/json" - ], - "tags": [ - "浠撳簱" - ], - "summary": "缂栬緫浠撳簱", - "parameters": [ - { - "description": "浠撳簱淇℃伅", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.UpdateWarehouse" - } - }, - { - "type": "string", - "description": "浠撳簱id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "$ref": "#/definitions/util.Response" - } - } - } - }, "delete": { "produces": [ "application/json" @@ -1223,6 +1258,24 @@ "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": [ @@ -1354,7 +1407,7 @@ }, "parentId": { "description": "涓婄骇id", - "type": "integer" + "type": "string" }, "replenishLocation": { "description": "鏄惁琛ュ厖浣嶇疆", @@ -1377,9 +1430,11 @@ "type": "object", "properties": { "HSCode": { + "description": "HS缂栫爜", "type": "string" }, "amount": { + "description": "鏁伴噺", "type": "number" }, "barcode": { @@ -1387,6 +1442,7 @@ "type": "string" }, "buyExplain": { + "description": "閲囪喘璇存槑", "type": "string" }, "canBePurchased": { @@ -1397,20 +1453,32 @@ "description": "浜у搧绫诲埆id", "type": "integer" }, + "categoryName": { + "description": "浜у搧绫诲埆鍚嶇О", + "type": "string" + }, "companyId": { + "description": "鍏徃id", "type": "integer" }, "companyName": { + "description": "鍏徃鍚嶇О", "type": "string" }, "controlStrategy": { - "$ref": "#/definitions/constvar.InvoicingStrategy" + "description": "鎺у埗绛栫暐", + "allOf": [ + { + "$ref": "#/definitions/constvar.InvoicingStrategy" + } + ] }, "cost": { "description": "鎴愭湰", "type": "number" }, "currencyName": { + "description": "甯佺鍚嶇О", "type": "string" }, "customerTaxes": { @@ -1418,12 +1486,14 @@ "type": "number" }, "deliveryAdvanceTime": { + "description": "浜よ揣鎻愬墠鏃堕棿(澶�)", "type": "integer" }, "id": { "type": "string" }, "inStorageExplain": { + "description": "鍏ュ簱璇存槑", "type": "string" }, "internalNotes": { @@ -1435,10 +1505,11 @@ "type": "string" }, "internalTransferExplain": { + "description": "鍐呴儴璋冩嫧璇存槑", "type": "string" }, "invoicingStrategy": { - "description": "wms娣诲姞瀛楁", + "description": "寮�绁ㄧ瓥鐣�", "allOf": [ { "$ref": "#/definitions/constvar.InvoicingStrategy" @@ -1450,6 +1521,7 @@ "type": "boolean" }, "maxInventory": { + "description": "鏈�澶у簱瀛�", "type": "number" }, "minInventory": { @@ -1469,18 +1541,27 @@ ] }, "name": { + "description": "鐗╂枡鍚嶇О", "type": "string" }, "orderCreation": { - "$ref": "#/definitions/constvar.OrderCreation" + "description": "璁㈠崟鍒涘缓", + "allOf": [ + { + "$ref": "#/definitions/constvar.OrderCreation" + } + ] }, "originCountryId": { + "description": "鍘熶骇鍦癷d", "type": "integer" }, "originCountryName": { + "description": "鍘熶骇鍦板悕绉�", "type": "string" }, "outStorageExplain": { + "description": "鍑哄簱璇存槑", "type": "string" }, "principal": { @@ -1488,26 +1569,43 @@ "type": "string" }, "productTagId": { - "description": "浜у搧鏍囩", + "description": "浜у搧鏍囩id", "type": "integer" }, "productTagName": { + "description": "浜у搧鏍囩鍚嶇О", "type": "string" }, + "productType": { + "description": "wms娣诲姞瀛楁", + "allOf": [ + { + "$ref": "#/definitions/constvar.ProductType" + } + ] + }, "purchasePrice": { + "description": "閲囪喘浠锋牸", "type": "number" }, "salePrice": { + "description": "閿�鍞崟浠�", "type": "number" }, "selectProduct": { + "description": "鍙�変骇鍝乮d", "type": "integer" }, "sellExplain": { + "description": "閿�鍞鏄�", "type": "string" }, "supplier": { "description": "FSource string `gorm:\"type:varchar(191);comment:鐢熶骇杞﹂棿\" json:\"-\"`\nStatus constvar.MaterialStatus `gorm:\"type:int(11);comment:鐘舵�乗" json:\"status\"`", + "type": "string" + }, + "templateID": { + "description": "Note string `gorm:\"type:varchar(1024);comment:澶囨敞\" json:\"note\"`", "type": "string" }, "unit": { @@ -1677,6 +1775,7 @@ "type": "integer" }, "routeId": { + "description": "璺嚎id", "type": "integer" }, "routeName": { @@ -1694,6 +1793,10 @@ "active": { "description": "鏄惁鍚敤锛屼紶true灏辫", "type": "boolean" + }, + "address": { + "description": "鍦板潃", + "type": "string" }, "buyToResupply": { "description": "鏄惁璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�", @@ -1717,9 +1820,21 @@ "id": { "type": "integer" }, + "inboundTransportation": { + "description": "鍏ュ悜杩愯緭", + "type": "integer" + }, + "locationId": { + "description": "浣嶇疆id", + "type": "integer" + }, "name": { "description": "浠撳簱鍚嶇О", "type": "string" + }, + "outboundTransportation": { + "description": "鍑哄簱杩愯緭", + "type": "integer" }, "partnerId": { "description": "鍚堜綔浼欎即id", @@ -1740,6 +1855,10 @@ } }, "updateTime": { + "type": "string" + }, + "warehouseLocation": { + "description": "搴撳瓨浣嶇疆", "type": "string" } } @@ -1928,6 +2047,10 @@ "description": "鏄惁鍚敤锛屼紶true灏辫", "type": "boolean" }, + "address": { + "description": "鍦板潃", + "type": "string" + }, "buyToResupply": { "description": "璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�", "type": "boolean" @@ -1938,9 +2061,21 @@ "maxLength": 5, "minLength": 1 }, + "inboundTransportation": { + "description": "鍏ュ悜杩愯緭", + "type": "integer" + }, + "locationId": { + "description": "浣嶇疆id", + "type": "integer" + }, "name": { "description": "浠撳簱鍚嶇О", "type": "string" + }, + "outboundTransportation": { + "description": "鍑哄簱杩愯緭", + "type": "integer" }, "partnerId": { "description": "鍚堜綔浼欎即id", @@ -2169,46 +2304,6 @@ "warehouseId": { "description": "浠撳簱id", "type": "integer" - } - } - }, - "request.UpdateWarehouse": { - "type": "object", - "required": [ - "code" - ], - "properties": { - "active": { - "description": "鏄惁鍚敤锛屼紶true灏辫", - "type": "boolean" - }, - "buyToResupply": { - "description": "璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�", - "type": "boolean" - }, - "code": { - "description": "浠撳簱缂栫爜", - "type": "string", - "maxLength": 5, - "minLength": 1 - }, - "id": { - "type": "integer" - }, - "name": { - "description": "浠撳簱鍚嶇О", - "type": "string" - }, - "partnerId": { - "description": "鍚堜綔浼欎即id", - "type": "integer" - }, - "resupplyWhIds": { - "description": "琛ョ粰鏉ユ簮浠撳簱ID", - "type": "array", - "items": { - "type": "string" - } } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 2dc5f06..a30050d 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -138,6 +138,20 @@ - 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 @@ -232,7 +246,7 @@ type: string parentId: description: 涓婄骇id - type: integer + type: string replenishLocation: description: 鏄惁琛ュ厖浣嶇疆 type: boolean @@ -246,13 +260,16 @@ models.Material: properties: HSCode: + description: HS缂栫爜 type: string amount: + description: 鏁伴噺 type: number barcode: description: 鏉$爜 type: string buyExplain: + description: 閲囪喘璇存槑 type: string canBePurchased: description: 鏄惁鍙噰璐� @@ -260,25 +277,35 @@ categoryId: description: 浜у搧绫诲埆id type: integer + categoryName: + description: 浜у搧绫诲埆鍚嶇О + type: string companyId: + description: 鍏徃id type: integer companyName: + description: 鍏徃鍚嶇О type: string controlStrategy: - $ref: '#/definitions/constvar.InvoicingStrategy' + allOf: + - $ref: '#/definitions/constvar.InvoicingStrategy' + description: 鎺у埗绛栫暐 cost: description: 鎴愭湰 type: number currencyName: + description: 甯佺鍚嶇О type: string customerTaxes: description: 瀹㈡埛绋庣櫨鍒嗘瘮 type: number deliveryAdvanceTime: + description: 浜よ揣鎻愬墠鏃堕棿(澶�) type: integer id: type: string inStorageExplain: + description: 鍏ュ簱璇存槑 type: string internalNotes: description: 鍐呴儴璇存槑 @@ -287,16 +314,18 @@ description: 鍐呴儴鍙傝�� type: string internalTransferExplain: + description: 鍐呴儴璋冩嫧璇存槑 type: string invoicingStrategy: allOf: - $ref: '#/definitions/constvar.InvoicingStrategy' - description: wms娣诲姞瀛楁 + description: 寮�绁ㄧ瓥鐣� isSale: description: PurchaseType constvar.PurchaseType `gorm:"type:int(11);comment:閲囪喘绫诲瀷" json:"purchaseType"` type: boolean maxInventory: + description: 鏈�澶у簱瀛� type: number minInventory: description: |- @@ -316,35 +345,54 @@ description: MaterialType constvar.ProductType `gorm:"index;type:int(11);comment:鐗╂枡绫诲瀷(鏁板瓧)" json:"materialType"` name: + description: 鐗╂枡鍚嶇О type: string orderCreation: - $ref: '#/definitions/constvar.OrderCreation' + allOf: + - $ref: '#/definitions/constvar.OrderCreation' + description: 璁㈠崟鍒涘缓 originCountryId: + description: 鍘熶骇鍦癷d type: integer originCountryName: + description: 鍘熶骇鍦板悕绉� type: string outStorageExplain: + description: 鍑哄簱璇存槑 type: string principal: description: 璐熻矗浜� type: string productTagId: - description: 浜у搧鏍囩 + description: 浜у搧鏍囩id type: integer productTagName: + description: 浜у搧鏍囩鍚嶇О type: string + productType: + allOf: + - $ref: '#/definitions/constvar.ProductType' + description: wms娣诲姞瀛楁 purchasePrice: + description: 閲囪喘浠锋牸 type: number salePrice: + description: 閿�鍞崟浠� type: number selectProduct: + description: 鍙�変骇鍝乮d type: integer sellExplain: + description: 閿�鍞鏄� type: string supplier: description: |- FSource string `gorm:"type:varchar(191);comment:鐢熶骇杞﹂棿" json:"-"` Status constvar.MaterialStatus `gorm:"type:int(11);comment:鐘舵��" json:"status"` + type: string + templateID: + description: Note string `gorm:"type:varchar(1024);comment:澶囨敞" + json:"note"` type: string unit: description: LockAmount decimal.Decimal `gorm:"type:decimal(35,18);default:0;comment:閿佸畾鏁伴噺" @@ -450,6 +498,7 @@ description: 涓婄骇id type: integer routeId: + description: 璺嚎id type: integer routeName: description: 鍏徃 @@ -460,6 +509,9 @@ active: description: 鏄惁鍚敤锛屼紶true灏辫 type: boolean + address: + description: 鍦板潃 + type: string buyToResupply: description: 鏄惁璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴� type: boolean @@ -476,9 +528,18 @@ type: string id: type: integer + inboundTransportation: + description: 鍏ュ悜杩愯緭 + type: integer + locationId: + description: 浣嶇疆id + type: integer name: description: 浠撳簱鍚嶇О type: string + outboundTransportation: + description: 鍑哄簱杩愯緭 + type: integer partnerId: description: 鍚堜綔浼欎即id type: integer @@ -493,6 +554,9 @@ type: string type: array updateTime: + type: string + warehouseLocation: + description: 搴撳瓨浣嶇疆 type: string required: - code @@ -618,6 +682,9 @@ active: description: 鏄惁鍚敤锛屼紶true灏辫 type: boolean + address: + description: 鍦板潃 + type: string buyToResupply: description: 璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴� type: boolean @@ -626,9 +693,18 @@ maxLength: 5 minLength: 1 type: string + inboundTransportation: + description: 鍏ュ悜杩愯緭 + type: integer + locationId: + description: 浣嶇疆id + type: integer name: description: 浠撳簱鍚嶇О type: string + outboundTransportation: + description: 鍑哄簱杩愯緭 + type: integer partnerId: description: 鍚堜綔浼欎即id type: integer @@ -785,35 +861,6 @@ warehouseId: description: 浠撳簱id type: integer - type: object - request.UpdateWarehouse: - properties: - active: - description: 鏄惁鍚敤锛屼紶true灏辫 - type: boolean - buyToResupply: - description: 璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴� - type: boolean - code: - description: 浠撳簱缂栫爜 - maxLength: 5 - minLength: 1 - type: string - id: - type: integer - name: - description: 浠撳簱鍚嶇О - type: string - partnerId: - description: 鍚堜綔浼欎即id - type: integer - resupplyWhIds: - description: 琛ョ粰鏉ユ簮浠撳簱ID - items: - type: string - type: array - required: - - code type: object util.Response: properties: @@ -1098,6 +1145,96 @@ summary: 淇敼鍏ュ簱/鍑哄簱淇℃伅 tags: - 鍏ュ簱/鍑哄簱 + /api-wms/v1/operationType/operationType: + get: + parameters: + - in: query + name: keyword + type: string + - description: 椤电爜 + in: query + name: page + type: integer + - description: 姣忛〉澶у皬 + in: query + name: pageSize + type: integer + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/util.ResponseList' + - properties: + data: + items: + $ref: '#/definitions/models.OperationType' + type: array + type: object + summary: 鏌ヨ浣滀笟绫诲瀷鍒楄〃 + tags: + - 浣滀笟绫诲瀷 + post: + parameters: + - description: 浣滀笟绫诲瀷淇℃伅 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.AddOperationType' + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 娣诲姞浣滀笟绫诲瀷 + tags: + - 浣滀笟绫诲瀷 + /api-wms/v1/operationType/operationType/{id}: + delete: + parameters: + - description: 浣滀笟绫诲瀷id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 鍒犻櫎浣滀笟绫诲瀷 + tags: + - 浣滀笟绫诲瀷 + put: + parameters: + - description: 浣滀笟绫诲瀷淇℃伅 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.UpdateOperationType' + - description: 浣滀笟绫诲瀷id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 缂栬緫浣滀笟绫诲瀷 + tags: + - 浣滀笟绫诲瀷 /api-wms/v1/product/addProduct: post: parameters: @@ -1308,20 +1445,14 @@ summary: 淇敼浜у搧绫诲瀷 tags: - 浜у搧绫诲瀷 - /api-wms/v1/warehouse/operationType: + /api-wms/v1/warehouse/getWarehouseDetails/{id}: get: parameters: - - in: query - name: keyword + - description: 浠撳簱id + in: path + name: id + required: true type: string - - description: 椤电爜 - in: query - name: page - type: integer - - description: 姣忛〉澶у皬 - in: query - name: pageSize - type: integer produces: - application/json responses: @@ -1329,24 +1460,23 @@ description: 鎴愬姛 schema: allOf: - - $ref: '#/definitions/util.ResponseList' + - $ref: '#/definitions/util.Response' - properties: data: - items: - $ref: '#/definitions/models.OperationType' - type: array + $ref: '#/definitions/models.Warehouse' type: object - summary: 鏌ヨ浣滀笟绫诲瀷鍒楄〃 + summary: 鑾峰彇浠撳簱璇︽儏 tags: - - 浣滀笟绫诲瀷 + - 浠撳簱 + /api-wms/v1/warehouse/updateWarehouse: post: parameters: - - description: 浣滀笟绫诲瀷淇℃伅 + - description: 浠撳簱淇℃伅 in: body name: object required: true schema: - $ref: '#/definitions/request.AddOperationType' + $ref: '#/definitions/models.Warehouse' produces: - application/json responses: @@ -1354,50 +1484,9 @@ description: 鎴愬姛 schema: $ref: '#/definitions/util.Response' - summary: 娣诲姞浣滀笟绫诲瀷 + summary: 缂栬緫浠撳簱 tags: - - 浣滀笟绫诲瀷 - /api-wms/v1/warehouse/operationType/{id}: - delete: - parameters: - - description: 浣滀笟绫诲瀷id - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: 鎴愬姛 - schema: - $ref: '#/definitions/util.Response' - summary: 鍒犻櫎浣滀笟绫诲瀷 - tags: - - 浣滀笟绫诲瀷 - put: - parameters: - - description: 浣滀笟绫诲瀷淇℃伅 - in: body - name: object - required: true - schema: - $ref: '#/definitions/request.UpdateOperationType' - - description: 浣滀笟绫诲瀷id - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: 鎴愬姛 - schema: - $ref: '#/definitions/util.Response' - summary: 缂栬緫浣滀笟绫诲瀷 - tags: - - 浣滀笟绫诲瀷 + - 浠撳簱 /api-wms/v1/warehouse/warehouse: get: parameters: @@ -1463,29 +1552,6 @@ schema: $ref: '#/definitions/util.Response' summary: 鍒犻櫎浠撳簱 - tags: - - 浠撳簱 - put: - parameters: - - description: 浠撳簱淇℃伅 - in: body - name: object - required: true - schema: - $ref: '#/definitions/request.UpdateWarehouse' - - description: 浠撳簱id - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: 鎴愬姛 - schema: - $ref: '#/definitions/util.Response' - summary: 缂栬緫浠撳簱 tags: - 浠撳簱 swagger: "2.0" diff --git a/models/location.go b/models/location.go index 5bcffe7..a11b1a9 100644 --- a/models/location.go +++ b/models/location.go @@ -12,15 +12,15 @@ Location 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:浣嶇疆鍚嶇О"` //浣嶇疆鍚嶇О - ParentId int `json:"parentId" gorm:"type:int;not null"` //涓婄骇id - CompanyId int `json:"companyId" gorm:"type:int;not null"` //鍏徃id - Company Company `json:"company" gorm:"foreignKey:CompanyId"` //鍏徃 - Type constvar.LocationType `json:"type" gorm:"type:int(11);not null;comment:浣嶇疆绫诲瀷"` //浣嶇疆绫诲瀷 - CountFrequency int `json:"countFrequency" gorm:"type:tinyint;not null;comment:鐩樼偣棰戠巼锛堝ぉ锛�"` //鐩樼偣棰戠巼锛堝ぉ锛� - IsScrapLocation bool `json:"isScrapLocation" gorm:"type:tinyint;not null;comment:鏄惁鎶ュ簾浣嶇疆"` //鏄惁鎶ュ簾浣嶇疆 - IsReturnLocation bool `json:"isReturnLocation" gorm:"type:tinyint;not null;comment:鏄惁閫�璐т綅缃�"` //鏄惁閫�璐т綅缃� - ReplenishLocation bool `json:"replenishLocation" gorm:"type:tinyint;not null;comment:鏄惁琛ュ厖浣嶇疆"` //鏄惁琛ュ厖浣嶇疆 + Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:浣嶇疆鍚嶇О"` //浣嶇疆鍚嶇О + ParentId string `json:"parentId" gorm:"type:varchar(255)"` //涓婄骇id + CompanyId int `json:"companyId" gorm:"type:int"` //鍏徃id + Company Company `json:"company" gorm:"foreignKey:CompanyId"` //鍏徃 + Type constvar.LocationType `json:"type" gorm:"type:int(11);comment:浣嶇疆绫诲瀷"` //浣嶇疆绫诲瀷 + CountFrequency int `json:"countFrequency" gorm:"type:tinyint;comment:鐩樼偣棰戠巼锛堝ぉ锛�"` //鐩樼偣棰戠巼锛堝ぉ锛� + IsScrapLocation bool `json:"isScrapLocation" gorm:"type:tinyint;comment:鏄惁鎶ュ簾浣嶇疆"` //鏄惁鎶ュ簾浣嶇疆 + IsReturnLocation bool `json:"isReturnLocation" gorm:"type:tinyint;comment:鏄惁閫�璐т綅缃�"` //鏄惁閫�璐т綅缃� + ReplenishLocation bool `json:"replenishLocation" gorm:"type:tinyint;comment:鏄惁琛ュ厖浣嶇疆"` //鏄惁琛ュ厖浣嶇疆 } LocationSearch struct { @@ -31,6 +31,7 @@ Keyword string Orm *gorm.DB Preload bool + Parents []string } ) @@ -57,8 +58,12 @@ return slf } -func (slf *LocationSearch) SetID(id uint) *LocationSearch { - slf.ID = id +func (slf *LocationSearch) SetID(id int) *LocationSearch { + slf.Id = id + return slf +} +func (slf *LocationSearch) SetParents(ids []string) *LocationSearch { + slf.Parents = ids return slf } @@ -82,7 +87,7 @@ return slf } -func (slf *LocationSearch) SetParentId(parentId int) *LocationSearch { +func (slf *LocationSearch) SetParentId(parentId string) *LocationSearch { slf.ParentId = parentId return slf } @@ -93,10 +98,10 @@ } func (slf *LocationSearch) build() *gorm.DB { - var db = slf.Orm.Model(&Location{}) + var db = slf.Orm.Table(slf.TableName()) - if slf.ID != 0 { - db = db.Where("id = ?", slf.ID) + if slf.Id != 0 { + db = db.Where("id = ?", slf.Id) } if slf.Order != "" { @@ -115,11 +120,14 @@ db = db.Where("type=?", slf.Type) } - if slf.ParentId != 0 { + if slf.ParentId != "" { db = db.Where("parent_id=?", slf.ParentId) } if slf.CompanyId != 0 { db = db.Where("company_id=?", slf.CompanyId) + } + if len(slf.Parents) != 0 { + db = db.Where("parent_id in (?)", slf.Parents) } return db @@ -134,6 +142,16 @@ } return nil +} + +func (slf *LocationSearch) CreateReturnId(record *Location) (int, error) { + var db = slf.build() + + if err := db.Create(record).Error; err != nil { + return 0, err + } + + return record.Id, nil } // CreateBatch 鎵归噺鎻掑叆 @@ -183,7 +201,7 @@ func (slf *LocationSearch) Delete() error { var db = slf.build() - return db.Delete(&Location{}).Error + return db.Unscoped().Delete(&Location{}).Error } func (slf *LocationSearch) First() (*Location, error) { @@ -278,7 +296,9 @@ records = make([]*Location, 0) db = slf.build() ) - if err := db.Find(&records); err != nil { + err := db.Find(&records) + if err != nil { + fmt.Println(err) return records, fmt.Errorf("func FindAll err: %v", err) } return records, nil diff --git a/models/material.go b/models/material.go index 26bd05e..8d9a4ee 100644 --- a/models/material.go +++ b/models/material.go @@ -12,61 +12,62 @@ // Material 鐗╂枡 Material struct { BaseModelString - Name string `gorm:"unique;type:varchar(191);not null;comment:鐗╂枡鍚嶇О" json:"name"` + Name string `gorm:"unique;type:varchar(191);not null;comment:鐗╂枡鍚嶇О" json:"name"` //鐗╂枡鍚嶇О //MaterialType constvar.ProductType `gorm:"index;type:int(11);comment:鐗╂枡绫诲瀷(鏁板瓧)" json:"materialType"` - Model constvar.MaterialMode `gorm:"type:varchar(191);not null;comment:鐗╂枡绫诲瀷(瀛楃涓�)" json:"model"` + Model constvar.MaterialMode `gorm:"type:varchar(191);not null;comment:鐗╂枡绫诲瀷(瀛楃涓�)" json:"model"` //鐗╂枡绫诲瀷(瀛楃涓�) //Explain string `gorm:"type:varchar(512);comment:缂栧彿璇存槑" json:"explain"` //CodeStandardID string `gorm:"type:varchar(191);comment:缂栫爜瑙勮寖ID" json:"codeStandardID"` //Specs string `gorm:"type:varchar(191);comment:鐗╂枡瑙勬牸" json:"specs"` //Type string `gorm:"type:varchar(191);comment:鐗╂枡鍨嬪彿" json:"type"` - MinInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忓簱瀛�" json:"minInventory"` - MaxInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�澶у簱瀛�" json:"maxInventory"` - Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏁伴噺" json:"amount"` + MinInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忓簱瀛�" json:"minInventory"` //鏈�灏忓簱瀛� + MaxInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�澶у簱瀛�" json:"maxInventory"` //鏈�澶у簱瀛� + Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏁伴噺" json:"amount"` //鏁伴噺 //LockAmount decimal.Decimal `gorm:"type:decimal(35,18);default:0;comment:閿佸畾鏁伴噺" json:"lockAmount"` - Unit string `gorm:"type:varchar(100);comment:鍗曚綅" json:"unit"` + Unit string `gorm:"type:varchar(100);comment:鍗曚綅" json:"unit"` //鍗曚綅 //Note string `gorm:"type:varchar(1024);comment:澶囨敞" json:"note"` - TemplateID string `gorm:"type:varchar(191);comment:妯℃澘ID" json:"-"` + TemplateID string `gorm:"type:varchar(191);comment:妯℃澘ID" json:"templateID"` //妯℃澘ID //FSource string `gorm:"type:varchar(191);comment:鐢熶骇杞﹂棿" json:"-"` //Status constvar.MaterialStatus `gorm:"type:int(11);comment:鐘舵��" json:"status"` - Supplier string `gorm:"type:varchar(191);comment:渚涘簲鍟�" json:"supplier"` - PurchasePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閲囪喘浠锋牸" json:"purchasePrice"` + Supplier string `gorm:"type:varchar(191);comment:渚涘簲鍟�" json:"supplier"` //渚涘簲鍟� + PurchasePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閲囪喘浠锋牸" json:"purchasePrice"` //閲囪喘浠锋牸 //PurchaseAheadDay int `gorm:"type:int(11);comment:閲囪喘鎻愬墠鏈�(澶�)" json:"purchaseAheadDay"` //ProduceAheadDay int `gorm:"type:int(11);comment:鍒堕�犳彁鍓嶆湡(澶�)" json:"produceAheadDay"` - MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忛噰璐噺" json:"minPurchaseAmount"` + MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忛噰璐噺" json:"minPurchaseAmount"` //鏈�灏忛噰璐噺 //PurchaseType constvar.PurchaseType `gorm:"type:int(11);comment:閲囪喘绫诲瀷" json:"purchaseType"` - IsSale bool `gorm:"type:tinyint(1);comment:鏄惁閿�鍞�" json:"isSale"` - SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閿�鍞崟浠�" json:"salePrice"` + IsSale bool `gorm:"type:tinyint(1);comment:鏄惁閿�鍞�" json:"isSale"` //鏄惁閿�鍞� + SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閿�鍞崟浠�" json:"salePrice"` //閿�鍞崟浠� AutoIncr uint `gorm:"type:int(11);comment:鑷ID;default:0;" json:"-"` //wms娣诲姞瀛楁 - InvoicingStrategy constvar.InvoicingStrategy `gorm:"type:int(11);comment:寮�绁ㄧ瓥鐣�" json:"invoicingStrategy"` - OrderCreation constvar.OrderCreation `gorm:"type:int(11);comment:璁㈠崟鍒涘缓" json:"orderCreation"` - 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"` //鍐呴儴璇存槑 - 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"` //鏄惁鍙噰璐� - CurrencyName string `gorm:"type:varchar(255);comment:甯佺鍚嶇О" json:"currencyName"` - DeliveryAdvanceTime int `gorm:"type:int(11);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"` //浣撶Н - 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"` - //CompanyArr []IdAndName `gorm:"-" json:"companyArr"` + ProductType constvar.ProductType `gorm:"type:int(11);comment:浜у搧绫诲瀷" json:"productType"` //浜у搧绫诲瀷 + InvoicingStrategy constvar.InvoicingStrategy `gorm:"type:int(11);comment:寮�绁ㄧ瓥鐣�" json:"invoicingStrategy"` //寮�绁ㄧ瓥鐣� + OrderCreation constvar.OrderCreation `gorm:"type:int(11);comment:璁㈠崟鍒涘缓" json:"orderCreation"` //璁㈠崟鍒涘缓 + 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 + CategoryName string `gorm:"type:varchar(255);comment:浜у搧绫诲埆鍚嶇О" json:"categoryName"` //浜у搧绫诲埆鍚嶇О + 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"` //浜у搧鏍囩id + ProductTagName string `gorm:"type:varchar(255);comment:浜у搧鏍囩鍚嶇О" json:"productTagName"` //浜у搧鏍囩鍚嶇О + CompanyId int `gorm:"type:int(11);comment:鍏徃id" json:"companyId"` //鍏徃id + CompanyName string `gorm:"type:varchar(255);comment:鍏徃鍚嶇О" json:"companyName"` //鍏徃鍚嶇О + InternalNotes string `gorm:"type:varchar(512);comment:鍐呴儴璇存槑" json:"internalNotes"` //鍐呴儴璇存槑 + SelectProduct string `gorm:"type:varchar(255);comment:鍙�変骇鍝乮d" json:"selectProduct"` //鍙�変骇鍝乮d + SellExplain string `gorm:"type:varchar(512);comment:閿�鍞鏄�" json:"sellExplain"` //閿�鍞鏄� + CanBePurchased bool `gorm:"type:int(11);comment:鏄惁鍙噰璐�" json:"canBePurchased"` //鏄惁鍙噰璐� + CurrencyName string `gorm:"type:varchar(255);comment:甯佺鍚嶇О" json:"currencyName"` //甯佺鍚嶇О + DeliveryAdvanceTime int `gorm:"type:int(11);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"` //浣撶Н + HSCode string `gorm:"type:varchar(255);comment:HS缂栫爜" json:"HSCode"` //HS缂栫爜 + OriginCountryId int `gorm:"type:int(11);comment:鍘熶骇鍦癷d" json:"originCountryId"` //鍘熶骇鍦癷d + 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"` //鍐呴儴璋冩嫧璇存槑 } MaterialSearch struct { diff --git a/models/product.go b/models/product.go deleted file mode 100644 index 373ee26..0000000 --- a/models/product.go +++ /dev/null @@ -1,294 +0,0 @@ -package models - -// -//import ( -// "fmt" -// "github.com/shopspring/decimal" -// "gorm.io/gorm" -// "wms/constvar" -// "wms/pkg/mysqlx" -//) -// -//type ( -// // Product 浜у搧 -// Product struct { -// WmsModel -// 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 { -// Product -// Order string -// PageNum int -// PageSize int -// Keyword string -// Orm *gorm.DB -// Preload bool -// } -// -// PurchaseInfo struct { -// PurchasePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閲囪喘浠锋牸" json:"purchasePrice"` -// PurchaseAheadDay int `gorm:"type:int(11);comment:閲囪喘鎻愬墠鏈�(澶�)" json:"purchaseAheadDay"` -// ProduceAheadDay int `gorm:"type:int(11);comment:鍒堕�犳彁鍓嶆湡(澶�)" json:"produceAheadDay"` -// MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忛噰璐噺" json:"minPurchaseAmount"` -// } -//) -// -//func (slf *Product) TableName() string { -// return "wms_product" -//} -// -//func (slf *Product) BeforeCreate(db *gorm.DB) error { -// return nil -//} -// -//func (slf *Product) AfterFind(db *gorm.DB) error { -// return nil -//} -// -//func NewProductSearch() *ProductSearch { -// return &ProductSearch{Orm: mysqlx.GetDB()} -//} -// -//func (slf *ProductSearch) SetOrm(tx *gorm.DB) *ProductSearch { -// slf.Orm = tx -// return slf -//} -// -//func (slf *ProductSearch) SetPage(page, size int) *ProductSearch { -// slf.PageNum, slf.PageSize = page, size -// return slf -//} -// -//func (slf *ProductSearch) SetOrder(order string) *ProductSearch { -// slf.Order = order -// return slf -//} -// -//func (slf *ProductSearch) SetID(id uint) *ProductSearch { -// slf.ID = id -// return slf -//} -// -//func (slf *ProductSearch) SetName(name string) *ProductSearch { -// slf.Name = name -// return slf -//} -// -//func (slf *ProductSearch) SetKeyword(keyword string) *ProductSearch { -// slf.Keyword = keyword -// return slf -//} -// -//func (slf *ProductSearch) SetPreload(preload bool) *ProductSearch { -// slf.Preload = preload -// return slf -//} -// -//func (slf *ProductSearch) build() *gorm.DB { -// var db = slf.Orm.Model(&Product{}) -// -// if slf.ID != 0 { -// db = db.Where("id = ?", slf.ID) -// } -// -// if slf.Order != "" { -// db = db.Order(slf.Order) -// } -// -// if slf.Keyword != "" { -// db = db.Where("name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) -// } -// -// if slf.Name != "" { -// db = db.Where("name = ?", slf.Name) -// } -// -// return db -//} -// -//// Create 鍗曟潯鎻掑叆 -//func (slf *ProductSearch) Create(record *Product) error { -// var db = slf.build() -// -// if err := db.Create(record).Error; err != nil { -// return err -// } -// -// return nil -//} -// -//// CreateBatch 鎵归噺鎻掑叆 -//func (slf *ProductSearch) CreateBatch(records []*Product) error { -// var db = slf.build() -// -// if err := db.Create(&records).Error; err != nil { -// return fmt.Errorf("create batch err: %v, records: %+v", err, records) -// } -// -// return nil -//} -// -//func (slf *ProductSearch) Update(record *Product) error { -// var db = slf.build() -// -// if err := db.Omit("CreatedAt").Updates(record).Error; err != nil { -// return fmt.Errorf("save err: %v, record: %+v", err, record) -// } -// -// return nil -//} -// -//func (slf *ProductSearch) UpdateByMap(upMap map[string]interface{}) error { -// var ( -// db = slf.build() -// ) -// -// if err := db.Updates(upMap).Error; err != nil { -// return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) -// } -// -// return nil -//} -// -//func (slf *ProductSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error { -// var ( -// db = slf.Orm.Table(slf.TableName()).Where(query, args...) -// ) -// -// if err := db.Updates(upMap).Error; err != nil { -// return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap) -// } -// -// return nil -//} -// -//func (slf *ProductSearch) Delete() error { -// var db = slf.build() -// return db.Delete(&Product{}).Error -//} -// -//func (slf *ProductSearch) First() (*Product, error) { -// var ( -// record = new(Product) -// db = slf.build() -// ) -// -// if err := db.First(record).Error; err != nil { -// return record, err -// } -// -// return record, nil -//} -// -//func (slf *ProductSearch) Find() ([]*Product, int64, error) { -// var ( -// records = make([]*Product, 0) -// total int64 -// db = slf.build() -// ) -// -// if err := db.Count(&total).Error; err != nil { -// return records, total, fmt.Errorf("find count err: %v", err) -// } -// if slf.PageNum*slf.PageSize > 0 { -// db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) -// } -// if err := db.Find(&records).Error; err != nil { -// return records, total, fmt.Errorf("find records err: %v", err) -// } -// -// return records, total, nil -//} -// -//func (slf *ProductSearch) FindNotTotal() ([]*Product, error) { -// var ( -// records = make([]*Product, 0) -// db = slf.build() -// ) -// -// if slf.PageNum*slf.PageSize > 0 { -// db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) -// } -// if err := db.Find(&records).Error; err != nil { -// return records, fmt.Errorf("find records err: %v", err) -// } -// -// return records, nil -//} -// -//// FindByQuery 鎸囧畾鏉′欢鏌ヨ. -//func (slf *ProductSearch) FindByQuery(query string, args []interface{}) ([]*Product, int64, error) { -// var ( -// records = make([]*Product, 0) -// total int64 -// db = slf.Orm.Table(slf.TableName()).Where(query, args...) -// ) -// -// if err := db.Count(&total).Error; err != nil { -// return records, total, fmt.Errorf("find by query count err: %v", err) -// } -// if slf.PageNum*slf.PageSize > 0 { -// db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) -// } -// if err := db.Find(&records).Error; err != nil { -// return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) -// } -// -// return records, total, nil -//} -// -//// FindByQueryNotTotal 鎸囧畾鏉′欢鏌ヨ&涓嶆煡璇㈡�绘潯鏁�. -//func (slf *ProductSearch) FindByQueryNotTotal(query string, args []interface{}) ([]*Product, error) { -// var ( -// records = make([]*Product, 0) -// db = slf.Orm.Table(slf.TableName()).Where(query, args...) -// ) -// -// if slf.PageNum*slf.PageSize > 0 { -// db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) -// } -// if err := db.Find(&records).Error; err != nil { -// return records, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) -// } -// -// return records, nil -//} diff --git a/models/product_category.go b/models/product_category.go index b1985d3..5f6ebbf 100644 --- a/models/product_category.go +++ b/models/product_category.go @@ -13,11 +13,11 @@ BaseModelInt Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:鍒嗙被鍚嶇О"` //浣嶇疆鍚嶇О ParentId int `json:"parentId" gorm:"type:int;comment:涓婄骇鍒嗙被id"` //涓婄骇id - RouteId int `json:"routeId" gorm:"type:int;comment:璺嚎id"` - RouteName string `json:"routeName" gorm:"type:varchar(512);comment:璺嚎鍚嶇О"` //鍏徃 - ForceRemovalStrategy constvar.ForceRemovalStrategy `json:"forceRemovalStrategy" gorm:"type:tinyint;comment:寮哄埗涓嬫灦绛栫暐"` //寮哄埗涓嬫灦绛栫暐 - CostingMethod constvar.CostingMethod `json:"costingMethod" gorm:"type:tinyint;comment:鎴愭湰鏂规硶"` //鎴愭湰鏂规硶 - InventoryValuation constvar.InventoryValuation `json:"inventoryValuation" gorm:"type:tinyint;comment:搴撳瓨璁′环"` //搴撳瓨璁′环 + RouteId int `json:"routeId" gorm:"type:int;comment:璺嚎id"` //璺嚎id + RouteName string `json:"routeName" gorm:"type:varchar(512);comment:璺嚎鍚嶇О"` //鍏徃 + ForceRemovalStrategy constvar.ForceRemovalStrategy `json:"forceRemovalStrategy" gorm:"type:tinyint;comment:寮哄埗涓嬫灦绛栫暐"` //寮哄埗涓嬫灦绛栫暐 + CostingMethod constvar.CostingMethod `json:"costingMethod" gorm:"type:tinyint;comment:鎴愭湰鏂规硶"` //鎴愭湰鏂规硶 + InventoryValuation constvar.InventoryValuation `json:"inventoryValuation" gorm:"type:tinyint;comment:搴撳瓨璁′环"` //搴撳瓨璁′环 } ProductCategorySearch struct { diff --git a/models/warehouse.go b/models/warehouse.go index c6cd670..8e8a779 100644 --- a/models/warehouse.go +++ b/models/warehouse.go @@ -11,17 +11,22 @@ // Warehouse 浠撳簱 Warehouse 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:浠撳簱鍚嶇О"` //浠撳簱鍚嶇О - Active bool `json:"active" gorm:"type:tinyint(1);not null;comment:鏄惁婵�娲�"` //鏄惁鍚敤锛屼紶true灏辫 - Code string `json:"code" binding:"required,min=1,max=5" gorm:"index;type:varchar(255);not null;comment:浠撳簱缂栫爜"` //浠撳簱缂栫爜 - PartnerID int `json:"partnerId" gorm:"type:int;not null;comment:鍚堜綔浼欎即id"` //鍚堜綔浼欎即id - BuyToResupply bool `json:"buyToResupply" gorm:"type:tinyint(1);not null;comment:鏄惁璐拱琛ョ粰"` //鏄惁璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴� - ResupplyWhIdsStr string `json:"-" gorm:"column:resupply_wh_ids;type:varchar(255);not null;comment:琛ョ粰鏉ユ簮浠撳簱ID"` //琛ョ粰鏉ユ簮浠撳簱ID - ResupplyWhIds []string `json:"resupplyWhIds" gorm:"-"` //琛ョ粰鏉ユ簮浠撳簱ID - ResupplyWh []*Warehouse `json:"resupplyWh" gorm:"-"` //琛ョ粰鏉ユ簮浠撳簱 - CompanyId int `json:"companyId" gorm:"type:int;not null;comment:鍏徃id"` - Company Company `json:"company" gorm:"foreignKey:CompanyId"` + Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` + Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:浠撳簱鍚嶇О"` //浠撳簱鍚嶇О + Active bool `json:"active" gorm:"type:tinyint(1);not null;comment:鏄惁婵�娲�"` //鏄惁鍚敤锛屼紶true灏辫 + Code string `json:"code" binding:"required,min=1,max=5" gorm:"index;type:varchar(255);not null;comment:浠撳簱缂栫爜"` //浠撳簱缂栫爜 + PartnerID int `json:"partnerId" gorm:"type:int;not null;comment:鍚堜綔浼欎即id"` //鍚堜綔浼欎即id + BuyToResupply bool `json:"buyToResupply" gorm:"type:tinyint(1);not null;comment:鏄惁璐拱琛ョ粰"` //鏄惁璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴� + ResupplyWhIdsStr string `json:"-" gorm:"column:resupply_wh_ids;type:varchar(255);not null;comment:琛ョ粰鏉ユ簮浠撳簱ID"` //琛ョ粰鏉ユ簮浠撳簱ID + ResupplyWhIds []string `json:"resupplyWhIds" gorm:"-"` //琛ョ粰鏉ユ簮浠撳簱ID + ResupplyWh []*Warehouse `json:"resupplyWh" gorm:"-"` //琛ョ粰鏉ユ簮浠撳簱 + CompanyId int `json:"companyId" gorm:"type:int;not null;comment:鍏徃id"` + Company Company `json:"company" gorm:"foreignKey:CompanyId"` + Address string `json:"address" gorm:"type:varchar(512);comment:鍦板潃"` //鍦板潃 + InboundTransportation int `json:"inboundTransportation" gorm:"type:int;comment:鍏ュ悜杩愯緭"` //鍏ュ悜杩愯緭 + OutboundTransportation int `json:"outboundTransportation" gorm:"type:int;comment:鍑哄簱杩愯緭"` //鍑哄簱杩愯緭 + LocationId int `json:"locationId" gorm:"type:int;comment:浣嶇疆id"` //浣嶇疆id + WarehouseLocation string `json:"warehouseLocation" gorm:"-"` //搴撳瓨浣嶇疆 } WarehouseSearch struct { @@ -63,8 +68,8 @@ return slf } -func (slf *WarehouseSearch) SetID(id uint) *WarehouseSearch { - slf.ID = id +func (slf *WarehouseSearch) SetID(id int) *WarehouseSearch { + slf.Id = id return slf } @@ -89,10 +94,10 @@ } func (slf *WarehouseSearch) build() *gorm.DB { - var db = slf.Orm.Model(&Warehouse{}) + var db = slf.Orm.Table(slf.TableName()) - if slf.ID != 0 { - db = db.Where("id = ?", slf.ID) + if slf.Id != 0 { + db = db.Where("id = ?", slf.Id) } if slf.Order != "" { @@ -109,6 +114,9 @@ if slf.Preload { db = db.Preload("Company") + } + if slf.Code != "" { + db = db.Where("code = ?", slf.Code) } return db @@ -172,7 +180,7 @@ func (slf *WarehouseSearch) Delete() error { var db = slf.build() - return db.Delete(&Warehouse{}).Error + return db.Unscoped().Delete(&Warehouse{}).Error } func (slf *WarehouseSearch) First() (*Warehouse, error) { diff --git a/request/location.go b/request/location.go index 18a6c36..f3e9708 100644 --- a/request/location.go +++ b/request/location.go @@ -3,6 +3,6 @@ type LocationByType struct { Type int `json:"type" form:"type"` Keyword string `json:"keyword" form:"keyword"` - ParentId int `json:"parentId" form:"parentId"` + ParentId string `json:"parentId" form:"parentId"` CompanyId int `json:"companyId" form:"companyId"` } diff --git a/request/warehouse.go b/request/warehouse.go index c2c4fef..c509583 100644 --- a/request/warehouse.go +++ b/request/warehouse.go @@ -6,12 +6,16 @@ } type AddWarehouse struct { - Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:浠撳簱鍚嶇О"` //浠撳簱鍚嶇О - Active bool `json:"active" gorm:"type:tinyint(1);not null;comment:鏄惁婵�娲�"` //鏄惁鍚敤锛屼紶true灏辫 - Code string `json:"code" binding:"required,min=1,max=5" gorm:"index;type:varchar(255);not null;comment:浠撳簱缂栫爜"` //浠撳簱缂栫爜 - PartnerID int `json:"partnerId" gorm:"type:int;not null;comment:鍚堜綔浼欎即id"` //鍚堜綔浼欎即id - BuyToResupply bool `json:"buyToResupply"` //璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴� - ResupplyWhIds []string `json:"resupplyWhIds"` //琛ョ粰鏉ユ簮浠撳簱ID + Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:浠撳簱鍚嶇О"` //浠撳簱鍚嶇О + Active bool `json:"active" gorm:"type:tinyint(1);not null;comment:鏄惁婵�娲�"` //鏄惁鍚敤锛屼紶true灏辫 + Code string `json:"code" binding:"required,min=1,max=5" gorm:"index;type:varchar(255);not null;comment:浠撳簱缂栫爜"` //浠撳簱缂栫爜 + PartnerID int `json:"partnerId" gorm:"type:int;not null;comment:鍚堜綔浼欎即id"` //鍚堜綔浼欎即id + BuyToResupply bool `json:"buyToResupply"` //璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴� + ResupplyWhIds []string `json:"resupplyWhIds"` //琛ョ粰鏉ユ簮浠撳簱ID + Address string `json:"address" gorm:"type:varchar(512);comment:鍦板潃"` //鍦板潃 + InboundTransportation int `json:"inboundTransportation" gorm:"type:int;comment:鍏ュ悜杩愯緭"` //鍏ュ悜杩愯緭 + OutboundTransportation int `json:"outboundTransportation" gorm:"type:int;comment:鍑哄簱杩愯緭"` //鍑哄簱杩愯緭 + LocationId int `json:"locationId" gorm:"type:int;comment:浣嶇疆id"` //浣嶇疆id } type UpdateWarehouse struct { diff --git a/router/router.go b/router/router.go index f4ee8b9..2a98f20 100644 --- a/router/router.go +++ b/router/router.go @@ -45,10 +45,11 @@ warehouseController := new(controllers.WarehouseController) warehouseAPI := r.Group(urlPrefix + "/warehouse") { - warehouseAPI.GET("warehouse", warehouseController.List) // 鑾峰彇浠撳簱鍒楄〃 - warehouseAPI.POST("warehouse", warehouseController.Add) // 鏂板浠撳簱 - warehouseAPI.PUT("warehouse/:id", warehouseController.Update) // 淇敼浠撳簱 - warehouseAPI.DELETE("warehouse/:id", warehouseController.Delete) // 鍒犻櫎浠撳簱 + warehouseAPI.GET("warehouse", warehouseController.List) // 鑾峰彇浠撳簱鍒楄〃 + warehouseAPI.POST("warehouse", warehouseController.Add) // 鏂板浠撳簱 + warehouseAPI.POST("updateWarehouse", warehouseController.UpdateWarehouse) // 淇敼浠撳簱 + warehouseAPI.DELETE("warehouse/:id", warehouseController.Delete) // 鍒犻櫎浠撳簱 + warehouseAPI.GET("getWarehouseDetails/:id", warehouseController.GetWarehouseDetails) // 鑾峰彇浠撳簱璇︽儏 } // 涓氬姟绫诲瀷 -- Gitblit v1.8.0