Skip to content

Commit

Permalink
完成了openapi的idl定义 (#10)
Browse files Browse the repository at this point in the history
* feat: 初步完成了user服务中有关用户认证和凭证管理的模块

* fix: 修改了分支的名字以适应触发条件

* feat: auth中增加了刷新密钥内容的接口

* fix: 用户信息传递方式修正为userMeta,纠正了user服务中用户初始化的逻辑错误
feat: 增加了设置用户余额的接口

* other: 触发gen莫名没有生效,再试一次

* feat: 增加刷新key的接口

* fix: 优化了新签发一个密钥的请求,能够直接设置名字与hosts

* fix: key的状态中补充了过期状态

* fix: message Key中添加了创建、修改、删除时间的字段

* fix: 删除了获取用户信息响应中的user meta字段

* fix: 简化了用户注册的响应

* fix: 将两个service合并成一个

* feat: 初步完成openapi-charge部分的服务接口定义

* fix: 修正了GetLog服务命名的错误

* fix: 删除了向core_api层传递分页数据时数据携带的deleteTime字段

* fix: 将下游服务中使用usermeta的都改为使用userId进行简化

* feat: 初步搭建了core_api层的接口

* feat: 补充了用户信息修改的接口

* feat: 删除了修改用户信息请求时需要的userId

* feat: 新增校验并获取密钥信息的接口

* fix: 修正错误把check的类型设为string,应为bool

* feat: 新增获取完整接口与基本接口信息用于校验

* feat: 新增用于登录的包装接口

* fix: 获取用户信息的响应补充了userId字段

* feat: 增加了用户购买完整接口的接口

* feat: 增加了根据interfaceId获取一个fullInterface的接口

* fix: 将梯度和fullInterfaceId管理

* fix: 修正了购买了错误设置为string
feat: 创建完整接口请求中添加了返回创建的接口信息

* fix: 修正了购买了错误设置为string
feat: 创建完整接口请求中添加了返回创建的接口信息

* fix: 因为不知道为什么没有触发gen,将fullInterface改为fullInterfaceId

* fix: 将梯度和baseInterface绑定,因为fullInterface难以和模板唯一绑定

* fix: gradient定义中full也改为base

* fix: 考虑到扩展性问题,将接口余量和完整接口分离

* fix: 补充接口余量和完整接口分离需要修改的地方

* fix: 删除了校验响应中的margin

* fix: 增加了创建log时需要接口余量id

* feat: getKeyForCheck时顺带返回用户的角色

* feat: GetFullAndBaseInterfaceForCheck请求携带role避免找不到接口模板

* fix: 修正了需要分页的获取的接口应该是post请求

* fix: 获取key也改成post

* feat: call接口中的url参数调整为action

* feat: 更新接口余量请求和更新用户余额请求添加可选的txId字段

* feat: 下游服务添加了提供流水txId查询的接口

* feat: 完善了essay-show的idl定义
  • Loading branch information
universero authored Nov 27, 2024
1 parent 92ed7be commit 57a4c34
Show file tree
Hide file tree
Showing 14 changed files with 1,309 additions and 19 deletions.
116 changes: 116 additions & 0 deletions essay/show/common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
syntax = "proto3";

package essay.show;

option go_package = "essay/show";
option java_package = "com.xhpolaris.idlgen.essay.show";
option java_outer_classname = "CommonProto";
option java_multiple_files = true;

import "basic/pagination.proto";

/*
* 用户相关
*/

// 注册请求
message SignUpReq {
string name = 1;
string phone = 2;
string password = 3; // 需要MD5加密
}

// 注册响应
message SignUpResp {
string id = 1;
string accessToken = 2;
int64 accessExpire = 3;
}

/*
* 作文批改相关
*/

// 批改文本作文的请求
message EssayEvaluateReq {
string title = 1;
string content = 2;
}

// 批改文本作文的响应
message EssayEvaluateResp {
int64 code = 1;
string msg = 2;
EvaluateResponse response = 3;
}

// 获取批改记录请求
message GetEssayEvaluateLogsReq {
basic.PaginationOptions paginationOptions = 1;
}

// 获取批改记录响应
message GetEssayEvaluateLogsResp {
int64 total = 1;
repeated EvaluateResponse responses = 2;
}

// 响应
//message Response {
// bool done = 1;
// string msg = 2;
//}
//

// beta接口批改的响应
message EvaluateResponse {
// message ModelVersion {
// string name = 1;
// string version = 2;
// }
//
// message OverallEvaluation {
// int64 topicRelevanceScore = 1;
// string description = 2;
// }
//
// message FluencyEvaluation {
// int64 fluencyScore = 1;
// string fluencyDescription = 2;
// }
//
// message WordSentenceEvaluation {
// int64 wordSentenceScore = 1;
// string wordSentenceDescription = 2;
// repeated google.protobuf.Any sentenceEvaluations = 3;
// }
//
// message ExpressionEvaluation {
// int64 expressionScore = 1;
// string expressDescription = 2;
// repeated google.protobuf.Any expressionEvaluations = 3;
// }
//
// message SuggestionEvaluation {
// string suggestionDescription = 1;
// }
//
// message ParagraphEvaluations {
// int64 paragraphIndex = 1;
// string content = 2;
// }
//
// message AIEvaluation {
// ModelVersion modelVersion = 1;
// OverallEvaluation overallEvaluation = 2;
// FluencyEvaluation fluencyEvaluation = 3;
// WordSentenceEvaluation wordSentenceEvaluation = 4;
// ExpressionEvaluation expressionEvaluation = 5;
// SuggestionEvaluation suggestionEvaluation = 6;
// repeated ParagraphEvaluations paragraphEvaluations = 7;
// }
//
string title = 1;
// repeated repeated string text = 2;
// AIEvaluation aiEvaluation = 3;
}
26 changes: 26 additions & 0 deletions essay/show/show.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";

package essay.show;

option go_package = "essay/show";
option java_package = "com.xhpolaris.idlgen.essay.show";
option java_outer_classname = "ShowProto";
option java_multiple_files = true;

import "essay/show/common.proto";
import "http/http.proto";

service show {
// 注册
rpc SignUp(SignUpReq) returns (SignUpResp) {
option (http.post) = "/user/sign_up";
}
// 文本作文批改
rpc EssayEvaluate(EssayEvaluateReq) returns (EssayEvaluateResp) {
option (http.post) = "/essay/evaluate";
}
// 获取批改记录
rpc GetEvaluateLogs(GetEssayEvaluateLogsReq) returns (GetEssayEvaluateLogsResp) {
option (http.post) = "/essay/logs";
}
}
19 changes: 0 additions & 19 deletions open_platform/core_api/user.proto

This file was deleted.

61 changes: 61 additions & 0 deletions openapi/charge/charge.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
syntax = "proto3";

package openapi.charge;

option go_package = "openapi/charge";
option java_package = "com.xhpolaris.idlgen.openapi.charge";
option java_outer_classname = "ChargeProto";
option java_multiple_files = true;

import "openapi/charge/interface.proto";
import "openapi/charge/log.proto";

/*
* 接口管理、调用记录、扣费部分
*/
service charge {
/*
* interface.proto
* 接口的管理
*/

// 基础接口部分
rpc CreateBaseInterface(CreateBaseInterfaceReq) returns (CreateBaseInterfaceResp);
rpc UpdateBaseInterface(UpdateBaseInterfaceReq) returns (UpdateBaseInterfaceResp);
rpc DeleteBaseInterface(DeleteBaseInterfaceReq) returns (DeleteBaseInterfaceResp);
rpc GetBaseInterface(GetBaseInterfaceReq) returns (GetBaseInterfaceResp);

// 完整接口部分
rpc CreateFullInterface(CreateFullInterfaceReq) returns (CreateFullInterfaceResp);
rpc UpdateFullInterface(UpdateFullInterfaceReq) returns (UpdateFullInterfaceResp);
rpc DeleteFullInterface(DeleteFullInterfaceReq) returns (DeleteFullInterfaceResp);
rpc GetFullInterface(GetFullInterfaceReq) returns (GetFullInterfaceResp);
rpc GetOneFullInterface(GetOneFullInterfaceReq) returns (GetOneFullInterfaceResp);

// 余量管理部分
rpc CreateMargin(CreateMarginReq) returns (CreateMarginResp);
rpc UpdateMargin(UpdateMarginReq) returns (UpdateMarginResp);
rpc GetMargin(GetMarginReq) returns (GetMarginResp);
rpc DeleteMargin(DeleteMarginReq) returns (DeleteMarginResp);

// 校验用部分
rpc GetFullAndBaseInterfaceForCheck(GetFullAndBaseInterfaceForCheckReq) returns (GetFullAndBaseInterfaceForCheckResp);

// 梯度折扣部分
rpc CreateGradient(CreateGradientReq) returns (CreateGradientResp);
rpc UpdateGradient(UpdateGradientReq) returns (UpdateGradientResp);
rpc GetGradient(GetGradientReq) returns (GetGradientResp);

/*
* log.proto
* 调用记录的管理
*/

// 调用记录部分
rpc CreateLog(CreateLogReq) returns (CreateLogResp);
rpc GetLog(GetLogReq) returns (GetLogResp);

// 流水管理部分
rpc GetAccountByTxId(GetAccountByTxIdReq) returns (GetAccountByTxIdResp);
}

117 changes: 117 additions & 0 deletions openapi/charge/common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
syntax = "proto3";

package openapi.charge;

option go_package = "openapi/charge";
option java_package = "com.xhpolaris.idlgen.openapi.charge";
option java_outer_classname = "CommonProto";
option java_multiple_files = true;

enum MethodType {
GET = 0;
POST = 1;
PUT = 2;
}

enum PassWayType {
QUERY = 0; // Query Param
PATH = 1; // Path Param
BODY = 2; // Request Body(json)
MULTIPART = 3; // Multipart/form-data
}

enum InterfaceStatus {
ABLE = 0;
UNABLE = 1;
DELETE = 2;
}

enum ChargeType {
TIMES = 0; // 按次计费
TOKENS = 1; // 按量计费
}

enum LogStatus {
SUCCESS = 0; // 成功
UNKNOWN_FAIL = 1; // 未知错误
NETWORK_FAIL = 2; // 网络错误
INVALID_PARAMS = 3; // 参数错误
PERMISSION_DENIED = 4; // 没有对应权限
}

message Parameter {
string name = 1;
string type = 2;
}

message BaseInterface {
string id = 1;
string name = 2; // 接口名
string host = 3; // 域名
string path = 4; // 调用路径
MethodType method = 5; // 调用方式
PassWayType passWay = 6; // 传值方式
repeated Parameter params = 7; // 参数列表
string content = 8;
InterfaceStatus status = 9; // 接口状态
int64 createTime = 10;
int64 updateTime = 11;
}

message FullInterface {
string id = 1;
string baseInterfaceId = 2; // 基础接口id
string userId = 3; // 面向用户id
ChargeType chargeType = 4; // 收费模式
int64 price = 5; // 接口单价
InterfaceStatus status = 7; // 接口状态
int64 createTime = 8; // 创建时间
int64 updateTime = 9; // 更新时间
}

message Margin {
string id = 1;
string userId = 2;
string fullInterfaceId = 3;
int64 margin = 4;
int64 createTime = 5;
int64 updateTime = 6;
}

message Discount {
int64 num = 1;
int64 rate = 2;
int64 low = 3;
}

message Gradient {
string id = 1;
string baseInterfaceId = 2;
repeated Discount discounts = 3;
InterfaceStatus status = 4;
int64 createTime = 5;
int64 updateTime = 6;
}

message Log {
string id = 1; // 记录id
string fullInterfaceId = 2; // 被调用的完整接口id
string userId = 3; // 调用用户的id
string keyId = 4; // 调用key的id
LogStatus status = 5; // 调用的状态
string info = 6; // 调用相关信息
int64 count = 7; // 数量(按次则是次数1,按token则是token数)
int64 value = 8; // 调用扣费
int64 timestamp = 9; // 调用时间
int64 createTime = 10; // 创建时间
}

message Account {
string id = 1;
string txId = 2;
int64 increment = 3;
string marginId = 4;
int64 createTime = 5;
}


Loading

0 comments on commit 57a4c34

Please sign in to comment.