From fe6ad48054cdf93d0450bc55f0ff8e9a8c6a66ab Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Thu, 27 Mar 2025 20:12:03 +0800 Subject: [PATCH] salary status2 --- common/dao/staff_salary.go | 10 +++++++--- server/api/salary.go | 3 ++- server/service/staff_salary.go | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/common/dao/staff_salary.go b/common/dao/staff_salary.go index 6852034..3831163 100644 --- a/common/dao/staff_salary.go +++ b/common/dao/staff_salary.go @@ -2,6 +2,7 @@ package dao import ( "enterprise/common/model" + "github.com/spf13/cast" "gorm.io/gorm" "time" ) @@ -88,7 +89,7 @@ func (d *StaffSalaryDao) QueryAll(corpId int64, month string) ([]*model.StaffSal return u, nil } -func (d *StaffSalaryDao) QueryAdmin(page, size int, corpId int64, username string, startMonth, endMonth string) ([]*model.StaffSalary, int64, error) { +func (d *StaffSalaryDao) QueryAdmin(page, size int, corpId int64, staffId string, startMonth, endMonth, status string) ([]*model.StaffSalary, int64, error) { var u []*model.StaffSalary tx := GetDB().Table(d.TableName()) tx.Where("corp_id = ?", corpId) @@ -98,8 +99,11 @@ func (d *StaffSalaryDao) QueryAdmin(page, size int, corpId int64, username strin if endMonth != "" { tx.Where("month <= ?", endMonth) } - if username != "" { - tx.Where("username = ?", username) + if staffId != "" { + tx.Where("user_id = ?", cast.ToInt64(staffId)) + } + if status != "" { + tx.Where("status = ?", cast.ToInt(status)) } var count int64 diff --git a/server/api/salary.go b/server/api/salary.go index 41ddd0e..1b3dc95 100644 --- a/server/api/salary.go +++ b/server/api/salary.go @@ -53,7 +53,8 @@ type ListSalaryReq struct { BaseRequest StartMonth string `form:"start_month"` EndMonth string `form:"end_month"` - Username string `form:"username"` + StaffId string `form:"staff_id"` + Status string `json:"status"` } func (s *Salary) From(m *model.StaffSalary) { diff --git a/server/service/staff_salary.go b/server/service/staff_salary.go index c2c82f5..451693e 100644 --- a/server/service/staff_salary.go +++ b/server/service/staff_salary.go @@ -34,7 +34,7 @@ func NewStaffSalary() *StaffSalary { } func (s *StaffSalary) List(sess *session.AdminSession, req *api.ListSalaryReq) (int64, interface{}, interface{}) { - salarys, total, err := dao.NewStaffSalaryDao().QueryAdmin(1, -1, sess.GetCorpId(), req.Username, req.StartMonth, req.EndMonth) + salarys, total, err := dao.NewStaffSalaryDao().QueryAdmin(1, -1, sess.GetCorpId(), req.StaffId, req.StartMonth, req.EndMonth, req.Status) session.CheckDBError(err) start := (req.Page - 1) * req.Size end := start + req.Size