271 lines
5.6 KiB
Protocol Buffer
271 lines
5.6 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;
|
|
}
|
|
message GetUserInfoResp{
|
|
string username = 1;
|
|
string phone = 2;
|
|
int64 disable = 3;
|
|
int64 quotaExceeded = 4;
|
|
}
|
|
|
|
message GetEnterpriseAuthStatusReq {
|
|
int64 userId = 1;
|
|
}
|
|
message GetEnterpriseAuthStatusResp {
|
|
bool isAuth = 1;
|
|
}
|
|
service User {
|
|
// 获取用户信息
|
|
rpc UserInfo(UserInfoReq) returns (UserInfoResp);
|
|
|
|
rpc GetUserInfo(UserInfoReq) returns (GetUserInfoResp);
|
|
|
|
rpc GetEnterpriseAuthStatus(GetEnterpriseAuthStatusReq) returns (GetEnterpriseAuthStatusResp);
|
|
}
|
|
|
|
|
|
// 定义钱包服务
|
|
service WalletService {
|
|
|
|
|
|
// 修改钱包余额
|
|
rpc UpdateWallet (UpdateWalletRequest) returns (UpdateWalletResponse);
|
|
|
|
// 查询钱包信息
|
|
rpc GetWallet (GetWalletRequest) returns (GetWalletResponse);
|
|
|
|
// 查询扣款记录
|
|
rpc GetDeductions (GetDeductionsRequest) returns (GetDeductionsResponse);
|
|
|
|
rpc GetDeductionByTransactionId (GetDeductionByTransactionIdRequest) returns (GetDeductionByTransactionIdResponse);
|
|
}
|
|
|
|
// 更新钱包余额
|
|
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;
|
|
}
|
|
|
|
|
|
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;
|
|
} |