From a5435e6664093cd4b2ead49409cb41e301e46514 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期二, 30 四月 2024 14:07:04 +0800 Subject: [PATCH] 薪资计算2 --- models/salary_report_form.go | 29 +++++++++++++++++++---------- 1 files changed, 19 insertions(+), 10 deletions(-) diff --git a/models/salary_report_form.go b/models/salary_report_form.go index 67aa59f..a03738b 100644 --- a/models/salary_report_form.go +++ b/models/salary_report_form.go @@ -11,27 +11,28 @@ // SalaryReportForm 钖祫鎶ヨ〃 SalaryReportForm struct { gorm.Model - WorkerId string `json:"workerId" gorm:"type:varchar(255);comment:浜哄憳id"` - WorkerName string `json:"workerName" gorm:"type:varchar(255);comment:浜哄憳濮撳悕"` - Phone string `json:"phone" gorm:"type:varchar(255);comment:鐢佃瘽"` - WorkTypeId uint `json:"workTypeId" gorm:"type:int(11);comment:宸ョ绫诲瀷id"` - WorkType WorkTypeManage `json:"workType" gorm:"foreignKey:WorkTypeId;references:ID"` - Month string `json:"month" gorm:"type:varchar(255);comment:鏈堜唤"` - IssueSalary decimal.Decimal `json:"issueSalary" gorm:"type:decimal(20,3);comment:搴斿彂宸ヨ祫"` - Remark string `json:"remark" gorm:"type:varchar(255);comment:澶囨敞"` - Details []SalaryDetails `json:"details" gorm:"foreignKey:SalaryReportFormId;references:Id"` + WorkerId string `json:"workerId" gorm:"type:varchar(255);comment:浜哄憳id"` + WorkerName string `json:"workerName" gorm:"type:varchar(255);comment:浜哄憳濮撳悕"` + Phone string `json:"phone" gorm:"type:varchar(255);comment:鐢佃瘽"` + WorkTypeId uint `json:"workTypeId" gorm:"type:int(11);comment:宸ョ绫诲瀷id"` + WorkType WorkTypeManage `json:"workType" gorm:"foreignKey:WorkTypeId;references:ID"` + Month string `json:"month" gorm:"type:varchar(255);comment:鏈堜唤"` + IssueSalary decimal.Decimal `json:"issueSalary" gorm:"type:decimal(20,3);comment:搴斿彂宸ヨ祫"` + Remark string `json:"remark" gorm:"type:varchar(255);comment:澶囨敞"` + Details []*SalaryDetails `json:"details" gorm:"foreignKey:SalaryReportFormId"` } SalaryReportFormSearch struct { SalaryReportForm PageNum int PageSize int Preload bool + Keyword string Orm *gorm.DB } ) func (slf SalaryReportForm) TableName() string { - return "salary_report_form" + return "silk_salary_report_form" } func NewSalaryReportFormSearch() *SalaryReportFormSearch { @@ -53,12 +54,20 @@ return slf } +func (slf *SalaryReportFormSearch) SetKeyword(keyword string) *SalaryReportFormSearch { + slf.Keyword = keyword + return slf +} + func (slf *SalaryReportFormSearch) build() *gorm.DB { var db = slf.Orm.Table(slf.TableName()) if slf.Preload { db = db.Model(SalaryReportForm{}).Preload("Details").Preload("WorkType") } + if slf.Keyword != "" { + db = db.Where("worker_name like ? or worker_id like ?", "%"+slf.Keyword+"%", "%"+slf.Keyword+"%") + } return db } -- Gitblit v1.8.0