Files
sundynix-micro-be/app/system/rpc/pb/system.proto
T
2026-05-01 12:56:08 +08:00

441 lines
8.4 KiB
Protocol Buffer

syntax = "proto3";
package system;
option go_package = "./system";
// ========== 通用消息 ==========
message CommonResp {
int64 code = 1;
string msg = 2;
}
message IdReq {
string id = 1;
}
message IdsReq {
repeated string ids = 1;
}
// ========== 角色 ==========
message RoleInfo {
string id = 1;
string name = 2;
string code = 3;
int32 sort = 4;
repeated string menuIds = 5;
int64 createdAt = 6;
}
message RoleReq {
string name = 1;
string code = 2;
int32 sort = 3;
repeated string menuIds = 4;
}
message RoleUpdateReq {
string id = 1;
string name = 2;
string code = 3;
int32 sort = 4;
}
// RBAC 授权
message AssignRoleMenusReq {
string roleId = 1;
repeated string menuIds = 2;
}
message AssignUserRolesReq {
string userId = 1;
repeated string roleIds = 2;
}
message RoleListReq {
int32 current = 1;
int32 pageSize = 2;
string name = 3;
}
message RoleListResp {
repeated RoleInfo list = 1;
int64 total = 2;
}
message GetRoleDetailReq {
string id = 1;
}
message RoleDetailResp {
string id = 1;
string name = 2;
string code = 3;
int32 sort = 4;
repeated string menuIds = 5;
}
// ========== 菜单 ==========
message MenuInfo {
string id = 1;
string parentId = 2;
int32 category = 3;
string name = 4;
string title = 5;
string code = 6;
string path = 7;
string permission = 8;
string locale = 9;
string icon = 10;
int32 sort = 11;
repeated MenuInfo children = 12;
}
message MenuReq {
string parentId = 1;
int32 category = 2;
string name = 3;
string title = 4;
string code = 5;
string path = 6;
string permission = 7;
string locale = 8;
string icon = 9;
int32 sort = 10;
}
message MenuUpdateReq {
string id = 1;
string parentId = 2;
int32 category = 3;
string name = 4;
string title = 5;
string code = 6;
string path = 7;
string permission = 8;
string locale = 9;
string icon = 10;
int32 sort = 11;
}
message MenuListResp {
repeated MenuInfo menus = 1;
}
// ========== 客户端 ==========
message ClientInfo {
string id = 1;
string clientId = 2;
string name = 3;
string grantType = 4;
string additionalInfo = 5;
int64 activeTimeout = 6;
}
message ClientReq {
string clientId = 1;
string name = 2;
string grantType = 3;
string additionalInfo = 4;
int64 activeTimeout = 5;
}
message ClientUpdateReq {
string id = 1;
string clientId = 2;
string name = 3;
string grantType = 4;
string additionalInfo = 5;
int64 activeTimeout = 6;
}
message ClientListReq {
int32 current = 1;
int32 pageSize = 2;
string name = 3;
}
message ClientListResp {
repeated ClientInfo list = 1;
int64 total = 2;
}
// ========== 字典 ==========
message DictInfo {
string id = 1;
string type = 2;
string label = 3;
string value = 4;
int32 sort = 5;
string desc = 6;
}
message DictReq {
string type = 1;
string label = 2;
string value = 3;
int32 sort = 4;
string desc = 5;
}
message DictUpdateReq {
string id = 1;
string type = 2;
string label = 3;
string value = 4;
int32 sort = 5;
string desc = 6;
}
message DictListReq {
int32 current = 1;
int32 pageSize = 2;
string type = 3;
}
message DictListResp {
repeated DictInfo list = 1;
int64 total = 2;
}
// ========== 操作日志 ==========
message OperationRecordInfo {
string id = 1;
string clientId = 2;
string ip = 3;
string method = 4;
string path = 5;
int32 status = 6;
int64 latency = 7;
string agent = 8;
string errorMessage = 9;
string body = 10;
string resp = 11;
string userId = 12;
int64 createdAt = 13;
}
message CreateOperationRecordReq {
string clientId = 1;
string ip = 2;
string method = 3;
string path = 4;
int32 status = 5;
int64 latency = 6;
string agent = 7;
string errorMessage = 8;
string body = 9;
string resp = 10;
string userId = 11;
}
message OperationRecordListReq {
int32 current = 1;
int32 pageSize = 2;
string method = 3;
string path = 4;
int32 status = 5;
}
message OperationRecordListResp {
repeated OperationRecordInfo list = 1;
int64 total = 2;
}
// ========== 用户 ==========
message UserInfo {
string id = 1;
string tenantId = 2;
string clientId = 3;
string name = 4;
string account = 5;
string nickName = 6;
string phone = 7;
string sessionKey = 8;
string unionId = 9;
string openId = 10;
string saOpenId = 11;
string avatarId = 12;
int32 gender = 13;
string country = 14;
string province = 15;
string city = 16;
string language = 17;
int32 isVip = 18;
int64 vipExpireAt = 19;
string lastLoginIp = 20;
int64 lastLoginAt = 21;
int64 createdAt = 22;
int64 updatedAt = 23;
string avatarUrl = 24;
repeated RoleInfo roles = 25;
}
message GetUserByIdReq {
string id = 1;
}
message GetUserByIdResp {
UserInfo user = 1;
}
message GetUserByOpenIdReq {
string openId = 1;
}
message GetUserByOpenIdResp {
UserInfo user = 1;
}
message CreateUserReq {
string name = 1;
string account = 2;
string password = 3;
string openId = 4;
string sessionKey = 5;
string clientId = 6;
string phone = 7;
}
message CreateUserResp {
UserInfo user = 1;
}
message UpdateUserReq {
string id = 1;
string name = 2;
string account = 3;
string phone = 4;
string avatarId = 5;
string nickName = 6;
}
message LoginByAccountReq {
string account = 1;
string password = 2;
}
message LoginByAccountResp {
UserInfo user = 1;
}
message GetUserListReq {
int32 current = 1;
int32 pageSize = 2;
string name = 3;
string account = 4;
}
message GetUserListResp {
repeated UserInfo list = 1;
int64 total = 2;
}
message GetUserDetailReq {
string id = 1;
}
message UserDetailResp {
string id = 1;
string name = 2;
string account = 3;
string nickName = 4;
string phone = 5;
repeated string roleIds = 6;
}
message DeleteUserReq {
repeated string ids = 1;
}
message ResetPasswordReq {
string id = 1;
string password = 2;
}
// ========== 请求/响应(跨模块) ==========
message GetRolesByUserIdReq {
string userId = 1;
}
message GetRolesByUserIdResp {
repeated RoleInfo roles = 1;
}
message GetMenusByRoleIdReq {
string roleId = 1;
}
message GetMenusByRoleIdResp {
repeated MenuInfo menus = 1;
}
message GetClientByIdReq {
string clientId = 1;
}
message GetClientByIdResp {
ClientInfo client = 1;
}
// ========== 服务定义 ==========
service SystemService {
// --- 用户 ---
rpc GetUserById(GetUserByIdReq) returns (GetUserByIdResp);
rpc GetUserByOpenId(GetUserByOpenIdReq) returns (GetUserByOpenIdResp);
rpc LoginByAccount(LoginByAccountReq) returns (LoginByAccountResp);
rpc CreateUser(CreateUserReq) returns (CreateUserResp);
rpc UpdateUser(UpdateUserReq) returns (CommonResp);
rpc GetUserList(GetUserListReq) returns (GetUserListResp);
rpc GetUserDetail(GetUserDetailReq) returns (UserDetailResp);
rpc DeleteUser(DeleteUserReq) returns (CommonResp);
rpc ResetPassword(ResetPasswordReq) returns (CommonResp);
// --- 角色 ---
rpc GetRolesByUserId(GetRolesByUserIdReq) returns (GetRolesByUserIdResp);
rpc CreateRole(RoleReq) returns (CommonResp);
rpc UpdateRole(RoleUpdateReq) returns (CommonResp);
rpc DeleteRole(IdsReq) returns (CommonResp);
rpc GetRoleList(RoleListReq) returns (RoleListResp);
rpc GetRoleDetail(GetRoleDetailReq) returns (RoleDetailResp);
rpc AssignRoleMenus(AssignRoleMenusReq) returns (CommonResp);
// --- RBAC 用户授权 ---
rpc AssignUserRoles(AssignUserRolesReq) returns (CommonResp);
// --- 菜单 ---
rpc GetMenusByRoleId(GetMenusByRoleIdReq) returns (GetMenusByRoleIdResp);
rpc CreateMenu(MenuReq) returns (CommonResp);
rpc UpdateMenu(MenuUpdateReq) returns (CommonResp);
rpc DeleteMenu(IdsReq) returns (CommonResp);
rpc GetMenuList(IdReq) returns (MenuListResp);
// --- 客户端 ---
rpc GetClientById(GetClientByIdReq) returns (GetClientByIdResp);
rpc CreateClient(ClientReq) returns (CommonResp);
rpc UpdateClient(ClientUpdateReq) returns (CommonResp);
rpc DeleteClient(IdsReq) returns (CommonResp);
rpc GetClientList(ClientListReq) returns (ClientListResp);
// --- 字典 ---
rpc CreateDict(DictReq) returns (CommonResp);
rpc UpdateDict(DictUpdateReq) returns (CommonResp);
rpc DeleteDict(IdsReq) returns (CommonResp);
rpc GetDictList(DictListReq) returns (DictListResp);
// --- 操作日志 ---
rpc CreateOperationRecord(CreateOperationRecordReq) returns (CommonResp);
rpc DeleteOperationRecord(IdsReq) returns (CommonResp);
rpc GetOperationRecordList(OperationRecordListReq) returns (OperationRecordListResp);
}