This commit is contained in:
oneao committed 2026-02-06 22:28:44 +08:00
1 parent b8c8a04c85
commit bce259f165
3 files changed
+31 -10

No files matched your search

@@ -14,10 +14,10 @@ import (
"allapp/utils/timex"
"context"
"fmt"
"time"
"github.com/cloudwego/hertz/pkg/app"
"github.com/cloudwego/hertz/pkg/protocol/consts"
"github.com/jackc/pgx/v5/pgtype"
)
// ListMoneyRecords 账目列表
@@ -42,6 +42,18 @@ func ListMoneyRecords(ctx context.Context, c *app.RequestContext) {
return
}
// 开始时间兜底
if startTime == nil {
t := time.Unix(0, 0)
startTime = &t
}
// 结束时间兜底
if endTime == nil {
t := time.Now().AddDate(10, 0, 0)
endTime = &t
}
userID := middleware.GetUserID(ctx)
// 查询账目列表(统一 SQL)
@@ -49,8 +61,8 @@ func ListMoneyRecords(ctx context.Context, c *app.RequestContext) {
ctx,
repo.ListMoneyRecordsParams{
UserID: userID,
RecordTime: pgtype.Date{Time: startTime, Valid: true},
RecordTime_2: pgtype.Date{Time: endTime, Valid: true},
RecordTime: pgtypex.TimePtrToPgDate(startTime),
RecordTime_2: pgtypex.TimePtrToPgDate(endTime),
},
)
if err != nil {