331 lines
7.3 KiB
Protocol Buffer
331 lines
7.3 KiB
Protocol Buffer
syntax = "proto3";
|
||
|
||
|
||
option go_package = "./user";
|
||
|
||
|
||
//-------------------------global message -----------------------
|
||
message EmptyResponse {}
|
||
|
||
//------------------------ enterprise ------------------------
|
||
// 请求获取待审核企业列表
|
||
message GetPendingEnterpriseReq {
|
||
int64 page = 1;
|
||
int64 page_size = 2;
|
||
}
|
||
|
||
|
||
message EnterpriseItem {
|
||
int64 id = 1;
|
||
string enterprise_name = 2;
|
||
string credit_code = 3;
|
||
string legal_person = 4;
|
||
string enterprise_contact = 5;
|
||
string auth_status = 6;
|
||
string business_license = 7;
|
||
string created_at = 8;
|
||
string updated_at = 9;
|
||
}
|
||
|
||
message GetPendingEnterpriseResp {
|
||
int64 total = 1;
|
||
repeated EnterpriseItem list = 2;
|
||
}
|
||
|
||
// 审核企业请求
|
||
message ReviewEnterpriseReq {
|
||
int64 enterprise_id = 1;
|
||
string status = 2;
|
||
string remarks = 3;
|
||
}
|
||
message EnterpriseAuthReq {
|
||
int64 userId = 1;
|
||
string enterprise_name = 2; // 企业名称
|
||
string credit_code = 3; // 信用代码
|
||
string legal_person = 4; // 法人
|
||
string business_license = 5; // 营业执照
|
||
string enterprise_contact = 6; // 联系人
|
||
}
|
||
|
||
// 定义服务
|
||
service Enterprise {
|
||
// 获取待审核企业列表
|
||
rpc GetPendingEnterprise(GetPendingEnterpriseReq) returns (GetPendingEnterpriseResp);
|
||
|
||
// 审核企业
|
||
rpc ReviewEnterprise(ReviewEnterpriseReq) returns (EmptyResponse);
|
||
|
||
// 提交审核
|
||
rpc CreateEnterpriseAuth(EnterpriseAuthReq) returns (EmptyResponse);
|
||
}
|
||
|
||
//------------------------ User Auth ------------------------
|
||
// 定义注册请求
|
||
message RegisterReq {
|
||
string username = 1;
|
||
string password = 2;
|
||
string confirmPassword = 3;
|
||
string phone = 4;
|
||
string code = 5;
|
||
}
|
||
|
||
// 定义登录请求
|
||
message LoginReq {
|
||
string username = 1;
|
||
string password = 2;
|
||
}
|
||
|
||
// 定义手机登录请求
|
||
message PhoneLoginReq {
|
||
string phone = 1;
|
||
string code = 2;
|
||
}
|
||
|
||
message LoginResp{
|
||
string token = 1;
|
||
}
|
||
|
||
|
||
|
||
// 定义认证服务
|
||
service Auth {
|
||
// 注册接口
|
||
rpc RegisterUser(RegisterReq) returns (EmptyResponse);
|
||
|
||
// 登录接口
|
||
rpc LoginUser(LoginReq) returns (LoginResp);
|
||
|
||
// 手机登录接口
|
||
rpc PhoneLoginUser(PhoneLoginReq) returns (LoginResp);
|
||
}
|
||
|
||
// 定义手机登录请求
|
||
message UserInfoReq {
|
||
int64 userId = 1;
|
||
}
|
||
|
||
message UserInfoResp{
|
||
string username = 1;
|
||
string phone = 2;
|
||
int64 disable = 3;
|
||
int64 quotaExceeded = 4;
|
||
string enterpriseAuthStatus = 5;
|
||
string enterpriseName = 6;
|
||
string creditCode = 7;
|
||
string legalPerson = 8;
|
||
double balance = 9;
|
||
}
|
||
message GetUserInfoResp{
|
||
string username = 1;
|
||
string phone = 2;
|
||
int64 disable = 3;
|
||
int64 quotaExceeded = 4;
|
||
}
|
||
|
||
message GetEnterpriseAuthStatusReq {
|
||
int64 userId = 1;
|
||
}
|
||
message GetEnterpriseAuthStatusResp {
|
||
bool isAuth = 1;
|
||
}
|
||
|
||
message UserListRequest {
|
||
int64 page = 1; // 分页页码
|
||
int64 page_size = 2; // 每页大小
|
||
}
|
||
|
||
message UserListResponse {
|
||
repeated UserItem list = 1;
|
||
int64 total = 2;
|
||
}
|
||
|
||
message UserItem {
|
||
int64 id = 1; // 主键ID
|
||
string username = 2;
|
||
string phone = 3;
|
||
int64 disable = 4;
|
||
int64 quotaExceeded = 5;
|
||
double balance = 6;
|
||
string created_at = 7; // 创建时间
|
||
string updated_at = 8; // 更新时间
|
||
}
|
||
service User {
|
||
// 获取用户信息
|
||
rpc UserInfo(UserInfoReq) returns (UserInfoResp);
|
||
|
||
rpc GetUserInfo(UserInfoReq) returns (GetUserInfoResp);
|
||
|
||
rpc GetEnterpriseAuthStatus(GetEnterpriseAuthStatusReq) returns (GetEnterpriseAuthStatusResp);
|
||
|
||
rpc GetUserList(UserListRequest) returns (UserListResponse);
|
||
|
||
}
|
||
|
||
|
||
// 定义钱包服务
|
||
service WalletService {
|
||
// 修改钱包余额
|
||
rpc UpdateWallet (UpdateWalletRequest) returns (UpdateWalletResponse);
|
||
|
||
// 查询钱包信息
|
||
rpc GetWallet (GetWalletRequest) returns (GetWalletResponse);
|
||
|
||
// 查询扣款记录
|
||
rpc GetDeductions (GetDeductionsRequest) returns (GetDeductionsResponse);
|
||
|
||
rpc GetDeductionByTransactionId (GetDeductionByTransactionIdRequest) returns (GetDeductionByTransactionIdResponse);
|
||
|
||
// 定义充值请求接口
|
||
rpc RechargeWallet (RechargeWalletRequest) returns (RechargeWalletResponse);
|
||
|
||
// 充值记录列表篇
|
||
rpc GetRechargeList(RechargeRequest) returns (RechargeResponse);
|
||
}
|
||
|
||
// 更新钱包余额
|
||
message UpdateWalletRequest {
|
||
int64 user_id = 1;
|
||
string transaction_id = 2;
|
||
string product_code = 3;
|
||
string remark = 4;
|
||
bool charge = 5;
|
||
}
|
||
|
||
message UpdateWalletResponse {
|
||
|
||
}
|
||
|
||
// 查询钱包信息
|
||
message GetWalletRequest {
|
||
int64 id = 1;
|
||
}
|
||
|
||
message GetWalletResponse {
|
||
int64 id = 1;
|
||
int64 user_id = 2;
|
||
double balance = 3;
|
||
int64 version = 4;
|
||
}
|
||
|
||
// 查询扣款记录
|
||
message GetDeductionsRequest {
|
||
int64 user_id = 1;
|
||
int64 page = 2;
|
||
int64 size = 3;
|
||
}
|
||
|
||
message GetDeductionsResponse {
|
||
repeated Deduction deductions = 1;
|
||
}
|
||
message GetDeductionByTransactionIdRequest {
|
||
string transaction_id = 1;
|
||
}
|
||
message GetDeductionByTransactionIdResponse {
|
||
int64 id = 1;
|
||
int64 user_id = 2;
|
||
double amount = 3;
|
||
string transaction_id = 4;
|
||
string created_at = 5;
|
||
}
|
||
message Deduction {
|
||
int64 id = 1;
|
||
int64 user_id = 2;
|
||
double amount = 3;
|
||
string transaction_id = 4;
|
||
string created_at = 5;
|
||
}
|
||
|
||
message RechargeWalletRequest {
|
||
int64 user_id = 1; // 用户ID
|
||
string out_trade_no = 2; // 订单号
|
||
int64 amount = 3; // 充值金额
|
||
int64 payment_method = 4; // 充值方式(1-支付宝在线支付, 2-对公转账)
|
||
}
|
||
|
||
message RechargeWalletResponse {
|
||
|
||
}
|
||
message RechargeRequest {
|
||
int64 user_id = 1; // 用户ID
|
||
int64 page = 2; // 分页页码
|
||
int64 page_size = 3; // 每页大小
|
||
}
|
||
|
||
message RechargeResponse {
|
||
repeated RechargeItem list = 1; // 充值记录列表
|
||
int64 total = 2; // 总记录数
|
||
}
|
||
|
||
message RechargeItem {
|
||
int64 id = 1; // 主键ID
|
||
int64 user_id = 2; // 用户ID
|
||
string transaction_id = 3; // 交易ID
|
||
string out_trade_no = 4; // 外部订单号
|
||
float amount = 5; // 充值金额
|
||
int64 payment_method = 6; // 支付方式
|
||
string created_at = 7; // 创建时间
|
||
string updated_at = 8; // 更新时间
|
||
}
|
||
|
||
service ApiRequestService {
|
||
// 添加API请求记录
|
||
rpc AddApiRequest (AddApiRequestRequest) returns (AddApiRequestResponse);
|
||
|
||
// 查询API请求记录
|
||
rpc GetApiRequests (GetApiRequestsRequest) returns (GetApiRequestsResponse);
|
||
|
||
// 查询API请求记录ByTransactionId
|
||
rpc GetApiRequestByTransactionId (GetApiRequestByTransactionIdRequest) returns (GetApiRequestByTransactionIdResponse);
|
||
}
|
||
// 添加API请求记录
|
||
message AddApiRequestRequest {
|
||
string transaction_id = 1;
|
||
int64 user_id = 2;
|
||
string product_code = 3;
|
||
string status = 4;
|
||
bool charges = 5;
|
||
string remark = 6;
|
||
string timestamp = 7;
|
||
}
|
||
|
||
message AddApiRequestResponse {
|
||
bool success = 1;
|
||
}
|
||
|
||
// 查询API请求记录
|
||
message GetApiRequestsRequest {
|
||
int64 user_id = 1;
|
||
int64 page = 2;
|
||
int64 size = 3;
|
||
}
|
||
|
||
message GetApiRequestsResponse {
|
||
repeated ApiRequest api_requests = 1;
|
||
}
|
||
|
||
message ApiRequest {
|
||
int64 id = 1;
|
||
string transaction_id = 2;
|
||
int64 user_id = 3;
|
||
string product_code = 4;
|
||
string status = 5;
|
||
double charges = 6;
|
||
string remark = 7;
|
||
string timestamp = 8;
|
||
}
|
||
|
||
// 查询API请求记录
|
||
message GetApiRequestByTransactionIdRequest {
|
||
string transaction_id = 1;
|
||
}
|
||
|
||
message GetApiRequestByTransactionIdResponse {
|
||
int64 id = 1;
|
||
string transaction_id = 2;
|
||
int64 user_id = 3;
|
||
string product_code = 4;
|
||
string status = 5;
|
||
double charges = 6;
|
||
string remark = 7;
|
||
string timestamp = 8;
|
||
} |