From 440392a932fb2dc8118caf1f4996e7d8b72574a1 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 29 四月 2024 19:18:21 +0800
Subject: [PATCH] 编辑纤度检验支持编辑明细并重新生成个人生丝等级
---
models/dict.go | 51 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/models/dict.go b/models/dict.go
index 94acfe0..e585f01 100644
--- a/models/dict.go
+++ b/models/dict.go
@@ -11,23 +11,25 @@
// Dict 璇嶅吀
Dict struct {
gorm.Model
- DictType constvar.DictType `gorm:"index;type:tinyint(3);not null;comment:瀛楀吀绫诲瀷"` //瀛楀吀绫诲瀷
- Number string `gorm:"type:varchar(255);not null;comment:缂栧彿" json:"number"` //缂栧彿
- Name string `gorm:"type:varchar(255);not null;comment:鍚嶇О" json:"name"` //鍚嶇О
- Remark string `gorm:"type:varchar(255);not null;comment:澶囨敞" json:"remark"` //澶囨敞
+ DictType *constvar.DictType `gorm:"index;type:tinyint(3);not null;comment:瀛楀吀绫诲瀷"` //瀛楀吀绫诲瀷
+ Number string `gorm:"type:varchar(255);not null;comment:缂栧彿" json:"number"` //缂栧彿
+ Name string `gorm:"type:varchar(255);not null;comment:鍚嶇О" json:"name"` //鍚嶇О
+ Remark string `gorm:"type:varchar(255);not null;comment:澶囨敞" json:"remark"` //澶囨敞
}
DictSearch struct {
Dict
- Order string
- PageNum int
- PageSize int
- Orm *gorm.DB
+ Order string
+ PageNum int
+ PageSize int
+ Orm *gorm.DB
+ Keyword string
+ DictTypes []constvar.DictType
}
)
func (slf *Dict) TableName() string {
- return "dict"
+ return "silk_dict"
}
func NewDictSearch() *DictSearch {
@@ -64,8 +66,18 @@
return slf
}
-func (slf *DictSearch) SetDictType(dt constvar.DictType) *DictSearch {
+func (slf *DictSearch) SetKeyword(keyword string) *DictSearch {
+ slf.Keyword = keyword
+ return slf
+}
+
+func (slf *DictSearch) SetDictType(dt *constvar.DictType) *DictSearch {
slf.DictType = dt
+ return slf
+}
+
+func (slf *DictSearch) SetDictTypes(dts []constvar.DictType) *DictSearch {
+ slf.DictTypes = dts
return slf
}
@@ -84,8 +96,21 @@
db = db.Where("number = ?", slf.Number)
}
- if slf.DictType != 0 {
+ if slf.DictType != nil {
db = db.Where("dict_type = ?", slf.DictType)
+ }
+
+ if slf.Name != "" {
+ db = db.Where("name = ?", slf.Name)
+ }
+
+ if slf.Keyword != "" {
+ kw := "%" + slf.Keyword + "%"
+ db = db.Where("name like ? or number like ?", kw, kw)
+ }
+
+ if len(slf.DictTypes) > 0 {
+ db = db.Where("dict_type in (?)", slf.DictTypes)
}
return db
@@ -205,10 +230,6 @@
records = make([]*Dict, 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)
}
--
Gitblit v1.8.0