This commit is contained in:
oneao committed 2026-02-25 17:31:09 +08:00
1 parent 835958886e
commit d04d22723b
155 files changed
+543 -9793

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;
}
+39
View File
@@ -0,0 +1,39 @@
syntax = "proto3";
package auth;
option go_package = "auth";
import "api.proto";
message LoginQqReq {
string openid = 1;
string username = 2;
string avatar = 3;
}
message LoginWxReq {
string code = 1;
}
// 登录响应
message LoginResp {
// JWT
string token = 1 [(api.body)="token"];
// 用户ID
int64 userId = 2 [(api.body)="userId"];
// 昵称
string username = 3 [(api.body)="username"];
// 头像
string avatar = 4 [(api.body)="avatar"];
}
// 登录服务
service LoginService {
rpc LoginQq(LoginQqReq) returns (LoginResp) {
option (api.post) = "/auth/login/qq";
}
rpc LoginWx(LoginWxReq) returns (LoginResp) {
option (api.post) = "/auth/login/wx";
}
}
@@ -0,0 +1,52 @@
syntax = "proto3";
package money;
option go_package = "money";
import "api.proto";
import "money/money_category_types.proto";
import "money/money_record_types.proto";
import "money/money_analysis_types.proto";
service MoneyCategoryService {
rpc List(ListMoneyCategoryReq) returns (ListMoneyCategoryResp){
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';
};
rpc CreateMoneyCategory(CreateMoneyCategoryReq) returns (CreateMoneyCategoryResp){
option (api.post) = '/money/category/create';
};
rpc UpdateMoneyCategory(UpdateMoneyCategoryReq) returns (UpdateMoneyCategoryResp){
option (api.post) = '/money/category/update';
};
}
service MoneyRecordService {
rpc ListMoneyRecords(ListMoneyRecordsParams) returns (ListMoneyRecordsResult){
option (api.post) = '/money/records';
}
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';
}
}
service MoneyAnalysisService {
rpc AnalysisMoneyLine(AnalysisMoneyParams) returns (AnalysisMoneyLineResult){
option (api.post) = '/money/analysis/line';
}
rpc AnalysisMoneyPie(AnalysisMoneyParams) returns (AnalysisMoneyPieResult){
option (api.post) = '/money/analysis/pie';
}
}
@@ -0,0 +1,27 @@
syntax = "proto3";
import "api.proto";
package money;
option go_package = "money";
message AnalysisMoneyParams {
string StartDate = 1 [(api.body) = "start_date"]; // 开始时间
string EndDate = 2 [(api.body) = "end_date"]; // 结束时间
int32 Type = 3 [(api.body) = "type"];// 0 支出 1 收入
int32 PeriodType = 4 [(api.body) = "period_type"]; // 0 = 日分析, 1 = 月分析, 2 = 年分析
}
// PeriodAmount 用于存储按天、月、年汇总的金额
message AnalysisMoneyAmount {
string X = 1 [(api.body) = "x"]; // 时间段(按天、月、年)
string Y = 2 [(api.body) = "y"]; // 汇总金额
}
message AnalysisMoneyLineResult {
repeated AnalysisMoneyAmount Records = 1 [(api.body) = "records"];
}
message AnalysisMoneyPieResult {
repeated AnalysisMoneyAmount Records = 1 [(api.body) = "records"];
}
@@ -0,0 +1,78 @@
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 ListMoneyCategoryReq {}
// 查询记账分类响应
message ListMoneyCategoryResp {
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 {}
message CreateMoneyCategoryReq {
string Name = 1 [
(api.body)="name",
(api.vd) = "$ != ''"
];
string Icon = 2 [
(api.body)="icon",
(api.vd) = "$ != ''"
];
int32 Type = 3 [(api.body)="type"];
int32 SortNumber = 4 [(api.body)="sort_number"];
}
message CreateMoneyCategoryResp {
int64 Id = 1 [(api.body)="id"];
}
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 {}
@@ -0,0 +1,72 @@
syntax = "proto3";
package money;
option go_package = "money";
import "api.proto";
// 单条记账记录
message MoneyRecord {
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"];
int64 CreateTime = 7 [(api.body)="create_time"];
int64 UpdateTime = 8 [(api.body)="update_time"];
string Username = 9 [(api.body)="username"];
}
// 查询记账记录请求参数
message ListMoneyRecordsParams {
string StartTime = 1 [(api.body)="start_time"];
string EndTime = 2 [(api.body)="end_time"];
int64 CategoryId = 3 [(api.body)="category_id"];
}
// 查询记账记录结果
message ListMoneyRecordsResult {
repeated MoneyRecord Records = 1 [(api.body)="records"];
}
// 新增记账记录参数
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 {
}
// 更新记账记录
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,46 @@
syntax = "proto3";
package space;
option go_package = "space";
import "api.proto";
import "space/space_types.proto";
service SpaceService {
// 创建空间
rpc CreateSpace(CreateSpaceParams) returns (CreateSpaceParams){
option (api.post) = '/space/create';
};
// 解散空间
rpc DissolveSpace(DissolveSpaceParams) returns (DissolveSpaceResult){
option (api.post) = '/space/dissolve';
};
// 退出空间
rpc ExitSpace(ExitSpaceParams) returns (ExitSpaceResult){
option (api.post) = '/space/exit';
};
// 获取空间用户列表
rpc ListSpaceMembers(ListSpaceMembersParams) returns (ListSpaceMembersResult){
option (api.post) = '/space/members';
};
// 踢出某人
rpc RemoveSpaceMember(RemoveSpaceMemberParams) returns (RemoveSpaceMemberResult){
option (api.post) = '/space/remove';
};
// 加入空间
rpc JoinSpace(JoinSpaceParams) returns (JoinSpaceResult) {
option (api.post) = "/space/join";
};
// 赋予权限
rpc UpdateSpaceMemberRole(UpdateSpaceMemberRoleParams) returns (UpdateSpaceMemberRoleResult) {
option (api.post) = "/space/updateRole";
}
}
@@ -0,0 +1,83 @@
syntax = "proto3";
package space;
option go_package = "space";
import "api.proto";
// 创建空间
message CreateSpaceParams {
string Name = 1 [(api.body)="name"];
}
message CreateSpaceResult {
int64 SpaceId = 1 [(api.body)="space_id"];
string InviteCode = 2 [(api.body)="invite_code"];
}
// 解散空间
message DissolveSpaceParams {
int64 SpaceId = 1 [(api.body) = "space_id"];
}
message DissolveSpaceResult {
}
// 获取空间下的成员
message ListSpaceMembersParams {
int64 SpaceId = 1 [(api.body)="space_id"];
}
message SpaceMember {
int64 Id = 1 [(api.body)="id"];
string Username = 2 [(api.body)="username"];
string Avatar = 3 [(api.body)="avatar"];
int32 Role = 4 [(api.body)="role"];
int64 LastLoginTime = 5 [(api.body)="last_login_time"];
}
message ListSpaceMembersResult {
repeated SpaceMember members = 1;
}
// 加入空间
message JoinSpaceParams {
string InviteCode = 1 [(api.body)="invite_code",(api.vd)="$ != ''"]; // 邀请码
}
message JoinSpaceResult {
int64 SpaceId = 1 [(api.body)="space_id"];
string SpaceName = 2 [(api.body)="space_name"];
}
// 退出空间
message ExitSpaceParams {
int64 SpaceId = 1 [(api.body)="space_id"];
}
message ExitSpaceResult {
}
// 踢出成员
message RemoveSpaceMemberParams {
int64 SpaceId = 1 [(api.body) = "space_id",(api.vd)="$ != 0"];
int64 UserId = 2 [(api.body) = "user_id",(api.vd)="$ != 0"];
}
message RemoveSpaceMemberResult {
}
// 更新权限
message UpdateSpaceMemberRoleParams {
int64 SpaceId = 1 [(api.body) = "space_id",(api.vd)="$ != 0"];
int64 UserId = 2 [(api.body) = "user_id",(api.vd)="$ != 0"];
int32 Role = 3 [(api.body) = "role",(api.vd)="$ != 0"];
}
message UpdateSpaceMemberRoleResult {
}
@@ -0,0 +1,16 @@
syntax = "proto3";
package user;
option go_package = "user";
import "api.proto";
import "user/user_types.proto";
service UserService {
// 获取当前用户所属的所有空间
rpc GetUserSpace(GetUserSpaceParams) returns (UserSpace) {
option (api.get) = "/user/space";
};
}
@@ -0,0 +1,18 @@
syntax = "proto3";
package user;
option go_package = "user";
import "api.proto";
// --- 用户下的空间列表 ---
message GetUserSpaceParams {}
message UserSpace {
int64 Id = 1 [(api.body)="id"];
string Name = 2 [(api.body)="name"];
string InviteCode = 3 [(api.body)="invite_code"];
int32 Role = 4 [(api.body)="role"];
}