mirror of https://github.com/rocboss/paopao-ce
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.
157 lines
4.4 KiB
157 lines
4.4 KiB
// Code generated by go-mir. DO NOT EDIT.
|
|
|
|
package v1
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/alimy/mir/v3"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/rocboss/paopao-ce/internal/model/web"
|
|
)
|
|
|
|
type WebFollowship interface {
|
|
// Chain provide handlers chain for gin
|
|
Chain() gin.HandlersChain
|
|
|
|
ListFollowers(*web.ListFollowersReq) (*web.ListFollowersResp, mir.Error)
|
|
ListFollowings() mir.Error
|
|
DeleteFollowing() mir.Error
|
|
AddFollowing() mir.Error
|
|
|
|
mustEmbedUnimplementedWebFollowshipServant()
|
|
}
|
|
|
|
type WebFollowshipBinding interface {
|
|
BindListFollowers(*gin.Context) (*web.ListFollowersReq, mir.Error)
|
|
|
|
mustEmbedUnimplementedWebFollowshipBinding()
|
|
}
|
|
|
|
type WebFollowshipRender interface {
|
|
RenderListFollowers(*gin.Context, *web.ListFollowersResp, mir.Error)
|
|
RenderListFollowings(*gin.Context, mir.Error)
|
|
RenderDeleteFollowing(*gin.Context, mir.Error)
|
|
RenderAddFollowing(*gin.Context, mir.Error)
|
|
|
|
mustEmbedUnimplementedWebFollowshipRender()
|
|
}
|
|
|
|
// RegisterWebFollowshipServant register WebFollowship servant to gin
|
|
func RegisterWebFollowshipServant(e *gin.Engine, s WebFollowship, b WebFollowshipBinding, r WebFollowshipRender) {
|
|
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:
|
|
}
|
|
|
|
r.RenderListFollowings(c, s.ListFollowings())
|
|
})
|
|
|
|
router.Handle("POST", "/following/delete", func(c *gin.Context) {
|
|
select {
|
|
case <-c.Request.Context().Done():
|
|
return
|
|
default:
|
|
}
|
|
|
|
r.RenderDeleteFollowing(c, s.DeleteFollowing())
|
|
})
|
|
|
|
router.Handle("POST", "/following/add", func(c *gin.Context) {
|
|
select {
|
|
case <-c.Request.Context().Done():
|
|
return
|
|
default:
|
|
}
|
|
|
|
r.RenderAddFollowing(c, s.AddFollowing())
|
|
})
|
|
|
|
}
|
|
|
|
// UnimplementedWebFollowshipServant can be embedded to have forward compatible implementations.
|
|
type UnimplementedWebFollowshipServant struct {
|
|
}
|
|
|
|
func (UnimplementedWebFollowshipServant) Chain() gin.HandlersChain {
|
|
return nil
|
|
}
|
|
|
|
func (UnimplementedWebFollowshipServant) ListFollowers(req *web.ListFollowersReq) (*web.ListFollowersResp, mir.Error) {
|
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
}
|
|
|
|
func (UnimplementedWebFollowshipServant) ListFollowings() mir.Error {
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
}
|
|
|
|
func (UnimplementedWebFollowshipServant) DeleteFollowing() mir.Error {
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
}
|
|
|
|
func (UnimplementedWebFollowshipServant) AddFollowing() mir.Error {
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
}
|
|
|
|
func (UnimplementedWebFollowshipServant) mustEmbedUnimplementedWebFollowshipServant() {}
|
|
|
|
// UnimplementedWebFollowshipRender can be embedded to have forward compatible implementations.
|
|
type UnimplementedWebFollowshipRender struct {
|
|
RenderAny func(*gin.Context, any, mir.Error)
|
|
}
|
|
|
|
func (r *UnimplementedWebFollowshipRender) RenderListFollowers(c *gin.Context, data *web.ListFollowersResp, err mir.Error) {
|
|
r.RenderAny(c, data, err)
|
|
}
|
|
|
|
func (r *UnimplementedWebFollowshipRender) RenderListFollowings(c *gin.Context, err mir.Error) {
|
|
r.RenderAny(c, nil, err)
|
|
}
|
|
|
|
func (r *UnimplementedWebFollowshipRender) RenderDeleteFollowing(c *gin.Context, err mir.Error) {
|
|
r.RenderAny(c, nil, err)
|
|
}
|
|
|
|
func (r *UnimplementedWebFollowshipRender) RenderAddFollowing(c *gin.Context, err mir.Error) {
|
|
r.RenderAny(c, nil, err)
|
|
}
|
|
|
|
func (r *UnimplementedWebFollowshipRender) mustEmbedUnimplementedWebFollowshipRender() {}
|
|
|
|
// UnimplementedWebFollowshipBinding can be embedded to have forward compatible implementations.
|
|
type UnimplementedWebFollowshipBinding struct {
|
|
BindAny func(*gin.Context, any) mir.Error
|
|
}
|
|
|
|
func (b *UnimplementedWebFollowshipBinding) BindListFollowers(c *gin.Context) (*web.ListFollowersReq, mir.Error) {
|
|
obj := new(web.ListFollowersReq)
|
|
err := b.BindAny(c, obj)
|
|
return obj, err
|
|
}
|
|
|
|
func (b *UnimplementedWebFollowshipBinding) mustEmbedUnimplementedWebFollowshipBinding() {}
|