fix: filter monthly reports by month range

This commit is contained in:
richjohnrambo
2026-09-28 15:07:23 +08:00
parent 75f811bb9f
commit a85393b2b8
2 changed files with 37 additions and 3 deletions
+9 -1
View File
@@ -935,10 +935,18 @@ func (s *Store) DailyReportStats(ctx context.Context, date time.Time, department
return stats, nil
}
func (s *Store) MonthlyReports(ctx context.Context, userID int64, cursor string, limit int) ([]MonthlyReport, string, error) {
func (s *Store) MonthlyReports(ctx context.Context, userID int64, fromMonth, toMonth, cursor string, limit int) ([]MonthlyReport, string, error) {
var items []MonthlyReport
query := `SELECT report_id,author_id,report_month,work_summary,next_plan,attachments,status,read_state,version,submitted_at,created_at,updated_at FROM im_monthly_reports WHERE tenant_id=? AND author_id=?`
args := []any{s.tenant(), userID}
if fromMonth != "" {
query += ` AND report_month>=?`
args = append(args, fromMonth)
}
if toMonth != "" {
query += ` AND report_month<=?`
args = append(args, toMonth)
}
if cursor != "" {
query += ` AND report_id>?`
args = append(args, cursor)