This commit is contained in:
jiangyong27 2025-03-27 21:15:37 +08:00
parent bef38983f5
commit 4048e2d5db
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,46 @@
package dao
import (
"enterprise/common/model"
"github.com/spf13/cast"
"time"
)
type StaffPayLogDao struct {
}
func NewStaffPayLogDao() *StaffPayLogDao {
return &StaffPayLogDao{}
}
func (d *StaffPayLogDao) TableName() string {
return "staff_pay_log"
}
func (d *StaffPayLogDao) Create(o *model.StaffPayLog) (int64, error) {
o.CreateTime = time.Now().Unix()
res := GetDB().Table(d.TableName()).Create(o)
return o.Id, res.Error
}
func (d *StaffPayLogDao) QueryAdmin(page, size int, corpId int64, staffId string) ([]*model.StaffPayLog, int64, error) {
var u []*model.StaffPayLog
tx := GetDB().Table(d.TableName())
tx.Where("corp_id = ?", corpId)
if staffId != "" {
tx.Where("user_id = ?", cast.ToInt64(staffId))
}
var count int64
tx.Count(&count)
tx.Order("month DESC")
tx.Offset((page - 1) * size).Limit(size)
res := tx.Find(&u)
if res.Error != nil {
return nil, 0, res.Error
}
return u, count, nil
}

View File

@ -0,0 +1,10 @@
package model
type StaffPayLog struct {
Id int64
StaffId int64
PayType string
Amount int64
Title string
CreateTime int64
}