From cfb6fbce3687230ccb4704dbc0c87fd411b39af1 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期三, 20 九月 2023 17:37:22 +0800
Subject: [PATCH] 仓库字段添加与功能修改
---
models/warehouse.go | 17
request/warehouse.go | 1
models/location.go | 56 ++-
models/material.go | 2
controllers/warehouse.go | 125 +++++++--
docs/swagger.yaml | 137 +++++----
controllers/location.go | 4
docs/docs.go | 203 ++++++++------
docs/swagger.json | 203 ++++++++------
request/location.go | 2
router/router.go | 9
11 files changed, 456 insertions(+), 303 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 03c8ea4..f67d02f 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -916,6 +916,76 @@
}
}
},
+ "/api-wms/v1/warehouse/getWarehouseDetails/{id}": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浠撳簱"
+ ],
+ "summary": "鑾峰彇浠撳簱璇︽儏",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "浠撳簱id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/models.Warehouse"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/warehouse/updateWarehouse": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浠撳簱"
+ ],
+ "summary": "缂栬緫浠撳簱",
+ "parameters": [
+ {
+ "description": "浠撳簱淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/models.Warehouse"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/warehouse/warehouse": {
"get": {
"produces": [
@@ -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": "鏄惁琛ュ厖浣嶇疆",
@@ -1411,6 +1464,10 @@
"categoryId": {
"description": "浜у搧绫诲埆id",
"type": "integer"
+ },
+ "categoryName": {
+ "description": "浜у搧绫诲埆鍚嶇О",
+ "type": "string"
},
"companyId": {
"description": "鍏徃id",
@@ -1464,7 +1521,7 @@
"type": "string"
},
"invoicingStrategy": {
- "description": "wms娣诲姞瀛楁",
+ "description": "寮�绁ㄧ瓥鐣�",
"allOf": [
{
"$ref": "#/definitions/constvar.InvoicingStrategy"
@@ -1530,6 +1587,14 @@
"productTagName": {
"description": "浜у搧鏍囩鍚嶇О",
"type": "string"
+ },
+ "productType": {
+ "description": "wms娣诲姞瀛楁",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.ProductType"
+ }
+ ]
},
"purchasePrice": {
"description": "閲囪喘浠锋牸",
@@ -1771,6 +1836,10 @@
"description": "鍏ュ悜杩愯緭",
"type": "integer"
},
+ "locationId": {
+ "description": "浣嶇疆id",
+ "type": "integer"
+ },
"name": {
"description": "浠撳簱鍚嶇О",
"type": "string"
@@ -1798,6 +1867,10 @@
}
},
"updateTime": {
+ "type": "string"
+ },
+ "warehouseLocation": {
+ "description": "搴撳瓨浣嶇疆",
"type": "string"
}
}
@@ -2002,6 +2075,10 @@
},
"inboundTransportation": {
"description": "鍏ュ悜杩愯緭",
+ "type": "integer"
+ },
+ "locationId": {
+ "description": "浣嶇疆id",
"type": "integer"
},
"name": {
@@ -2239,58 +2316,6 @@
"warehouseId": {
"description": "浠撳簱id",
"type": "integer"
- }
- }
- },
- "request.UpdateWarehouse": {
- "type": "object",
- "required": [
- "code"
- ],
- "properties": {
- "active": {
- "description": "鏄惁鍚敤锛屼紶true灏辫",
- "type": "boolean"
- },
- "address": {
- "description": "鍦板潃",
- "type": "string"
- },
- "buyToResupply": {
- "description": "璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�",
- "type": "boolean"
- },
- "code": {
- "description": "浠撳簱缂栫爜",
- "type": "string",
- "maxLength": 5,
- "minLength": 1
- },
- "id": {
- "type": "integer"
- },
- "inboundTransportation": {
- "description": "鍏ュ悜杩愯緭",
- "type": "integer"
- },
- "name": {
- "description": "浠撳簱鍚嶇О",
- "type": "string"
- },
- "outboundTransportation": {
- "description": "鍑哄簱杩愯緭",
- "type": "integer"
- },
- "partnerId": {
- "description": "鍚堜綔浼欎即id",
- "type": "integer"
- },
- "resupplyWhIds": {
- "description": "琛ョ粰鏉ユ簮浠撳簱ID",
- "type": "array",
- "items": {
- "type": "string"
- }
}
}
},
diff --git a/docs/swagger.json b/docs/swagger.json
index b7f8f43..db0828c 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -904,6 +904,76 @@
}
}
},
+ "/api-wms/v1/warehouse/getWarehouseDetails/{id}": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浠撳簱"
+ ],
+ "summary": "鑾峰彇浠撳簱璇︽儏",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "浠撳簱id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/models.Warehouse"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/warehouse/updateWarehouse": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浠撳簱"
+ ],
+ "summary": "缂栬緫浠撳簱",
+ "parameters": [
+ {
+ "description": "浠撳簱淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/models.Warehouse"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/warehouse/warehouse": {
"get": {
"produces": [
@@ -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": "鏄惁琛ュ厖浣嶇疆",
@@ -1399,6 +1452,10 @@
"categoryId": {
"description": "浜у搧绫诲埆id",
"type": "integer"
+ },
+ "categoryName": {
+ "description": "浜у搧绫诲埆鍚嶇О",
+ "type": "string"
},
"companyId": {
"description": "鍏徃id",
@@ -1452,7 +1509,7 @@
"type": "string"
},
"invoicingStrategy": {
- "description": "wms娣诲姞瀛楁",
+ "description": "寮�绁ㄧ瓥鐣�",
"allOf": [
{
"$ref": "#/definitions/constvar.InvoicingStrategy"
@@ -1518,6 +1575,14 @@
"productTagName": {
"description": "浜у搧鏍囩鍚嶇О",
"type": "string"
+ },
+ "productType": {
+ "description": "wms娣诲姞瀛楁",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.ProductType"
+ }
+ ]
},
"purchasePrice": {
"description": "閲囪喘浠锋牸",
@@ -1759,6 +1824,10 @@
"description": "鍏ュ悜杩愯緭",
"type": "integer"
},
+ "locationId": {
+ "description": "浣嶇疆id",
+ "type": "integer"
+ },
"name": {
"description": "浠撳簱鍚嶇О",
"type": "string"
@@ -1786,6 +1855,10 @@
}
},
"updateTime": {
+ "type": "string"
+ },
+ "warehouseLocation": {
+ "description": "搴撳瓨浣嶇疆",
"type": "string"
}
}
@@ -1990,6 +2063,10 @@
},
"inboundTransportation": {
"description": "鍏ュ悜杩愯緭",
+ "type": "integer"
+ },
+ "locationId": {
+ "description": "浣嶇疆id",
"type": "integer"
},
"name": {
@@ -2227,58 +2304,6 @@
"warehouseId": {
"description": "浠撳簱id",
"type": "integer"
- }
- }
- },
- "request.UpdateWarehouse": {
- "type": "object",
- "required": [
- "code"
- ],
- "properties": {
- "active": {
- "description": "鏄惁鍚敤锛屼紶true灏辫",
- "type": "boolean"
- },
- "address": {
- "description": "鍦板潃",
- "type": "string"
- },
- "buyToResupply": {
- "description": "璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�",
- "type": "boolean"
- },
- "code": {
- "description": "浠撳簱缂栫爜",
- "type": "string",
- "maxLength": 5,
- "minLength": 1
- },
- "id": {
- "type": "integer"
- },
- "inboundTransportation": {
- "description": "鍏ュ悜杩愯緭",
- "type": "integer"
- },
- "name": {
- "description": "浠撳簱鍚嶇О",
- "type": "string"
- },
- "outboundTransportation": {
- "description": "鍑哄簱杩愯緭",
- "type": "integer"
- },
- "partnerId": {
- "description": "鍚堜綔浼欎即id",
- "type": "integer"
- },
- "resupplyWhIds": {
- "description": "琛ョ粰鏉ユ簮浠撳簱ID",
- "type": "array",
- "items": {
- "type": "string"
- }
}
}
},
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 3339932..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
@@ -263,6 +277,9 @@
categoryId:
description: 浜у搧绫诲埆id
type: integer
+ categoryName:
+ description: 浜у搧绫诲埆鍚嶇О
+ type: string
companyId:
description: 鍏徃id
type: integer
@@ -302,7 +319,7 @@
invoicingStrategy:
allOf:
- $ref: '#/definitions/constvar.InvoicingStrategy'
- description: wms娣诲姞瀛楁
+ description: 寮�绁ㄧ瓥鐣�
isSale:
description: PurchaseType constvar.PurchaseType `gorm:"type:int(11);comment:閲囪喘绫诲瀷"
json:"purchaseType"`
@@ -352,6 +369,10 @@
productTagName:
description: 浜у搧鏍囩鍚嶇О
type: string
+ productType:
+ allOf:
+ - $ref: '#/definitions/constvar.ProductType'
+ description: wms娣诲姞瀛楁
purchasePrice:
description: 閲囪喘浠锋牸
type: number
@@ -510,6 +531,9 @@
inboundTransportation:
description: 鍏ュ悜杩愯緭
type: integer
+ locationId:
+ description: 浣嶇疆id
+ type: integer
name:
description: 浠撳簱鍚嶇О
type: string
@@ -530,6 +554,9 @@
type: string
type: array
updateTime:
+ type: string
+ warehouseLocation:
+ description: 搴撳瓨浣嶇疆
type: string
required:
- code
@@ -668,6 +695,9 @@
type: string
inboundTransportation:
description: 鍏ュ悜杩愯緭
+ type: integer
+ locationId:
+ description: 浣嶇疆id
type: integer
name:
description: 浠撳簱鍚嶇О
@@ -831,44 +861,6 @@
warehouseId:
description: 浠撳簱id
type: integer
- type: object
- request.UpdateWarehouse:
- properties:
- active:
- description: 鏄惁鍚敤锛屼紶true灏辫
- type: boolean
- address:
- description: 鍦板潃
- type: string
- buyToResupply:
- description: 璐拱琛ョ粰锛屽凡璐拱浜у搧鑳藉鍙戦�佸埌姝や粨搴�
- type: boolean
- code:
- description: 浠撳簱缂栫爜
- maxLength: 5
- minLength: 1
- type: string
- id:
- type: integer
- inboundTransportation:
- description: 鍏ュ悜杩愯緭
- type: integer
- name:
- description: 浠撳簱鍚嶇О
- type: string
- outboundTransportation:
- description: 鍑哄簱杩愯緭
- type: integer
- partnerId:
- description: 鍚堜綔浼欎即id
- type: integer
- resupplyWhIds:
- description: 琛ョ粰鏉ユ簮浠撳簱ID
- items:
- type: string
- type: array
- required:
- - code
type: object
util.Response:
properties:
@@ -1453,6 +1445,48 @@
summary: 淇敼浜у搧绫诲瀷
tags:
- 浜у搧绫诲瀷
+ /api-wms/v1/warehouse/getWarehouseDetails/{id}:
+ get:
+ parameters:
+ - description: 浠撳簱id
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/util.Response'
+ - properties:
+ data:
+ $ref: '#/definitions/models.Warehouse'
+ type: object
+ summary: 鑾峰彇浠撳簱璇︽儏
+ tags:
+ - 浠撳簱
+ /api-wms/v1/warehouse/updateWarehouse:
+ post:
+ parameters:
+ - description: 浠撳簱淇℃伅
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/models.Warehouse'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 缂栬緫浠撳簱
+ tags:
+ - 浠撳簱
/api-wms/v1/warehouse/warehouse:
get:
parameters:
@@ -1518,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 5d616be..e9abefc 100644
--- a/models/material.go
+++ b/models/material.go
@@ -38,11 +38,13 @@
SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閿�鍞崟浠�" json:"salePrice"` //閿�鍞崟浠�
AutoIncr uint `gorm:"type:int(11);comment:鑷ID;default:0;" json:"-"`
//wms娣诲姞瀛楁
+ 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
diff --git a/models/warehouse.go b/models/warehouse.go
index a8db21e..8e8a779 100644
--- a/models/warehouse.go
+++ b/models/warehouse.go
@@ -25,6 +25,8 @@
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 {
@@ -66,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
}
@@ -92,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 != "" {
@@ -112,6 +114,9 @@
if slf.Preload {
db = db.Preload("Company")
+ }
+ if slf.Code != "" {
+ db = db.Where("code = ?", slf.Code)
}
return db
@@ -175,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 47fb595..c509583 100644
--- a/request/warehouse.go
+++ b/request/warehouse.go
@@ -15,6 +15,7 @@
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 d0a5e50..a566a15 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