This commit is contained in:
oneao committed 2026-03-05 22:24:22 +08:00
1 parent 173eb2dd37
commit 26ff2381b7
17 files changed
+596 -305

No files matched your search

@@ -51,14 +51,22 @@ func ListFinanceRecords(c fiber.Ctx) error {
endTime = &t
}
categoryId := dto.CategoryId
var categoryId int64 = -1
if dto.CategoryId != nil {
categoryId = *dto.CategoryId
}
var categoryType int16 = -1
if dto.CategoryType != nil {
categoryType = *dto.CategoryType
}
records, err := db.Queries.ListFinanceRecords(c.Context(), repo.ListFinanceRecordsParams{
SpaceID: spaceID,
RecordTime: pgtypex.TimePtrToPgDate(startTime),
RecordTime_2: pgtypex.TimePtrToPgDate(endTime),
Column4: categoryId,
Column5: dto.CategoryType,
Column5: categoryType,
})
if err != nil {
+2 -2
View File
@@ -65,8 +65,8 @@ type FinanceRecord struct {
type ListFinanceRecordsDTO struct {
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
CategoryId int64 `json:"category_id"`
CategoryType int16 `json:"category_type"`
CategoryId *int64 `json:"category_id"`
CategoryType *int16 `json:"category_type"`
}
type ListFinanceRecordsVO struct {
@@ -9,9 +9,9 @@ FROM finance_record fr
WHERE
fr.space_id = $1
AND fr.record_time >= $2
AND fr.record_time < $3
AND fr.category_id = COALESCE(NULLIF($4::bigint, 0), fr.category_id)
AND fcs.type = COALESCE(NULLIF($5::smallint, 0), fcs.type)
AND fr.record_time <= $3
AND ($4::bigint = -1 OR fr.category_id = $4)
AND ($5::smallint = -1 OR fcs.type = $5)
ORDER BY
fr.record_time DESC,
fr.create_time DESC;
@@ -123,9 +123,9 @@ FROM finance_record fr
WHERE
fr.space_id = $1
AND fr.record_time >= $2
AND fr.record_time < $3
AND fr.category_id = COALESCE(NULLIF($4::bigint, 0), fr.category_id)
AND fcs.type = COALESCE(NULLIF($5::smallint, 0), fcs.type)
AND fr.record_time <= $3
AND ($4::bigint = -1 OR fr.category_id = $4)
AND ($5::smallint = -1 OR fcs.type = $5)
ORDER BY
fr.record_time DESC,
fr.create_time DESC