This commit is contained in:
oneao committed 2026-01-13 22:18:01 +08:00
1 parent 6277fb2f9e
commit 8ecac0d7dd
270 files changed
+40438 -529

No files matched your search

+76
View File
@@ -0,0 +1,76 @@
// idl/api.proto; 注解拓展
syntax = "proto2";
package api;
import "google/protobuf/descriptor.proto";
option go_package = "/api";
extend google.protobuf.FieldOptions {
optional string raw_body = 50101;
optional string query = 50102;
optional string header = 50103;
optional string cookie = 50104;
optional string body = 50105;
optional string path = 50106;
optional string vd = 50107;
optional string form = 50108;
optional string js_conv = 50109;
optional string file_name = 50110;
optional string none = 50111;
// 50131~50160 used to extend field option by hz
optional string form_compatible = 50131;
optional string js_conv_compatible = 50132;
optional string file_name_compatible = 50133;
optional string none_compatible = 50134;
// 50135 is reserved to vt_compatible
// optional FieldRules vt_compatible = 50135;
optional string go_tag = 51001;
}
extend google.protobuf.MethodOptions {
optional string get = 50201;
optional string post = 50202;
optional string put = 50203;
optional string delete = 50204;
optional string patch = 50205;
optional string options = 50206;
optional string head = 50207;
optional string any = 50208;
optional string gen_path = 50301; // The path specified by the user when the client code is generated, with a higher priority than api_version
optional string api_version = 50302; // Specify the value of the :version variable in path when the client code is generated
optional string tag = 50303; // rpc tag, can be multiple, separated by commas
optional string name = 50304; // Name of rpc
optional string api_level = 50305; // Interface Level
optional string serializer = 50306; // Serialization method
optional string param = 50307; // Whether client requests take public parameters
optional string baseurl = 50308; // Baseurl used in ttnet routing
optional string handler_path = 50309; // handler_path specifies the path to generate the method
// 50331~50360 used to extend method option by hz
optional string handler_path_compatible = 50331; // handler_path specifies the path to generate the method
}
extend google.protobuf.EnumValueOptions {
optional int32 http_code = 50401;
// 50431~50460 used to extend enum option by hz
}
extend google.protobuf.ServiceOptions {
optional string base_domain = 50402;
// 50731~50760 used to extend service option by hz
optional string base_domain_compatible = 50731;
}
extend google.protobuf.MessageOptions {
// optional FieldRules msg_vt = 50111;
optional string reserve = 50830;
// 550831 is reserved to msg_vt_compatible
// optional FieldRules msg_vt_compatible = 50831;
}
+61
View File
@@ -0,0 +1,61 @@
syntax = "proto3";
package auth;
option go_package = "auth";
import "api.proto";
// 登录请求
message LoginDefaultReq {
string Account = 1 [(api.body)="account", (api.vd)="$!=''"];
string Password = 2 [(api.body)="password", (api.vd)="$!=''"];
}
// 登录响应
message LoginDefaultResp {
string Token = 1 [(api.body)="token"];
string RefreshToken = 2 [(api.body)="refreshToken"];
int64 UserId = 3 [(api.body)="userId"];
string Username = 4 [(api.body)="username"];
int32 SeqNo = 5 [(api.body)="seqNo"];
int32 Gender = 6 [(api.body)="gender"];
}
// 注册请求
message RegisterDefaultReq {
string Account = 1 [(api.body)="account", (api.vd)="$!=''"];
string Password = 2 [(api.body)="password", (api.vd)="$!=''"];
}
// 注册响应
message RegisterDefaultResp {}
// 刷新 access token 请求
message RefreshAccessTokenReq {}
// 刷新 access token 响应
message RefreshAccessTokenResp {
string AccessToken = 1 [(api.body)="accessToken"];
}
// 登录服务
service LoginService {
rpc LoginDefault(LoginDefaultReq) returns(LoginDefaultResp) {
option (api.post) = "/auth/login/default";
}
}
// 注册服务
service RegisterService {
rpc RegisterDefault(RegisterDefaultReq) returns(RegisterDefaultResp) {
option (api.post) = "/auth/register/default";
}
}
// token 服务
service TokenService {
rpc RefreshAccessToken(RefreshAccessTokenReq) returns(RefreshAccessTokenResp) {
option (api.get) = "/auth/refresh/token";
}
}
@@ -0,0 +1,36 @@
syntax = "proto3";
package money;
option go_package = "money";
import "api.proto";
import "money/money_category_types.proto";
import "money/money_record_types.proto";
service MoneyCategoryService {
rpc QueryUserMoneyCategory(QueryMoneyCategoryReq) returns (QueryMoneyCategoryResp){
option (api.get) = '/money/category';
};
rpc DeleteUserMoneyCategory(DeleteMoneyCategoryReq) returns (DeleteMoneyCategoryResp){
option (api.post) = '/money/category/delete';
};
rpc UpdateMoneyCategorySort(UpdateMoneyCategorySortReq) returns (UpdateMoneyCategorySortResp){
option (api.post) = '/money/category/updateSort';
};
}
service MoneyRecordService {
rpc QueryMoneyRecord(QueryMoneyRecordsParams) returns (QueryMoneyRecordsResult){
option (api.post) = '/money/record/query';
}
rpc InsertMoneyRecord(InsertMoneyRecordParams) returns (InsertMoneyRecordResult){
option (api.post) = '/money/record/insert';
}
rpc UpdateMoneyRecord(UpdateMoneyRecordParams) returns (UpdateMoneyRecordResult){
option (api.post) = '/money/record/update';
}
rpc DeleteMoneyRecord(DeleteMoneyRecordParams) returns (DeleteMoneyRecordResult){
option (api.post) = '/money/record/delete';
}
}
@@ -0,0 +1,45 @@
syntax = "proto3";
import "api.proto";
package money;
option go_package = "money";
// 记账分类
message MoneyCategory {
int64 Id = 1 [(api.body)="id"];
string Name = 2 [(api.body)="name"];
string Icon = 3 [(api.body)="icon"];
int32 Type = 4 [(api.body)="type"];
int32 SortNumber = 5 [(api.body)="sort_number"];
}
// 查询记账分类请求
message QueryMoneyCategoryReq {}
// 查询记账分类响应
message QueryMoneyCategoryResp {
repeated MoneyCategory Categories = 1 [(api.body)="categories"];
}
// 删除记账分类请求
message DeleteMoneyCategoryReq {
int64 Id = 1 [(api.body)="id", (api.vd)="$ != 0"];
}
// 删除记账分类响应
message DeleteMoneyCategoryResp {}
// 修改分类排序项
message MoneyCategorySortItem {
int64 Id = 1 [(api.body)="id"];
int32 SortNumber = 2 [(api.body)="sort_number"];
}
// 修改分类排序请求
message UpdateMoneyCategorySortReq {
repeated MoneyCategorySortItem Data = 1 [(api.body)="data"];
}
// 修改分类排序响应
message UpdateMoneyCategorySortResp {}
@@ -0,0 +1,94 @@
syntax = "proto3";
package money;
option go_package = "money";
import "api.proto";
// 单条记账记录
message MoneyRecordItem {
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"];
string Username = 9 [(api.body)="username"];
int32 CategoryType = 10 [(api.body)="category_type"];
string CategoryIcon = 11 [(api.body)="category_icon"];
string CategoryName = 12 [(api.body)="category_name"];
}
// 同一天的记账记录分组
message MoneyRecordGroup {
string RecordTime = 1 [(api.body)="record_time"];
string Expense = 2 [(api.body)="expense"];
string Income = 3 [(api.body)="income"];
repeated MoneyRecordItem Records = 4 [(api.body)="records"];
}
// 查询记账记录请求参数
message QueryMoneyRecordsParams {
string RecordTime = 1 [(api.body)="record_time"];
}
// 查询记账记录结果
message QueryMoneyRecordsResult {
repeated MoneyRecordGroup Records = 1 [(api.body)="records"];
string TotalIncome = 2 [(api.body)="total_income"];
string TotalExpense = 3 [(api.body)="total_expense"];
string TotalBalance = 4 [(api.body)="total_balance"];
}
// 新增记账记录参数
message InsertMoneyRecordParams {
int64 CategoryId = 1 [(api.body)="category_id",(api.vd)="$!=''"];
string Amount = 2 [
(api.body)="amount",
(api.vd)="$!='' && regexp('^\\d+(\\.\\d{1,2})?$', $)"
];
string Remark = 3 [(api.body)="remark"];
string RecordTime = 4 [
(api.body)="record_time",
(api.vd)="$!='' && regexp('^\\d{4}-\\d{2}-\\d{2}$', $)"
];
}
// 新增记账记录结果
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"];
}
// 更新记账记录
message UpdateMoneyRecordParams {
int64 Id = 1 [(api.body)="id",(api.vd)="$!=0"];
int64 CategoryId = 2 [(api.body)="category_id"];
string Amount = 3 [(api.body)="amount"];
string Remark = 4 [(api.body)="remark"];
string RecordTime = 5 [(api.body)="record_time"];
}
message UpdateMoneyRecordResult {
}
// 删除记账记录
message DeleteMoneyRecordParams{
int64 Id = 1 [(api.body)="id",(api.vd)="$!=0"];
}
message DeleteMoneyRecordResult {
}
@@ -0,0 +1,43 @@
syntax = "proto3";
package space;
option go_package = "space";
import "api.proto";
import "space/space_types.proto";
import "space/space_user_types.proto";
service SpaceService {
rpc CreateSpace(CreateSpaceParams) returns (CreateSpaceParams){
option (api.post) = '/space/create';
};
rpc DissolveSpace(DissolveSpaceParams) returns (DissolveSpaceResult){
option (api.post) = '/space/dissolve';
};
}
service SpaceUserService{
// 获取用户空间
rpc getUserSpace(GetUserSpaceParams) returns (GetUserSpaceResult){
option (api.get) = '/space/user/get';
};
// 退出空间
rpc ExitSpace(ExitSpaceParams) returns (ExitSpaceResult){
option (api.post) = '/space/user/exit';
};
// 获取空间用户列表
rpc ListSpaceUsers(ListSpaceUsersParams) returns (ListSpaceUsersResult){
option (api.post) = '/space/user/list';
};
// 踢出某人
rpc RemoveSpaceUser(RemoveSpaceUserParams) returns (RemoveSpaceUserResult){
option (api.post) = '/space/user/remove';
};
// 加入空间
rpc JoinSpace(JoinSpaceParams) returns (JoinSpaceResult) {
option (api.post) = "/space/user/join";
};
}
@@ -0,0 +1,27 @@
syntax = "proto3";
package space;
option go_package = "space";
import "api.proto";
// 创建空间
message CreateSpaceParams {
}
message CreateSpaceResult {
int64 Id = 1 [(api.body)="id"];
string InviteCode = 2 [(api.body)="invite_code"];
}
// 解散空间
message DissolveSpaceParams {
}
message DissolveSpaceResult {
}
@@ -0,0 +1,59 @@
syntax = "proto3";
package space;
option go_package = "space";
import "api.proto";
// 获取空间下的成员
message ListSpaceUsersParams {
}
message SpaceUser {
int64 UserId = 1 [(api.body)="user_id"];
string Username = 2 [(api.body)="username"];
int32 SpaceRole = 3 [(api.body)="space_role"];
string ActiveTime = 4 [(api.body)="active_time"];
}
message ListSpaceUsersResult {
repeated SpaceUser users = 1;
}
// 加入空间
message JoinSpaceParams {
string InviteCode = 1 [(api.body)="invite_code",(api.vd)="$ != ''"]; // 邀请码
}
message JoinSpaceResult {
}
// 退出空间
message ExitSpaceParams {
}
message ExitSpaceResult {
}
// 踢出成员
message RemoveSpaceUserParams {
int64 UserId = 1 [(api.body) = "user_id",(api.vd)="$ != 0"];
}
message RemoveSpaceUserResult {
}
// 获取当前用户的空间信息
message GetUserSpaceParams{
}
message GetUserSpaceResult{
int64 SpaceId = 1[(api.body)="space_id"];
string SpaceName = 2[(api.body)="space_name"];
string InviteCode = 3[(api.body)="invite_code"];
int32 Role = 4[(api.body)="role"];
}