fix
This commit is contained in:
parent
a51a9fe3bf
commit
b3133a08a1
|
@ -1,45 +1,60 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package v1;
|
||||
package controller;
|
||||
|
||||
option go_package = "./;main";
|
||||
option go_package = "./;core";
|
||||
|
||||
// @route_group: true
|
||||
// @base_url: /api/v1
|
||||
// @gen_to: ./example_controller.go
|
||||
service ExampleService { // tail
|
||||
// @author: xuthus
|
||||
// @desc: test rpc
|
||||
// @route_api: /api/file
|
||||
// @gen_to: ./core/file_controller.go
|
||||
service File {
|
||||
// @desc: 列表
|
||||
// @author: Young Xu
|
||||
// @method: GET
|
||||
rpc ExampleCall1(ExampleMessage1) returns(ReturnType) {}
|
||||
rpc ExampleCall2(ExampleMessage2) returns(ReturnType) {}
|
||||
// @api: /list
|
||||
rpc List (ListReq) returns (ListResp);
|
||||
// @desc: 上传
|
||||
// @author: Young Xu
|
||||
// @method: POST
|
||||
// @api: /upload
|
||||
rpc Upload (UploadReq) returns (UploadResp);
|
||||
// @desc: 删除
|
||||
// @author: Young Xu
|
||||
// @method: POST
|
||||
// @api: /delete
|
||||
rpc Delete (DeleteReq) returns (DeleteResp);
|
||||
// @desc: 下载
|
||||
// @author: Young Xu
|
||||
// @method: GET
|
||||
// @api: /download
|
||||
rpc Download (DownloadReq) returns (DownloadResp);
|
||||
}
|
||||
|
||||
// @route_group: true
|
||||
// @base_url: /api/v2
|
||||
service Example1Service { // tail
|
||||
rpc ExampleCall1(ExampleMessage1) returns(ReturnType) {}
|
||||
rpc ExampleCall2(ExampleMessage2) returns(ReturnType) {}
|
||||
}
|
||||
|
||||
// ExampleMessage1 - Example Leading Comment for ExampleMessage1
|
||||
message ExampleMessage1 {
|
||||
string MyString = 1;
|
||||
}
|
||||
message ListReq {}
|
||||
|
||||
/*
|
||||
ExampleMessage2 - Example Leading Comment for ExampleMessage2
|
||||
*/
|
||||
message ExampleMessage2 {
|
||||
int32 MyInt = 1;
|
||||
// MyInt - Example trailing Comment
|
||||
message ExampleNested {
|
||||
bytes data = 1;
|
||||
message ListResp {
|
||||
message Item {
|
||||
string filename = 1; // 文件名
|
||||
string file_size = 2; // 文件大小
|
||||
string created_at = 3; // 上传时间
|
||||
}
|
||||
ExampleNested nested = 2;
|
||||
repeated Item items = 1; // 列表
|
||||
}
|
||||
|
||||
/*
|
||||
ReturnType - Empty Structure Placeholder
|
||||
*/
|
||||
message ReturnType {}
|
||||
message UploadReq {}
|
||||
|
||||
message UploadResp {}
|
||||
|
||||
message DeleteReq {
|
||||
string filename = 1; // 文件名
|
||||
}
|
||||
|
||||
message DeleteResp {}
|
||||
|
||||
message DownloadReq {
|
||||
// @v: required
|
||||
string f = 1; // 文件地址
|
||||
}
|
||||
|
||||
message DownloadResp {}
|
||||
|
|
3
main.go
3
main.go
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"google.golang.org/protobuf/compiler/protogen"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Coco struct{}
|
||||
|
@ -29,6 +30,8 @@ func (c *Coco) generateRouterMap(plugin *protogen.Plugin) {
|
|||
filename := fmt.Sprintf("autogen_router_%s.go", pbFile.GeneratedFilenamePrefix)
|
||||
g := plugin.NewGeneratedFile(filename, pbFile.GoImportPath)
|
||||
g.P("// Code generated by protoc-gen-coco. DO NOT EDIT.")
|
||||
g.P("// source: ", pbFile.GeneratedFilenamePrefix, ".proto")
|
||||
g.P("// generate at: ", time.Now().Format("2006-01-02 15:04:05"))
|
||||
g.P()
|
||||
g.P("package ", pbFile.GoPackageName)
|
||||
g.P()
|
||||
|
|
Loading…
Reference in New Issue