From a06efe5575d6c66f9fc6dca991ae40621cf3cfff Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期一, 13 十一月 2023 11:16:26 +0800
Subject: [PATCH] 修改文件服务器端口号
---
models/material.go | 59 ++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/models/material.go b/models/material.go
index 77f3181..69c33d0 100644
--- a/models/material.go
+++ b/models/material.go
@@ -12,7 +12,7 @@
// Material 鐗╂枡
Material struct {
BaseModelString
- Name string `gorm:"unique;type:varchar(191);not null;comment:鐗╂枡鍚嶇О" json:"name"` //鐗╂枡鍚嶇О
+ 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"`
@@ -67,9 +67,11 @@
//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"` //鍐呴儴璋冩嫧璇存槑
+ 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 []*Attachment `json:"attachmentList" gorm:"many2many:material_attachment"`
+ AttachmentIDs []uint `json:"attachmentIDs" gorm:"-"`
}
MaterialSearch struct {
@@ -83,6 +85,7 @@
Ids []string
Orm *gorm.DB
CategoryIds []int
+ Preload bool
}
IdAndName struct {
@@ -174,6 +177,11 @@
// return slf
//}
+func (slf *MaterialSearch) SetPreload(preload bool) *MaterialSearch {
+ slf.Preload = preload
+ return slf
+}
+
func (slf *MaterialSearch) build() *gorm.DB {
var db = slf.Orm.Table(slf.TableName())
@@ -238,6 +246,10 @@
}
if len(slf.CategoryIds) > 0 {
db = db.Where("category_id in ?", slf.CategoryIds)
+ }
+
+ if slf.Preload {
+ db = db.Preload("AttachmentList")
}
return db
@@ -329,7 +341,7 @@
db = slf.build()
)
- if err := db.Count(&total).Error; err != nil {
+ if err := db.Model(&Material{}).Count(&total).Error; err != nil {
return records, total, fmt.Errorf("find count err: %v", err)
}
if slf.PageNum*slf.PageSize > 0 {
@@ -493,24 +505,25 @@
}
type ResponseDisuseList struct {
- Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
- Number string `json:"number" gorm:"type:varchar(255)"` //鍗曞彿
- SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //婧愬崟鍙�
- Status constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:鐘舵��"` //鐘舵��
- FromLocationID int `json:"fromLocationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d
- FromLocation Location `json:"fromLocation" gorm:"foreignKey:FromLocationID;references:Id"` //婧愪綅缃�
- ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //鐩爣浣嶇疆
- ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:鐩爣浣嶇疆id"` //鐩爣浣嶇疆id
- OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"`
- ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"`
- ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"`
- CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID-瀹㈡埛"`
- CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О-瀹㈡埛"`
- Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"`
- ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id
- ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О
- Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺
- Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"`
+ Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+ Number string `json:"number" gorm:"type:varchar(255)"` //鍗曞彿
+ SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //婧愬崟鍙�
+ Status constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:鐘舵��"` //鐘舵��
+ FromLocationID int `json:"fromLocationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d
+ FromLocation Location `json:"fromLocation" gorm:"foreignKey:FromLocationID;references:Id"` //婧愪綅缃�
+ ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //鐩爣浣嶇疆
+ ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:鐩爣浣嶇疆id"` //鐩爣浣嶇疆id
+ OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"`
+ ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"`
+ ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"`
+ CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID-瀹㈡埛"`
+ CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О-瀹㈡埛"`
+ Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"`
+ ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id
+ ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О
+ Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺
+ Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"`
+ BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷
}
func (slf *MaterialSearch) Update(record *Material) error {
--
Gitblit v1.8.0