You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
paopao-ce/auto/api/v1/followship.go

196 lines
5.7 KiB

// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v3.0.1
package v1
import (
"net/http"
"github.com/alimy/mir/v3"
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-ce/internal/model/web"
)
type Followship interface {
// Chain provide handlers chain for gin
Chain() gin.HandlersChain
ListFollowers(*web.ListFollowersReq) (*web.ListFollowersResp, mir.Error)
ListFollowings(*web.ListFollowingsReq) (*web.ListFollowingsResp, mir.Error)
DeleteFollowing(*web.DeleteFollowingReq) mir.Error
AddFollowing(*web.AddFollowingReq) mir.Error
mustEmbedUnimplementedFollowshipServant()
}
type FollowshipBinding interface {
BindListFollowers(*gin.Context) (*web.ListFollowersReq, mir.Error)
BindListFollowings(*gin.Context) (*web.ListFollowingsReq, mir.Error)
BindDeleteFollowing(*gin.Context) (*web.DeleteFollowingReq, mir.Error)
BindAddFollowing(*gin.Context) (*web.AddFollowingReq, mir.Error)
mustEmbedUnimplementedFollowshipBinding()
}
type FollowshipRender interface {
RenderListFollowers(*gin.Context, *web.ListFollowersResp, mir.Error)
RenderListFollowings(*gin.Context, *web.ListFollowingsResp, mir.Error)
RenderDeleteFollowing(*gin.Context, mir.Error)
RenderAddFollowing(*gin.Context, mir.Error)
mustEmbedUnimplementedFollowshipRender()
}
// RegisterFollowshipServant register Followship servant to gin
func RegisterFollowshipServant(e *gin.Engine, s Followship, b FollowshipBinding, r FollowshipRender) {
router := e.Group("v1")
// use chain for router
middlewares := s.Chain()
router.Use(middlewares...)
// register routes info to router
router.Handle("GET", "/follower/list", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
req, err := b.BindListFollowers(c)
if err != nil {
r.RenderListFollowers(c, nil, err)
return
}
resp, err := s.ListFollowers(req)
r.RenderListFollowers(c, resp, err)
})
router.Handle("GET", "/following/list", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
req, err := b.BindListFollowings(c)
if err != nil {
r.RenderListFollowings(c, nil, err)
return
}
resp, err := s.ListFollowings(req)
r.RenderListFollowings(c, resp, err)
})
router.Handle("POST", "/following/delete", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
req, err := b.BindDeleteFollowing(c)
if err != nil {
r.RenderDeleteFollowing(c, err)
return
}
r.RenderDeleteFollowing(c, s.DeleteFollowing(req))
})
router.Handle("POST", "/following/add", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
req, err := b.BindAddFollowing(c)
if err != nil {
r.RenderAddFollowing(c, err)
return
}
r.RenderAddFollowing(c, s.AddFollowing(req))
})
}
// UnimplementedFollowshipServant can be embedded to have forward compatible implementations.
type UnimplementedFollowshipServant struct {
}
func (UnimplementedFollowshipServant) Chain() gin.HandlersChain {
return nil
}
func (UnimplementedFollowshipServant) ListFollowers(req *web.ListFollowersReq) (*web.ListFollowersResp, mir.Error) {
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFollowshipServant) ListFollowings(req *web.ListFollowingsReq) (*web.ListFollowingsResp, mir.Error) {
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFollowshipServant) DeleteFollowing(req *web.DeleteFollowingReq) mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFollowshipServant) AddFollowing(req *web.AddFollowingReq) mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFollowshipServant) mustEmbedUnimplementedFollowshipServant() {}
// UnimplementedFollowshipRender can be embedded to have forward compatible implementations.
type UnimplementedFollowshipRender struct {
RenderAny func(*gin.Context, any, mir.Error)
}
func (r *UnimplementedFollowshipRender) RenderListFollowers(c *gin.Context, data *web.ListFollowersResp, err mir.Error) {
r.RenderAny(c, data, err)
}
func (r *UnimplementedFollowshipRender) RenderListFollowings(c *gin.Context, data *web.ListFollowingsResp, err mir.Error) {
r.RenderAny(c, data, err)
}
func (r *UnimplementedFollowshipRender) RenderDeleteFollowing(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedFollowshipRender) RenderAddFollowing(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedFollowshipRender) mustEmbedUnimplementedFollowshipRender() {}
// UnimplementedFollowshipBinding can be embedded to have forward compatible implementations.
type UnimplementedFollowshipBinding struct {
BindAny func(*gin.Context, any) mir.Error
}
func (b *UnimplementedFollowshipBinding) BindListFollowers(c *gin.Context) (*web.ListFollowersReq, mir.Error) {
obj := new(web.ListFollowersReq)
err := b.BindAny(c, obj)
return obj, err
}
func (b *UnimplementedFollowshipBinding) BindListFollowings(c *gin.Context) (*web.ListFollowingsReq, mir.Error) {
obj := new(web.ListFollowingsReq)
err := b.BindAny(c, obj)
return obj, err
}
func (b *UnimplementedFollowshipBinding) BindDeleteFollowing(c *gin.Context) (*web.DeleteFollowingReq, mir.Error) {
obj := new(web.DeleteFollowingReq)
err := b.BindAny(c, obj)
return obj, err
}
func (b *UnimplementedFollowshipBinding) BindAddFollowing(c *gin.Context) (*web.AddFollowingReq, mir.Error) {
obj := new(web.AddFollowingReq)
err := b.BindAny(c, obj)
return obj, err
}
func (b *UnimplementedFollowshipBinding) mustEmbedUnimplementedFollowshipBinding() {}