| | |
| | | // 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 { |
| | |
| | | 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 |
| | | } |