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

No files matched your search

@@ -69,7 +69,24 @@ func DeleteUserMoneyCategory(ctx context.Context, c *app.RequestContext) {
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 {
errorx.AddError(c, err)
@@ -12,101 +12,66 @@ import (
"allapp/utils/response"
"context"
"fmt"
"time"
money "allapp/biz/model/money"
"github.com/cloudwego/hertz/pkg/app"
"github.com/cloudwego/hertz/pkg/protocol/consts"
"github.com/jackc/pgx/v5/pgtype"
)
// QueryMoneyRecord .
// @router /money/record/query [POST]
func QueryMoneyRecord(ctx context.Context, c *app.RequestContext) {
var req money.QueryMoneyRecordsParams
// ListMoneyRecords 账目列表
// @router /money/record/list [POST]
func ListMoneyRecords(ctx context.Context, c *app.RequestContext) {
var req money.ListMoneyRecordsParams
if err := c.BindAndValidate(&req); err != nil {
c.String(consts.StatusBadRequest, err.Error())
return
}
//// 解析年月
//startTime, err := time.Parse("2006-01", req.RecordTime)
//if err != nil {
// errorx.AddError(c, fmt.Errorf("invalid record_time format: %v", err))
// return
//}
//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,
//}
// 解析年月(yyyy-MM)
startTime, err := time.Parse("2006-01", req.RecordTime)
if err != nil {
errorx.AddError(c, fmt.Errorf("invalid record_time format: %v", err))
return
}
endTime := startTime.AddDate(0, 1, 0).Add(-time.Nanosecond)
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 .
@@ -122,8 +87,6 @@ func InsertMoneyRecord(ctx context.Context, c *app.RequestContext) {
return
}
resp := new(money.InsertMoneyRecordResult)
params := repo.InsertMoneyRecordParams{
ID: idgen.NextId(),
CategoryID: req.CategoryId,
@@ -133,22 +96,14 @@ func InsertMoneyRecord(ctx context.Context, c *app.RequestContext) {
RecordTime: pgtypex.StringToDate(req.RecordTime),
}
record, err := db.Queries.InsertMoneyRecord(ctx, params)
err = db.Queries.InsertMoneyRecord(ctx, params)
if err != nil {
errorx.AddError(c, err)
return
}
resp.Id = record.ID
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()
response.Success(c).Message("新增成功").Send()
}
// UpdateMoneyRecord .
@@ -34,7 +34,7 @@ func GetUserSpace(ctx context.Context, c *app.RequestContext) {
if err != nil {
if errorx.IsNotFound(err) {
response.Success(c).Data(resp).Send()
response.Success(c).Data(nil).Send()
return
}
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v4.25.3
// protoc v6.33.1
// source: api.proto
package api
@@ -10,7 +10,6 @@ import (
_ "allapp/biz/model/api"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/known/emptypb"
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,
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,
0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xcb,
0x04, 0x0a, 0x14, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x56, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12,
0x1b, 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,
0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x13, 0xca, 0xc1, 0x18, 0x0f,
0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12,
0x74, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e,
0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x1d, 0x2e, 0x6d, 0x6f, 0x6e,
0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 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, 0x44, 0x65, 0x6c, 0x65, 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, 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,
0x6f, 0x32, 0xcb, 0x04, 0x0a, 0x14, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67,
0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x56, 0x0a, 0x04, 0x4c, 0x69,
0x73, 0x74, 0x12, 0x1b, 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, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65,
0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x13, 0xca,
0xc1, 0x18, 0x0f, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f,
0x72, 0x79, 0x12, 0x74, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72,
0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x1d, 0x2e,
0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 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, 0x44, 0x65, 0x6c, 0x65, 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, 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, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1e, 0xd2, 0xc1, 0x18, 0x1a, 0x2f, 0x6d,
0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2f, 0x75, 0x70,
0x64, 0x61, 0x74, 0x65, 0x53, 0x6f, 0x72, 0x74, 0x12, 0x70, 0x0a, 0x13, 0x43, 0x72, 0x65, 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, 0x43, 0x72, 0x65, 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, 0x43, 0x72, 0x65, 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, 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,
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, 0x53, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1e, 0xd2, 0xc1, 0x18,
0x1a, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6f, 0x72, 0x74, 0x12, 0x70, 0x0a, 0x13, 0x43,
0x72, 0x65, 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, 0x43, 0x72, 0x65, 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, 0x43, 0x72, 0x65, 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, 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,
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, 0xce, 0x03, 0x0a,
0x12, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x6e, 0x65,
0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e,
0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1e, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e,
0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x17, 0xd2, 0xc1, 0x18, 0x13, 0x2f, 0x6d, 0x6f,
0x6e, 0x65, 0x79, 0x2f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79,
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, 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,
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{}{
@@ -108,7 +105,7 @@ var file_money_proto_goTypes = []interface{}{
(*UpdateMoneyCategorySortReq)(nil), // 2: money.UpdateMoneyCategorySortReq
(*CreateMoneyCategoryReq)(nil), // 3: money.CreateMoneyCategoryReq
(*UpdateMoneyCategoryReq)(nil), // 4: money.UpdateMoneyCategoryReq
(*QueryMoneyRecordsParams)(nil), // 5: money.QueryMoneyRecordsParams
(*ListMoneyRecordsParams)(nil), // 5: money.ListMoneyRecordsParams
(*InsertMoneyRecordParams)(nil), // 6: money.InsertMoneyRecordParams
(*UpdateMoneyRecordParams)(nil), // 7: money.UpdateMoneyRecordParams
(*DeleteMoneyRecordParams)(nil), // 8: money.DeleteMoneyRecordParams
@@ -117,7 +114,7 @@ var file_money_proto_goTypes = []interface{}{
(*UpdateMoneyCategorySortResp)(nil), // 11: money.UpdateMoneyCategorySortResp
(*CreateMoneyCategoryResp)(nil), // 12: money.CreateMoneyCategoryResp
(*UpdateMoneyCategoryResp)(nil), // 13: money.UpdateMoneyCategoryResp
(*QueryMoneyRecordsResult)(nil), // 14: money.QueryMoneyRecordsResult
(*ListMoneyRecordsResult)(nil), // 14: money.ListMoneyRecordsResult
(*InsertMoneyRecordResult)(nil), // 15: money.InsertMoneyRecordResult
(*UpdateMoneyRecordResult)(nil), // 16: money.UpdateMoneyRecordResult
(*DeleteMoneyRecordResult)(nil), // 17: money.DeleteMoneyRecordResult
@@ -128,7 +125,7 @@ var file_money_proto_depIdxs = []int32{
2, // 2: money.MoneyCategoryService.UpdateMoneyCategorySort:input_type -> money.UpdateMoneyCategorySortReq
3, // 3: money.MoneyCategoryService.CreateMoneyCategory:input_type -> money.CreateMoneyCategoryReq
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
7, // 7: money.MoneyRecordService.UpdateMoneyRecord:input_type -> money.UpdateMoneyRecordParams
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
12, // 12: money.MoneyCategoryService.CreateMoneyCategory:output_type -> money.CreateMoneyCategoryResp
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
16, // 16: money.MoneyRecordService.UpdateMoneyRecord:output_type -> money.UpdateMoneyRecordResult
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
sizeCache protoimpl.SizeCache
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"`
}
func (x *QueryMoneyRecordsParams) Reset() {
*x = QueryMoneyRecordsParams{}
func (x *ListMoneyRecordsParams) Reset() {
*x = ListMoneyRecordsParams{}
if protoimpl.UnsafeEnabled {
mi := &file_money_money_record_types_proto_msgTypes[1]
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)
}
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]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -169,12 +169,12 @@ func (x *QueryMoneyRecordsParams) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use QueryMoneyRecordsParams.ProtoReflect.Descriptor instead.
func (*QueryMoneyRecordsParams) Descriptor() ([]byte, []int) {
// Deprecated: Use ListMoneyRecordsParams.ProtoReflect.Descriptor instead.
func (*ListMoneyRecordsParams) Descriptor() ([]byte, []int) {
return file_money_money_record_types_proto_rawDescGZIP(), []int{1}
}
func (x *QueryMoneyRecordsParams) GetRecordTime() string {
func (x *ListMoneyRecordsParams) GetRecordTime() string {
if x != nil {
return x.RecordTime
}
@@ -182,7 +182,7 @@ func (x *QueryMoneyRecordsParams) GetRecordTime() string {
}
// 查询记账记录结果
type QueryMoneyRecordsResult struct {
type ListMoneyRecordsResult struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@@ -190,8 +190,8 @@ type QueryMoneyRecordsResult struct {
Records []*MoneyRecord `protobuf:"bytes,1,rep,name=Records,proto3" form:"records" json:"records"`
}
func (x *QueryMoneyRecordsResult) Reset() {
*x = QueryMoneyRecordsResult{}
func (x *ListMoneyRecordsResult) Reset() {
*x = ListMoneyRecordsResult{}
if protoimpl.UnsafeEnabled {
mi := &file_money_money_record_types_proto_msgTypes[2]
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)
}
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]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -217,12 +217,12 @@ func (x *QueryMoneyRecordsResult) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use QueryMoneyRecordsResult.ProtoReflect.Descriptor instead.
func (*QueryMoneyRecordsResult) Descriptor() ([]byte, []int) {
// Deprecated: Use ListMoneyRecordsResult.ProtoReflect.Descriptor instead.
func (*ListMoneyRecordsResult) Descriptor() ([]byte, []int) {
return file_money_money_record_types_proto_rawDescGZIP(), []int{2}
}
func (x *QueryMoneyRecordsResult) GetRecords() []*MoneyRecord {
func (x *ListMoneyRecordsResult) GetRecords() []*MoneyRecord {
if x != nil {
return x.Records
}
@@ -306,15 +306,6 @@ type InsertMoneyRecordResult struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
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() {
@@ -349,62 +340,6 @@ func (*InsertMoneyRecordResult) Descriptor() ([]byte, []int) {
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 {
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,
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,
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x4a, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f,
0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73,
0x12, 0x2f, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01,
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, 0x54, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x39, 0x0a, 0x07,
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e,
0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2e, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72,
0x64, 0x42, 0x0b, 0xca, 0xbb, 0x18, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x07,
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0xa4, 0x02, 0x0a, 0x17, 0x49, 0x6e, 0x73, 0x65,
0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72,
0x61, 0x6d, 0x73, 0x12, 0x38, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x18, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x61, 0x74,
0x65, 0x67, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x05, 0x24, 0x21, 0x3d, 0x27,
0x27, 0x52, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x4d, 0x0a,
0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x35, 0xca,
0xbb, 0x18, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0xda, 0xbb, 0x18, 0x27, 0x24, 0x21, 0x3d,
0x27, 0x27, 0x20, 0x26, 0x26, 0x20, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x28, 0x27, 0x5e, 0x5c,
0x64, 0x2b, 0x28, 0x5c, 0x2e, 0x5c, 0x64, 0x7b, 0x31, 0x2c, 0x32, 0x7d, 0x29, 0x3f, 0x24, 0x27,
0x2c, 0x20, 0x24, 0x29, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x06,
0x52, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x03, 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, 0x5c, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x42, 0x3c, 0xca, 0xbb, 0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x5f, 0x74, 0x69, 0x6d, 0x65, 0xda, 0xbb, 0x18, 0x29, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x20, 0x26,
0x26, 0x20, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x28, 0x27, 0x5e, 0x5c, 0x64, 0x7b, 0x34, 0x7d,
0x2d, 0x5c, 0x64, 0x7b, 0x32, 0x7d, 0x2d, 0x5c, 0x64, 0x7b, 0x32, 0x7d, 0x24, 0x27, 0x2c, 0x20,
0x24, 0x29, 0x52, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xe2,
0x02, 0x0a, 0x17, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x16, 0x0a, 0x02, 0x49, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xca, 0xbb, 0x18, 0x02, 0x69, 0x64, 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, 0x23, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20,
0x01, 0x28, 0x03, 0x42, 0x0b, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64,
0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75,
0x6e, 0x74, 0x18, 0x04, 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, 0x05, 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, 0x06,
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, 0x12, 0x2f, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18,
0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74,
0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69,
0x6d, 0x65, 0x12, 0x2f, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65,
0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x75, 0x70, 0x64, 0x61,
0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x52, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54,
0x69, 0x6d, 0x65, 0x22, 0xe3, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 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, 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,
0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x49, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e,
0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12,
0x2f, 0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 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, 0x53, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63,
0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x39, 0x0a, 0x07, 0x52, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x6f,
0x6e, 0x65, 0x79, 0x2e, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42,
0x0b, 0xca, 0xbb, 0x18, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x07, 0x52, 0x65,
0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0xa4, 0x02, 0x0a, 0x17, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74,
0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d,
0x73, 0x12, 0x38, 0x0a, 0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x18, 0xca, 0xbb, 0x18, 0x0b, 0x63, 0x61, 0x74, 0x65, 0x67,
0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x05, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x52,
0x0a, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x4d, 0x0a, 0x06, 0x41,
0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x35, 0xca, 0xbb, 0x18,
0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0xda, 0xbb, 0x18, 0x27, 0x24, 0x21, 0x3d, 0x27, 0x27,
0x20, 0x26, 0x26, 0x20, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x28, 0x27, 0x5e, 0x5c, 0x64, 0x2b,
0x28, 0x5c, 0x2e, 0x5c, 0x64, 0x7b, 0x31, 0x2c, 0x32, 0x7d, 0x29, 0x3f, 0x24, 0x27, 0x2c, 0x20,
0x24, 0x29, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x52, 0x65,
0x6d, 0x61, 0x72, 0x6b, 0x18, 0x03, 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, 0x5c,
0x0a, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x42, 0x3c, 0xca, 0xbb, 0x18, 0x0b, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x5f, 0x74,
0x69, 0x6d, 0x65, 0xda, 0xbb, 0x18, 0x29, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x20, 0x26, 0x26, 0x20,
0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x28, 0x27, 0x5e, 0x5c, 0x64, 0x7b, 0x34, 0x7d, 0x2d, 0x5c,
0x64, 0x7b, 0x32, 0x7d, 0x2d, 0x5c, 0x64, 0x7b, 0x32, 0x7d, 0x24, 0x27, 0x2c, 0x20, 0x24, 0x29,
0x52, 0x0a, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x19, 0x0a, 0x17,
0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72,
0x64, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0xe3, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61,
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, 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 (
@@ -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_goTypes = []interface{}{
(*MoneyRecord)(nil), // 0: money.MoneyRecord
(*QueryMoneyRecordsParams)(nil), // 1: money.QueryMoneyRecordsParams
(*QueryMoneyRecordsResult)(nil), // 2: money.QueryMoneyRecordsResult
(*ListMoneyRecordsParams)(nil), // 1: money.ListMoneyRecordsParams
(*ListMoneyRecordsResult)(nil), // 2: money.ListMoneyRecordsResult
(*InsertMoneyRecordParams)(nil), // 3: money.InsertMoneyRecordParams
(*InsertMoneyRecordResult)(nil), // 4: money.InsertMoneyRecordResult
(*UpdateMoneyRecordParams)(nil), // 5: money.UpdateMoneyRecordParams
@@ -741,7 +655,7 @@ var file_money_money_record_types_proto_goTypes = []interface{}{
(*DeleteMoneyRecordResult)(nil), // 8: money.DeleteMoneyRecordResult
}
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 input_type
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{} {
switch v := v.(*QueryMoneyRecordsParams); i {
switch v := v.(*ListMoneyRecordsParams); i {
case 0:
return &v.state
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{} {
switch v := v.(*QueryMoneyRecordsResult); i {
switch v := v.(*ListMoneyRecordsResult); i {
case 0:
return &v.state
case 1:
@@ -4,6 +4,7 @@ import (
"allapp/db"
"allapp/logx"
"context"
"github.com/cloudwego/hertz/pkg/app"
)
@@ -18,10 +19,12 @@ func RefreshActive() app.HandlerFunc {
}
// 异步刷新活跃时间
go func() {
if err := db.Queries.UpdateUserActiveTime(c, userID); err != nil {
logx.CtxError(c, "刷新用户活跃时间失败, userID=%d, err=%v", userID, err)
go func(userID int64) {
ctx := context.Background()
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...
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("/update", append(_updatemoneycategoryMw(), money.UpdateMoneyCategory)...)
_category.POST("/updateSort", append(_updatemoneycategorysortMw(), money.UpdateMoneyCategorySort)...)
_money.POST("/records", append(_listmoneyrecordsMw(), money.ListMoneyRecords)...)
{
_record := _money.Group("/record", _recordMw()...)
_record.POST("/delete", append(_deletemoneyrecordMw(), money.DeleteMoneyRecord)...)
_record.POST("/insert", append(_insertmoneyrecordMw(), money.InsertMoneyRecord)...)
_record.POST("/query", append(_querymoneyrecordMw(), money.QueryMoneyRecord)...)
_record.POST("/update", append(_updatemoneyrecordMw(), money.UpdateMoneyRecord)...)
}
}
@@ -1,25 +1,26 @@
-- name: FindUserMoneyRecords :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
-- name: ListMoneyRecords :many
SELECT
mr.*,
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;
LEFT JOIN space_user su
ON su.user_id = mr.user_id
LEFT JOIN "user" u
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;
-- name: InsertMoneyRecord :one
-- name: InsertMoneyRecord :exec
INSERT INTO money_record (
id,
category_id,
@@ -31,8 +32,7 @@ INSERT INTO money_record (
update_time
) VALUES (
$1, $2, $3, $4, $5,$6,NOW(),NOW()
)
RETURNING *;
);
-- name: GetMoneyRecordById :one
SELECT * FROM money_record WHERE id = $1;
@@ -50,3 +50,6 @@ RETURNING *;
-- name: DeleteMoneyRecord :exec
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;
+73 -106
View File
@@ -20,109 +20,18 @@ func (q *Queries) DeleteMoneyRecord(ctx context.Context, id int64) error {
return err
}
const findMoneyRecordsBySpace = `-- name: FindMoneyRecordsBySpace :many
SELECT
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
const deleteMoneyRecordByCategoryId = `-- name: DeleteMoneyRecordByCategoryId :exec
DELETE FROM money_record WHERE user_id = $1 AND category_id = $2
`
type FindMoneyRecordsBySpaceParams struct {
SpaceID int64
RecordTime pgtype.Date
RecordTime_2 pgtype.Date
}
type FindMoneyRecordsBySpaceRow struct {
ID int64
type DeleteMoneyRecordByCategoryIdParams struct {
UserID 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) FindMoneyRecordsBySpace(ctx context.Context, arg FindMoneyRecordsBySpaceParams) ([]FindMoneyRecordsBySpaceRow, error) {
rows, err := q.db.Query(ctx, findMoneyRecordsBySpace, arg.SpaceID, arg.RecordTime, arg.RecordTime_2)
if err != nil {
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
func (q *Queries) DeleteMoneyRecordByCategoryId(ctx context.Context, arg DeleteMoneyRecordByCategoryIdParams) error {
_, err := q.db.Exec(ctx, deleteMoneyRecordByCategoryId, arg.UserID, arg.CategoryID)
return err
}
const getMoneyRecordById = `-- name: GetMoneyRecordById :one
@@ -145,7 +54,7 @@ func (q *Queries) GetMoneyRecordById(ctx context.Context, id int64) (MoneyRecord
return i, err
}
const insertMoneyRecord = `-- name: InsertMoneyRecord :one
const insertMoneyRecord = `-- name: InsertMoneyRecord :exec
INSERT INTO money_record (
id,
category_id,
@@ -158,7 +67,6 @@ INSERT INTO money_record (
) VALUES (
$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 {
@@ -170,8 +78,8 @@ type InsertMoneyRecordParams struct {
RecordTime pgtype.Date
}
func (q *Queries) InsertMoneyRecord(ctx context.Context, arg InsertMoneyRecordParams) (MoneyRecord, error) {
row := q.db.QueryRow(ctx, insertMoneyRecord,
func (q *Queries) InsertMoneyRecord(ctx context.Context, arg InsertMoneyRecordParams) error {
_, err := q.db.Exec(ctx, insertMoneyRecord,
arg.ID,
arg.CategoryID,
arg.UserID,
@@ -179,8 +87,59 @@ func (q *Queries) InsertMoneyRecord(ctx context.Context, arg InsertMoneyRecordPa
arg.Remark,
arg.RecordTime,
)
var i MoneyRecord
err := row.Scan(
return err
}
const listMoneyRecords = `-- name: ListMoneyRecords :many
SELECT
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
LEFT JOIN space_user su
ON su.user_id = mr.user_id
LEFT JOIN "user" u
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,
@@ -189,8 +148,16 @@ func (q *Queries) InsertMoneyRecord(ctx context.Context, arg InsertMoneyRecordPa
&i.RecordTime,
&i.CreateTime,
&i.UpdateTime,
)
return i, err
&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
@@ -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 "money/money_category_types.proto";
import "money/money_record_types.proto";
import "google/protobuf/empty.proto";
service MoneyCategoryService {
rpc List(ListMoneyCategoryReq) returns (ListMoneyCategoryResp){
@@ -28,8 +27,8 @@ service MoneyCategoryService {
}
service MoneyRecordService {
rpc QueryMoneyRecord(QueryMoneyRecordsParams) returns (QueryMoneyRecordsResult){
option (api.post) = '/money/record/query';
rpc ListMoneyRecords(ListMoneyRecordsParams) returns (ListMoneyRecordsResult){
option (api.post) = '/money/records';
}
rpc InsertMoneyRecord(InsertMoneyRecordParams) returns (InsertMoneyRecordResult){
option (api.post) = '/money/record/insert';
@@ -64,15 +64,15 @@ message CreateMoneyCategoryResp {
message UpdateMoneyCategoryReq {
int64 Id = 1[
(api.body)="id"
];;
];
string Name = 2 [
(api.body)="name",
(api.vd) = "$ != ''"
];;
];
string Icon = 3 [
(api.body)="icon",
(api.vd) = "$ != ''"
];;
];
}
message UpdateMoneyCategoryResp {}
@@ -19,14 +19,13 @@ message MoneyRecord {
string Username = 9 [(api.body)="username"];
}
// 查询记账记录请求参数
message QueryMoneyRecordsParams {
message ListMoneyRecordsParams {
string RecordTime = 1 [(api.body)="record_time"];
}
// 查询记账记录结果
message QueryMoneyRecordsResult {
message ListMoneyRecordsResult {
repeated MoneyRecord Records = 1 [(api.body)="records"];
}
@@ -46,14 +45,7 @@ message InsertMoneyRecordParams {
// 新增记账记录结果
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-constants": "~18.0.13",
"expo-font": "~14.0.11",
"expo-keep-awake": "~15.0.8",
"expo-linear-gradient": "~15.0.8",
"expo-linking": "~8.0.11",
"expo-qq": "^0.1.6",
+3
View File
@@ -65,6 +65,9 @@ importers:
expo-font:
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)
expo-keep-awake:
specifier: ~15.0.8
version: 15.0.8(expo@54.0.32)(react@19.1.0)
expo-linear-gradient:
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)
@@ -69,16 +69,6 @@ export default function StaticTransactions({
data: group.records,
}))
if (records.length === 0) {
return (
<EmptyState
type="empty"
title="暂无记账记录"
description="快去添加你的第一笔记账吧 "
/>
)
}
return (
<SectionList
sections={sections}
@@ -90,6 +80,15 @@ export default function StaticTransactions({
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={handleRefresh} />
}
ListEmptyComponent={() => (
<View className="flex-1 justify-center py-20">
<EmptyState
type="empty"
title="暂无记账记录"
description="快去添加你的第一笔记账吧"
/>
</View>
)}
renderSectionHeader={({ section }) => (
<View className="bg-white py-2 px-4 border-b border-gray-50">
<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 { Fab, FabIcon } from '@/components/ui/fab'
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 { getCurrentYearMonth } from '@/utils/time'
import { toast } from '@/utils/toast'
@@ -26,12 +26,11 @@ export default function Money() {
// 操作菜单
const [showActionsMenu, setShowActionsMenu] = useState(false)
function getMoneyRecords() {
queryMoneyRecordsApi({
function fetchMoneyRecords() {
listMoneyRecordsApi({
record_time: searchParams.record_time,
}).then((res) => {
if (res.isSuccess) {
console.log(res.data.records)
moneyRecordStore.setRecords(res.data.records || [], searchParams.record_time)
}
else {
@@ -43,18 +42,20 @@ export default function Money() {
console.log(err)
})
}
useFocusEffect(
useCallback(() => {
// 页面显示 / 返回时
console.log('===show===')
return () => {
// 页面离开(可选)
}
}, []),
fetchMoneyRecords()
}, [searchParams.record_time]),
)
async function handleDeleteRecord(id: number) {
await deleteMoneyRecordApi({
id,
})
fetchMoneyRecords()
}
return (
<View
className="flex-1"
@@ -129,22 +130,6 @@ export default function Money() {
</Text>
</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>
@@ -164,10 +149,10 @@ export default function Money() {
})
}}
onDelete={(id) => {
moneyRecordStore.deleteMoneyRecord(id)
handleDeleteRecord(id)
}}
onRefreshData={() => {
getMoneyRecords()
fetchMoneyRecords()
}}
/>
</View>
+137 -137
View File
@@ -1,7 +1,7 @@
import { useEvent } from 'expo'
// import ExpoQQ from 'expo-qq'
import ExpoQQ from 'expo-qq'
import { useRouter } from 'expo-router'
// import ExpoWeChat from 'expo-wechat'
import ExpoWeChat from 'expo-wechat'
import { useEffect, useState } from 'react'
import { Image, Text, View } from 'react-native'
import { AButton, ACheckbox } from '@/components/common/ao'
@@ -23,167 +23,167 @@ export default function Auth() {
const router = useRouter()
const userStore = useUserStore()
// const onLoginFinished = useEvent(ExpoQQ, 'onLoginFinished')
// const onGetUserInfo = useEvent(ExpoQQ, 'onGetUserInfo')
// const authResult = useEvent(ExpoWeChat, 'onAuthResult')
const onLoginFinished = useEvent(ExpoQQ, 'onLoginFinished')
const onGetUserInfo = useEvent(ExpoQQ, 'onGetUserInfo')
const authResult = useEvent(ExpoWeChat, 'onAuthResult')
// async function onQQLogin() {
// setLoading(true)
// setForm(val => ({
// ...val,
// type: 1,
// }))
// await ExpoQQ.login(['get_user_info'])
// }
async function onQQLogin() {
setLoading(true)
setForm(val => ({
...val,
type: 1,
}))
await ExpoQQ.login(['get_user_info'])
}
// async function onWeChatLogin() {
// setLoading(true)
async function onWeChatLogin() {
setLoading(true)
// // 检查微信是否安装
// const isInstalled = await ExpoWeChat.isWXAppInstalled()
// if (!isInstalled) {
// toast.show({
// title: onLoginFinished?.errorMessage || '请先安装微信',
// })
// setLoading(false)
// return
// }
// 检查微信是否安装
const isInstalled = await ExpoWeChat.isWXAppInstalled()
if (!isInstalled) {
toast.show({
title: onLoginFinished?.errorMessage || '请先安装微信',
})
setLoading(false)
return
}
// setForm(val => ({
// ...val,
// type: 0,
// }))
setForm(val => ({
...val,
type: 0,
}))
// ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123')
// }
ExpoWeChat.sendAuthRequest('snsapi_userinfo', 'state123')
}
// useEffect(() => {
// ExpoQQ.init('102826474', '')
// ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '')
// }, [])
useEffect(() => {
ExpoQQ.init('102826474', '')
ExpoWeChat.registerApp('wxdab3e21a1f7e392f', '')
}, [])
// useEffect(() => {
// if (!onLoginFinished) {
// return
// }
useEffect(() => {
if (!onLoginFinished) {
return
}
// if (!onLoginFinished.success) {
// toast.show({
// title: onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
// })
// setLoading(false)
// return
// }
if (!onLoginFinished.success) {
toast.show({
title: onLoginFinished?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
})
setLoading(false)
return
}
// const fetchUserInfo = async () => {
// try {
// const tokenInfo = await ExpoQQ.getLoginTokenInfo()
// if (!tokenInfo.openId) {
// toast.show({
// title: tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
// })
// setLoading(false)
// return
// }
const fetchUserInfo = async () => {
try {
const tokenInfo = await ExpoQQ.getLoginTokenInfo()
if (!tokenInfo.openId) {
toast.show({
title: tokenInfo?.errorMessage || '授权失败,请检查手机是否安装 QQ 或确认授权',
})
setLoading(false)
return
}
// setForm(val => ({
// ...val,
// openid: String(tokenInfo.openId),
// }))
setForm(val => ({
...val,
openid: String(tokenInfo.openId),
}))
// await ExpoQQ.sendGetUserInfoReq()
// }
// catch (e) {
// console.error('QQ 登录未完成', e)
// setLoading(false)
// }
// }
await ExpoQQ.sendGetUserInfoReq()
}
catch (e) {
console.error('QQ 登录未完成', e)
setLoading(false)
}
}
// fetchUserInfo()
// }, [onLoginFinished])
fetchUserInfo()
}, [onLoginFinished])
// // QQ登录
// useEffect(() => {
// const handleLogin = async () => {
// if (!onGetUserInfo)
// return
// QQ登录
useEffect(() => {
const handleLogin = async () => {
if (!onGetUserInfo)
return
// try {
// const loginRes = await loginQqApi({
// openid: form.openid,
// username: onGetUserInfo.nickname || '',
// avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
// })
try {
const loginRes = await loginQqApi({
openid: form.openid,
username: onGetUserInfo.nickname || '',
avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
})
// if (loginRes.isSuccess) {
// userStore.setUserInfo({
// token: loginRes.data.token,
// id: loginRes.data.userId,
// username: loginRes.data.username,
// avatar: loginRes.data.avatar,
// })
if (loginRes.isSuccess) {
userStore.setUserInfo({
token: loginRes.data.token,
id: loginRes.data.userId,
username: loginRes.data.username,
avatar: loginRes.data.avatar,
})
// console.log(loginRes.data.token)
console.log(loginRes.data.token)
// router.push('/')
// }
// }
// catch (err) {
// console.error('登录接口出错', err)
// }
// finally {
// setLoading(false)
// }
// }
router.push('/')
}
}
catch (err) {
console.error('登录接口出错', err)
}
finally {
setLoading(false)
}
}
// handleLogin()
// }, [onGetUserInfo])
handleLogin()
}, [onGetUserInfo])
// // 微信登录
// useEffect(() => {
// if (!authResult)
// return
// 微信登录
useEffect(() => {
if (!authResult)
return
// const handleLogin = async () => {
// if (authResult.errorCode === 0) {
// try {
// const loginRes = await loginWxApi({
// code: authResult.code,
// })
const handleLogin = async () => {
if (authResult.errorCode === 0) {
try {
const loginRes = await loginWxApi({
code: authResult.code,
})
// if (loginRes.isSuccess) {
// userStore.setUserInfo({
// token: loginRes.data.token,
// id: loginRes.data.userId,
// username: loginRes.data.username,
// avatar: loginRes.data.avatar,
// })
if (loginRes.isSuccess) {
userStore.setUserInfo({
token: loginRes.data.token,
id: loginRes.data.userId,
username: loginRes.data.username,
avatar: loginRes.data.avatar,
})
// router.push('/')
// }
// }
// catch (err) {
// console.error('登录接口出错', err)
// }
// finally {
// setLoading(false)
// }
// }
// else {
// console.log('授权失败:', authResult.errorMessage)
// setLoading(false)
// }
// }
router.push('/')
}
}
catch (err) {
console.error('登录接口出错', err)
}
finally {
setLoading(false)
}
}
else {
console.log('授权失败:', authResult.errorMessage)
setLoading(false)
}
}
// handleLogin()
// }, [authResult])
handleLogin()
}, [authResult])
function testLogin() {
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs
userStore.setUserInfo({
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs',
id: 766785982165061,
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3Njc4NjM3NTU5MzE3MTcsImlhdCI6MTc2OTYwMzEzOX0.xfW-uyFBi799u4VJ-93A88c2CC8jwpYOPsALUuaIizg',
id: 767863755931717,
username: 'Zhang',
avatar: 'http://thirdqq.qlogo.cn/ek_qqapp/AQHVialeUibE42oV8RvTTVZ4tyRlPYeJrUibWTwtCPfV68E4rSzn9cw00GkXQ3QDTiawwhjoqQb7/100',
})
@@ -208,7 +208,7 @@ export default function Auth() {
</View>
<View className="flex flex-col gap-4">
{/* <AButton
<AButton
leftIcon={
<IconWeixin color="#fff" />
}
@@ -227,7 +227,7 @@ export default function Auth() {
onPress={onQQLogin}
>
QQ
</AButton> */}
</AButton>
<AButton
variant="outline"
@@ -33,10 +33,10 @@ export default function CreateCategory({
const [form, setForm] = useState<EditCategoryForm>({ icon: '', name: '' })
const [confirmDisabled, setConfirmDisabled] = useState(true)
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 iconPositions = useRef<Record<string, number>>({}) // 记录每个 icon 的 y 坐标
const flatListRef = useRef<FlatList<any>>(null)
// Drawer 打开/关闭控制
useEffect(() => {
setIsOpen(open)
@@ -47,6 +47,22 @@ export default function CreateCategory({
// 确认按钮状态
useEffect(() => {
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])
// 编辑已有分类时填充数据
@@ -61,20 +77,28 @@ export default function CreateCategory({
onClose?.()
}
// 缓存点击 Icon 的回调
const handlePressIcon = useCallback(
(icon: string) => {
setForm(v => ({ ...v, icon }))
},
[setForm],
)
// 渲染每组 Icon
const renderGroup = useCallback(
({ item }: { item: [string, string[]] }) => {
const [groupName, icons] = item
return (
<View className="mb-4">
<Text className="text-center text-sm mb-3">{groupName}</Text>
<View className="flex flex-row flex-wrap">
{icons.map((icon) => {
const selected = form.icon === icon
// Memo 化单个 IconItem,避免重复渲染
const IconItem = useCallback(({ icon, selected }: { icon: string, selected: boolean }) => {
return (
<Pressable
key={icon}
className="w-1/5 mb-3 flex items-center"
onPress={() => handlePressIcon(icon)}
onPress={() =>
setForm(v => ({
...v,
icon,
}))}
>
<View
style={{
@@ -94,29 +118,14 @@ export default function CreateCategory({
</View>
</Pressable>
)
}, [handlePressIcon])
// Memo 化渲染每组 Icon 的组件
const renderGroup = useCallback(
({ item }: { item: [string, string[]] }) => {
const [groupName, icons] = item
return (
<View className="mb-4">
<Text className="text-center text-sm mb-3">{groupName}</Text>
<View className="flex flex-row flex-wrap">
{icons.map(icon => (
<IconItem key={icon} icon={icon} selected={form.icon === icon} />
))}
})}
</View>
</View>
)
},
[IconItem, form.icon],
[form.icon],
)
// 使用 useMemo 缓存 FlatList 的数据
const flatListData = useMemo(() => Object.entries(moneyCategoryStore.ICON_GROUPS), [moneyCategoryStore.ICON_GROUPS])
return (
<ADrawer
visible={isOpen}
@@ -153,10 +162,13 @@ export default function CreateCategory({
)}
>
<FlatList
ref={scrollRef}
ref={flatListRef}
data={flatListData}
keyExtractor={([groupName]) => groupName}
renderItem={renderGroup}
getItemLayout={(data, index) => {
return { length: 80, offset: 80 * index, index }
}}
/>
</ADrawer>
)
@@ -88,13 +88,6 @@ export default function MoenyRecordEditor() {
record_time: moneyRecord.record_time,
}).then((res) => {
if (res.isSuccess) {
const result: MoneyRecord = {
...moneyRecord,
category_id: selectedCategory.id,
}
moneyRecordStore.updateMoneyRecord(result)
router.back()
}
}).catch((err) => {
@@ -110,13 +103,6 @@ export default function MoenyRecordEditor() {
})
.then((res) => {
if (res.isSuccess) {
const result: MoneyRecord = {
...res.data,
category_id: selectedCategory.id,
}
moneyRecordStore.addMoneyRecord(result)
router.back()
}
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 { useState } from 'react'
import { FlatList, TouchableHighlight, TouchableOpacity, View } from 'react-native'
@@ -10,7 +10,7 @@ import {
renderers,
} from 'react-native-popup-menu'
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 {
Accordion,
@@ -21,19 +21,14 @@ import {
AccordionTitleText,
AccordionTrigger,
} from '@/components/ui/accordion'
import {
Avatar,
AvatarBadge,
AvatarFallbackText,
} from '@/components/ui/avatar'
import { Badge, BadgeText } from '@/components/ui/badge'
import { Heading } from '@/components/ui/heading'
import { HStack } from '@/components/ui/hstack'
import { ChevronDownIcon, ChevronUpIcon } from '@/components/ui/icon'
import { Text } from '@/components/ui/text'
import { VStack } from '@/components/ui/vstack'
import { dissolveSpaceApi } from '@/request/api/space/space'
import { exitSpaceApi, removeSpaceUserApi } from '@/request/api/space/spaceUser'
import { dissolveSpaceApi, exitSpaceApi, removeSpaceUserApi } from '@/request/api/space/space'
import { useUserStore } from '@/store/user'
import { formatRelativeTime } from '@/utils/time'
import { toast } from '@/utils/toast'
@@ -86,7 +81,9 @@ export default function SpaceInvite({
}
if (modal.type === 'exit') {
// 退出
exitSpaceApi({}).catch((err) => {
exitSpaceApi({
space_id: userSpace.id,
}).catch((err) => {
console.log(err)
})
}
@@ -96,6 +93,7 @@ export default function SpaceInvite({
}
// 移除
removeSpaceUserApi({
space_id: userSpace.id,
user_id: modal.userId,
}).catch((err) => {
console.log(err)
@@ -103,7 +101,9 @@ export default function SpaceInvite({
}
else {
// 解散
dissolveSpaceApi({}).catch((err) => {
dissolveSpaceApi({
space_id: userSpace.id,
}).catch((err) => {
console.log(err)
})
}
@@ -177,7 +177,7 @@ export default function SpaceInvite({
<ADivider direction="horizontal" text="扫描二维码" />
<QRCode
size={120}
value={userSpace?.invite_code}
value={userSpace?.invite_code || ''}
/>
</View>
</AccordionContent>
@@ -198,26 +198,21 @@ export default function SpaceInvite({
<View>
<FlatList
data={spaceUsers}
keyExtractor={item => item.user_id.toString()}
keyExtractor={item => item.id.toString()}
renderItem={({ item }) => (
<TouchableOpacity>
<HStack space="md" className="my-2 items-center">
<Avatar className="bg-indigo-600">
<AvatarFallbackText className="text-white text-2xl">
{item.username}
</AvatarFallbackText>
<AvatarBadge />
</Avatar>
<AAvatar avatar={item.avatar} username={item.username} showBadge={true} />
<VStack>
<HStack space="sm">
<Heading size="sm">{item.username}</Heading>
{item.space_role === 0 && (
{item.role === 0 && (
<Badge size="sm" variant="solid" action="muted">
<BadgeText>创建者</BadgeText>
</Badge>
)}
{
userStore.userInfo?.id === item.user_id && (
userStore.userInfo?.id === item.id && (
<Badge size="sm" variant="solid" action="info">
<BadgeText>
我
@@ -226,7 +221,7 @@ export default function SpaceInvite({
)
}
</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>
{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
customStyles={{
OptionTouchableComponent: TouchableHighlight,
@@ -268,7 +263,7 @@ export default function SpaceInvite({
open: true,
title: `确定将 ${item.username} 提出空间?`,
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 { View } from 'react-native'
import CustomHeader from '@/components/custom/Header'
import { createSpaceApi } from '@/request/api/space/space'
import { getUserSpaceApi, joinSpaceApi, listSpaceUsersApi } from '@/request/api/space/spaceUser'
import { createSpaceApi, joinSpaceApi, listSpaceUsersApi } from '@/request/api/space/space'
import { useSpaceStore } from '@/store/space'
import { useUserStore } from '@/store/user'
import JoinSpace from './components/JoinSpace'
import SpaceHome from './components/SpaceHome'
import SpaceInvite from './components/SpaceInvite'
@@ -12,71 +12,73 @@ import StepFade from './components/StepFade'
export default function PagerWithTab() {
const spaceStore = useSpaceStore()
const userStore = useUserStore()
const [headerTitle, setHeaderTitle] = useState('我的空间')
const [step, setStep] = useState<'join' | 'invite' | 'home'>('home')
const [spaceUsers, setSpaceUsers] = useState<SpaceUser[]>([])
const fetchData = async () => {
await Promise.all([
getUserSpaceApi()
.then((res) => {
if (res.isSuccess) {
if (res.data === null) {
spaceStore.setUserSpace(null)
setStep('home')
}
else {
spaceStore.setUserSpace({
space_id: res.data.space_id,
space_name: res.data.space_name,
role: res.data.role,
invite_code: res.data.invite_code,
})
setStep('invite')
}
}
else {
// 提示
}
})
.catch(err => console.error('getUserSpaceApi error:', err)),
listSpaceUsersApi({})
.then((res) => {
// 封装获取空间用户列表并直接更新状态
const fetchSpaceUsers = async (spaceId: number) => {
try {
const res = await listSpaceUsersApi({ space_id: spaceId })
if (res.isSuccess) {
setSpaceUsers(res.data.users)
console.log(res.data.users)
}
else {
// 提示
console.warn('获取空间用户失败')
setSpaceUsers([])
}
}
catch (err) {
console.error('listSpaceUsersApi error:', err)
setSpaceUsers([])
}
})
.catch(err => console.error('listSpaceUsersApi error:', err)),
])
}
// 页面加载时判断并拉取用户列表
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() {
createSpaceApi({}).then((res) => {
createSpaceApi({
name: getSpaceName(),
}).then((res) => {
if (res.isSuccess) {
spaceStore.setUserSpace({
space_id: res.data.id,
space_name: '',
id: res.data.space_id,
name: getSpaceName(),
role: 0,
invite_code: res.data.invite_code,
})
listSpaceUsersApi({})
.then((res) => {
if (res.isSuccess) {
setSpaceUsers(res.data.users)
}
else {
// 提示
}
})
.catch(err => console.error('listSpaceUsersApi error:', err))
fetchSpaceUsers(res.data.space_id)
setStep('invite')
}
}).catch((err) => {
@@ -89,7 +91,14 @@ export default function PagerWithTab() {
invite_code: code,
}).then((res) => {
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) => {
console.log(err)
@@ -98,7 +107,7 @@ export default function PagerWithTab() {
return (
<View className="flex-1">
<CustomHeader title="共享空间" />
<CustomHeader title={headerTitle} />
<View className="flex-1">
<StepFade visible={step === 'home'}>
<SpaceHome
@@ -129,12 +138,13 @@ export default function PagerWithTab() {
onExit={(data) => {
if (data.type === 'remove' && data.userId !== undefined) {
setSpaceUsers(prevUsers =>
prevUsers.filter(user => user.user_id !== data.userId),
prevUsers.filter(user => user.id !== data.userId),
)
return
}
setStep('home')
spaceStore.setUserSpace(null)
spaceStore.clear()
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 React, { useEffect, useMemo, useState } from 'react'
import { Dimensions, StyleSheet, Text, View } from 'react-native'
import { Gesture, GestureDetector } from 'react-native-gesture-handler'
import Animated, {
interpolate,
runOnJS,
@@ -103,24 +102,6 @@ export default function Drawer({
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)
return null
@@ -135,7 +116,6 @@ export default function Drawer({
{/* Drawer */}
<View style={[styles.drawerBox, drawerBox]}>
<GestureDetector gesture={pan}>
<Animated.View
style={[
styles.drawer,
@@ -162,7 +142,6 @@ export default function Drawer({
{children}
</Animated.View>
</GestureDetector>
</View>
</View>
)
@@ -1,9 +1,10 @@
import { Avatar } from './Avatar'
import Button from './Button'
import { Cell, CellGroup } from './Cell'
import Checkbox from './Checkbox'
import DatePicker from './DatePicker'
import Divider from './Divider'
import Divider from './Divider'
import Drawer from './Drawer'
import Form, { FormRef } from './Form'
import FormItem from './FormItem'
@@ -12,9 +13,11 @@ import ListItem from './ListItem'
import LucideIcon from './LucideIcon'
import Modal from './Modal'
import SegmentedTabs from './SegmentedTabs'
import Tab from './Tab'
export {
Avatar as AAvatar,
Button as AButton,
Cell as ACell,
CellGroup as ACellGroup,
@@ -2,27 +2,27 @@ import type {
DeleteMoneyRecordParams,
InsertMoneyRecordParams,
InsertMoneyRecordResult,
QueryMoneyRecordsParams,
QueryMoneyRecordsResult,
ListMoneyRecordsParams,
ListMoneyRecordsResult,
UpdateMoneyRecordParams,
} from '@/types/money/record'
import alovaInstance from '../../index'
const API_PREFIX = '/money/record'
const API_PREFIX = '/money'
export function queryMoneyRecordsApi(params: QueryMoneyRecordsParams) {
return alovaInstance.Post<ResponseData<QueryMoneyRecordsResult>>(`${API_PREFIX}/query`, params)
export function listMoneyRecordsApi(params: ListMoneyRecordsParams) {
return alovaInstance.Post<ResponseData<ListMoneyRecordsResult>>(`${API_PREFIX}/records`, params)
}
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) {
return alovaInstance.Post<ResponseData<any>>(`${API_PREFIX}/update`, params)
return alovaInstance.Post<ResponseData<any>>(`${API_PREFIX}/record/update`, params)
}
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'
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 { AxiosError } from 'axios'
import type { ListUserSpacesResult } from '@/types/user'
import { axiosRequestAdapter } from '@alova/adapter-axios'
import { createAlova } from 'alova'
import { useNavStore } from '@/store/navigation'
import { useSpaceStore } from '@/store/space'
import { useUserStore } from '@/store/user'
import { toast } from '@/utils/toast'
@@ -12,8 +10,6 @@ enum HttpCode {
Success = 200,
Unauthorized = 401,
Fail = 500,
ErrSpaceRequired = 501,
ErrSpaceNoPermission = 502,
}
// 仅保留「无需登录」接口
@@ -52,29 +48,15 @@ const alovaInstance = createAlova({
useNavStore.getState().navigateToAuth()
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
},
onError: (error: AxiosError) => {
const status = error.status
const config = error.config
console.warn(`[HTTP ${status}] ${config?.method?.toUpperCase()} ${config?.url}`)
switch (status) {
case 400:
@@ -125,12 +107,6 @@ const alovaInstance = createAlova({
// 注入 JWT
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 spaceStore = useSpaceStore.getState()
// 如果没登录,跳转到登录页,但不退出初始化
if (!userStore.isLoggedIn()) {
navStore.navigateToAuth()
set({ ready: true })
return
}
try {
// 分类初始化
// 初始化分类
await moneyCategoryStore.init()
// 获取空间信息
const res = await getUserSpaceApi()
console.log(res.data)
spaceStore.setUserSpace(res.data)
}
catch (err) {
@@ -47,6 +49,7 @@ export const useAppStore = create<AppState>((set, get) => ({
// 初始化完成
set({ ready: true })
},
reset: () => {
set({ ready: false })
@@ -1,6 +1,5 @@
import type { MoneyRecord, MoneyRecordGroup } from '@/types/money/record'
import { create } from 'zustand'
import { deleteMoneyRecordApi } from '@/request/api/money/record'
import { MoneyCategoryEnum } from '@/types/money/category'
import { add, sub } from '@/utils/math'
import { isInMonth } from '@/utils/time'
@@ -18,10 +17,6 @@ interface MoneyRecordStore {
setRecords: (records: MoneyRecord[], month: string) => void
setCurrentMonth: (month: string) => void
addMoneyRecord: (data: MoneyRecord) => void
updateMoneyRecord: (updated: MoneyRecord) => void
deleteMoneyRecord: (id: number) => void
getMoneyRecordById: (id: number) => MoneyRecord | null
}
@@ -86,33 +81,6 @@ export const useMoneyRecordStore = create<MoneyRecordStore>((set, get) => ({
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) => {
for (const group of get().records) {
const record = group.records.find(r => r.id === id)
+1 -1
View File
@@ -6,7 +6,7 @@ interface SpaceState {
clear: () => void
}
export const useSpaceStore = create<SpaceState>(set => ({
export const useSpaceStore = create<SpaceState>((set, get) => ({
userSpace: null,
setUserSpace: space => set({ userSpace: space }),
clear: () => {
@@ -14,7 +14,7 @@ export interface MoneyRecord {
}
// 查询条件(请求参数)
export interface QueryMoneyRecordsParams {
export interface ListMoneyRecordsParams {
record_time: string
}
@@ -26,7 +26,7 @@ export interface MoneyRecordGroup {
records: MoneyRecord[]
}
export interface QueryMoneyRecordsResult {
export interface ListMoneyRecordsResult {
records: MoneyRecord[]
}
@@ -38,7 +38,7 @@ export interface InsertMoneyRecordParams {
record_time: string
}
export interface InsertMoneyRecordResult extends MoneyRecord {}
export interface InsertMoneyRecordResult {}
// 更新
export interface UpdateMoneyRecordParams {
@@ -51,7 +51,7 @@ export interface UpdateSpaceUserRoleResult {
// 空间用户列表
export interface SpaceUser {
id: number
name: number
username: string
avatar: string
role: number
last_login_time: number