This commit is contained in:
oneao committed 2026-01-28 22:32:28 +08:00
1 parent d9c49b34db
commit d33cef825a
36 files changed
+753 -1077

No files matched your search

@@ -69,7 +69,24 @@ func DeleteUserMoneyCategory(ctx context.Context, c *app.RequestContext) {
return return
} }
err = db.Queries.DeleteMoneyCategoryById(ctx, req.Id) userID := middleware.GetUserID(ctx)
categoryId := req.Id
err = db.WithTx(ctx, func(q *repo.Queries) error {
err2 := q.DeleteMoneyCategoryById(ctx, categoryId)
if err2 != nil {
return err2
}
err2 = q.DeleteMoneyRecordByCategoryId(ctx, repo.DeleteMoneyRecordByCategoryIdParams{
UserID: userID,
CategoryID: categoryId,
})
if err2 != nil {
return err2
}
return nil
})
if err != nil { if err != nil {
errorx.AddError(c, err) errorx.AddError(c, err)
@@ -12,101 +12,66 @@ import (
"allapp/utils/response" "allapp/utils/response"
"context" "context"
"fmt" "fmt"
"time"
money "allapp/biz/model/money" money "allapp/biz/model/money"
"github.com/cloudwego/hertz/pkg/app" "github.com/cloudwego/hertz/pkg/app"
"github.com/cloudwego/hertz/pkg/protocol/consts" "github.com/cloudwego/hertz/pkg/protocol/consts"
"github.com/jackc/pgx/v5/pgtype"
) )
// QueryMoneyRecord . // ListMoneyRecords 账目列表
// @router /money/record/query [POST] // @router /money/record/list [POST]
func QueryMoneyRecord(ctx context.Context, c *app.RequestContext) { func ListMoneyRecords(ctx context.Context, c *app.RequestContext) {
var req money.QueryMoneyRecordsParams var req money.ListMoneyRecordsParams
if err := c.BindAndValidate(&req); err != nil { if err := c.BindAndValidate(&req); err != nil {
c.String(consts.StatusBadRequest, err.Error()) c.String(consts.StatusBadRequest, err.Error())
return return
} }
//// 解析年月 // 解析年月(yyyy-MM)
//startTime, err := time.Parse("2006-01", req.RecordTime) startTime, err := time.Parse("2006-01", req.RecordTime)
//if err != nil { if err != nil {
// errorx.AddError(c, fmt.Errorf("invalid record_time format: %v", err)) errorx.AddError(c, fmt.Errorf("invalid record_time format: %v", err))
// return return
//} }
//endTime := startTime.AddDate(0, 1, 0).Add(-time.Nanosecond) endTime := startTime.AddDate(0, 1, 0).Add(-time.Nanosecond)
//
//// 获取 userID 和 spaceID
//userID := middleware.GetUserID(ctx)
//spaceIspaceID := middleware.GetSpaceID(ctx)
//
//// 定义统一的 records 切片
//var dbRecordsUser []repo.MoneyRecord
//var dbRecordsSpace []repo.FindMoneyRecordsBySpaceRow
//var errQuery error
//
//// 最终返回统一类型
//var records []*money.MoneyRecord
//
//// 有空间ID,查询空间内所有用户
//if ok {
// params := repo.FindMoneyRecordsBySpaceParams{
// SpaceID: spaceID,
// RecordTime: pgtype.Date{Time: startTime, Valid: true},
// RecordTime_2: pgtype.Date{Time: endTime, Valid: true},
// }
// dbRecordsSpace, errQuery = db.Queries.FindMoneyRecordsBySpace(ctx, params)
// if errQuery != nil {
// errorx.AddError(c, errQuery)
// return
// }
//
// for _, r := range dbRecordsSpace {
// records = append(records, &money.MoneyRecord{
// Id: r.ID,
// CategoryId: r.CategoryID,
// UserId: r.UserID,
// Username: r.Username.String,
// Amount: pgtypex.NumericToString(r.Amount),
// Remark: r.Remark.String,
// RecordTime: pgtypex.DateToString(r.RecordTime),
// CreateTime: pgtypex.TimestampToMillis(r.CreateTime),
// UpdateTime: pgtypex.TimestampToMillis(r.UpdateTime),
// })
// }
//} else {
// // 没有空间ID,只查询单用户
// params := repo.FindUserMoneyRecordsParams{
// UserID: userID,
// RecordTime: pgtype.Date{Time: startTime, Valid: true},
// RecordTime_2: pgtype.Date{Time: endTime, Valid: true},
// }
// dbRecordsUser, errQuery = db.Queries.FindUserMoneyRecords(ctx, params)
// if errQuery != nil {
// errorx.AddError(c, errQuery)
// return
// }
//
// for _, r := range dbRecordsUser {
// records = append(records, &money.MoneyRecord{
// Id: r.ID,
// CategoryId: r.CategoryID,
// UserId: r.UserID,
// Username: "",
// Amount: pgtypex.NumericToString(r.Amount),
// Remark: r.Remark.String,
// RecordTime: pgtypex.DateToString(r.RecordTime),
// CreateTime: pgtypex.TimestampToMillis(r.CreateTime),
// UpdateTime: pgtypex.TimestampToMillis(r.UpdateTime),
// })
// }
//}
//
//result := &money.QueryMoneyRecordsResult{
// Records: records,
//}
response.Success(c).Send() userID := middleware.GetUserID(ctx)
// 查询账目列表(统一 SQL)
dbRecords, err := db.Queries.ListMoneyRecords(
ctx,
repo.ListMoneyRecordsParams{
UserID: userID,
RecordTime: pgtype.Date{Time: startTime, Valid: true},
RecordTime_2: pgtype.Date{Time: endTime, Valid: true},
},
)
if err != nil {
errorx.AddError(c, err)
return
}
records := make([]*money.MoneyRecord, 0, len(dbRecords))
for _, r := range dbRecords {
records = append(records, &money.MoneyRecord{
Id: r.ID,
CategoryId: r.CategoryID,
UserId: r.UserID,
Username: r.Username.String,
Amount: pgtypex.NumericToString(r.Amount),
Remark: r.Remark.String,
RecordTime: pgtypex.DateToString(r.RecordTime),
CreateTime: pgtypex.TimestampToMillis(r.CreateTime),
UpdateTime: pgtypex.TimestampToMillis(r.UpdateTime),
})
}
response.Success(c).Data(&money.ListMoneyRecordsResult{
Records: records,
}).Send()
} }
// InsertMoneyRecord . // InsertMoneyRecord .
@@ -122,8 +87,6 @@ func InsertMoneyRecord(ctx context.Context, c *app.RequestContext) {
return return
} }
resp := new(money.InsertMoneyRecordResult)
params := repo.InsertMoneyRecordParams{ params := repo.InsertMoneyRecordParams{
ID: idgen.NextId(), ID: idgen.NextId(),
CategoryID: req.CategoryId, CategoryID: req.CategoryId,
@@ -133,22 +96,14 @@ func InsertMoneyRecord(ctx context.Context, c *app.RequestContext) {
RecordTime: pgtypex.StringToDate(req.RecordTime), RecordTime: pgtypex.StringToDate(req.RecordTime),
} }
record, err := db.Queries.InsertMoneyRecord(ctx, params) err = db.Queries.InsertMoneyRecord(ctx, params)
if err != nil { if err != nil {
errorx.AddError(c, err) errorx.AddError(c, err)
return return
} }
resp.Id = record.ID response.Success(c).Message("新增成功").Send()
resp.CategoryId = record.CategoryID
resp.UserId = record.UserID
resp.Amount = pgtypex.NumericToString(record.Amount)
resp.Remark = record.Remark.String
resp.RecordTime = pgtypex.DateToString(record.RecordTime)
resp.CreateTime = pgtypex.TimestampToDateTimeString(record.CreateTime)
resp.UpdateTime = pgtypex.TimestampToDateTimeString(record.UpdateTime)
response.Success(c).Data(resp).Message("新增成功").Send()
} }
// UpdateMoneyRecord . // UpdateMoneyRecord .
@@ -34,7 +34,7 @@ func GetUserSpace(ctx context.Context, c *app.RequestContext) {
if err != nil { if err != nil {
if errorx.IsNotFound(err) { if errorx.IsNotFound(err) {
response.Success(c).Data(resp).Send() response.Success(c).Data(nil).Send()
return return
} }
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.28.0 // protoc-gen-go v1.28.0
// protoc v4.25.3 // protoc v6.33.1
// source: api.proto // source: api.proto
package api package api
@@ -10,7 +10,6 @@ import (
_ "allapp/biz/model/api" _ "allapp/biz/model/api"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect" reflect "reflect"
) )
@@ -30,76 +29,74 @@ var file_money_proto_rawDesc = []byte{
0x65, 0x67, 0x6f, 0x72, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x1a, 0x1e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x72, 0x6f, 0x1a, 0x1e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x72,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x6f, 0x32, 0xcb, 0x04, 0x0a, 0x14, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67,
0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xcb, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x56, 0x0a, 0x04, 0x4c, 0x69,
0x04, 0x0a, 0x14, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x73, 0x74, 0x12, 0x1b, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x56, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a,
0x1b, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x1c, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65,
0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x6d, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x13, 0xca,
0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0xc1, 0x18, 0x0f, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x13, 0xca, 0xc1, 0x18, 0x0f, 0x72, 0x79, 0x12, 0x74, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72,
0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x1d, 0x2e,
0x74, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65,
0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x1d, 0x2e, 0x6d, 0x6f, 0x6e, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d,
0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1a, 0xd2, 0xc1,
0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x18, 0x16, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72,
0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1a, 0xd2, 0xc1, 0x18, 0x16, 0x2f, 0x79, 0x2f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64,
0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2f, 0x64,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x53, 0x6f, 0x72,
0x74, 0x12, 0x21, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x53, 0x6f, 0x72,
0x74, 0x52, 0x65, 0x71, 0x1a, 0x22, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
0x53, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1e, 0xd2, 0xc1, 0x18, 0x1a, 0x2f, 0x6d, 0x53, 0x6f, 0x72, 0x74, 0x12, 0x21, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64,
0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2f, 0x75, 0x70, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
0x64, 0x61, 0x74, 0x65, 0x53, 0x6f, 0x72, 0x74, 0x12, 0x70, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x53, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x22, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e,
0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67,
0x1d, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6f, 0x72, 0x79, 0x53, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1e, 0xd2, 0xc1, 0x18,
0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x1a, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6f, 0x72, 0x74, 0x12, 0x70, 0x0a, 0x13, 0x43,
0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1a, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f,
0xd2, 0xc1, 0x18, 0x16, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x72, 0x79, 0x12, 0x1d, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74,
0x6f, 0x72, 0x79, 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x70, 0x0a, 0x13, 0x55, 0x70, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65,
0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x79, 0x12, 0x1d, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73,
0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x70, 0x22, 0x1a, 0xd2, 0xc1, 0x18, 0x16, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x70, 0x0a,
0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65,
0x67, 0x6f, 0x72, 0x79, 0x12, 0x1d, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52,
0x65, 0x73, 0x70, 0x22, 0x1a, 0xd2, 0xc1, 0x18, 0x16, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f,
0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x32,
0xc7, 0x03, 0x0a, 0x12, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f,
0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x1d, 0x2e, 0x6d, 0x6f, 0x6e,
0x65, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f,
0x72, 0x64, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1d, 0x2e, 0x6d, 0x6f, 0x6e, 0x65,
0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72,
0x64, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x12, 0xd2, 0xc1, 0x18, 0x0e, 0x2f, 0x6d,
0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x6d, 0x0a, 0x11,
0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72,
0x64, 0x12, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74,
0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d,
0x73, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74,
0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c,
0x74, 0x22, 0x18, 0xd2, 0xc1, 0x18, 0x14, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x72, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x2f, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x12, 0x6d, 0x0a, 0x11, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x12, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d,
0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73,
0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d,
0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74,
0x22, 0x1a, 0xd2, 0xc1, 0x18, 0x16, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x22, 0x18, 0xd2, 0xc1, 0x18, 0x14, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x72, 0x65, 0x63,
0x65, 0x67, 0x6f, 0x72, 0x79, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x32, 0xce, 0x03, 0x0a, 0x6f, 0x72, 0x64, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x6d, 0x0a, 0x11, 0x44, 0x65,
0x12, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x65, 0x72, 0x76, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12,
0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x6e, 0x65, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f,
0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a,
0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f,
0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22,
0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0xd2, 0xc1, 0x18, 0x14, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x72, 0x65, 0x63, 0x6f,
0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x17, 0xd2, 0xc1, 0x18, 0x13, 0x2f, 0x6d, 0x6f, 0x72, 0x64, 0x2f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x18, 0x5a, 0x16, 0x61, 0x6c, 0x6c,
0x6e, 0x65, 0x79, 0x2f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x61, 0x70, 0x70, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x6d, 0x6f,
0x12, 0x6d, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x6e, 0x65, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x49, 0x6e,
0x73, 0x65, 0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50,
0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x49, 0x6e,
0x73, 0x65, 0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52,
0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x18, 0xd2, 0xc1, 0x18, 0x14, 0x2f, 0x6d, 0x6f, 0x6e, 0x65,
0x79, 0x2f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2f, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x12,
0x6d, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x12, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61,
0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65,
0x73, 0x75, 0x6c, 0x74, 0x22, 0x18, 0xd2, 0xc1, 0x18, 0x14, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79,
0x2f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x6d,
0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63,
0x6f, 0x72, 0x64, 0x12, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72,
0x61, 0x6d, 0x73, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73,
0x75, 0x6c, 0x74, 0x22, 0x18, 0xd2, 0xc1, 0x18, 0x14, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f,
0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x18, 0x5a,
0x16, 0x61, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65,
0x6c, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var file_money_proto_goTypes = []interface{}{ var file_money_proto_goTypes = []interface{}{
@@ -108,7 +105,7 @@ var file_money_proto_goTypes = []interface{}{
(*UpdateMoneyCategorySortReq)(nil), // 2: money.UpdateMoneyCategorySortReq (*UpdateMoneyCategorySortReq)(nil), // 2: money.UpdateMoneyCategorySortReq
(*CreateMoneyCategoryReq)(nil), // 3: money.CreateMoneyCategoryReq (*CreateMoneyCategoryReq)(nil), // 3: money.CreateMoneyCategoryReq
(*UpdateMoneyCategoryReq)(nil), // 4: money.UpdateMoneyCategoryReq (*UpdateMoneyCategoryReq)(nil), // 4: money.UpdateMoneyCategoryReq
(*QueryMoneyRecordsParams)(nil), // 5: money.QueryMoneyRecordsParams (*ListMoneyRecordsParams)(nil), // 5: money.ListMoneyRecordsParams
(*InsertMoneyRecordParams)(nil), // 6: money.InsertMoneyRecordParams (*InsertMoneyRecordParams)(nil), // 6: money.InsertMoneyRecordParams
(*UpdateMoneyRecordParams)(nil), // 7: money.UpdateMoneyRecordParams (*UpdateMoneyRecordParams)(nil), // 7: money.UpdateMoneyRecordParams
(*DeleteMoneyRecordParams)(nil), // 8: money.DeleteMoneyRecordParams (*DeleteMoneyRecordParams)(nil), // 8: money.DeleteMoneyRecordParams
@@ -117,7 +114,7 @@ var file_money_proto_goTypes = []interface{}{
(*UpdateMoneyCategorySortResp)(nil), // 11: money.UpdateMoneyCategorySortResp (*UpdateMoneyCategorySortResp)(nil), // 11: money.UpdateMoneyCategorySortResp
(*CreateMoneyCategoryResp)(nil), // 12: money.CreateMoneyCategoryResp (*CreateMoneyCategoryResp)(nil), // 12: money.CreateMoneyCategoryResp
(*UpdateMoneyCategoryResp)(nil), // 13: money.UpdateMoneyCategoryResp (*UpdateMoneyCategoryResp)(nil), // 13: money.UpdateMoneyCategoryResp
(*QueryMoneyRecordsResult)(nil), // 14: money.QueryMoneyRecordsResult (*ListMoneyRecordsResult)(nil), // 14: money.ListMoneyRecordsResult
(*InsertMoneyRecordResult)(nil), // 15: money.InsertMoneyRecordResult (*InsertMoneyRecordResult)(nil), // 15: money.InsertMoneyRecordResult
(*UpdateMoneyRecordResult)(nil), // 16: money.UpdateMoneyRecordResult (*UpdateMoneyRecordResult)(nil), // 16: money.UpdateMoneyRecordResult
(*DeleteMoneyRecordResult)(nil), // 17: money.DeleteMoneyRecordResult (*DeleteMoneyRecordResult)(nil), // 17: money.DeleteMoneyRecordResult
@@ -128,7 +125,7 @@ var file_money_proto_depIdxs = []int32{
2, // 2: money.MoneyCategoryService.UpdateMoneyCategorySort:input_type -> money.UpdateMoneyCategorySortReq 2, // 2: money.MoneyCategoryService.UpdateMoneyCategorySort:input_type -> money.UpdateMoneyCategorySortReq
3, // 3: money.MoneyCategoryService.CreateMoneyCategory:input_type -> money.CreateMoneyCategoryReq 3, // 3: money.MoneyCategoryService.CreateMoneyCategory:input_type -> money.CreateMoneyCategoryReq
4, // 4: money.MoneyCategoryService.UpdateMoneyCategory:input_type -> money.UpdateMoneyCategoryReq 4, // 4: money.MoneyCategoryService.UpdateMoneyCategory:input_type -> money.UpdateMoneyCategoryReq
5, // 5: money.MoneyRecordService.QueryMoneyRecord:input_type -> money.QueryMoneyRecordsParams 5, // 5: money.MoneyRecordService.ListMoneyRecords:input_type -> money.ListMoneyRecordsParams
6, // 6: money.MoneyRecordService.InsertMoneyRecord:input_type -> money.InsertMoneyRecordParams 6, // 6: money.MoneyRecordService.InsertMoneyRecord:input_type -> money.InsertMoneyRecordParams
7, // 7: money.MoneyRecordService.UpdateMoneyRecord:input_type -> money.UpdateMoneyRecordParams 7, // 7: money.MoneyRecordService.UpdateMoneyRecord:input_type -> money.UpdateMoneyRecordParams
8, // 8: money.MoneyRecordService.DeleteMoneyRecord:input_type -> money.DeleteMoneyRecordParams 8, // 8: money.MoneyRecordService.DeleteMoneyRecord:input_type -> money.DeleteMoneyRecordParams
@@ -137,7 +134,7 @@ var file_money_proto_depIdxs = []int32{
11, // 11: money.MoneyCategoryService.UpdateMoneyCategorySort:output_type -> money.UpdateMoneyCategorySortResp 11, // 11: money.MoneyCategoryService.UpdateMoneyCategorySort:output_type -> money.UpdateMoneyCategorySortResp
12, // 12: money.MoneyCategoryService.CreateMoneyCategory:output_type -> money.CreateMoneyCategoryResp 12, // 12: money.MoneyCategoryService.CreateMoneyCategory:output_type -> money.CreateMoneyCategoryResp
13, // 13: money.MoneyCategoryService.UpdateMoneyCategory:output_type -> money.UpdateMoneyCategoryResp 13, // 13: money.MoneyCategoryService.UpdateMoneyCategory:output_type -> money.UpdateMoneyCategoryResp
14, // 14: money.MoneyRecordService.QueryMoneyRecord:output_type -> money.QueryMoneyRecordsResult 14, // 14: money.MoneyRecordService.ListMoneyRecords:output_type -> money.ListMoneyRecordsResult
15, // 15: money.MoneyRecordService.InsertMoneyRecord:output_type -> money.InsertMoneyRecordResult 15, // 15: money.MoneyRecordService.InsertMoneyRecord:output_type -> money.InsertMoneyRecordResult
16, // 16: money.MoneyRecordService.UpdateMoneyRecord:output_type -> money.UpdateMoneyRecordResult 16, // 16: money.MoneyRecordService.UpdateMoneyRecord:output_type -> money.UpdateMoneyRecordResult
17, // 17: money.MoneyRecordService.DeleteMoneyRecord:output_type -> money.DeleteMoneyRecordResult 17, // 17: money.MoneyRecordService.DeleteMoneyRecord:output_type -> money.DeleteMoneyRecordResult
@@ -134,7 +134,7 @@ func (x *MoneyRecord) GetUsername() string {
} }
// 查询记账记录请求参数 // 查询记账记录请求参数
type QueryMoneyRecordsParams struct { type ListMoneyRecordsParams struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
@@ -142,8 +142,8 @@ type QueryMoneyRecordsParams struct {
RecordTime string `protobuf:"bytes,1,opt,name=RecordTime,proto3" form:"record_time" json:"record_time"` RecordTime string `protobuf:"bytes,1,opt,name=RecordTime,proto3" form:"record_time" json:"record_time"`
} }
func (x *QueryMoneyRecordsParams) Reset() { func (x *ListMoneyRecordsParams) Reset() {
*x = QueryMoneyRecordsParams{} *x = ListMoneyRecordsParams{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_money_money_record_types_proto_msgTypes[1] mi := &file_money_money_record_types_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -151,13 +151,13 @@ func (x *QueryMoneyRecordsParams) Reset() {
} }
} }
func (x *QueryMoneyRecordsParams) String() string { func (x *ListMoneyRecordsParams) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*QueryMoneyRecordsParams) ProtoMessage() {} func (*ListMoneyRecordsParams) ProtoMessage() {}
func (x *QueryMoneyRecordsParams) ProtoReflect() protoreflect.Message { func (x *ListMoneyRecordsParams) ProtoReflect() protoreflect.Message {
mi := &file_money_money_record_types_proto_msgTypes[1] mi := &file_money_money_record_types_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -169,12 +169,12 @@ func (x *QueryMoneyRecordsParams) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use QueryMoneyRecordsParams.ProtoReflect.Descriptor instead. // Deprecated: Use ListMoneyRecordsParams.ProtoReflect.Descriptor instead.
func (*QueryMoneyRecordsParams) Descriptor() ([]byte, []int) { func (*ListMoneyRecordsParams) Descriptor() ([]byte, []int) {
return file_money_money_record_types_proto_rawDescGZIP(), []int{1} return file_money_money_record_types_proto_rawDescGZIP(), []int{1}
} }
func (x *QueryMoneyRecordsParams) GetRecordTime() string { func (x *ListMoneyRecordsParams) GetRecordTime() string {
if x != nil { if x != nil {
return x.RecordTime return x.RecordTime
} }
@@ -182,7 +182,7 @@ func (x *QueryMoneyRecordsParams) GetRecordTime() string {
} }
// 查询记账记录结果 // 查询记账记录结果
type QueryMoneyRecordsResult struct { type ListMoneyRecordsResult struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
@@ -190,8 +190,8 @@ type QueryMoneyRecordsResult struct {
Records []*MoneyRecord `protobuf:"bytes,1,rep,name=Records,proto3" form:"records" json:"records"` Records []*MoneyRecord `protobuf:"bytes,1,rep,name=Records,proto3" form:"records" json:"records"`
} }
func (x *QueryMoneyRecordsResult) Reset() { func (x *ListMoneyRecordsResult) Reset() {
*x = QueryMoneyRecordsResult{} *x = ListMoneyRecordsResult{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_money_money_record_types_proto_msgTypes[2] mi := &file_money_money_record_types_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -199,13 +199,13 @@ func (x *QueryMoneyRecordsResult) Reset() {
} }
} }
func (x *QueryMoneyRecordsResult) String() string { func (x *ListMoneyRecordsResult) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*QueryMoneyRecordsResult) ProtoMessage() {} func (*ListMoneyRecordsResult) ProtoMessage() {}
func (x *QueryMoneyRecordsResult) ProtoReflect() protoreflect.Message { func (x *ListMoneyRecordsResult) ProtoReflect() protoreflect.Message {
mi := &file_money_money_record_types_proto_msgTypes[2] mi := &file_money_money_record_types_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -217,12 +217,12 @@ func (x *QueryMoneyRecordsResult) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use QueryMoneyRecordsResult.ProtoReflect.Descriptor instead. // Deprecated: Use ListMoneyRecordsResult.ProtoReflect.Descriptor instead.
func (*QueryMoneyRecordsResult) Descriptor() ([]byte, []int) { func (*ListMoneyRecordsResult) Descriptor() ([]byte, []int) {
return file_money_money_record_types_proto_rawDescGZIP(), []int{2} return file_money_money_record_types_proto_rawDescGZIP(), []int{2}
} }
func (x *QueryMoneyRecordsResult) GetRecords() []*MoneyRecord { func (x *ListMoneyRecordsResult) GetRecords() []*MoneyRecord {
if x != nil { if x != nil {
return x.Records return x.Records
} }
@@ -306,15 +306,6 @@ type InsertMoneyRecordResult struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=Id,proto3" form:"id" json:"id"`
CategoryId int64 `protobuf:"varint,2,opt,name=CategoryId,proto3" form:"category_id" json:"category_id"`
UserId int64 `protobuf:"varint,3,opt,name=UserId,proto3" form:"user_id" json:"user_id"`
Amount string `protobuf:"bytes,4,opt,name=Amount,proto3" form:"amount" json:"amount"`
Remark string `protobuf:"bytes,5,opt,name=Remark,proto3" form:"remark" json:"remark"`
RecordTime string `protobuf:"bytes,6,opt,name=RecordTime,proto3" form:"record_time" json:"record_time"`
CreateTime string `protobuf:"bytes,7,opt,name=CreateTime,proto3" form:"create_time" json:"create_time"`
UpdateTime string `protobuf:"bytes,8,opt,name=UpdateTime,proto3" form:"update_time" json:"update_time"`
} }
func (x *InsertMoneyRecordResult) Reset() { func (x *InsertMoneyRecordResult) Reset() {
@@ -349,62 +340,6 @@ func (*InsertMoneyRecordResult) Descriptor() ([]byte, []int) {
return file_money_money_record_types_proto_rawDescGZIP(), []int{4} return file_money_money_record_types_proto_rawDescGZIP(), []int{4}
} }
func (x *InsertMoneyRecordResult) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *InsertMoneyRecordResult) GetCategoryId() int64 {
if x != nil {
return x.CategoryId
}
return 0
}
func (x *InsertMoneyRecordResult) GetUserId() int64 {
if x != nil {
return x.UserId
}
return 0
}
func (x *InsertMoneyRecordResult) GetAmount() string {
if x != nil {
return x.Amount
}
return ""
}
func (x *InsertMoneyRecordResult) GetRemark() string {
if x != nil {
return x.Remark
}
return ""
}
func (x *InsertMoneyRecordResult) GetRecordTime() string {
if x != nil {
return x.RecordTime
}
return ""
}
func (x *InsertMoneyRecordResult) GetCreateTime() string {
if x != nil {
return x.CreateTime
}
return ""
}
func (x *InsertMoneyRecordResult) GetUpdateTime() string {
if x != nil {
return x.UpdateTime
}
return ""
}
// 更新记账记录 // 更新记账记录
type UpdateMoneyRecordParams struct { type UpdateMoneyRecordParams struct {
state protoimpl.MessageState state protoimpl.MessageState
@@ -639,81 +574,60 @@ var file_money_money_record_types_proto_rawDesc = []byte{
0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x55, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x55,
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xca, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xca,
0xbb, 0x18, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x08, 0x55, 0x73, 0x65, 0xbb, 0x18, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x08, 0x55, 0x73, 0x65,
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x4a, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x49, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e,
0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12,
0x12, 0x2f, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x2f, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f,
0x5f, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65,
0x65, 0x22, 0x54, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x22, 0x53, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x39, 0x0a, 0x07, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x39, 0x0a, 0x07, 0x52, 0x65,
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x6f,
0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x6e, 0x65, 0x79, 0x2e, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42,
0x64, 0x42, 0x0b, 0xca, 0xbb, 0x18, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x07, 0x0b, 0xca, 0xbb, 0x18, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x07, 0x52, 0x65,
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0xa4, 0x02, 0x0a, 0x17, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0xa4, 0x02, 0x0a, 0x17, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74,
0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d,
0x61, 0x6d, 0x73, 0x12, 0x38, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x73, 0x12, 0x38, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x18, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x61, 0x74, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x18, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x61, 0x74, 0x65, 0x67,
0x65, 0x67, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x05, 0x24, 0x21, 0x3d, 0x27, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x05, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x52,
0x27, 0x52, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x4d, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x4d, 0x0a, 0x06, 0x41,
0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x35, 0xca, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x35, 0xca, 0xbb, 0x18,
0xbb, 0x18, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0xda, 0xbb, 0x18, 0x27, 0x24, 0x21, 0x3d, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0xda, 0xbb, 0x18, 0x27, 0x24, 0x21, 0x3d, 0x27, 0x27,
0x27, 0x27, 0x20, 0x26, 0x26, 0x20, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x28, 0x27, 0x5e, 0x5c, 0x20, 0x26, 0x26, 0x20, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x28, 0x27, 0x5e, 0x5c, 0x64, 0x2b,
0x64, 0x2b, 0x28, 0x5c, 0x2e, 0x5c, 0x64, 0x7b, 0x31, 0x2c, 0x32, 0x7d, 0x29, 0x3f, 0x24, 0x27, 0x28, 0x5c, 0x2e, 0x5c, 0x64, 0x7b, 0x31, 0x2c, 0x32, 0x7d, 0x29, 0x3f, 0x24, 0x27, 0x2c, 0x20,
0x2c, 0x20, 0x24, 0x29, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x24, 0x29, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x52, 0x65,
0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xca, 0xbb, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xca, 0xbb, 0x18, 0x06,
0x18, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x52, 0x06, 0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x52, 0x06, 0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x5c,
0x12, 0x5c, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01,
0x20, 0x01, 0x28, 0x09, 0x42, 0x3c, 0xca, 0xbb, 0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x28, 0x09, 0x42, 0x3c, 0xca, 0xbb, 0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x74,
0x5f, 0x74, 0x69, 0x6d, 0x65, 0xda, 0xbb, 0x18, 0x29, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x20, 0x26, 0x69, 0x6d, 0x65, 0xda, 0xbb, 0x18, 0x29, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x20, 0x26, 0x26, 0x20,
0x26, 0x20, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x28, 0x27, 0x5e, 0x5c, 0x64, 0x7b, 0x34, 0x7d, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x28, 0x27, 0x5e, 0x5c, 0x64, 0x7b, 0x34, 0x7d, 0x2d, 0x5c,
0x2d, 0x5c, 0x64, 0x7b, 0x32, 0x7d, 0x2d, 0x5c, 0x64, 0x7b, 0x32, 0x7d, 0x24, 0x27, 0x2c, 0x20, 0x64, 0x7b, 0x32, 0x7d, 0x2d, 0x5c, 0x64, 0x7b, 0x32, 0x7d, 0x24, 0x27, 0x2c, 0x20, 0x24, 0x29,
0x24, 0x29, 0x52, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xe2, 0x52, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x19, 0x0a, 0x17,
0x02, 0x0a, 0x17, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72,
0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x16, 0x0a, 0x02, 0x49, 0x64, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0xe3, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61,
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xca, 0xbb, 0x18, 0x02, 0x69, 0x64, 0x52, 0x02, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72,
0x49, 0x64, 0x12, 0x2f, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x61, 0x6d, 0x73, 0x12, 0x1e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42,
0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x61, 0x74, 0x65, 0x0e, 0xca, 0xbb, 0x18, 0x02, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x04, 0x24, 0x21, 0x3d, 0x30, 0x52,
0x67, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x52, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x02, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49,
0x79, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x61, 0x74,
0x01, 0x28, 0x03, 0x42, 0x0b, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x52, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f,
0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x72, 0x79, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03,
0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xca, 0xbb, 0x18, 0x06, 0x61, 0x6d, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xca, 0xbb, 0x18, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
0x6f, 0x75, 0x6e, 0x74, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x52, 0x65, 0x6d, 0x61,
0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xca, 0xbb, 0x72, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xca, 0xbb, 0x18, 0x06, 0x72, 0x65,
0x18, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x52, 0x06, 0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x52, 0x06, 0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x2f, 0x0a, 0x0a,
0x12, 0x2f, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x74, 0x69, 0x6d,
0x5f, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x19, 0x0a,
0x65, 0x12, 0x2f, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f,
0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x72, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x39, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65,
0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72,
0x6d, 0x65, 0x12, 0x2f, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x61, 0x6d, 0x73, 0x12, 0x1e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42,
0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x0e, 0xca, 0xbb, 0x18, 0x02, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x04, 0x24, 0x21, 0x3d, 0x30, 0x52,
0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x02, 0x49, 0x64, 0x22, 0x19, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f, 0x6e,
0x69, 0x6d, 0x65, 0x22, 0xe3, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x42, 0x18,
0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x5a, 0x16, 0x61, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64,
0x1e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0e, 0xca, 0xbb, 0x18, 0x65, 0x6c, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x02, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x04, 0x24, 0x21, 0x3d, 0x30, 0x52, 0x02, 0x49, 0x64, 0x12,
0x2f, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18, 0x02, 0x20,
0x01, 0x28, 0x03, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72,
0x79, 0x5f, 0x69, 0x64, 0x52, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64,
0x12, 0x22, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x42, 0x0a, 0xca, 0xbb, 0x18, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x06, 0x41, 0x6d,
0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xca, 0xbb, 0x18, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b,
0x52, 0x06, 0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x2f, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f,
0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb,
0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x52,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x19, 0x0a, 0x17, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65,
0x73, 0x75, 0x6c, 0x74, 0x22, 0x39, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f,
0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12,
0x1e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0e, 0xca, 0xbb, 0x18,
0x02, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x04, 0x24, 0x21, 0x3d, 0x30, 0x52, 0x02, 0x49, 0x64, 0x22,
0x19, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x42, 0x18, 0x5a, 0x16, 0x61, 0x6c,
0x6c, 0x61, 0x70, 0x70, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x6d,
0x6f, 0x6e, 0x65, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -731,8 +645,8 @@ func file_money_money_record_types_proto_rawDescGZIP() []byte {
var file_money_money_record_types_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_money_money_record_types_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_money_money_record_types_proto_goTypes = []interface{}{ var file_money_money_record_types_proto_goTypes = []interface{}{
(*MoneyRecord)(nil), // 0: money.MoneyRecord (*MoneyRecord)(nil), // 0: money.MoneyRecord
(*QueryMoneyRecordsParams)(nil), // 1: money.QueryMoneyRecordsParams (*ListMoneyRecordsParams)(nil), // 1: money.ListMoneyRecordsParams
(*QueryMoneyRecordsResult)(nil), // 2: money.QueryMoneyRecordsResult (*ListMoneyRecordsResult)(nil), // 2: money.ListMoneyRecordsResult
(*InsertMoneyRecordParams)(nil), // 3: money.InsertMoneyRecordParams (*InsertMoneyRecordParams)(nil), // 3: money.InsertMoneyRecordParams
(*InsertMoneyRecordResult)(nil), // 4: money.InsertMoneyRecordResult (*InsertMoneyRecordResult)(nil), // 4: money.InsertMoneyRecordResult
(*UpdateMoneyRecordParams)(nil), // 5: money.UpdateMoneyRecordParams (*UpdateMoneyRecordParams)(nil), // 5: money.UpdateMoneyRecordParams
@@ -741,7 +655,7 @@ var file_money_money_record_types_proto_goTypes = []interface{}{
(*DeleteMoneyRecordResult)(nil), // 8: money.DeleteMoneyRecordResult (*DeleteMoneyRecordResult)(nil), // 8: money.DeleteMoneyRecordResult
} }
var file_money_money_record_types_proto_depIdxs = []int32{ var file_money_money_record_types_proto_depIdxs = []int32{
0, // 0: money.QueryMoneyRecordsResult.Records:type_name -> money.MoneyRecord 0, // 0: money.ListMoneyRecordsResult.Records:type_name -> money.MoneyRecord
1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension type_name
@@ -768,7 +682,7 @@ func file_money_money_record_types_proto_init() {
} }
} }
file_money_money_record_types_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_money_money_record_types_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*QueryMoneyRecordsParams); i { switch v := v.(*ListMoneyRecordsParams); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -780,7 +694,7 @@ func file_money_money_record_types_proto_init() {
} }
} }
file_money_money_record_types_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_money_money_record_types_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*QueryMoneyRecordsResult); i { switch v := v.(*ListMoneyRecordsResult); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -4,6 +4,7 @@ import (
"allapp/db" "allapp/db"
"allapp/logx" "allapp/logx"
"context" "context"
"github.com/cloudwego/hertz/pkg/app" "github.com/cloudwego/hertz/pkg/app"
) )
@@ -18,10 +19,12 @@ func RefreshActive() app.HandlerFunc {
} }
// 异步刷新活跃时间 // 异步刷新活跃时间
go func() { go func(userID int64) {
if err := db.Queries.UpdateUserActiveTime(c, userID); err != nil { ctx := context.Background()
logx.CtxError(c, "刷新用户活跃时间失败, userID=%d, err=%v", userID, err)
if err := db.Queries.UpdateUserLastLoginTime(ctx, userID); err != nil {
logx.CtxError(ctx, "刷新用户活跃时间失败, userID=%d, err=%v", userID, err)
} }
}() }(userID)
} }
} }
@@ -75,3 +75,8 @@ func _updatemoneycategoryMw() []app.HandlerFunc {
// your code... // your code...
return nil return nil
} }
func _listmoneyrecordsMw() []app.HandlerFunc {
// your code...
return nil
}
@@ -25,11 +25,11 @@ func Register(r *server.Hertz) {
_category.POST("/delete", append(_deleteusermoneycategoryMw(), money.DeleteUserMoneyCategory)...) _category.POST("/delete", append(_deleteusermoneycategoryMw(), money.DeleteUserMoneyCategory)...)
_category.POST("/update", append(_updatemoneycategoryMw(), money.UpdateMoneyCategory)...) _category.POST("/update", append(_updatemoneycategoryMw(), money.UpdateMoneyCategory)...)
_category.POST("/updateSort", append(_updatemoneycategorysortMw(), money.UpdateMoneyCategorySort)...) _category.POST("/updateSort", append(_updatemoneycategorysortMw(), money.UpdateMoneyCategorySort)...)
_money.POST("/records", append(_listmoneyrecordsMw(), money.ListMoneyRecords)...)
{ {
_record := _money.Group("/record", _recordMw()...) _record := _money.Group("/record", _recordMw()...)
_record.POST("/delete", append(_deletemoneyrecordMw(), money.DeleteMoneyRecord)...) _record.POST("/delete", append(_deletemoneyrecordMw(), money.DeleteMoneyRecord)...)
_record.POST("/insert", append(_insertmoneyrecordMw(), money.InsertMoneyRecord)...) _record.POST("/insert", append(_insertmoneyrecordMw(), money.InsertMoneyRecord)...)
_record.POST("/query", append(_querymoneyrecordMw(), money.QueryMoneyRecord)...)
_record.POST("/update", append(_updatemoneyrecordMw(), money.UpdateMoneyRecord)...) _record.POST("/update", append(_updatemoneyrecordMw(), money.UpdateMoneyRecord)...)
} }
} }
@@ -1,25 +1,26 @@
-- name: FindUserMoneyRecords :many -- name: ListMoneyRecords :many
SELECT mr.*
FROM money_record mr
WHERE mr.user_id = $1
AND mr.record_time BETWEEN $2 AND $3
ORDER BY mr.record_time DESC, mr.create_time DESC;
-- name: FindMoneyRecordsBySpace :many
SELECT SELECT
mr.*, mr.*,
u.username AS username u.username AS username
FROM money_record mr FROM money_record mr
INNER JOIN space_user su LEFT JOIN space_user su
ON mr.user_id = su.user_id ON su.user_id = mr.user_id
AND su.space_id = $1 LEFT JOIN "user" u
LEFT JOIN user_info u ON u.id = mr.user_id
ON mr.user_id = u.id WHERE
WHERE mr.record_time BETWEEN $2 AND $3 mr.record_time BETWEEN $2 AND $3
ORDER BY mr.record_time DESC, mr.create_time DESC; AND (
-- 空间账本:属于当前空间的用户
su.user_id IS NOT NULL
-- 个人账本:当前用户
OR mr.user_id = $1
)
ORDER BY
mr.record_time DESC,
mr.create_time DESC;
-- name: InsertMoneyRecord :one -- name: InsertMoneyRecord :exec
INSERT INTO money_record ( INSERT INTO money_record (
id, id,
category_id, category_id,
@@ -31,8 +32,7 @@ INSERT INTO money_record (
update_time update_time
) VALUES ( ) VALUES (
$1, $2, $3, $4, $5,$6,NOW(),NOW() $1, $2, $3, $4, $5,$6,NOW(),NOW()
) );
RETURNING *;
-- name: GetMoneyRecordById :one -- name: GetMoneyRecordById :one
SELECT * FROM money_record WHERE id = $1; SELECT * FROM money_record WHERE id = $1;
@@ -49,4 +49,7 @@ WHERE id = $1
RETURNING *; RETURNING *;
-- name: DeleteMoneyRecord :exec -- name: DeleteMoneyRecord :exec
DELETE FROM money_record WHERE id = $1; DELETE FROM money_record WHERE id = $1;
-- name: DeleteMoneyRecordByCategoryId :exec
DELETE FROM money_record WHERE user_id = $1 AND category_id = $2;
@@ -1,30 +0,0 @@
-- 根据 ID 查询单条用户记录
-- name: GetUserById :one
SELECT *
FROM user_info
WHERE id = $1;
-- 根据账号查询单条用户记录
-- name: GetUserByAccount :one
SELECT *
FROM user_info
WHERE account = $1;
-- 根据账号和密码查询单条用户记录(登录用)
-- name: GetUserForLogin :one
SELECT *
FROM user_info
WHERE account = $1
AND password = $2;
-- 更新用户最后登录时间,并返回更新后的记录
-- name: UpdateUserLoginLastTime :exec
UPDATE user_info
SET last_login_time = now()
WHERE id = $1;
-- 更新用户活跃时间
-- name: UpdateUserActiveTime :exec
UPDATE user_info
SET active_time = now()
WHERE id = $1;
+81 -114
View File
@@ -20,109 +20,18 @@ func (q *Queries) DeleteMoneyRecord(ctx context.Context, id int64) error {
return err return err
} }
const findMoneyRecordsBySpace = `-- name: FindMoneyRecordsBySpace :many const deleteMoneyRecordByCategoryId = `-- name: DeleteMoneyRecordByCategoryId :exec
SELECT DELETE FROM money_record WHERE user_id = $1 AND category_id = $2
mr.id, mr.category_id, mr.user_id, mr.amount, mr.remark, mr.record_time, mr.create_time, mr.update_time,
u.username AS username
FROM money_record mr
INNER JOIN space_user su
ON mr.user_id = su.user_id
AND su.space_id = $1
LEFT JOIN user_info u
ON mr.user_id = u.id
WHERE mr.record_time BETWEEN $2 AND $3
ORDER BY mr.record_time DESC, mr.create_time DESC
` `
type FindMoneyRecordsBySpaceParams struct { type DeleteMoneyRecordByCategoryIdParams struct {
SpaceID int64
RecordTime pgtype.Date
RecordTime_2 pgtype.Date
}
type FindMoneyRecordsBySpaceRow struct {
ID int64
CategoryID int64
UserID int64 UserID int64
Amount pgtype.Numeric CategoryID int64
Remark pgtype.Text
RecordTime pgtype.Date
CreateTime pgtype.Timestamp
UpdateTime pgtype.Timestamp
Username pgtype.Text
} }
func (q *Queries) FindMoneyRecordsBySpace(ctx context.Context, arg FindMoneyRecordsBySpaceParams) ([]FindMoneyRecordsBySpaceRow, error) { func (q *Queries) DeleteMoneyRecordByCategoryId(ctx context.Context, arg DeleteMoneyRecordByCategoryIdParams) error {
rows, err := q.db.Query(ctx, findMoneyRecordsBySpace, arg.SpaceID, arg.RecordTime, arg.RecordTime_2) _, err := q.db.Exec(ctx, deleteMoneyRecordByCategoryId, arg.UserID, arg.CategoryID)
if err != nil { return err
return nil, err
}
defer rows.Close()
var items []FindMoneyRecordsBySpaceRow
for rows.Next() {
var i FindMoneyRecordsBySpaceRow
if err := rows.Scan(
&i.ID,
&i.CategoryID,
&i.UserID,
&i.Amount,
&i.Remark,
&i.RecordTime,
&i.CreateTime,
&i.UpdateTime,
&i.Username,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const findUserMoneyRecords = `-- name: FindUserMoneyRecords :many
SELECT mr.id, mr.category_id, mr.user_id, mr.amount, mr.remark, mr.record_time, mr.create_time, mr.update_time
FROM money_record mr
WHERE mr.user_id = $1
AND mr.record_time BETWEEN $2 AND $3
ORDER BY mr.record_time DESC, mr.create_time DESC
`
type FindUserMoneyRecordsParams struct {
UserID int64
RecordTime pgtype.Date
RecordTime_2 pgtype.Date
}
func (q *Queries) FindUserMoneyRecords(ctx context.Context, arg FindUserMoneyRecordsParams) ([]MoneyRecord, error) {
rows, err := q.db.Query(ctx, findUserMoneyRecords, arg.UserID, arg.RecordTime, arg.RecordTime_2)
if err != nil {
return nil, err
}
defer rows.Close()
var items []MoneyRecord
for rows.Next() {
var i MoneyRecord
if err := rows.Scan(
&i.ID,
&i.CategoryID,
&i.UserID,
&i.Amount,
&i.Remark,
&i.RecordTime,
&i.CreateTime,
&i.UpdateTime,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
} }
const getMoneyRecordById = `-- name: GetMoneyRecordById :one const getMoneyRecordById = `-- name: GetMoneyRecordById :one
@@ -145,7 +54,7 @@ func (q *Queries) GetMoneyRecordById(ctx context.Context, id int64) (MoneyRecord
return i, err return i, err
} }
const insertMoneyRecord = `-- name: InsertMoneyRecord :one const insertMoneyRecord = `-- name: InsertMoneyRecord :exec
INSERT INTO money_record ( INSERT INTO money_record (
id, id,
category_id, category_id,
@@ -158,7 +67,6 @@ INSERT INTO money_record (
) VALUES ( ) VALUES (
$1, $2, $3, $4, $5,$6,NOW(),NOW() $1, $2, $3, $4, $5,$6,NOW(),NOW()
) )
RETURNING id, category_id, user_id, amount, remark, record_time, create_time, update_time
` `
type InsertMoneyRecordParams struct { type InsertMoneyRecordParams struct {
@@ -170,8 +78,8 @@ type InsertMoneyRecordParams struct {
RecordTime pgtype.Date RecordTime pgtype.Date
} }
func (q *Queries) InsertMoneyRecord(ctx context.Context, arg InsertMoneyRecordParams) (MoneyRecord, error) { func (q *Queries) InsertMoneyRecord(ctx context.Context, arg InsertMoneyRecordParams) error {
row := q.db.QueryRow(ctx, insertMoneyRecord, _, err := q.db.Exec(ctx, insertMoneyRecord,
arg.ID, arg.ID,
arg.CategoryID, arg.CategoryID,
arg.UserID, arg.UserID,
@@ -179,18 +87,77 @@ func (q *Queries) InsertMoneyRecord(ctx context.Context, arg InsertMoneyRecordPa
arg.Remark, arg.Remark,
arg.RecordTime, arg.RecordTime,
) )
var i MoneyRecord return err
err := row.Scan( }
&i.ID,
&i.CategoryID, const listMoneyRecords = `-- name: ListMoneyRecords :many
&i.UserID, SELECT
&i.Amount, mr.id, mr.category_id, mr.user_id, mr.amount, mr.remark, mr.record_time, mr.create_time, mr.update_time,
&i.Remark, u.username AS username
&i.RecordTime, FROM money_record mr
&i.CreateTime, LEFT JOIN space_user su
&i.UpdateTime, ON su.user_id = mr.user_id
) LEFT JOIN "user" u
return i, err ON u.id = mr.user_id
WHERE
mr.record_time BETWEEN $2 AND $3
AND (
-- 空间账本:属于当前空间的用户
su.user_id IS NOT NULL
-- 个人账本:当前用户
OR mr.user_id = $1
)
ORDER BY
mr.record_time DESC,
mr.create_time DESC
`
type ListMoneyRecordsParams struct {
UserID int64
RecordTime pgtype.Date
RecordTime_2 pgtype.Date
}
type ListMoneyRecordsRow struct {
ID int64
CategoryID int64
UserID int64
Amount pgtype.Numeric
Remark pgtype.Text
RecordTime pgtype.Date
CreateTime pgtype.Timestamp
UpdateTime pgtype.Timestamp
Username pgtype.Text
}
func (q *Queries) ListMoneyRecords(ctx context.Context, arg ListMoneyRecordsParams) ([]ListMoneyRecordsRow, error) {
rows, err := q.db.Query(ctx, listMoneyRecords, arg.UserID, arg.RecordTime, arg.RecordTime_2)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListMoneyRecordsRow
for rows.Next() {
var i ListMoneyRecordsRow
if err := rows.Scan(
&i.ID,
&i.CategoryID,
&i.UserID,
&i.Amount,
&i.Remark,
&i.RecordTime,
&i.CreateTime,
&i.UpdateTime,
&i.Username,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
} }
const updateMoneyRecord = `-- name: UpdateMoneyRecord :exec const updateMoneyRecord = `-- name: UpdateMoneyRecord :exec
@@ -1,118 +0,0 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: user_info.sql
package repo
import (
"context"
)
const getUserByAccount = `-- name: GetUserByAccount :one
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, active_time, last_login_time
FROM user_info
WHERE account = $1
`
// 根据账号查询单条用户记录
func (q *Queries) GetUserByAccount(ctx context.Context, account string) (UserInfo, error) {
row := q.db.QueryRow(ctx, getUserByAccount, account)
var i UserInfo
err := row.Scan(
&i.ID,
&i.SeqNo,
&i.Account,
&i.Password,
&i.Email,
&i.Username,
&i.Gender,
&i.CreateTime,
&i.UpdateTime,
&i.ActiveTime,
&i.LastLoginTime,
)
return i, err
}
const getUserById = `-- name: GetUserById :one
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, active_time, last_login_time
FROM user_info
WHERE id = $1
`
// 根据 ID 查询单条用户记录
func (q *Queries) GetUserById(ctx context.Context, id int64) (UserInfo, error) {
row := q.db.QueryRow(ctx, getUserById, id)
var i UserInfo
err := row.Scan(
&i.ID,
&i.SeqNo,
&i.Account,
&i.Password,
&i.Email,
&i.Username,
&i.Gender,
&i.CreateTime,
&i.UpdateTime,
&i.ActiveTime,
&i.LastLoginTime,
)
return i, err
}
const getUserForLogin = `-- name: GetUserForLogin :one
SELECT id, seq_no, account, password, email, username, gender, create_time, update_time, active_time, last_login_time
FROM user_info
WHERE account = $1
AND password = $2
`
type GetUserForLoginParams struct {
Account string
Password string
}
// 根据账号和密码查询单条用户记录(登录用)
func (q *Queries) GetUserForLogin(ctx context.Context, arg GetUserForLoginParams) (UserInfo, error) {
row := q.db.QueryRow(ctx, getUserForLogin, arg.Account, arg.Password)
var i UserInfo
err := row.Scan(
&i.ID,
&i.SeqNo,
&i.Account,
&i.Password,
&i.Email,
&i.Username,
&i.Gender,
&i.CreateTime,
&i.UpdateTime,
&i.ActiveTime,
&i.LastLoginTime,
)
return i, err
}
const updateUserActiveTime = `-- name: UpdateUserActiveTime :exec
UPDATE user_info
SET active_time = now()
WHERE id = $1
`
// 更新用户活跃时间
func (q *Queries) UpdateUserActiveTime(ctx context.Context, id int64) error {
_, err := q.db.Exec(ctx, updateUserActiveTime, id)
return err
}
const updateUserLoginLastTime = `-- name: UpdateUserLoginLastTime :exec
UPDATE user_info
SET last_login_time = now()
WHERE id = $1
`
// 更新用户最后登录时间,并返回更新后的记录
func (q *Queries) UpdateUserLoginLastTime(ctx context.Context, id int64) error {
_, err := q.db.Exec(ctx, updateUserLoginLastTime, id)
return err
}
+2 -3
View File
@@ -7,7 +7,6 @@ option go_package = "money";
import "api.proto"; import "api.proto";
import "money/money_category_types.proto"; import "money/money_category_types.proto";
import "money/money_record_types.proto"; import "money/money_record_types.proto";
import "google/protobuf/empty.proto";
service MoneyCategoryService { service MoneyCategoryService {
rpc List(ListMoneyCategoryReq) returns (ListMoneyCategoryResp){ rpc List(ListMoneyCategoryReq) returns (ListMoneyCategoryResp){
@@ -28,8 +27,8 @@ service MoneyCategoryService {
} }
service MoneyRecordService { service MoneyRecordService {
rpc QueryMoneyRecord(QueryMoneyRecordsParams) returns (QueryMoneyRecordsResult){ rpc ListMoneyRecords(ListMoneyRecordsParams) returns (ListMoneyRecordsResult){
option (api.post) = '/money/record/query'; option (api.post) = '/money/records';
} }
rpc InsertMoneyRecord(InsertMoneyRecordParams) returns (InsertMoneyRecordResult){ rpc InsertMoneyRecord(InsertMoneyRecordParams) returns (InsertMoneyRecordResult){
option (api.post) = '/money/record/insert'; option (api.post) = '/money/record/insert';
@@ -64,15 +64,15 @@ message CreateMoneyCategoryResp {
message UpdateMoneyCategoryReq { message UpdateMoneyCategoryReq {
int64 Id = 1[ int64 Id = 1[
(api.body)="id" (api.body)="id"
];; ];
string Name = 2 [ string Name = 2 [
(api.body)="name", (api.body)="name",
(api.vd) = "$ != ''" (api.vd) = "$ != ''"
];; ];
string Icon = 3 [ string Icon = 3 [
(api.body)="icon", (api.body)="icon",
(api.vd) = "$ != ''" (api.vd) = "$ != ''"
];; ];
} }
message UpdateMoneyCategoryResp {} message UpdateMoneyCategoryResp {}
@@ -19,14 +19,13 @@ message MoneyRecord {
string Username = 9 [(api.body)="username"]; string Username = 9 [(api.body)="username"];
} }
// 查询记账记录请求参数 // 查询记账记录请求参数
message QueryMoneyRecordsParams { message ListMoneyRecordsParams {
string RecordTime = 1 [(api.body)="record_time"]; string RecordTime = 1 [(api.body)="record_time"];
} }
// 查询记账记录结果 // 查询记账记录结果
message QueryMoneyRecordsResult { message ListMoneyRecordsResult {
repeated MoneyRecord Records = 1 [(api.body)="records"]; repeated MoneyRecord Records = 1 [(api.body)="records"];
} }
@@ -46,14 +45,7 @@ message InsertMoneyRecordParams {
// 新增记账记录结果 // 新增记账记录结果
message InsertMoneyRecordResult { message InsertMoneyRecordResult {
int64 Id = 1 [(api.body)="id"];
int64 CategoryId = 2 [(api.body)="category_id"];
int64 UserId = 3 [(api.body)="user_id"];
string Amount = 4 [(api.body)="amount"];
string Remark = 5 [(api.body)="remark"];
string RecordTime = 6 [(api.body)="record_time"];
string CreateTime = 7 [(api.body)="create_time"];
string UpdateTime = 8 [(api.body)="update_time"];
} }
// 更新记账记录 // 更新记账记录
+1
View File
@@ -29,6 +29,7 @@
"expo-clipboard": "~8.0.8", "expo-clipboard": "~8.0.8",
"expo-constants": "~18.0.13", "expo-constants": "~18.0.13",
"expo-font": "~14.0.11", "expo-font": "~14.0.11",
"expo-keep-awake": "~15.0.8",
"expo-linear-gradient": "~15.0.8", "expo-linear-gradient": "~15.0.8",
"expo-linking": "~8.0.11", "expo-linking": "~8.0.11",
"expo-qq": "^0.1.6", "expo-qq": "^0.1.6",
+3
View File
@@ -65,6 +65,9 @@ importers:
expo-font: expo-font:
specifier: ~14.0.11 specifier: ~14.0.11
version: 14.0.11(expo@54.0.32)(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0) version: 14.0.11(expo@54.0.32)(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
expo-keep-awake:
specifier: ~15.0.8
version: 15.0.8(expo@54.0.32)(react@19.1.0)
expo-linear-gradient: expo-linear-gradient:
specifier: ~15.0.8 specifier: ~15.0.8
version: 15.0.8(expo@54.0.32)(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0) version: 15.0.8(expo@54.0.32)(react-native@0.81.5(@babel/core@7.28.5)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
@@ -69,16 +69,6 @@ export default function StaticTransactions({
data: group.records, data: group.records,
})) }))
if (records.length === 0) {
return (
<EmptyState
type="empty"
title="暂无记账记录"
description="快去添加你的第一笔记账吧 "
/>
)
}
return ( return (
<SectionList <SectionList
sections={sections} sections={sections}
@@ -90,6 +80,15 @@ export default function StaticTransactions({
refreshControl={ refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={handleRefresh} /> <RefreshControl refreshing={refreshing} onRefresh={handleRefresh} />
} }
ListEmptyComponent={() => (
<View className="flex-1 justify-center py-20">
<EmptyState
type="empty"
title="暂无记账记录"
description="快去添加你的第一笔记账吧"
/>
</View>
)}
renderSectionHeader={({ section }) => ( renderSectionHeader={({ section }) => (
<View className="bg-white py-2 px-4 border-b border-gray-50"> <View className="bg-white py-2 px-4 border-b border-gray-50">
<View className="flex-row items-center justify-between"> <View className="flex-row items-center justify-between">
@@ -5,7 +5,7 @@ import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
import { ADatePicker, ADrawer, AListItem, LucideIcon } from '@/components/common/ao' import { ADatePicker, ADrawer, AListItem, LucideIcon } from '@/components/common/ao'
import { Fab, FabIcon } from '@/components/ui/fab' import { Fab, FabIcon } from '@/components/ui/fab'
import { AddIcon } from '@/components/ui/icon' import { AddIcon } from '@/components/ui/icon'
import { queryMoneyRecordsApi } from '@/request/api/money/record' import { deleteMoneyRecordApi, listMoneyRecordsApi } from '@/request/api/money/record'
import { useMoneyRecordStore } from '@/store/moneyRecord' import { useMoneyRecordStore } from '@/store/moneyRecord'
import { getCurrentYearMonth } from '@/utils/time' import { getCurrentYearMonth } from '@/utils/time'
import { toast } from '@/utils/toast' import { toast } from '@/utils/toast'
@@ -26,12 +26,11 @@ export default function Money() {
// 操作菜单 // 操作菜单
const [showActionsMenu, setShowActionsMenu] = useState(false) const [showActionsMenu, setShowActionsMenu] = useState(false)
function getMoneyRecords() { function fetchMoneyRecords() {
queryMoneyRecordsApi({ listMoneyRecordsApi({
record_time: searchParams.record_time, record_time: searchParams.record_time,
}).then((res) => { }).then((res) => {
if (res.isSuccess) { if (res.isSuccess) {
console.log(res.data.records)
moneyRecordStore.setRecords(res.data.records || [], searchParams.record_time) moneyRecordStore.setRecords(res.data.records || [], searchParams.record_time)
} }
else { else {
@@ -43,18 +42,20 @@ export default function Money() {
console.log(err) console.log(err)
}) })
} }
useFocusEffect( useFocusEffect(
useCallback(() => { useCallback(() => {
// 页面显示 / 返回时 fetchMoneyRecords()
console.log('===show===') }, [searchParams.record_time]),
return () => {
// 页面离开(可选)
}
}, []),
) )
async function handleDeleteRecord(id: number) {
await deleteMoneyRecordApi({
id,
})
fetchMoneyRecords()
}
return ( return (
<View <View
className="flex-1" className="flex-1"
@@ -129,22 +130,6 @@ export default function Money() {
</Text> </Text>
</View> </View>
</View> </View>
{/* <View
className="flex-row items-center gap-3 mt-2"
style={{
borderBottomLeftRadius: 8,
borderBottomRightRadius: 8,
}}
>
<Text className="text-sm text-gray-600 text-right">预算</Text>
<View className="flex-1">
<Progress size="sm">
<ProgressFilledTrack />
</Progress>
</View>
<Text className="text-xs text-blue-500">点击设置</Text>
</View> */}
</View> </View>
</View> </View>
@@ -164,10 +149,10 @@ export default function Money() {
}) })
}} }}
onDelete={(id) => { onDelete={(id) => {
moneyRecordStore.deleteMoneyRecord(id) handleDeleteRecord(id)
}} }}
onRefreshData={() => { onRefreshData={() => {
getMoneyRecords() fetchMoneyRecords()
}} }}
/> />
</View> </View>
+137 -137
View File
@@ -1,7 +1,7 @@
import { useEvent } from 'expo' import { useEvent } from 'expo'
// import ExpoQQ from 'expo-qq' import ExpoQQ from 'expo-qq'
import { useRouter } from 'expo-router' import { useRouter } from 'expo-router'
// import ExpoWeChat from 'expo-wechat' import ExpoWeChat from 'expo-wechat'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { Image, Text, View } from 'react-native' import { Image, Text, View } from 'react-native'
import { AButton, ACheckbox } from '@/components/common/ao' import { AButton, ACheckbox } from '@/components/common/ao'
@@ -23,167 +23,167 @@ export default function Auth() {
const router = useRouter() const router = useRouter()
const userStore = useUserStore() const userStore = useUserStore()
// const onLoginFinished = useEvent(ExpoQQ, 'onLoginFinished') const onLoginFinished = useEvent(ExpoQQ, 'onLoginFinished')
// const onGetUserInfo = useEvent(ExpoQQ, 'onGetUserInfo') const onGetUserInfo = useEvent(ExpoQQ, 'onGetUserInfo')
// const authResult = useEvent(ExpoWeChat, 'onAuthResult') const authResult = useEvent(ExpoWeChat, 'onAuthResult')
// async function onQQLogin() { async function onQQLogin() {
// setLoading(true) setLoading(true)
// setForm(val => ({ setForm(val => ({
// ...val, ...val,
// type: 1, type: 1,
// })) }))
// await ExpoQQ.login(['get_user_info']) await ExpoQQ.login(['get_user_info'])
// } }
// async function onWeChatLogin() { async function onWeChatLogin() {
// setLoading(true) setLoading(true)
// // 检查微信是否安装 // 检查微信是否安装
// const isInstalled = await ExpoWeChat.isWXAppInstalled() const isInstalled = await ExpoWeChat.isWXAppInstalled()
// if (!isInstalled) { if (!isInstalled) {
// toast.show({ toast.show({
// title: onLoginFinished?.errorMessage || '请先安装微信', title: onLoginFinished?.errorMessage || '请先安装微信',
// }) })
// setLoading(false) setLoading(false)
// return return
// } }
// setForm(val => ({ setForm(val => ({
// ...val, ...val,
// type: 0, type: 0,
// })) }))
// ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123') ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123')
// } }
// useEffect(() => { useEffect(() => {
// ExpoQQ.init('102826474', '') ExpoQQ.init('102826474', '')
// ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '') ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '')
// }, []) }, [])
// useEffect(() => { useEffect(() => {
// if (!onLoginFinished) { if (!onLoginFinished) {
// return return
// } }
// if (!onLoginFinished.success) { if (!onLoginFinished.success) {
// toast.show({ toast.show({
// title: onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权', title: onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
// }) })
// setLoading(false) setLoading(false)
// return return
// } }
// const fetchUserInfo = async () => { const fetchUserInfo = async () => {
// try { try {
// const tokenInfo = await ExpoQQ.getLoginTokenInfo() const tokenInfo = await ExpoQQ.getLoginTokenInfo()
// if (!tokenInfo.openId) { if (!tokenInfo.openId) {
// toast.show({ toast.show({
// title: tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权', title: tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
// }) })
// setLoading(false) setLoading(false)
// return return
// } }
// setForm(val => ({ setForm(val => ({
// ...val, ...val,
// openid: String(tokenInfo.openId), openid: String(tokenInfo.openId),
// })) }))
// await ExpoQQ.sendGetUserInfoReq() await ExpoQQ.sendGetUserInfoReq()
// } }
// catch (e) { catch (e) {
// console.error('QQ 登录未完成', e) console.error('QQ 登录未完成', e)
// setLoading(false) setLoading(false)
// } }
// } }
// fetchUserInfo() fetchUserInfo()
// }, [onLoginFinished]) }, [onLoginFinished])
// // QQ登录 // QQ登录
// useEffect(() => { useEffect(() => {
// const handleLogin = async () => { const handleLogin = async () => {
// if (!onGetUserInfo) if (!onGetUserInfo)
// return return
// try { try {
// const loginRes = await loginQqApi({ const loginRes = await loginQqApi({
// openid: form.openid, openid: form.openid,
// username: onGetUserInfo.nickname || '', username: onGetUserInfo.nickname || '',
// avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2, avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
// }) })
// if (loginRes.isSuccess) { if (loginRes.isSuccess) {
// userStore.setUserInfo({ userStore.setUserInfo({
// token: loginRes.data.token, token: loginRes.data.token,
// id: loginRes.data.userId, id: loginRes.data.userId,
// username: loginRes.data.username, username: loginRes.data.username,
// avatar: loginRes.data.avatar, avatar: loginRes.data.avatar,
// }) })
// console.log(loginRes.data.token) console.log(loginRes.data.token)
// router.push('/') router.push('/')
// } }
// } }
// catch (err) { catch (err) {
// console.error('登录接口出错', err) console.error('登录接口出错', err)
// } }
// finally { finally {
// setLoading(false) setLoading(false)
// } }
// } }
// handleLogin() handleLogin()
// }, [onGetUserInfo]) }, [onGetUserInfo])
// // 微信登录 // 微信登录
// useEffect(() => { useEffect(() => {
// if (!authResult) if (!authResult)
// return return
// const handleLogin = async () => { const handleLogin = async () => {
// if (authResult.errorCode === 0) { if (authResult.errorCode === 0) {
// try { try {
// const loginRes = await loginWxApi({ const loginRes = await loginWxApi({
// code: authResult.code, code: authResult.code,
// }) })
// if (loginRes.isSuccess) { if (loginRes.isSuccess) {
// userStore.setUserInfo({ userStore.setUserInfo({
// token: loginRes.data.token, token: loginRes.data.token,
// id: loginRes.data.userId, id: loginRes.data.userId,
// username: loginRes.data.username, username: loginRes.data.username,
// avatar: loginRes.data.avatar, avatar: loginRes.data.avatar,
// }) })
// router.push('/') router.push('/')
// } }
// } }
// catch (err) { catch (err) {
// console.error('登录接口出错', err) console.error('登录接口出错', err)
// } }
// finally { finally {
// setLoading(false) setLoading(false)
// } }
// } }
// else { else {
// console.log('授权失败:', authResult.errorMessage) console.log('授权失败:', authResult.errorMessage)
// setLoading(false) setLoading(false)
// } }
// } }
// handleLogin() handleLogin()
// }, [authResult]) }, [authResult])
function testLogin() { function testLogin() {
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs
userStore.setUserInfo({ userStore.setUserInfo({
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs', token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3Njc4NjM3NTU5MzE3MTcsImlhdCI6MTc2OTYwMzEzOX0.xfW-uyFBi799u4VJ-93A88c2CC8jwpYOPsALUuaIizg',
id: 766785982165061, id: 767863755931717,
username: 'Zhang', username: 'Zhang',
avatar: 'http://thirdqq.qlogo.cn/ek_qqapp/AQHVialeUibE42oV8RvTTVZ4tyRlPYeJrUibWTwtCPfV68E4rSzn9cw00GkXQ3QDTiawwhjoqQb7/100', avatar: 'http://thirdqq.qlogo.cn/ek_qqapp/AQHVialeUibE42oV8RvTTVZ4tyRlPYeJrUibWTwtCPfV68E4rSzn9cw00GkXQ3QDTiawwhjoqQb7/100',
}) })
@@ -208,7 +208,7 @@ export default function Auth() {
</View> </View>
<View className="flex flex-col gap-4"> <View className="flex flex-col gap-4">
{/* <AButton <AButton
leftIcon={ leftIcon={
<IconWeixin color="#fff" /> <IconWeixin color="#fff" />
} }
@@ -227,7 +227,7 @@ export default function Auth() {
onPress={onQQLogin} onPress={onQQLogin}
> >
QQ QQ
</AButton> */} </AButton>
<AButton <AButton
variant="outline" variant="outline"
@@ -33,10 +33,10 @@ export default function CreateCategory({
const [form, setForm] = useState<EditCategoryForm>({ icon: '', name: '' }) const [form, setForm] = useState<EditCategoryForm>({ icon: '', name: '' })
const [confirmDisabled, setConfirmDisabled] = useState(true) const [confirmDisabled, setConfirmDisabled] = useState(true)
const [confirmLoading, setConfirmLoading] = useState(false) const [confirmLoading, setConfirmLoading] = useState(false)
const flatListData = Object.entries(moneyCategoryStore.ICON_GROUPS)
const flatListData2 = Object.values(moneyCategoryStore.ICON_GROUPS).flat()
const scrollRef = useRef<any>(null) const flatListRef = useRef<FlatList<any>>(null)
const iconPositions = useRef<Record<string, number>>({}) // 记录每个 icon 的 y 坐标
// Drawer 打开/关闭控制 // Drawer 打开/关闭控制
useEffect(() => { useEffect(() => {
setIsOpen(open) setIsOpen(open)
@@ -47,6 +47,22 @@ export default function CreateCategory({
// 确认按钮状态 // 确认按钮状态
useEffect(() => { useEffect(() => {
setConfirmDisabled(!(form.name && form.name.length <= 5 && form.icon)) setConfirmDisabled(!(form.name && form.name.length <= 5 && form.icon))
const itemIndex = flatListData2.findIndex(item => item === form.icon)
if (itemIndex === -1 || !flatListRef.current)
return
if (form.icon) {
setTimeout(() => {
if (flatListRef.current) {
flatListRef.current.scrollToIndex({
index: Math.floor(itemIndex / 5),
animated: true,
viewPosition: 0.5,
})
}
}, 0)
}
}, [form.name, form.icon]) }, [form.name, form.icon])
// 编辑已有分类时填充数据 // 编辑已有分类时填充数据
@@ -61,62 +77,55 @@ export default function CreateCategory({
onClose?.() onClose?.()
} }
// 缓存点击 Icon 的回调 // 渲染每组 Icon
const handlePressIcon = useCallback(
(icon: string) => {
setForm(v => ({ ...v, icon }))
},
[setForm],
)
// Memo 化单个 IconItem,避免重复渲染
const IconItem = useCallback(({ icon, selected }: { icon: string, selected: boolean }) => {
return (
<Pressable
className="w-1/5 mb-3 flex items-center"
onPress={() => handlePressIcon(icon)}
>
<View
style={{
width: 46,
height: 46,
borderRadius: 28,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: selected ? '#333' : '#F3F4F6',
}}
>
<MoneyCategoryIcon
name={icon}
size={32}
color={selected ? '#fff' : '#000'}
/>
</View>
</Pressable>
)
}, [handlePressIcon])
// Memo 化渲染每组 Icon 的组件
const renderGroup = useCallback( const renderGroup = useCallback(
({ item }: { item: [string, string[]] }) => { ({ item }: { item: [string, string[]] }) => {
const [groupName, icons] = item const [groupName, icons] = item
return ( return (
<View className="mb-4"> <View className="mb-4">
<Text className="text-center text-sm mb-3">{groupName}</Text> <Text className="text-center text-sm mb-3">{groupName}</Text>
<View className="flex flex-row flex-wrap"> <View className="flex flex-row flex-wrap">
{icons.map(icon => ( {icons.map((icon) => {
<IconItem key={icon} icon={icon} selected={form.icon === icon} /> const selected = form.icon === icon
))}
return (
<Pressable
key={icon}
className="w-1/5 mb-3 flex items-center"
onPress={() =>
setForm(v => ({
...v,
icon,
}))}
>
<View
style={{
width: 46,
height: 46,
borderRadius: 28,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: selected ? '#333' : '#F3F4F6',
}}
>
<MoneyCategoryIcon
name={icon}
size={32}
color={selected ? '#fff' : '#000'}
/>
</View>
</Pressable>
)
})}
</View> </View>
</View> </View>
) )
}, },
[IconItem, form.icon], [form.icon],
) )
// 使用 useMemo 缓存 FlatList 的数据
const flatListData = useMemo(() => Object.entries(moneyCategoryStore.ICON_GROUPS), [moneyCategoryStore.ICON_GROUPS])
return ( return (
<ADrawer <ADrawer
visible={isOpen} visible={isOpen}
@@ -153,10 +162,13 @@ export default function CreateCategory({
)} )}
> >
<FlatList <FlatList
ref={scrollRef} ref={flatListRef}
data={flatListData} data={flatListData}
keyExtractor={([groupName]) => groupName} keyExtractor={([groupName]) => groupName}
renderItem={renderGroup} renderItem={renderGroup}
getItemLayout={(data, index) => {
return { length: 80, offset: 80 * index, index }
}}
/> />
</ADrawer> </ADrawer>
) )
@@ -88,13 +88,6 @@ export default function MoenyRecordEditor() {
record_time: moneyRecord.record_time, record_time: moneyRecord.record_time,
}).then((res) => { }).then((res) => {
if (res.isSuccess) { if (res.isSuccess) {
const result: MoneyRecord = {
...moneyRecord,
category_id: selectedCategory.id,
}
moneyRecordStore.updateMoneyRecord(result)
router.back() router.back()
} }
}).catch((err) => { }).catch((err) => {
@@ -110,13 +103,6 @@ export default function MoenyRecordEditor() {
}) })
.then((res) => { .then((res) => {
if (res.isSuccess) { if (res.isSuccess) {
const result: MoneyRecord = {
...res.data,
category_id: selectedCategory.id,
}
moneyRecordStore.addMoneyRecord(result)
router.back() router.back()
} }
else { else {
@@ -1,4 +1,4 @@
import type { SpaceUser } from '@/types/space/spaceUser' import type { SpaceUser } from '@/types/space/space'
import * as Clipboard from 'expo-clipboard' import * as Clipboard from 'expo-clipboard'
import { useState } from 'react' import { useState } from 'react'
import { FlatList, TouchableHighlight, TouchableOpacity, View } from 'react-native' import { FlatList, TouchableHighlight, TouchableOpacity, View } from 'react-native'
@@ -10,7 +10,7 @@ import {
renderers, renderers,
} from 'react-native-popup-menu' } from 'react-native-popup-menu'
import QRCode from 'react-native-qrcode-svg' import QRCode from 'react-native-qrcode-svg'
import { AButton, ADivider, LucideIcon } from '@/components/common/ao' import { AAvatar, AButton, ADivider, LucideIcon } from '@/components/common/ao'
import { AModal } from '@/components/common/ao/index' import { AModal } from '@/components/common/ao/index'
import { import {
Accordion, Accordion,
@@ -21,19 +21,14 @@ import {
AccordionTitleText, AccordionTitleText,
AccordionTrigger, AccordionTrigger,
} from '@/components/ui/accordion' } from '@/components/ui/accordion'
import {
Avatar,
AvatarBadge,
AvatarFallbackText,
} from '@/components/ui/avatar'
import { Badge, BadgeText } from '@/components/ui/badge' import { Badge, BadgeText } from '@/components/ui/badge'
import { Heading } from '@/components/ui/heading' import { Heading } from '@/components/ui/heading'
import { HStack } from '@/components/ui/hstack' import { HStack } from '@/components/ui/hstack'
import { ChevronDownIcon, ChevronUpIcon } from '@/components/ui/icon' import { ChevronDownIcon, ChevronUpIcon } from '@/components/ui/icon'
import { Text } from '@/components/ui/text' import { Text } from '@/components/ui/text'
import { VStack } from '@/components/ui/vstack' import { VStack } from '@/components/ui/vstack'
import { dissolveSpaceApi } from '@/request/api/space/space' import { dissolveSpaceApi, exitSpaceApi, removeSpaceUserApi } from '@/request/api/space/space'
import { exitSpaceApi, removeSpaceUserApi } from '@/request/api/space/spaceUser'
import { useUserStore } from '@/store/user' import { useUserStore } from '@/store/user'
import { formatRelativeTime } from '@/utils/time' import { formatRelativeTime } from '@/utils/time'
import { toast } from '@/utils/toast' import { toast } from '@/utils/toast'
@@ -86,7 +81,9 @@ export default function SpaceInvite({
} }
if (modal.type === 'exit') { if (modal.type === 'exit') {
// 退出 // 退出
exitSpaceApi({}).catch((err) => { exitSpaceApi({
space_id: userSpace.id,
}).catch((err) => {
console.log(err) console.log(err)
}) })
} }
@@ -96,6 +93,7 @@ export default function SpaceInvite({
} }
// 移除 // 移除
removeSpaceUserApi({ removeSpaceUserApi({
space_id: userSpace.id,
user_id: modal.userId, user_id: modal.userId,
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
@@ -103,7 +101,9 @@ export default function SpaceInvite({
} }
else { else {
// 解散 // 解散
dissolveSpaceApi({}).catch((err) => { dissolveSpaceApi({
space_id: userSpace.id,
}).catch((err) => {
console.log(err) console.log(err)
}) })
} }
@@ -177,7 +177,7 @@ export default function SpaceInvite({
<ADivider direction="horizontal" text="扫描二维码" /> <ADivider direction="horizontal" text="扫描二维码" />
<QRCode <QRCode
size={120} size={120}
value={userSpace?.invite_code} value={userSpace?.invite_code || ''}
/> />
</View> </View>
</AccordionContent> </AccordionContent>
@@ -198,26 +198,21 @@ export default function SpaceInvite({
<View> <View>
<FlatList <FlatList
data={spaceUsers} data={spaceUsers}
keyExtractor={item => item.user_id.toString()} keyExtractor={item => item.id.toString()}
renderItem={({ item }) => ( renderItem={({ item }) => (
<TouchableOpacity> <TouchableOpacity>
<HStack space="md" className="my-2 items-center"> <HStack space="md" className="my-2 items-center">
<Avatar className="bg-indigo-600"> <AAvatar avatar={item.avatar} username={item.username} showBadge={true} />
<AvatarFallbackText className="text-white text-2xl">
{item.username}
</AvatarFallbackText>
<AvatarBadge />
</Avatar>
<VStack> <VStack>
<HStack space="sm"> <HStack space="sm">
<Heading size="sm">{item.username}</Heading> <Heading size="sm">{item.username}</Heading>
{item.space_role === 0 && ( {item.role === 0 && (
<Badge size="sm" variant="solid" action="muted"> <Badge size="sm" variant="solid" action="muted">
<BadgeText>创建者</BadgeText> <BadgeText>创建者</BadgeText>
</Badge> </Badge>
)} )}
{ {
userStore.userInfo?.id === item.user_id && ( userStore.userInfo?.id === item.id && (
<Badge size="sm" variant="solid" action="info"> <Badge size="sm" variant="solid" action="info">
<BadgeText> <BadgeText>
我 我
@@ -226,7 +221,7 @@ export default function SpaceInvite({
) )
} }
</HStack> </HStack>
<Text size="sm" className="mt-1">{formatRelativeTime(item.active_time)}</Text> <Text size="sm" className="mt-1">{formatRelativeTime(item.last_login_time)}</Text>
</VStack> </VStack>
{userSpace?.role === 0 && ( {userSpace?.role === 0 && (
@@ -253,7 +248,7 @@ export default function SpaceInvite({
}, },
}} }}
> >
{userSpace.role === 0 && userStore.userInfo?.id !== item.user_id && ( {userSpace.role === 0 && userStore.userInfo?.id !== item.id && (
<MenuOption <MenuOption
customStyles={{ customStyles={{
OptionTouchableComponent: TouchableHighlight, OptionTouchableComponent: TouchableHighlight,
@@ -268,7 +263,7 @@ export default function SpaceInvite({
open: true, open: true,
title: `确定将 ${item.username} 提出空间?`, title: `确定将 ${item.username} 提出空间?`,
type: 'remove', type: 'remove',
userId: item.user_id, userId: item.id,
}) })
}} }}
> >
@@ -1,10 +1,10 @@
import type { SpaceUser } from '@/types/space/spaceUser' import type { SpaceUser } from '@/types/space/space'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { View } from 'react-native' import { View } from 'react-native'
import CustomHeader from '@/components/custom/Header' import CustomHeader from '@/components/custom/Header'
import { createSpaceApi } from '@/request/api/space/space' import { createSpaceApi, joinSpaceApi, listSpaceUsersApi } from '@/request/api/space/space'
import { getUserSpaceApi, joinSpaceApi, listSpaceUsersApi } from '@/request/api/space/spaceUser'
import { useSpaceStore } from '@/store/space' import { useSpaceStore } from '@/store/space'
import { useUserStore } from '@/store/user'
import JoinSpace from './components/JoinSpace' import JoinSpace from './components/JoinSpace'
import SpaceHome from './components/SpaceHome' import SpaceHome from './components/SpaceHome'
import SpaceInvite from './components/SpaceInvite' import SpaceInvite from './components/SpaceInvite'
@@ -12,71 +12,73 @@ import StepFade from './components/StepFade'
export default function PagerWithTab() { export default function PagerWithTab() {
const spaceStore = useSpaceStore() const spaceStore = useSpaceStore()
const userStore = useUserStore()
const [headerTitle, setHeaderTitle] = useState('我的空间')
const [step, setStep] = useState<'join' | 'invite' | 'home'>('home') const [step, setStep] = useState<'join' | 'invite' | 'home'>('home')
const [spaceUsers, setSpaceUsers] = useState<SpaceUser[]>([]) const [spaceUsers, setSpaceUsers] = useState<SpaceUser[]>([])
const fetchData = async () => { // 封装获取空间用户列表并直接更新状态
await Promise.all([ const fetchSpaceUsers = async (spaceId: number) => {
getUserSpaceApi() try {
.then((res) => { const res = await listSpaceUsersApi({ space_id: spaceId })
if (res.isSuccess) { if (res.isSuccess) {
if (res.data === null) { setSpaceUsers(res.data.users)
spaceStore.setUserSpace(null) console.log(res.data.users)
setStep('home') }
} else {
else { console.warn('获取空间用户失败')
spaceStore.setUserSpace({ setSpaceUsers([])
space_id: res.data.space_id, }
space_name: res.data.space_name, }
role: res.data.role, catch (err) {
invite_code: res.data.invite_code, console.error('listSpaceUsersApi error:', err)
}) setSpaceUsers([])
setStep('invite') }
}
}
else {
// 提示
}
})
.catch(err => console.error('getUserSpaceApi error:', err)),
listSpaceUsersApi({})
.then((res) => {
if (res.isSuccess) {
setSpaceUsers(res.data.users)
}
else {
// 提示
}
})
.catch(err => console.error('listSpaceUsersApi error:', err)),
])
} }
// 页面加载时判断并拉取用户列表
useEffect(() => { useEffect(() => {
fetchData() const loadSpaceUsers = () => {
if (spaceStore.userSpace !== null) {
setStep('invite')
fetchSpaceUsers(spaceStore.userSpace.id)
}
else {
setStep('home')
}
}
loadSpaceUsers()
}, []) }, [])
useEffect(() => {
if (spaceStore.userSpace) {
setHeaderTitle(spaceStore.userSpace.name || '我的空间')
}
else {
setHeaderTitle('我的空间')
}
}, [spaceStore.userSpace])
function getSpaceName() {
const username = userStore.userInfo?.username
return username ? `${username}的空间` : '我的空间'
}
function createSpace() { function createSpace() {
createSpaceApi({}).then((res) => { createSpaceApi({
name: getSpaceName(),
}).then((res) => {
if (res.isSuccess) { if (res.isSuccess) {
spaceStore.setUserSpace({ spaceStore.setUserSpace({
space_id: res.data.id, id: res.data.space_id,
space_name: '', name: getSpaceName(),
role: 0, role: 0,
invite_code: res.data.invite_code, invite_code: res.data.invite_code,
}) })
listSpaceUsersApi({}) fetchSpaceUsers(res.data.space_id)
.then((res) => {
if (res.isSuccess) {
setSpaceUsers(res.data.users)
}
else {
// 提示
}
})
.catch(err => console.error('listSpaceUsersApi error:', err))
setStep('invite') setStep('invite')
} }
}).catch((err) => { }).catch((err) => {
@@ -89,7 +91,14 @@ export default function PagerWithTab() {
invite_code: code, invite_code: code,
}).then((res) => { }).then((res) => {
if (res.isSuccess) { if (res.isSuccess) {
fetchData() spaceStore.setUserSpace({
id: res.data.space_id,
name: res.data.space_name,
invite_code: code,
role: 0,
})
setStep('invite')
fetchSpaceUsers(res.data.space_id)
} }
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
@@ -98,7 +107,7 @@ export default function PagerWithTab() {
return ( return (
<View className="flex-1"> <View className="flex-1">
<CustomHeader title="共享空间" /> <CustomHeader title={headerTitle} />
<View className="flex-1"> <View className="flex-1">
<StepFade visible={step === 'home'}> <StepFade visible={step === 'home'}>
<SpaceHome <SpaceHome
@@ -129,12 +138,13 @@ export default function PagerWithTab() {
onExit={(data) => { onExit={(data) => {
if (data.type === 'remove' && data.userId !== undefined) { if (data.type === 'remove' && data.userId !== undefined) {
setSpaceUsers(prevUsers => setSpaceUsers(prevUsers =>
prevUsers.filter(user => user.user_id !== data.userId), prevUsers.filter(user => user.id !== data.userId),
) )
return return
} }
setStep('home') setStep('home')
spaceStore.setUserSpace(null) spaceStore.clear()
setSpaceUsers([]) setSpaceUsers([])
}} }}
/> />
@@ -0,0 +1,52 @@
import type { StyleProp, ViewStyle } from 'react-native'
import React from 'react'
import {
AvatarBadge,
AvatarFallbackText,
AvatarImage,
Avatar as NativeAvatar,
} from '@/components/ui/avatar'
interface AvatarProps {
username?: string
avatar?: string
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
showBadge?: boolean
className?: string
style?: StyleProp<ViewStyle>
badgeClassName?: string
badgeStyle?: StyleProp<ViewStyle>
}
export const Avatar: React.FC<AvatarProps> = ({
username = '',
avatar,
size,
showBadge,
className = '',
style,
badgeClassName,
badgeStyle,
}) => {
return (
<NativeAvatar
size={size}
className={`${!avatar ? 'bg-indigo-600' : ''} ${className}`}
style={style}
>
{avatar
? (
<AvatarImage source={{ uri: avatar }} />
)
: (
<AvatarFallbackText className="text-white text-2xl">
{username[0] ?? ''}
</AvatarFallbackText>
)}
{showBadge && (
<AvatarBadge className={badgeClassName} style={badgeStyle} />
)}
</NativeAvatar>
)
}
@@ -2,7 +2,6 @@ import type { ReactNode } from 'react'
import type { DimensionValue, ViewStyle } from 'react-native' import type { DimensionValue, ViewStyle } from 'react-native'
import React, { useEffect, useMemo, useState } from 'react' import React, { useEffect, useMemo, useState } from 'react'
import { Dimensions, StyleSheet, Text, View } from 'react-native' import { Dimensions, StyleSheet, Text, View } from 'react-native'
import { Gesture, GestureDetector } from 'react-native-gesture-handler'
import Animated, { import Animated, {
interpolate, interpolate,
runOnJS, runOnJS,
@@ -103,24 +102,6 @@ export default function Drawer({
opacity: interpolate(progress.value, [0, 1], [0, 0.45], 'clamp'), opacity: interpolate(progress.value, [0, 1], [0, 0.45], 'clamp'),
})) }))
/* ================= 手势(只给 bottom) ================= */
const pan = Gesture.Pan()
.onUpdate((e) => {
if (menuPosition === 'bottom' && e.translationY > 0) {
drag.value = e.translationY
}
})
.onEnd(() => {
if (menuPosition === 'bottom' && drag.value > 120) {
progress.value = withTiming(0, { duration }, () => {
drag.value = 0
runOnJS(hideModal)()
})
}
else {
drag.value = withTiming(0)
}
})
if (!innerVisible) if (!innerVisible)
return null return null
@@ -135,34 +116,32 @@ export default function Drawer({
{/* Drawer */} {/* Drawer */}
<View style={[styles.drawerBox, drawerBox]}> <View style={[styles.drawerBox, drawerBox]}>
<GestureDetector gesture={pan}> <Animated.View
<Animated.View style={[
style={[ styles.drawer,
styles.drawer, drawerStyle,
drawerStyle, {
{ borderTopLeftRadius: isCircle ? CircleNum : 0,
borderTopLeftRadius: isCircle ? CircleNum : 0, borderTopRightRadius: isCircle ? CircleNum : 0,
borderTopRightRadius: isCircle ? CircleNum : 0, },
}, ]}
]} >
> {showHeader && (
{showHeader && ( header ?? (
header ?? ( <View style={styles.headTitle}>
<View style={styles.headTitle}> <Text style={styles.title}>{title}</Text>
<Text style={styles.title}>{title}</Text> <LucideIcon
<LucideIcon icon="X"
icon="X" size={22}
size={22} style={styles.close}
style={styles.close} onPress={hideModal}
onPress={hideModal} />
/> </View>
</View> )
) )}
)}
{children} {children}
</Animated.View> </Animated.View>
</GestureDetector>
</View> </View>
</View> </View>
) )
@@ -1,9 +1,10 @@
import { Avatar } from './Avatar'
import Button from './Button' import Button from './Button'
import { Cell, CellGroup } from './Cell' import { Cell, CellGroup } from './Cell'
import Checkbox from './Checkbox' import Checkbox from './Checkbox'
import DatePicker from './DatePicker' import DatePicker from './DatePicker'
import Divider from './Divider'
import Divider from './Divider'
import Drawer from './Drawer' import Drawer from './Drawer'
import Form, { FormRef } from './Form' import Form, { FormRef } from './Form'
import FormItem from './FormItem' import FormItem from './FormItem'
@@ -12,9 +13,11 @@ import ListItem from './ListItem'
import LucideIcon from './LucideIcon' import LucideIcon from './LucideIcon'
import Modal from './Modal' import Modal from './Modal'
import SegmentedTabs from './SegmentedTabs' import SegmentedTabs from './SegmentedTabs'
import Tab from './Tab' import Tab from './Tab'
export { export {
Avatar as AAvatar,
Button as AButton, Button as AButton,
Cell as ACell, Cell as ACell,
CellGroup as ACellGroup, CellGroup as ACellGroup,
@@ -2,27 +2,27 @@ import type {
DeleteMoneyRecordParams, DeleteMoneyRecordParams,
InsertMoneyRecordParams, InsertMoneyRecordParams,
InsertMoneyRecordResult, InsertMoneyRecordResult,
QueryMoneyRecordsParams, ListMoneyRecordsParams,
QueryMoneyRecordsResult, ListMoneyRecordsResult,
UpdateMoneyRecordParams, UpdateMoneyRecordParams,
} from '@/types/money/record' } from '@/types/money/record'
import alovaInstance from '../../index' import alovaInstance from '../../index'
const API_PREFIX = '/money/record' const API_PREFIX = '/money'
export function queryMoneyRecordsApi(params: QueryMoneyRecordsParams) { export function listMoneyRecordsApi(params: ListMoneyRecordsParams) {
return alovaInstance.Post<ResponseData<QueryMoneyRecordsResult>>(`${API_PREFIX}/query`, params) return alovaInstance.Post<ResponseData<ListMoneyRecordsResult>>(`${API_PREFIX}/records`, params)
} }
export function insertMoneyRecordApi(params: InsertMoneyRecordParams) { export function insertMoneyRecordApi(params: InsertMoneyRecordParams) {
return alovaInstance.Post<ResponseData<InsertMoneyRecordResult>>(`${API_PREFIX}/insert`, params) return alovaInstance.Post<ResponseData<InsertMoneyRecordResult>>(`${API_PREFIX}/record/insert`, params)
} }
export function updateMoneyRecordApi(params: UpdateMoneyRecordParams) { export function updateMoneyRecordApi(params: UpdateMoneyRecordParams) {
return alovaInstance.Post<ResponseData<any>>(`${API_PREFIX}/update`, params) return alovaInstance.Post<ResponseData<any>>(`${API_PREFIX}/record/update`, params)
} }
export function deleteMoneyRecordApi(params: DeleteMoneyRecordParams) { export function deleteMoneyRecordApi(params: DeleteMoneyRecordParams) {
return alovaInstance.Post<ResponseData<any>>(`${API_PREFIX}/delete`, params) return alovaInstance.Post<ResponseData<any>>(`${API_PREFIX}/record/delete`, params)
} }
@@ -4,5 +4,5 @@ import alovaInstance from '../index'
const API_PREFIX = '/user' const API_PREFIX = '/user'
export function getUserSpaceApi() { export function getUserSpaceApi() {
return alovaInstance.Post<ResponseData<UserSpace>>(`${API_PREFIX}/space`) return alovaInstance.Get<ResponseData<UserSpace>>(`${API_PREFIX}/space`)
} }
+3 -27
View File
@@ -1,10 +1,8 @@
import type { Method } from 'alova' import type { Method } from 'alova'
import type { AxiosError } from 'axios' import type { AxiosError } from 'axios'
import type { ListUserSpacesResult } from '@/types/user'
import { axiosRequestAdapter } from '@alova/adapter-axios' import { axiosRequestAdapter } from '@alova/adapter-axios'
import { createAlova } from 'alova' import { createAlova } from 'alova'
import { useNavStore } from '@/store/navigation' import { useNavStore } from '@/store/navigation'
import { useSpaceStore } from '@/store/space'
import { useUserStore } from '@/store/user' import { useUserStore } from '@/store/user'
import { toast } from '@/utils/toast' import { toast } from '@/utils/toast'
@@ -12,8 +10,6 @@ enum HttpCode {
Success = 200, Success = 200,
Unauthorized = 401, Unauthorized = 401,
Fail = 500, Fail = 500,
ErrSpaceRequired = 501,
ErrSpaceNoPermission = 502,
} }
// 仅保留「无需登录」接口 // 仅保留「无需登录」接口
@@ -52,29 +48,15 @@ const alovaInstance = createAlova({
useNavStore.getState().navigateToAuth() useNavStore.getState().navigateToAuth()
return Promise.reject(new Error('登录已失效')) return Promise.reject(new Error('登录已失效'))
} }
else if (resData.code === HttpCode.ErrSpaceRequired || resData.code === HttpCode.ErrSpaceNoPermission) {
if (method.meta?.spaceRetried)
return Promise.reject(new Error('space retry failed'))
method.meta = { ...method.meta, spaceRetried: true }
const res = await alovaInstance.Post<ResponseData<ListUserSpacesResult>>('/user/spaces').send()
if (!res.isSuccess || res.data.spaces.length === 0)
return Promise.reject(new Error('没有可用空间,请刷新后再试'))
const defaultSpace = res.data.spaces[0]
useSpaceStore.getState().setUserSpace(defaultSpace)
method.config.headers['X-Space-Id'] = defaultSpace.id
return method.send()
}
return result return result
}, },
onError: (error: AxiosError) => { onError: (error: AxiosError) => {
const status = error.status const status = error.status
const config = error.config
console.warn(`[HTTP ${status}] ${config?.method?.toUpperCase()} ${config?.url}`)
switch (status) { switch (status) {
case 400: case 400:
@@ -125,12 +107,6 @@ const alovaInstance = createAlova({
// 注入 JWT // 注入 JWT
method.config.headers.Token = userStore.userInfo!.token method.config.headers.Token = userStore.userInfo!.token
// 注入 space 信息(如果存在)
const userSpace = useSpaceStore.getState().userSpace
if (userSpace) {
method.config.headers['X-Space-Id'] = userSpace.id
}
}, },
}) })
+5 -2
View File
@@ -26,18 +26,20 @@ export const useAppStore = create<AppState>((set, get) => ({
const moneyCategoryStore = useMoneyCategoryStore.getState() const moneyCategoryStore = useMoneyCategoryStore.getState()
const spaceStore = useSpaceStore.getState() const spaceStore = useSpaceStore.getState()
// 如果没登录,跳转到登录页,但不退出初始化
if (!userStore.isLoggedIn()) { if (!userStore.isLoggedIn()) {
navStore.navigateToAuth() navStore.navigateToAuth()
set({ ready: true })
return return
} }
try { try {
// 分类初始化 // 初始化分类
await moneyCategoryStore.init() await moneyCategoryStore.init()
// 获取空间信息 // 获取空间信息
const res = await getUserSpaceApi() const res = await getUserSpaceApi()
console.log(res.data)
spaceStore.setUserSpace(res.data) spaceStore.setUserSpace(res.data)
} }
catch (err) { catch (err) {
@@ -47,6 +49,7 @@ export const useAppStore = create<AppState>((set, get) => ({
// 初始化完成 // 初始化完成
set({ ready: true }) set({ ready: true })
}, },
reset: () => { reset: () => {
set({ ready: false }) set({ ready: false })
@@ -1,6 +1,5 @@
import type { MoneyRecord, MoneyRecordGroup } from '@/types/money/record' import type { MoneyRecord, MoneyRecordGroup } from '@/types/money/record'
import { create } from 'zustand' import { create } from 'zustand'
import { deleteMoneyRecordApi } from '@/request/api/money/record'
import { MoneyCategoryEnum } from '@/types/money/category' import { MoneyCategoryEnum } from '@/types/money/category'
import { add, sub } from '@/utils/math' import { add, sub } from '@/utils/math'
import { isInMonth } from '@/utils/time' import { isInMonth } from '@/utils/time'
@@ -18,10 +17,6 @@ interface MoneyRecordStore {
setRecords: (records: MoneyRecord[], month: string) => void setRecords: (records: MoneyRecord[], month: string) => void
setCurrentMonth: (month: string) => void setCurrentMonth: (month: string) => void
addMoneyRecord: (data: MoneyRecord) => void
updateMoneyRecord: (updated: MoneyRecord) => void
deleteMoneyRecord: (id: number) => void
getMoneyRecordById: (id: number) => MoneyRecord | null getMoneyRecordById: (id: number) => MoneyRecord | null
} }
@@ -86,33 +81,6 @@ export const useMoneyRecordStore = create<MoneyRecordStore>((set, get) => ({
setCurrentMonth: month => set({ currentMonth: month }), setCurrentMonth: month => set({ currentMonth: month }),
/* ---------------- actions ---------------- */
addMoneyRecord: (data) => {
if (!isInMonth(data.record_time, get().currentMonth))
return
const flatRecords = [...get().records.flatMap(g => g.records), data]
const newGroups = recomputeGroups(flatRecords)
set({ records: newGroups })
},
updateMoneyRecord: (updated) => {
const flatRecords = get().records.flatMap(g =>
g.records.map(r => r.id === updated.id ? updated : r),
)
// 如果更新后的记录不在当前月,则直接删除
const filteredRecords = flatRecords.filter(r => isInMonth(r.record_time, get().currentMonth))
const newGroups = recomputeGroups(filteredRecords)
set({ records: newGroups })
},
deleteMoneyRecord: (id) => {
const flatRecords = get().records.flatMap(g => g.records).filter(r => r.id !== id)
const newGroups = recomputeGroups(flatRecords)
set({ records: newGroups })
deleteMoneyRecordApi({ id }).catch(console.error)
},
getMoneyRecordById: (id) => { getMoneyRecordById: (id) => {
for (const group of get().records) { for (const group of get().records) {
const record = group.records.find(r => r.id === id) const record = group.records.find(r => r.id === id)
+1 -1
View File
@@ -6,7 +6,7 @@ interface SpaceState {
clear: () => void clear: () => void
} }
export const useSpaceStore = create<SpaceState>(set => ({ export const useSpaceStore = create<SpaceState>((set, get) => ({
userSpace: null, userSpace: null,
setUserSpace: space => set({ userSpace: space }), setUserSpace: space => set({ userSpace: space }),
clear: () => { clear: () => {
@@ -14,7 +14,7 @@ export interface MoneyRecord {
} }
// 查询条件(请求参数) // 查询条件(请求参数)
export interface QueryMoneyRecordsParams { export interface ListMoneyRecordsParams {
record_time: string record_time: string
} }
@@ -26,7 +26,7 @@ export interface MoneyRecordGroup {
records: MoneyRecord[] records: MoneyRecord[]
} }
export interface QueryMoneyRecordsResult { export interface ListMoneyRecordsResult {
records: MoneyRecord[] records: MoneyRecord[]
} }
@@ -38,7 +38,7 @@ export interface InsertMoneyRecordParams {
record_time: string record_time: string
} }
export interface InsertMoneyRecordResult extends MoneyRecord {} export interface InsertMoneyRecordResult {}
// 更新 // 更新
export interface UpdateMoneyRecordParams { export interface UpdateMoneyRecordParams {
@@ -51,7 +51,7 @@ export interface UpdateSpaceUserRoleResult {
// 空间用户列表 // 空间用户列表
export interface SpaceUser { export interface SpaceUser {
id: number id: number
name: number username: string
avatar: string avatar: string
role: number role: number
last_login_time: number last_login_time: number