|
|
|
// Code generated by go-mir. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// - mir v4.0.0
|
|
|
|
|
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/alimy/mir/v4"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/rocboss/paopao-ce/internal/model/web"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Friendship interface {
|
|
|
|
_default_
|
|
|
|
|
|
|
|
// Chain provide handlers chain for gin
|
|
|
|
Chain() gin.HandlersChain
|
|
|
|
|
|
|
|
GetContacts(*web.GetContactsReq) (*web.GetContactsResp, mir.Error)
|
|
|
|
DeleteFriend(*web.DeleteFriendReq) mir.Error
|
|
|
|
RejectFriend(*web.RejectFriendReq) mir.Error
|
|
|
|
AddFriend(*web.AddFriendReq) mir.Error
|
|
|
|
RequestingFriend(*web.RequestingFriendReq) mir.Error
|
|
|
|
|
|
|
|
mustEmbedUnimplementedFriendshipServant()
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterFriendshipServant register Friendship servant to gin
|
|
|
|
func RegisterFriendshipServant(e *gin.Engine, s Friendship) {
|
|
|
|
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:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.GetContactsReq)
|
|
|
|
obj = req
|
|
|
|
if bv, ok := obj.(_binding_); !ok {
|
|
|
|
err = s.Bind(c, req)
|
|
|
|
} else {
|
|
|
|
err = bv.Bind(c)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
obj, err = s.GetContacts(req)
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if rv, ok := obj.(_render_); !ok {
|
|
|
|
s.Render(c, obj, nil)
|
|
|
|
} else {
|
|
|
|
rv.Render(c)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
router.Handle("POST", "/friend/delete", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.DeleteFriendReq)
|
|
|
|
obj = req
|
|
|
|
if bv, ok := obj.(_binding_); !ok {
|
|
|
|
err = s.Bind(c, req)
|
|
|
|
} else {
|
|
|
|
err = bv.Bind(c)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
s.Render(c, nil, s.DeleteFriend(req))
|
|
|
|
})
|
|
|
|
router.Handle("POST", "/friend/reject", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.RejectFriendReq)
|
|
|
|
obj = req
|
|
|
|
if bv, ok := obj.(_binding_); !ok {
|
|
|
|
err = s.Bind(c, req)
|
|
|
|
} else {
|
|
|
|
err = bv.Bind(c)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
s.Render(c, nil, s.RejectFriend(req))
|
|
|
|
})
|
|
|
|
router.Handle("POST", "/friend/add", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.AddFriendReq)
|
|
|
|
obj = req
|
|
|
|
if bv, ok := obj.(_binding_); !ok {
|
|
|
|
err = s.Bind(c, req)
|
|
|
|
} else {
|
|
|
|
err = bv.Bind(c)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
s.Render(c, nil, s.AddFriend(req))
|
|
|
|
})
|
|
|
|
router.Handle("POST", "/friend/requesting", func(c *gin.Context) {
|
|
|
|
select {
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
obj any
|
|
|
|
err mir.Error
|
|
|
|
)
|
|
|
|
req := new(web.RequestingFriendReq)
|
|
|
|
obj = req
|
|
|
|
if bv, ok := obj.(_binding_); !ok {
|
|
|
|
err = s.Bind(c, req)
|
|
|
|
} else {
|
|
|
|
err = bv.Bind(c)
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
s.Render(c, nil, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
s.Render(c, nil, s.RequestingFriend(req))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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(req *web.DeleteFriendReq) mir.Error {
|
|
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedFriendshipServant) RejectFriend(req *web.RejectFriendReq) mir.Error {
|
|
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedFriendshipServant) AddFriend(req *web.AddFriendReq) mir.Error {
|
|
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedFriendshipServant) RequestingFriend(req *web.RequestingFriendReq) mir.Error {
|
|
|
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (UnimplementedFriendshipServant) mustEmbedUnimplementedFriendshipServant() {}
|