first commit
This commit is contained in:
67
README.md
Normal file
67
README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# 神仙盒公共 gRPC 服务定义
|
||||
|
||||
## 项目简介
|
||||
|
||||
这是神仙盒(Shenxianhe)项目的公共 gRPC 服务 Protocol Buffers 定义文件。本仓库包含了项目中所有微服务的接口定义,用于服务间通信和客户端 SDK 生成。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
proto/
|
||||
├── README.md
|
||||
├── buf.yaml
|
||||
└── shenxianhe/
|
||||
└── v1/
|
||||
└── account.proto # 账户服务接口定义
|
||||
```
|
||||
|
||||
## 使用指南
|
||||
|
||||
### 安装依赖
|
||||
|
||||
本项目使用 [Buf](https://buf.build/) 进行 Protocol Buffers 的管理和构建。请先安装 Buf:
|
||||
|
||||
```bash
|
||||
go install github.com/bufbuild/buf/cmd/buf@latest
|
||||
```
|
||||
|
||||
### 检查语法
|
||||
|
||||
```bash
|
||||
# 在 proto 目录下运行
|
||||
buf lint
|
||||
```
|
||||
|
||||
### 检查兼容性
|
||||
|
||||
```bash
|
||||
# 检查 API 兼容性
|
||||
buf breaking --against .git#branch=main
|
||||
```
|
||||
|
||||
## 版本控制
|
||||
|
||||
本项目使用语义化版本控制,服务接口的变更遵循以下原则:
|
||||
|
||||
1. **向后兼容**:尽量保持接口的向后兼容性
|
||||
2. **版本升级**:不兼容的变更会导致版本号的升级
|
||||
3. **Breaking Change 检查**:使用 buf breaking 工具检查不兼容的变更
|
||||
|
||||
## 开发规范
|
||||
|
||||
1. 遵循 [Protocol Buffers Style Guide](https://developers.google.com/protocol-buffers/docs/style)
|
||||
2. 使用标准的 lint 规则(STANDARD)
|
||||
3. 每个服务定义放在单独的目录下,并按版本号组织
|
||||
4. 新增字段时使用新的字段编号,不要重用已删除字段的编号
|
||||
|
||||
## 贡献指南
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 创建特性分支
|
||||
3. 提交变更
|
||||
4. 运行 `buf lint` 和 `buf breaking` 检查
|
||||
5. 创建 Pull Request
|
||||
|
||||
## 版权信息
|
||||
|
||||
© 2025 神仙盒团队. All rights reserved.
|
||||
8
buf.yaml
Normal file
8
buf.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
|
||||
version: v2
|
||||
lint:
|
||||
use:
|
||||
- STANDARD
|
||||
breaking:
|
||||
use:
|
||||
- FILE
|
||||
43
shenxianhe/v1/account.proto
Normal file
43
shenxianhe/v1/account.proto
Normal file
@@ -0,0 +1,43 @@
|
||||
syntax = "proto3";
|
||||
package shenxianhe.v1;
|
||||
option go_package = "shenxianhe/gen/shenxianhe/v1;accountv1";
|
||||
|
||||
message LoginRequest {
|
||||
string phone = 1;
|
||||
string email = 2;
|
||||
string code = 10;
|
||||
}
|
||||
|
||||
message LoginResponse { string token = 1; }
|
||||
|
||||
message SetPasswordRequest {
|
||||
LoginRequest login = 1;
|
||||
string password = 2;
|
||||
}
|
||||
message SetPasswordResponse {}
|
||||
|
||||
message SetNameRequest { string name = 1; }
|
||||
message SetNameResponse {}
|
||||
|
||||
message GetAvatarUploadURLRequest {}
|
||||
message GetAvatarUploadURLResponse { string url = 1; }
|
||||
message SetAvatarRequest { string url = 1; }
|
||||
message SetAvatarResponse {}
|
||||
|
||||
message GetUserInfoRequest {}
|
||||
message GetUserInfoResponse {
|
||||
string name = 1;
|
||||
string avatar_url = 2;
|
||||
string phone = 3;
|
||||
string email = 4;
|
||||
}
|
||||
|
||||
service AccountService {
|
||||
rpc Login(LoginRequest) returns (LoginResponse);
|
||||
rpc SetPassword(SetPasswordRequest) returns (SetPasswordResponse);
|
||||
rpc SetName(SetNameRequest) returns (SetNameResponse);
|
||||
rpc GetAvatarUploadURL(GetAvatarUploadURLRequest)
|
||||
returns (GetAvatarUploadURLResponse);
|
||||
rpc SetAvatar(SetAvatarRequest) returns (SetAvatarResponse);
|
||||
rpc GetUserInfo(GetUserInfoRequest) returns (GetUserInfoResponse);
|
||||
}
|
||||
Reference in New Issue
Block a user