coco upgrade
This commit is contained in:
parent
eaab943a68
commit
cb23d9e80d
|
@ -1,4 +1,4 @@
|
||||||
package core
|
package coco
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -4,7 +4,7 @@
|
||||||
// protoc v3.21.5
|
// protoc v3.21.5
|
||||||
// source: core.proto
|
// source: core.proto
|
||||||
|
|
||||||
package core
|
package coco
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
@ -1,8 +1,8 @@
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package core;
|
package coco;
|
||||||
|
|
||||||
option go_package = "./;core";
|
option go_package = "./;coco";
|
||||||
|
|
||||||
message ErrMsg {
|
message ErrMsg {
|
||||||
int32 err_code = 1; // 错误码
|
int32 err_code = 1; // 错误码
|
|
@ -1,61 +0,0 @@
|
||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package controller;
|
|
||||||
|
|
||||||
option go_package = "./;core";
|
|
||||||
|
|
||||||
|
|
||||||
// @route_group: true
|
|
||||||
// @base_url: /api/file
|
|
||||||
// @gen_to: ./core/file_controller.go
|
|
||||||
service File {
|
|
||||||
// @desc: 列表
|
|
||||||
// @author: Young Xu
|
|
||||||
// @method: GET
|
|
||||||
// @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
message ListReq {}
|
|
||||||
|
|
||||||
message ListResp {
|
|
||||||
message Item {
|
|
||||||
string filename = 1; // 文件名
|
|
||||||
string file_size = 2; // 文件大小
|
|
||||||
string created_at = 3; // 上传时间
|
|
||||||
}
|
|
||||||
repeated Item items = 1; // 列表
|
|
||||||
}
|
|
||||||
|
|
||||||
message UploadReq {}
|
|
||||||
|
|
||||||
message UploadResp {}
|
|
||||||
|
|
||||||
message DeleteReq {
|
|
||||||
string filename = 1; // 文件名
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteResp {}
|
|
||||||
|
|
||||||
message DownloadReq {
|
|
||||||
// @v: required
|
|
||||||
string f = 1; // 文件地址
|
|
||||||
}
|
|
||||||
|
|
||||||
message DownloadResp {}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package core
|
package coco
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
12
go.mod
12
go.mod
|
@ -4,7 +4,7 @@ go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-gonic/gin v1.9.1
|
github.com/gin-gonic/gin v1.9.1
|
||||||
github.com/go-playground/validator/v10 v10.15.3
|
github.com/go-playground/validator/v10 v10.15.5
|
||||||
github.com/gorilla/schema v1.2.0
|
github.com/gorilla/schema v1.2.0
|
||||||
github.com/json-iterator/go v1.1.12
|
github.com/json-iterator/go v1.1.12
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
|
@ -13,10 +13,10 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bytedance/sonic v1.10.0 // indirect
|
github.com/bytedance/sonic v1.10.2 // indirect
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||||
github.com/chenzhuoyu/iasm v0.9.0 // indirect
|
github.com/chenzhuoyu/iasm v0.9.0 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
@ -30,9 +30,9 @@ require (
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||||
golang.org/x/arch v0.5.0 // indirect
|
golang.org/x/arch v0.5.0 // indirect
|
||||||
golang.org/x/crypto v0.12.0 // indirect
|
golang.org/x/crypto v0.14.0 // indirect
|
||||||
golang.org/x/net v0.14.0 // indirect
|
golang.org/x/net v0.17.0 // indirect
|
||||||
golang.org/x/sys v0.12.0 // indirect
|
golang.org/x/sys v0.13.0 // indirect
|
||||||
golang.org/x/text v0.13.0 // indirect
|
golang.org/x/text v0.13.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package core
|
package coco
|
||||||
|
|
||||||
import "github.com/gin-gonic/gin"
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package core
|
package coco
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -18,6 +18,10 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ImplGetRouterMap interface {
|
||||||
|
GetRouterMap() *Routers
|
||||||
|
}
|
||||||
|
|
||||||
type Result struct {
|
type Result struct {
|
||||||
ErrCode int `json:"err_code"`
|
ErrCode int `json:"err_code"`
|
||||||
ErrMsg string `json:"err_msg"`
|
ErrMsg string `json:"err_msg"`
|
||||||
|
@ -82,14 +86,23 @@ func (r *Register) DefaultRouter(opts ...RegisterOptions) *Register {
|
||||||
// routers: 绑定自动生成的路由配置文件 proto同级的 autogen_router_module.go 文件中的 AutoGenXXXMap
|
// routers: 绑定自动生成的路由配置文件 proto同级的 autogen_router_module.go 文件中的 AutoGenXXXMap
|
||||||
// ig: 需要注册的API组的struct ptr
|
// ig: 需要注册的API组的struct ptr
|
||||||
// 对于错误或异常零容忍 直接panic
|
// 对于错误或异常零容忍 直接panic
|
||||||
func (r *Register) RegisterStruct(routers *Routers, drv interface{}, mws ...gin.HandlerFunc) {
|
func (r *Register) RegisterStruct(drv interface{}, mws ...gin.HandlerFunc) {
|
||||||
if len(routers.Apis) == 0 {
|
if drv == nil {
|
||||||
logrus.Warnf("%s api list empty, skip register", routers.StructName)
|
logrus.Warnf("struct nil, skip register")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if drv == nil {
|
implGetRouters, ok := drv.(ImplGetRouterMap)
|
||||||
logrus.Warnf("%s api struct nil, skip register", routers.StructName)
|
if !ok {
|
||||||
|
logrus.Panicf("struct not impl ImplGetRouterMap interface")
|
||||||
|
}
|
||||||
|
routers := implGetRouters.GetRouterMap()
|
||||||
|
if routers == nil {
|
||||||
|
logrus.Warnf("routers empty, skip register")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(routers.Apis) == 0 {
|
||||||
|
logrus.Warnf("%s api list empty, skip register", routers.StructName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package core
|
package coco
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
Loading…
Reference in New Issue