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.3 KiB
157 lines
4.3 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 Followship 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
|
|
|
|
mustEmbedUnimplementedFollowshipServant()
|
|
}
|
|
|
|
type FollowshipBinding interface {
|
|
BindListFollowers(*gin.Context) (*web.ListFollowersReq, mir.Error)
|
|
|
|
mustEmbedUnimplementedFollowshipBinding()
|
|
}
|
|
|
|
type FollowshipRender interface {
|
|
RenderListFollowers(*gin.Context, *web.ListFollowersResp, mir.Error)
|
|
RenderListFollowings(*gin.Context, 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:
|
|
}
|
|
|
|
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())
|
|
})
|
|
|
|
}
|
|
|
|
// 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() mir.Error {
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
}
|
|
|
|
func (UnimplementedFollowshipServant) DeleteFollowing() mir.Error {
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
}
|
|
|
|
func (UnimplementedFollowshipServant) AddFollowing() 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, err mir.Error) {
|
|
r.RenderAny(c, nil, 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) mustEmbedUnimplementedFollowshipBinding() {}
|