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.
177 lines
4.8 KiB
177 lines
4.8 KiB
2 years ago
|
// 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"
|
||
|
)
|
||
|
|
||
2 years ago
|
type Friendship interface {
|
||
2 years ago
|
// 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
|
||
|
|
||
2 years ago
|
mustEmbedUnimplementedFriendshipServant()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
type FriendshipBinding interface {
|
||
2 years ago
|
BindGetContacts(*gin.Context) (*web.GetContactsReq, mir.Error)
|
||
|
|
||
2 years ago
|
mustEmbedUnimplementedFriendshipBinding()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
type FriendshipRender interface {
|
||
2 years ago
|
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)
|
||
|
|
||
2 years ago
|
mustEmbedUnimplementedFriendshipRender()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
// RegisterFriendshipServant register Friendship servant to gin
|
||
|
func RegisterFriendshipServant(e *gin.Engine, s Friendship, b FriendshipBinding, r FriendshipRender) {
|
||
2 years ago
|
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())
|
||
|
})
|
||
|
|
||
|
}
|
||
|
|
||
2 years ago
|
// UnimplementedFriendshipServant can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedFriendshipServant struct {
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedFriendshipServant) Chain() gin.HandlersChain {
|
||
2 years ago
|
return nil
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedFriendshipServant) GetContacts(req *web.GetContactsReq) (*web.GetContactsResp, mir.Error) {
|
||
2 years ago
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedFriendshipServant) DeleteFriend() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedFriendshipServant) RejectFriend() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedFriendshipServant) AddFriend() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedFriendshipServant) RequestingFriend() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedFriendshipServant) mustEmbedUnimplementedFriendshipServant() {}
|
||
2 years ago
|
|
||
2 years ago
|
// UnimplementedFriendshipRender can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedFriendshipRender struct {
|
||
2 years ago
|
RenderAny func(*gin.Context, any, mir.Error)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedFriendshipRender) RenderGetContacts(c *gin.Context, data *web.GetContactsResp, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, data, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedFriendshipRender) RenderDeleteFriend(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedFriendshipRender) RenderRejectFriend(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedFriendshipRender) RenderAddFriend(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedFriendshipRender) RenderRequestingFriend(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedFriendshipRender) mustEmbedUnimplementedFriendshipRender() {}
|
||
2 years ago
|
|
||
2 years ago
|
// UnimplementedFriendshipBinding can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedFriendshipBinding struct {
|
||
2 years ago
|
BindAny func(*gin.Context, any) mir.Error
|
||
|
}
|
||
|
|
||
2 years ago
|
func (b *UnimplementedFriendshipBinding) BindGetContacts(c *gin.Context) (*web.GetContactsReq, mir.Error) {
|
||
2 years ago
|
obj := new(web.GetContactsReq)
|
||
|
err := b.BindAny(c, obj)
|
||
|
return obj, err
|
||
|
}
|
||
|
|
||
2 years ago
|
func (b *UnimplementedFriendshipBinding) mustEmbedUnimplementedFriendshipBinding() {}
|