| | |
| | | WorkType WorkTypeManage `json:"workType" gorm:"foreignKey:WorkTypeId"` |
| | | Status constvar.AttendanceStatus `json:"status" gorm:"type:int(11);comment:状态"` |
| | | OverTimeDuration decimal.Decimal `json:"overTimeDuration" gorm:"type:decimal(20,2);comment:加班时长"` |
| | | PhoneNum string `gorm:"type:varchar(191);comment:手机号" json:"phoneNum"` |
| | | } |
| | | AttendanceManageSearch struct { |
| | | AttendanceManage |
| | |
| | | Preload bool |
| | | Ids []uint |
| | | Month string |
| | | Keyword string |
| | | Order string |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *AttendanceManageSearch) SetDate(date string) *AttendanceManageSearch { |
| | | slf.Date = date |
| | | return slf |
| | | } |
| | | |
| | | func (slf *AttendanceManageSearch) SetWorkerId(workerId string) *AttendanceManageSearch { |
| | | slf.WorkerId = workerId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *AttendanceManageSearch) SetKeyword(keyword string) *AttendanceManageSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *AttendanceManageSearch) SetOrder(order string) *AttendanceManageSearch { |
| | | slf.Order = order |
| | | return slf |
| | | } |
| | | |
| | | func (slf *AttendanceManageSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | db = db.Where("date like ?", slf.Month+"%") |
| | | } |
| | | |
| | | if slf.Date != "" { |
| | | db = db.Where("date = ?", slf.Date) |
| | | } |
| | | |
| | | if slf.WorkerId != "" { |
| | | db = db.Where("worker_id = ?", slf.WorkerId) |
| | | } |
| | | |
| | | if slf.Keyword != "" { |
| | | db = db.Where("worker_name like ? or worker_id like ?", "%"+slf.Keyword+"%", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Order != "" { |
| | | db = db.Order(slf.Order) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |