From a904aa32e66688ba76c9e4b71b6738b0ba5f5d4f Mon Sep 17 00:00:00 2001
From: yinbentan <yinbentan@live.com>
Date: 星期四, 25 七月 2024 11:44:09 +0800
Subject: [PATCH] 添加字段,工种添加工种编码,用于计算工资(id无法固定工种信息)

---
 models/raw_silk_price_standard.go |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/models/raw_silk_price_standard.go b/models/raw_silk_price_standard.go
index fea5114..888f6d3 100644
--- a/models/raw_silk_price_standard.go
+++ b/models/raw_silk_price_standard.go
@@ -12,6 +12,7 @@
 	RawSilkPriceStandard struct {
 		gorm.Model
 		MarketId     uint            `json:"marketId" gorm:"type:int(11);comment:搴勫彛id"`
+		MarketNumber string          `json:"marketNumber" gorm:"type:varchar(255);comment:搴勫彛缂栫爜"`
 		MarketName   string          `json:"marketName" gorm:"type:varchar(255);comment:搴勫彛鍚嶇О"`
 		RawSilkGrade string          `json:"rawSilkGrade" gorm:"type:varchar(255);comment:鐢熶笣绛夌骇"`
 		PayStandard  decimal.Decimal `json:"payStandard" gorm:"type:decimal(20,3);comment:钖叕鏍囧噯"`
@@ -56,6 +57,11 @@
 	return slf
 }
 
+func (slf *RawSilkPriceStandardSearch) SetMarketNumber(marketNumber string) *RawSilkPriceStandardSearch {
+	slf.MarketNumber = marketNumber
+	return slf
+}
+
 func (slf *RawSilkPriceStandardSearch) SetMarketNames(names []string) *RawSilkPriceStandardSearch {
 	slf.MarketNames = names
 	return slf
@@ -66,6 +72,10 @@
 
 	if slf.ID > 0 {
 		db = db.Where("id = ?", slf.ID)
+	}
+
+	if len(slf.MarketNumber) > 0 {
+		db = db.Where("market_number = ", slf.MarketNumber)
 	}
 
 	if len(slf.MarketNames) > 0 {
@@ -105,6 +115,22 @@
 	return records, total, nil
 }
 
+func (slf *RawSilkPriceStandardSearch) FindNotTotal() ([]*RawSilkPriceStandard, error) {
+	var (
+		records = make([]*RawSilkPriceStandard, 0)
+		db      = slf.build()
+	)
+
+	if slf.PageNum*slf.PageSize > 0 {
+		db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
+	}
+	if err := db.Order("updated_at desc").Find(&records).Error; err != nil {
+		return records, fmt.Errorf("find records err: %v", err)
+	}
+
+	return records, nil
+}
+
 func (slf *RawSilkPriceStandardSearch) Save(record *RawSilkPriceStandard) error {
 	var db = slf.build()
 

--
Gitblit v1.8.0