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/friendship.go

177 lines
4.8 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 Friendship interface {
// Chain provide handlers chain for gin
Chain() gin.HandlersChain
GetContacts(*web.GetContactsReq) (*web.GetContactsResp, mir.Error)
DeleteFriend() mir.Error
RejectFriend() mir.Error
AddFriend() mir.Error
RequestingFriend() mir.Error
mustEmbedUnimplementedFriendshipServant()
}
type FriendshipBinding interface {
BindGetContacts(*gin.Context) (*web.GetContactsReq, mir.Error)
mustEmbedUnimplementedFriendshipBinding()
}
type FriendshipRender interface {
RenderGetContacts(*gin.Context, *web.GetContactsResp, mir.Error)
RenderDeleteFriend(*gin.Context, mir.Error)
RenderRejectFriend(*gin.Context, mir.Error)
RenderAddFriend(*gin.Context, mir.Error)
RenderRequestingFriend(*gin.Context, mir.Error)
mustEmbedUnimplementedFriendshipRender()
}
// RegisterFriendshipServant register Friendship servant to gin
func RegisterFriendshipServant(e *gin.Engine, s Friendship, b FriendshipBinding, r FriendshipRender) {
router := e.Group("v1")
// use chain for router
middlewares := s.Chain()
router.Use(middlewares...)
// register routes info to router
router.Handle("GET", "/user/contacts", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
req, err := b.BindGetContacts(c)
if err != nil {
r.RenderGetContacts(c, nil, err)
return
}
resp, err := s.GetContacts(req)
r.RenderGetContacts(c, resp, err)
})
router.Handle("POST", "/friend/delete", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderDeleteFriend(c, s.DeleteFriend())
})
router.Handle("POST", "/friend/reject", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderRejectFriend(c, s.RejectFriend())
})
router.Handle("POST", "/friend/add", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderAddFriend(c, s.AddFriend())
})
router.Handle("POST", "/friend/requesting", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderRequestingFriend(c, s.RequestingFriend())
})
}
// UnimplementedFriendshipServant can be embedded to have forward compatible implementations.
type UnimplementedFriendshipServant struct {
}
func (UnimplementedFriendshipServant) Chain() gin.HandlersChain {
return nil
}
func (UnimplementedFriendshipServant) GetContacts(req *web.GetContactsReq) (*web.GetContactsResp, mir.Error) {
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFriendshipServant) DeleteFriend() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFriendshipServant) RejectFriend() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFriendshipServant) AddFriend() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFriendshipServant) RequestingFriend() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedFriendshipServant) mustEmbedUnimplementedFriendshipServant() {}
// UnimplementedFriendshipRender can be embedded to have forward compatible implementations.
type UnimplementedFriendshipRender struct {
RenderAny func(*gin.Context, any, mir.Error)
}
func (r *UnimplementedFriendshipRender) RenderGetContacts(c *gin.Context, data *web.GetContactsResp, err mir.Error) {
r.RenderAny(c, data, err)
}
func (r *UnimplementedFriendshipRender) RenderDeleteFriend(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedFriendshipRender) RenderRejectFriend(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedFriendshipRender) RenderAddFriend(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedFriendshipRender) RenderRequestingFriend(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedFriendshipRender) mustEmbedUnimplementedFriendshipRender() {}
// UnimplementedFriendshipBinding can be embedded to have forward compatible implementations.
type UnimplementedFriendshipBinding struct {
BindAny func(*gin.Context, any) mir.Error
}
func (b *UnimplementedFriendshipBinding) BindGetContacts(c *gin.Context) (*web.GetContactsReq, mir.Error) {
obj := new(web.GetContactsReq)
err := b.BindAny(c, obj)
return obj, err
}
func (b *UnimplementedFriendshipBinding) mustEmbedUnimplementedFriendshipBinding() {}