From 5200927fcd5a352c540d42f9ecba0845367d1938 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 04 七月 2024 20:02:49 +0800
Subject: [PATCH] 产品库存列表返回结构调整
---
response/location_product_response.go | 100 +++++++++++++++++++++++++++++++++
request/location_product_amount.go | 5 -
docs/swagger.yaml | 4
docs/docs.go | 4
docs/swagger.json | 4
controllers/location_product_amount.go | 18 +++++
6 files changed, 121 insertions(+), 14 deletions(-)
diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go
index 7754e46..abd668c 100644
--- a/controllers/location_product_amount.go
+++ b/controllers/location_product_amount.go
@@ -4,6 +4,7 @@
"errors"
"fmt"
"github.com/gin-gonic/gin"
+ "github.com/mitchellh/mapstructure"
"github.com/shopspring/decimal"
"gorm.io/gorm"
"strconv"
@@ -149,7 +150,7 @@
// @Produce application/json
// @Param object body request.GetLocationProductList true "鏌ヨ鍙傛暟"
// @Param Authorization header string true "token"
-// @Success 200 {object} util.Response "鎴愬姛"
+// @Success 200 {object} util.ResponseList(data=[]*response.LocationProductAmount) "鎴愬姛"
// @Router /api-wms/v1/locationProductAmount/locationProductList [post]
func (slf LocationProductAmountController) LocationProductList(c *gin.Context) {
var params request.GetLocationProductList
@@ -186,7 +187,20 @@
return
}
- util.ResponseFormatList(c, code.Success, records, int(total))
+ dataList := make([]*response.LocationProductAmount, 0, len(records))
+
+ for _, v := range records {
+ data := new(response.LocationProductAmount)
+ mapstructure.Decode(v.Product, &data)
+ data.ID = v.ProductId
+ data.LocationId = v.LocationId
+ data.Location = v.Location
+ data.Amount = v.Amount
+ data.ProductId = v.ProductId
+ dataList = append(dataList, data)
+ }
+
+ util.ResponseFormatList(c, code.Success, dataList, int(total))
}
// Add
diff --git a/docs/docs.go b/docs/docs.go
index 711fe86..659232c 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1876,9 +1876,9 @@
],
"responses": {
"200": {
- "description": "鎴愬姛",
+ "description": "OK",
"schema": {
- "$ref": "#/definitions/util.Response"
+ "$ref": "#/definitions/util.ResponseList"
}
}
}
diff --git a/docs/swagger.json b/docs/swagger.json
index 10da27b..b4e0835 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -1865,9 +1865,9 @@
],
"responses": {
"200": {
- "description": "鎴愬姛",
+ "description": "OK",
"schema": {
- "$ref": "#/definitions/util.Response"
+ "$ref": "#/definitions/util.ResponseList"
}
}
}
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index b575f22..830ad06 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -3570,9 +3570,9 @@
- application/json
responses:
"200":
- description: 鎴愬姛
+ description: OK
schema:
- $ref: '#/definitions/util.Response'
+ $ref: '#/definitions/util.ResponseList'
summary: 鑾峰彇浣嶇疆瀵瑰簲浜у搧鍒楄〃
tags:
- 搴撳瓨鐩樼偣
diff --git a/request/location_product_amount.go b/request/location_product_amount.go
index 4deb759..48b978f 100644
--- a/request/location_product_amount.go
+++ b/request/location_product_amount.go
@@ -2,7 +2,6 @@
import (
"github.com/shopspring/decimal"
- "wms/models"
)
type GetList struct {
@@ -45,8 +44,4 @@
Keyword string `json:"keyword"`
WarehouseId int `json:"warehouseId"`
LocationId int `json:"locationId"`
-}
-
-type GetLocationProductListResponse struct {
- models.Material
}
diff --git a/response/location_product_response.go b/response/location_product_response.go
index df9fbfd..6b5021f 100644
--- a/response/location_product_response.go
+++ b/response/location_product_response.go
@@ -1,8 +1,106 @@
package response
-import "wms/models"
+import (
+ "github.com/shopspring/decimal"
+ "wms/constvar"
+ "wms/models"
+)
type RuleList struct {
ProductList []models.Material `json:"productList"` //浜у搧鍒楄〃
LocationList []models.Location `json:"locationList"` //浣嶇疆鍒楄〃
}
+
+type LocationProductAmount struct {
+ ID string `gorm:"comment:涓婚敭ID;primaryKey;type:varchar(191);" json:"id"`
+ Name string `gorm:"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"` //鐗╂枡绫诲瀷(瀛楃涓�)
+ //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"` //鏁伴噺
+ //LockAmount decimal.Decimal `gorm:"type:decimal(35,18);default:0;comment:閿佸畾鏁伴噺" json:"lockAmount"`
+ 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"` //妯℃澘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"` //閲囪喘浠锋牸
+ //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"` //鏈�灏忛噰璐噺
+ PurchaseType constvar.PurchaseType `gorm:"type:int(11);comment:閲囪喘绫诲瀷" json:"purchaseType"`
+ PurchaseTypes string `gorm:"type:varchar(255);comment:閲囪喘绫诲瀷鑼冨洿" json:"-"`
+ PurchaseTypeList []int `gorm:"-" json:"purchaseTypeList"`
+ 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:"autoIncr"`
+ //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"` //鍐呴儴鍙傝��
+ 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"` //甯佺鍚嶇О
+ 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,3);comment:閲嶉噺" json:"weight"` //閲嶉噺
+ Volume decimal.Decimal `gorm:"type:decimal(20,2);comment:浣撶Н" json:"volume"` //浣撶Н
+ MakeAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:鍒堕�犲墠缃椂闂�" json:"makeAdvanceTime"` //鍒堕�犲墠缃椂闂�(澶�)
+ OrderAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:璁㈠崟鍑嗗澶╂暟" json:"orderAdvanceTime"` //璁㈠崟鍑嗗澶╂暟(澶�)
+ DeliveryAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:瀹㈡埛鍓嶇疆鏃堕棿" json:"deliveryAdvanceTime"` //瀹㈡埛鍓嶇疆鏃堕棿(澶�)
+ //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"` //鍐呴儴璋冩嫧璇存槑
+ AttachmentList []*models.Attachment `json:"attachmentList" gorm:"many2many:material_attachment"`
+ IsStorage int `gorm:"type:tinyint(1);default:1;comment:鏄惁瀛樺簱(1鏄�2鍚�)" json:"isStorage"` //鏃犲簱瀛樼殑鍦╳ms浠ュ強srm涓渶瑕佽繃婊ゆ帀
+ IsVirtual int `json:"isVirtual" gorm:"type:tinyint(1);default:2;comment:鏄惁铏氭嫙鐗╂枡(1鏄�2鍚�)"` //铏氭嫙鐗╂枡鍦∕RP璁$畻鏃惰烦杩囪灞傜骇鐩存帴棰嗙敤涓嬬骇鐗╂枡锛岃櫄鎷熺墿鏂欎笉鐢熸垚宸ュ崟
+ ReorderRuleNum int64 `json:"reorderRuleNum"`
+ MoreUnit *bool `json:"moreUnit" gorm:"type:tinyint(1);default:false;comment:鍚姩澶氬崟浣�"`
+ MoreUnitList []models.UnitItems `json:"moreUnitList" gorm:"-"`
+ MoreUnitValue string `json:"-" gorm:"type:varchar(255);comment:澶氬崟浣嶅��"`
+ GrossWeight decimal.Decimal `json:"grossWeight" gorm:"type:decimal(20,3);comment:姣涢噸"`
+ NetWeight decimal.Decimal `json:"netWeight" gorm:"type:decimal(20,3);comment:鍑�閲�"`
+ GrossUnit string `json:"grossUnit" gorm:"type:varchar(255);comment:姣涢噸鍗曚綅"`
+ NetUnit string `json:"netUnit" gorm:"type:varchar(255);comment:鍑�閲嶅崟浣�"`
+ Attributes []models.Attribute `json:"attributes" gorm:"-"` //鍔ㄦ�佸睘鎬�
+
+ //浠ヤ笅涓轰笉瀛樺簱鐨勫瓧娈�
+ AttachmentIDs []uint `json:"attachmentIDs" gorm:"-"`
+ PredictionAmount decimal.Decimal `json:"predictionAmount" gorm:"-"`
+ InputAmount decimal.Decimal `json:"inputAmount" gorm:"-"`
+ OutputAmount decimal.Decimal `json:"outputAmount" gorm:"-"`
+ MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //鏈�灏忓簱瀛�
+ MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //鏈�澶у簱瀛�
+
+ CreateBy string `gorm:"type:varchar(255);comment:瀵煎叆浜恒�佸垱寤轰汉" json:"createBy"` //鍒涘缓浜�
+ BarCode string `gorm:"type:varchar(255);comment:(鍟嗗搧/浜у搧/鐗╂枡鐨�)鏉″舰鐮�" json:"barCode"` //鏉$爜
+
+ LocationId int `json:"locationId" gorm:"type:int;not null;comment:浣嶇疆id"` //浣嶇疆id
+ WarehouseId int `json:"warehouseId" gorm:"type:int;not null;default:0;comment:浠撳簱id"`
+ Location models.Location `json:"location" gorm:"foreignKey:LocationId;references:id"`
+ ProductCategoryID int `json:"productCategoryId" gorm:"type:int;not null;comment:浜у搧绉嶇被id"` //浜у搧绉嶇被id
+ ProductCategory models.ProductCategory `json:"productCategory" gorm:"foreignKey:ProductCategoryID;references:Id"`
+ ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id
+ CreateDate string `json:"createDate" gorm:"type:varchar(63);comment:鏃ユ湡"` //鏃ユ湡
+}
--
Gitblit v1.8.0