mirror of https://github.com/rocboss/paopao-ce
parent
9be9eccda1
commit
6650d089b8
@ -0,0 +1,127 @@
|
||||
// Code generated by go-mir. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/alimy/mir/v3"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type LoginReq struct {
|
||||
AgentInfo AgentInfo `json:"agent_info"`
|
||||
Name string `json:"name"`
|
||||
Passwd string `json:"passwd"`
|
||||
}
|
||||
|
||||
type AgentInfo struct {
|
||||
Platform string `json:"platform"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
UserInfo
|
||||
ServerInfo ServerInfo `json:"server_info"`
|
||||
JwtToken string `json:"jwt_token"`
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
ApiVer string `json:"api_ver"`
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type User interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
Logout(c *gin.Context) mir.Error
|
||||
Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserServant()
|
||||
}
|
||||
|
||||
type UserBinding interface {
|
||||
BindLogin(c *gin.Context) (*LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserBinding()
|
||||
}
|
||||
|
||||
type UserRender interface {
|
||||
RenderLogout(c *gin.Context, err mir.Error)
|
||||
RenderLogin(c *gin.Context, data *LoginResp, err mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserRender()
|
||||
}
|
||||
|
||||
// RegisterUserServant register User servant to gin
|
||||
func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) {
|
||||
router := e.Group("m/v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("POST", "/user/logout/", func(c *gin.Context) {
|
||||
r.RenderLogout(c, s.Logout(c))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/login/", func(c *gin.Context) {
|
||||
req, err := b.BindLogin(c)
|
||||
if err != nil {
|
||||
r.RenderLogin(c, nil, err)
|
||||
}
|
||||
resp, err := s.Login(c, req)
|
||||
r.RenderLogin(c, resp, err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedUserServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Logout(c *gin.Context) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) mustEmbedUnimplementedUserServant() {}
|
||||
|
||||
// UnimplementedUserRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogout(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) mustEmbedUnimplementedUserRender() {}
|
||||
|
||||
// UnimplementedUserBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
||||
obj := new(LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) mustEmbedUnimplementedUserBinding() {}
|
@ -0,0 +1,131 @@
|
||||
// Code generated by go-mir. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/alimy/mir/v3"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type LoginReq struct {
|
||||
AgentInfo AgentInfo `json:"agent_info"`
|
||||
Name string `json:"name"`
|
||||
Passwd string `json:"passwd"`
|
||||
}
|
||||
|
||||
type AgentInfo struct {
|
||||
Platform string `json:"platform"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
UserInfo
|
||||
ServerInfo ServerInfo `json:"server_info"`
|
||||
JwtToken string `json:"jwt_token"`
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
ApiVer string `json:"api_ver"`
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type User interface {
|
||||
Logout(c *gin.Context) mir.Error
|
||||
Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error)
|
||||
Index(c *gin.Context) mir.Error
|
||||
|
||||
mustEmbedUnimplementedUserServant()
|
||||
}
|
||||
|
||||
type UserBinding interface {
|
||||
BindLogin(c *gin.Context) (*LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserBinding()
|
||||
}
|
||||
|
||||
type UserRender interface {
|
||||
RenderLogout(c *gin.Context, err mir.Error)
|
||||
RenderLogin(c *gin.Context, data *LoginResp, err mir.Error)
|
||||
RenderIndex(c *gin.Context, err mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserRender()
|
||||
}
|
||||
|
||||
// RegisterUserServant register User servant to gin
|
||||
func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) {
|
||||
router := e.Group("s/v1")
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("POST", "/user/logout/", func(c *gin.Context) {
|
||||
r.RenderLogout(c, s.Logout(c))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/login/", func(c *gin.Context) {
|
||||
req, err := b.BindLogin(c)
|
||||
if err != nil {
|
||||
r.RenderLogin(c, nil, err)
|
||||
}
|
||||
resp, err := s.Login(c, req)
|
||||
r.RenderLogin(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/index/", func(c *gin.Context) {
|
||||
r.RenderIndex(c, s.Index(c))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedUserServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Logout(c *gin.Context) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Index(c *gin.Context) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) mustEmbedUnimplementedUserServant() {}
|
||||
|
||||
// UnimplementedUserRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogout(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderIndex(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) mustEmbedUnimplementedUserRender() {}
|
||||
|
||||
// UnimplementedUserBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
||||
obj := new(LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) mustEmbedUnimplementedUserBinding() {}
|
@ -0,0 +1,127 @@
|
||||
// Code generated by go-mir. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/alimy/mir/v3"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type LoginReq struct {
|
||||
AgentInfo AgentInfo `json:"agent_info"`
|
||||
Name string `json:"name"`
|
||||
Passwd string `json:"passwd"`
|
||||
}
|
||||
|
||||
type AgentInfo struct {
|
||||
Platform string `json:"platform"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
UserInfo
|
||||
ServerInfo ServerInfo `json:"server_info"`
|
||||
JwtToken string `json:"jwt_token"`
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
ApiVer string `json:"api_ver"`
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type User interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
Logout(c *gin.Context) mir.Error
|
||||
Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserServant()
|
||||
}
|
||||
|
||||
type UserBinding interface {
|
||||
BindLogin(c *gin.Context) (*LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserBinding()
|
||||
}
|
||||
|
||||
type UserRender interface {
|
||||
RenderLogout(c *gin.Context, err mir.Error)
|
||||
RenderLogin(c *gin.Context, data *LoginResp, err mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserRender()
|
||||
}
|
||||
|
||||
// RegisterUserServant register User servant to gin
|
||||
func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) {
|
||||
router := e.Group("x/v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("POST", "/user/logout/", func(c *gin.Context) {
|
||||
r.RenderLogout(c, s.Logout(c))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/login/", func(c *gin.Context) {
|
||||
req, err := b.BindLogin(c)
|
||||
if err != nil {
|
||||
r.RenderLogin(c, nil, err)
|
||||
}
|
||||
resp, err := s.Login(c, req)
|
||||
r.RenderLogin(c, resp, err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedUserServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Logout(c *gin.Context) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Login(c *gin.Context, req *LoginReq) (*LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) mustEmbedUnimplementedUserServant() {}
|
||||
|
||||
// UnimplementedUserRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogout(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) mustEmbedUnimplementedUserRender() {}
|
||||
|
||||
// UnimplementedUserBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
||||
obj := new(LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) mustEmbedUnimplementedUserBinding() {}
|
@ -1 +1,7 @@
|
||||
### RESTful API for paopao-ce
|
||||
本目录包含所有RESTful API相关定义文件
|
||||
|
||||
* v1 - Web系列 v1版本 相关RESTful API相关定义文件
|
||||
* m - Manager系列相关RESTful API相关定义文件
|
||||
* x - SpaceX系列相关RESTful API相关定义文件
|
||||
* s - LocalOSS OBS系列RESTful API相关定义文件
|
||||
|
@ -0,0 +1,4 @@
|
||||
### Manager系列RESTful API相关定义文件
|
||||
本目录包含 Manager后台运维相关API定义文件。
|
||||
|
||||
* v1 - v1版本API
|
@ -0,0 +1,42 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(User))
|
||||
}
|
||||
|
||||
type AgentInfo struct {
|
||||
Platform string `json:"platform"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
ApiVer string `json:"api_ver"`
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
AgentInfo AgentInfo `json:"agent_info"`
|
||||
Name string `json:"name"`
|
||||
Passwd string `json:"passwd"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
UserInfo
|
||||
ServerInfo ServerInfo `json:"server_info"`
|
||||
JwtToken string `json:"jwt_token"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"m/v1"`
|
||||
Login func(Post, LoginReq) LoginResp `mir:"/user/login/"`
|
||||
Logout func(Post) `mir:"/user/logout/"`
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
### LocalOSS OBS系列RESTful API相关定义文件
|
||||
本目录包含 LocalOSS OBS 系列相关API定义文件。
|
||||
|
||||
* v1 - v1版本API
|
@ -0,0 +1,42 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(User))
|
||||
}
|
||||
|
||||
type AgentInfo struct {
|
||||
Platform string `json:"platform"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
ApiVer string `json:"api_ver"`
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
AgentInfo AgentInfo `json:"agent_info"`
|
||||
Name string `json:"name"`
|
||||
Passwd string `json:"passwd"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
UserInfo
|
||||
ServerInfo ServerInfo `json:"server_info"`
|
||||
JwtToken string `json:"jwt_token"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Group Group `mir:"s/v1"`
|
||||
Index func(Get) `mir:"/index/"`
|
||||
Login func(Post, LoginReq) LoginResp `mir:"/user/login/"`
|
||||
Logout func(Post) `mir:"/user/logout/"`
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
### SpaceX系列RESTful API
|
||||
本目录包含SpaceX系列RESTful API相关定义文件
|
||||
|
||||
* v1 - v1版本API
|
@ -0,0 +1,42 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(User))
|
||||
}
|
||||
|
||||
type AgentInfo struct {
|
||||
Platform string `json:"platform"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
ApiVer string `json:"api_ver"`
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
AgentInfo AgentInfo `json:"agent_info"`
|
||||
Name string `json:"name"`
|
||||
Passwd string `json:"passwd"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
UserInfo
|
||||
ServerInfo ServerInfo `json:"server_info"`
|
||||
JwtToken string `json:"jwt_token"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"x/v1"`
|
||||
Login func(Post, LoginReq) LoginResp `mir:"/user/login/"`
|
||||
Logout func(Post) `mir:"/user/logout/"`
|
||||
}
|
Loading…
Reference in new issue