mirror of https://github.com/rocboss/paopao-ce
parent
8139e4dbe2
commit
989d79080e
@ -0,0 +1,95 @@
|
||||
// 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 WebAdmin interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
ChangeUserStatus(*web.ChangeUserStatusReq) mir.Error
|
||||
|
||||
mustEmbedUnimplementedWebAdminServant()
|
||||
}
|
||||
|
||||
type WebAdminBinding interface {
|
||||
BindChangeUserStatus(*gin.Context) (*web.ChangeUserStatusReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebAdminBinding()
|
||||
}
|
||||
|
||||
type WebAdminRender interface {
|
||||
RenderChangeUserStatus(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebAdminRender()
|
||||
}
|
||||
|
||||
// RegisterWebAdminServant register WebAdmin servant to gin
|
||||
func RegisterWebAdminServant(e *gin.Engine, s WebAdmin, b WebAdminBinding, r WebAdminRender) {
|
||||
router := e.Group("v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("POST", "/admin/user/status", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindChangeUserStatus(c)
|
||||
if err != nil {
|
||||
r.RenderChangeUserStatus(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderChangeUserStatus(c, s.ChangeUserStatus(req))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedWebAdminServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAdminServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedWebAdminServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedWebAdminServant) ChangeUserStatus(req *web.ChangeUserStatusReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebAdminServant) mustEmbedUnimplementedWebAdminServant() {}
|
||||
|
||||
// UnimplementedWebAdminRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAdminRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebAdminRender) RenderChangeUserStatus(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebAdminRender) mustEmbedUnimplementedWebAdminRender() {}
|
||||
|
||||
// UnimplementedWebAdminBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAdminBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebAdminBinding) BindChangeUserStatus(c *gin.Context) (*web.ChangeUserStatusReq, mir.Error) {
|
||||
obj := new(web.ChangeUserStatusReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebAdminBinding) mustEmbedUnimplementedWebAdminBinding() {}
|
@ -0,0 +1,136 @@
|
||||
// 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 WebAlipayPriv interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
UserWalletBills(*web.UserWalletBillsReq) (*web.UserWalletBillsResp, mir.Error)
|
||||
UserRechargeResult() mir.Error
|
||||
UserRechargeLink() mir.Error
|
||||
|
||||
mustEmbedUnimplementedWebAlipayPrivServant()
|
||||
}
|
||||
|
||||
type WebAlipayPrivBinding interface {
|
||||
BindUserWalletBills(*gin.Context) (*web.UserWalletBillsReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebAlipayPrivBinding()
|
||||
}
|
||||
|
||||
type WebAlipayPrivRender interface {
|
||||
RenderUserWalletBills(*gin.Context, *web.UserWalletBillsResp, mir.Error)
|
||||
RenderUserRechargeResult(*gin.Context, mir.Error)
|
||||
RenderUserRechargeLink(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebAlipayPrivRender()
|
||||
}
|
||||
|
||||
// RegisterWebAlipayPrivServant register WebAlipayPriv servant to gin
|
||||
func RegisterWebAlipayPrivServant(e *gin.Engine, s WebAlipayPriv, b WebAlipayPrivBinding, r WebAlipayPrivRender) {
|
||||
router := e.Group("v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("GET", "/user/wallet/bills", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindUserWalletBills(c)
|
||||
if err != nil {
|
||||
r.RenderUserWalletBills(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.UserWalletBills(req)
|
||||
r.RenderUserWalletBills(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/user/recharge", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderUserRechargeResult(c, s.UserRechargeResult())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/recharge", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderUserRechargeLink(c, s.UserRechargeLink())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedWebAlipayPrivServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAlipayPrivServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedWebAlipayPrivServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedWebAlipayPrivServant) UserWalletBills(req *web.UserWalletBillsReq) (*web.UserWalletBillsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebAlipayPrivServant) UserRechargeResult() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebAlipayPrivServant) UserRechargeLink() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebAlipayPrivServant) mustEmbedUnimplementedWebAlipayPrivServant() {}
|
||||
|
||||
// UnimplementedWebAlipayPrivRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAlipayPrivRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebAlipayPrivRender) RenderUserWalletBills(c *gin.Context, data *web.UserWalletBillsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebAlipayPrivRender) RenderUserRechargeResult(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebAlipayPrivRender) RenderUserRechargeLink(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebAlipayPrivRender) mustEmbedUnimplementedWebAlipayPrivRender() {}
|
||||
|
||||
// UnimplementedWebAlipayPrivBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAlipayPrivBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebAlipayPrivBinding) BindUserWalletBills(c *gin.Context) (*web.UserWalletBillsReq, mir.Error) {
|
||||
obj := new(web.UserWalletBillsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebAlipayPrivBinding) mustEmbedUnimplementedWebAlipayPrivBinding() {}
|
@ -0,0 +1,85 @@
|
||||
// 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 WebAlipayPub interface {
|
||||
AlipayNotify(*web.AlipayNotifyReq) mir.Error
|
||||
|
||||
mustEmbedUnimplementedWebAlipayPubServant()
|
||||
}
|
||||
|
||||
type WebAlipayPubBinding interface {
|
||||
BindAlipayNotify(*gin.Context) (*web.AlipayNotifyReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebAlipayPubBinding()
|
||||
}
|
||||
|
||||
type WebAlipayPubRender interface {
|
||||
RenderAlipayNotify(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebAlipayPubRender()
|
||||
}
|
||||
|
||||
// RegisterWebAlipayPubServant register WebAlipayPub servant to gin
|
||||
func RegisterWebAlipayPubServant(e *gin.Engine, s WebAlipayPub, b WebAlipayPubBinding, r WebAlipayPubRender) {
|
||||
router := e.Group("v1")
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("POST", "/alipay/notify", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindAlipayNotify(c)
|
||||
if err != nil {
|
||||
r.RenderAlipayNotify(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderAlipayNotify(c, s.AlipayNotify(req))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedWebAlipayPubServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAlipayPubServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedWebAlipayPubServant) AlipayNotify(req *web.AlipayNotifyReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebAlipayPubServant) mustEmbedUnimplementedWebAlipayPubServant() {}
|
||||
|
||||
// UnimplementedWebAlipayPubRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAlipayPubRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebAlipayPubRender) RenderAlipayNotify(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebAlipayPubRender) mustEmbedUnimplementedWebAlipayPubRender() {}
|
||||
|
||||
// UnimplementedWebAlipayPubBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebAlipayPubBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebAlipayPubBinding) BindAlipayNotify(c *gin.Context) (*web.AlipayNotifyReq, mir.Error) {
|
||||
obj := new(web.AlipayNotifyReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebAlipayPubBinding) mustEmbedUnimplementedWebAlipayPubBinding() {}
|
@ -0,0 +1,156 @@
|
||||
// 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() {}
|
@ -0,0 +1,176 @@
|
||||
// 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 WebFriendship 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
|
||||
|
||||
mustEmbedUnimplementedWebFriendshipServant()
|
||||
}
|
||||
|
||||
type WebFriendshipBinding interface {
|
||||
BindGetContacts(*gin.Context) (*web.GetContactsReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebFriendshipBinding()
|
||||
}
|
||||
|
||||
type WebFriendshipRender 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)
|
||||
|
||||
mustEmbedUnimplementedWebFriendshipRender()
|
||||
}
|
||||
|
||||
// RegisterWebFriendshipServant register WebFriendship servant to gin
|
||||
func RegisterWebFriendshipServant(e *gin.Engine, s WebFriendship, b WebFriendshipBinding, r WebFriendshipRender) {
|
||||
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())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedWebFriendshipServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebFriendshipServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedWebFriendshipServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedWebFriendshipServant) GetContacts(req *web.GetContactsReq) (*web.GetContactsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebFriendshipServant) DeleteFriend() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebFriendshipServant) RejectFriend() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebFriendshipServant) AddFriend() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebFriendshipServant) RequestingFriend() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebFriendshipServant) mustEmbedUnimplementedWebFriendshipServant() {}
|
||||
|
||||
// UnimplementedWebFriendshipRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebFriendshipRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebFriendshipRender) RenderGetContacts(c *gin.Context, data *web.GetContactsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebFriendshipRender) RenderDeleteFriend(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebFriendshipRender) RenderRejectFriend(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebFriendshipRender) RenderAddFriend(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebFriendshipRender) RenderRequestingFriend(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebFriendshipRender) mustEmbedUnimplementedWebFriendshipRender() {}
|
||||
|
||||
// UnimplementedWebFriendshipBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebFriendshipBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebFriendshipBinding) BindGetContacts(c *gin.Context) (*web.GetContactsReq, mir.Error) {
|
||||
obj := new(web.GetContactsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebFriendshipBinding) mustEmbedUnimplementedWebFriendshipBinding() {}
|
@ -0,0 +1,136 @@
|
||||
// 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 WebLoose interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
GetUserProfile() mir.Error
|
||||
GetUserTweets() mir.Error
|
||||
Timeline(*web.TimelineReq) (*web.TimelineResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebLooseServant()
|
||||
}
|
||||
|
||||
type WebLooseBinding interface {
|
||||
BindTimeline(*gin.Context) (*web.TimelineReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebLooseBinding()
|
||||
}
|
||||
|
||||
type WebLooseRender interface {
|
||||
RenderGetUserProfile(*gin.Context, mir.Error)
|
||||
RenderGetUserTweets(*gin.Context, mir.Error)
|
||||
RenderTimeline(*gin.Context, *web.TimelineResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebLooseRender()
|
||||
}
|
||||
|
||||
// RegisterWebLooseServant register WebLoose servant to gin
|
||||
func RegisterWebLooseServant(e *gin.Engine, s WebLoose, b WebLooseBinding, r WebLooseRender) {
|
||||
router := e.Group("v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("GET", "/user/profile", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderGetUserProfile(c, s.GetUserProfile())
|
||||
})
|
||||
|
||||
router.Handle("GET", "/user/posts", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderGetUserTweets(c, s.GetUserTweets())
|
||||
})
|
||||
|
||||
router.Handle("GET", "/Posts", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindTimeline(c)
|
||||
if err != nil {
|
||||
r.RenderTimeline(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.Timeline(req)
|
||||
r.RenderTimeline(c, resp, err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedWebLooseServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebLooseServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedWebLooseServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedWebLooseServant) GetUserProfile() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebLooseServant) GetUserTweets() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebLooseServant) Timeline(req *web.TimelineReq) (*web.TimelineResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebLooseServant) mustEmbedUnimplementedWebLooseServant() {}
|
||||
|
||||
// UnimplementedWebLooseRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebLooseRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebLooseRender) RenderGetUserProfile(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebLooseRender) RenderGetUserTweets(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebLooseRender) RenderTimeline(c *gin.Context, data *web.TimelineResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebLooseRender) mustEmbedUnimplementedWebLooseRender() {}
|
||||
|
||||
// UnimplementedWebLooseBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebLooseBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebLooseBinding) BindTimeline(c *gin.Context) (*web.TimelineReq, mir.Error) {
|
||||
obj := new(web.TimelineReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebLooseBinding) mustEmbedUnimplementedWebLooseBinding() {}
|
@ -0,0 +1,356 @@
|
||||
// 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 WebPriv interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
DeleteCommentReply() mir.Error
|
||||
CreateCommentReply() mir.Error
|
||||
DeleteComment() mir.Error
|
||||
CreateComment() mir.Error
|
||||
VisiblePost() mir.Error
|
||||
StickTweet() mir.Error
|
||||
LockTweet() mir.Error
|
||||
CollectionTweet() mir.Error
|
||||
StarTweet() mir.Error
|
||||
DeleteTweet() mir.Error
|
||||
CreateTweet(*web.CreateTweetReq) (*web.CreateTweetResp, mir.Error)
|
||||
DownloadAttachment() mir.Error
|
||||
DownloadAttachmentPrecheck() mir.Error
|
||||
UploadAttachment() mir.Error
|
||||
|
||||
mustEmbedUnimplementedWebPrivServant()
|
||||
}
|
||||
|
||||
type WebPrivBinding interface {
|
||||
BindCreateTweet(*gin.Context) (*web.CreateTweetReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebPrivBinding()
|
||||
}
|
||||
|
||||
type WebPrivRender interface {
|
||||
RenderDeleteCommentReply(*gin.Context, mir.Error)
|
||||
RenderCreateCommentReply(*gin.Context, mir.Error)
|
||||
RenderDeleteComment(*gin.Context, mir.Error)
|
||||
RenderCreateComment(*gin.Context, mir.Error)
|
||||
RenderVisiblePost(*gin.Context, mir.Error)
|
||||
RenderStickTweet(*gin.Context, mir.Error)
|
||||
RenderLockTweet(*gin.Context, mir.Error)
|
||||
RenderCollectionTweet(*gin.Context, mir.Error)
|
||||
RenderStarTweet(*gin.Context, mir.Error)
|
||||
RenderDeleteTweet(*gin.Context, mir.Error)
|
||||
RenderCreateTweet(*gin.Context, *web.CreateTweetResp, mir.Error)
|
||||
RenderDownloadAttachment(*gin.Context, mir.Error)
|
||||
RenderDownloadAttachmentPrecheck(*gin.Context, mir.Error)
|
||||
RenderUploadAttachment(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebPrivRender()
|
||||
}
|
||||
|
||||
// RegisterWebPrivServant register WebPriv servant to gin
|
||||
func RegisterWebPrivServant(e *gin.Engine, s WebPriv, b WebPrivBinding, r WebPrivRender) {
|
||||
router := e.Group("v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("DELETE", "/post/comment/reply", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderDeleteCommentReply(c, s.DeleteCommentReply())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/comment/reply", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderCreateCommentReply(c, s.CreateCommentReply())
|
||||
})
|
||||
|
||||
router.Handle("DELETE", "/post/comment", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderDeleteComment(c, s.DeleteComment())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/comment", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderCreateComment(c, s.CreateComment())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/visibility", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderVisiblePost(c, s.VisiblePost())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/stick", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderStickTweet(c, s.StickTweet())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/lock", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderLockTweet(c, s.LockTweet())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/collection", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderCollectionTweet(c, s.CollectionTweet())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/start", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderStarTweet(c, s.StarTweet())
|
||||
})
|
||||
|
||||
router.Handle("DELETE", "/post", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderDeleteTweet(c, s.DeleteTweet())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindCreateTweet(c)
|
||||
if err != nil {
|
||||
r.RenderCreateTweet(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.CreateTweet(req)
|
||||
r.RenderCreateTweet(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/attachment", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderDownloadAttachment(c, s.DownloadAttachment())
|
||||
})
|
||||
|
||||
router.Handle("GET", "/attachment/precheck", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderDownloadAttachmentPrecheck(c, s.DownloadAttachmentPrecheck())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/attachment", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderUploadAttachment(c, s.UploadAttachment())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedWebPrivServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebPrivServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) DeleteCommentReply() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) CreateCommentReply() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) DeleteComment() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) CreateComment() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) VisiblePost() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) StickTweet() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) LockTweet() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) CollectionTweet() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) StarTweet() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) DeleteTweet() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) CreateTweet(req *web.CreateTweetReq) (*web.CreateTweetResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) DownloadAttachment() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) DownloadAttachmentPrecheck() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) UploadAttachment() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPrivServant) mustEmbedUnimplementedWebPrivServant() {}
|
||||
|
||||
// UnimplementedWebPrivRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebPrivRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderDeleteCommentReply(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderCreateCommentReply(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderDeleteComment(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderCreateComment(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderVisiblePost(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderStickTweet(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderLockTweet(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderCollectionTweet(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderStarTweet(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderDeleteTweet(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderCreateTweet(c *gin.Context, data *web.CreateTweetResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderDownloadAttachment(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderDownloadAttachmentPrecheck(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) RenderUploadAttachment(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPrivRender) mustEmbedUnimplementedWebPrivRender() {}
|
||||
|
||||
// UnimplementedWebPrivBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebPrivBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebPrivBinding) BindCreateTweet(c *gin.Context) (*web.CreateTweetReq, mir.Error) {
|
||||
obj := new(web.CreateTweetReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebPrivBinding) mustEmbedUnimplementedWebPrivBinding() {}
|
@ -0,0 +1,226 @@
|
||||
// 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 WebPub interface {
|
||||
TopicList() mir.Error
|
||||
TweetComments() mir.Error
|
||||
TweetDetail(*web.TweetDetailReq) (*web.TweetDetailResp, mir.Error)
|
||||
SendCaptcha() mir.Error
|
||||
GetCaptcha() mir.Error
|
||||
Register() mir.Error
|
||||
Login() mir.Error
|
||||
Version() mir.Error
|
||||
|
||||
mustEmbedUnimplementedWebPubServant()
|
||||
}
|
||||
|
||||
type WebPubBinding interface {
|
||||
BindTweetDetail(*gin.Context) (*web.TweetDetailReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebPubBinding()
|
||||
}
|
||||
|
||||
type WebPubRender interface {
|
||||
RenderTopicList(*gin.Context, mir.Error)
|
||||
RenderTweetComments(*gin.Context, mir.Error)
|
||||
RenderTweetDetail(*gin.Context, *web.TweetDetailResp, mir.Error)
|
||||
RenderSendCaptcha(*gin.Context, mir.Error)
|
||||
RenderGetCaptcha(*gin.Context, mir.Error)
|
||||
RenderRegister(*gin.Context, mir.Error)
|
||||
RenderLogin(*gin.Context, mir.Error)
|
||||
RenderVersion(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebPubRender()
|
||||
}
|
||||
|
||||
// RegisterWebPubServant register WebPub servant to gin
|
||||
func RegisterWebPubServant(e *gin.Engine, s WebPub, b WebPubBinding, r WebPubRender) {
|
||||
router := e.Group("v1")
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("GET", "/tags", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderTopicList(c, s.TopicList())
|
||||
})
|
||||
|
||||
router.Handle("GET", "/post/comments", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderTweetComments(c, s.TweetComments())
|
||||
})
|
||||
|
||||
router.Handle("GET", "/post", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindTweetDetail(c)
|
||||
if err != nil {
|
||||
r.RenderTweetDetail(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.TweetDetail(req)
|
||||
r.RenderTweetDetail(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/captcha", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderSendCaptcha(c, s.SendCaptcha())
|
||||
})
|
||||
|
||||
router.Handle("GET", "/captcha", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderGetCaptcha(c, s.GetCaptcha())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/auth/register", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderRegister(c, s.Register())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/auth/login", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderLogin(c, s.Login())
|
||||
})
|
||||
|
||||
router.Handle("GET", "/", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderVersion(c, s.Version())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedWebPubServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebPubServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) TopicList() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) TweetComments() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) SendCaptcha() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) GetCaptcha() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) Register() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) Login() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) Version() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebPubServant) mustEmbedUnimplementedWebPubServant() {}
|
||||
|
||||
// UnimplementedWebPubRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebPubRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) RenderTopicList(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) RenderTweetComments(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) RenderTweetDetail(c *gin.Context, data *web.TweetDetailResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) RenderSendCaptcha(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) RenderGetCaptcha(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) RenderRegister(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) RenderLogin(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) RenderVersion(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebPubRender) mustEmbedUnimplementedWebPubRender() {}
|
||||
|
||||
// UnimplementedWebPubBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebPubBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebPubBinding) BindTweetDetail(c *gin.Context) (*web.TweetDetailReq, mir.Error) {
|
||||
obj := new(web.TweetDetailReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebPubBinding) mustEmbedUnimplementedWebPubBinding() {}
|
@ -0,0 +1,5 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package model
|
@ -0,0 +1,5 @@
|
||||
package web
|
||||
|
||||
type ChangeUserStatusReq struct {
|
||||
*BaseInfo
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package web
|
||||
|
||||
type UserWalletBillsReq struct {
|
||||
*BaseInfo
|
||||
}
|
||||
|
||||
type UserWalletBillsResp struct {
|
||||
// TODO
|
||||
}
|
||||
|
||||
type AlipayNotifyReq struct {
|
||||
// TODO
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package web
|
||||
|
||||
type ChangeAvatarReq struct {
|
||||
*BaseInfo
|
||||
}
|
||||
|
||||
type UserInfoReq struct {
|
||||
*BaseInfo
|
||||
}
|
||||
|
||||
type UserInfoResp struct {
|
||||
// TODO
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package web
|
||||
|
||||
type ListFollowersReq struct {
|
||||
*BaseInfo
|
||||
}
|
||||
|
||||
type ListFollowersResp struct {
|
||||
// TODO
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package web
|
||||
|
||||
type GetContactsReq struct {
|
||||
*BaseInfo
|
||||
}
|
||||
|
||||
type GetContactsResp struct {
|
||||
// TODO
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package web
|
||||
|
||||
type TimelineReq struct {
|
||||
*BaseInfo
|
||||
}
|
||||
|
||||
type TimelineResp struct {
|
||||
// TODO
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package web
|
||||
|
||||
type CreateTweetReq struct {
|
||||
*BaseInfo
|
||||
}
|
||||
|
||||
type CreateTweetResp struct {
|
||||
// TODO
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package web
|
||||
|
||||
type TweetDetailReq struct {
|
||||
// TODO
|
||||
}
|
||||
|
||||
type TweetDetailResp struct {
|
||||
// TODO
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package web
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
)
|
||||
|
||||
type BaseInfo struct {
|
||||
User *core.User
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebAdmin))
|
||||
}
|
||||
|
||||
// // 管理·禁言/解封用户
|
||||
// adminApi.POST("/admin/user/status", api.ChangeUserStatus)
|
||||
|
||||
type WebAdmin struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// ChangeUserStatus 管理·禁言/解封用户
|
||||
ChangeUserStatus func(Post, web.ChangeUserStatusReq) `mir:"/admin/user/status"`
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntries(new(WebAlipayPub), new(WebAlipayPriv))
|
||||
}
|
||||
|
||||
// // routeAlipay register Alipay feature releated route if needed
|
||||
// func routeAlipay(public gin.IRoutes, authApi gin.IRoutes) {
|
||||
// // 支付宝回调
|
||||
// public.POST("/alipay/notify", api.AlipayNotify)
|
||||
|
||||
// // 用户充值
|
||||
// authApi.POST("/user/recharge", api.GetUserRechargeLink)
|
||||
|
||||
// // 获取钱包余额
|
||||
// authApi.GET("/user/recharge", api.GetUserRechargeResult)
|
||||
|
||||
// // 获取用户账单
|
||||
// authApi.GET("/user/wallet/bills", api.GetUserWalletBills)
|
||||
// }
|
||||
|
||||
type WebAlipayPub struct {
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// AlipayNotify 支付宝回调
|
||||
AlipayNotify func(Post, web.AlipayNotifyReq) `mir:"/alipay/notify"`
|
||||
}
|
||||
|
||||
type WebAlipayPriv struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// UserRechargeLink 用户充值
|
||||
UserRechargeLink func(Post) `mir:"/user/recharge"`
|
||||
// UserRechargeResult 获取钱包余额
|
||||
UserRechargeResult func(Get) `mir:"/user/recharge"`
|
||||
// UserWalletBills 获取用户账单
|
||||
UserWalletBills func(Get, web.UserWalletBillsReq) web.UserWalletBillsResp `mir:"/user/wallet/bills"`
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
)
|
||||
|
||||
type BaseInfo struct {
|
||||
User *core.User
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebCore))
|
||||
}
|
||||
|
||||
// // 同步索引
|
||||
// authApi.GET("/sync/index", api.SyncSearchIndex)
|
||||
|
||||
// // 获取当前用户信息
|
||||
// authApi.GET("/user/info", api.GetUserInfo)
|
||||
|
||||
// // 获取当前用户未读消息数量
|
||||
// authApi.GET("/user/msgcount/unread", api.GetUnreadMsgCount)
|
||||
|
||||
// // 获取消息列表
|
||||
// authApi.GET("/user/messages", api.GetMessages)
|
||||
|
||||
// // 标记消息已读
|
||||
// authApi.POST("/user/message/read", api.ReadMessage)
|
||||
|
||||
// // 发送用户私信
|
||||
// authApi.POST("/user/whisper", api.SendUserWhisper)
|
||||
|
||||
// // 获取用户收藏列表
|
||||
// authApi.GET("/user/collections", api.GetUserCollections)
|
||||
|
||||
// // 获取用户点赞列表
|
||||
// authApi.GET("/user/stars", api.GetUserStars)
|
||||
|
||||
// // 绑定用户手机号
|
||||
// authApi.POST("/user/phone", api.BindUserPhone)
|
||||
|
||||
// // 修改密码
|
||||
// authApi.POST("/user/password", api.ChangeUserPassword)
|
||||
|
||||
// // 修改昵称
|
||||
// authApi.POST("/user/nickname", api.ChangeNickname)
|
||||
|
||||
// // 修改头像
|
||||
// authApi.POST("/user/avatar", api.ChangeAvatar)
|
||||
|
||||
// // 检索用户
|
||||
// authApi.GET("/suggest/users", api.GetSuggestUsers)
|
||||
|
||||
// // 检索标签
|
||||
// authApi.GET("/suggest/tags", api.GetSuggestTags)
|
||||
|
||||
// // 获取动态点赞状态
|
||||
// authApi.GET("/post/star", api.GetPostStar)
|
||||
|
||||
// // 获取动态收藏状态
|
||||
// authApi.GET("/post/collection", api.GetPostCollection)
|
||||
|
||||
type WebCore struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// SyncSearchIndex 同步索引
|
||||
SyncSearchIndex func(Get) `mir:"/sync/index"`
|
||||
// GetUserInfo 获取当前用户信息
|
||||
GetUserInfo func(Get, web.UserInfoReq) web.UserInfoResp `mir:"/user/info"`
|
||||
// GetUnreadMsgCount 获取当前用户未读消息数量
|
||||
GetUnreadMsgCount func(Get) `mir:"/user/msgcount/unread"`
|
||||
// GetMessages 获取消息列表
|
||||
GetMessages func(Get) `mir:"/user/messages"`
|
||||
// ReadMessage 标记消息已读
|
||||
ReadMessage func(Post) `mir:"/user/message/read"`
|
||||
// SendUserWhisper 发送用户私信
|
||||
SendUserWhisper func(Post) `mir:"/user/whisper"`
|
||||
// GetCollections 获取用户收藏列表
|
||||
GetCollections func(Get) `mir:"/user/collections"`
|
||||
// GetStars 获取用户点赞列表
|
||||
GetStars func(Get) `mir:"/user/stars"`
|
||||
// UserPhoneBind 绑定用户手机号
|
||||
UserPhoneBind func(Post) `mir:"/user/phone"`
|
||||
// ChangePassword 修改密码
|
||||
ChangePassword func(Post) `mir:"/user/password"`
|
||||
// ChangeNickname 修改昵称
|
||||
ChangeNickname func(Post) `mir:"/user/nickname"`
|
||||
// ChangeAvatar 修改头像
|
||||
ChangeAvatar func(Post, web.ChangeAvatarReq) `mir:"/user/avatar"`
|
||||
// SuggestUsers 检索用户
|
||||
SuggestUsers func(Get) `mir:"/suggest/users"`
|
||||
// SuggestTags 检索标签
|
||||
SuggestTags func(Get) `mir:"/suggest/tags"`
|
||||
// TweetStarStatus 获取动态点赞状态
|
||||
TweetStarStatus func(Get) `mir:"/post/star"`
|
||||
// TweetCollectionStatus 获取动态收藏状态
|
||||
TweetCollectionStatus func(Get) `mir:"/post/collection"`
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebFollowship))
|
||||
}
|
||||
|
||||
type WebFollowship struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// AddFollowing 添加关注
|
||||
AddFollowing func(Post) `mir:"/following/add"`
|
||||
// DeleteFollowing 取消关注
|
||||
DeleteFollowing func(Post) `mir:"/following/delete"`
|
||||
// ListFollowings 获取用户的关注列表
|
||||
ListFollowings func(Get) `mir:"/following/list"`
|
||||
// ListFollowers 获取用户的追随者列表
|
||||
ListFollowers func(Get, web.ListFollowersReq) web.ListFollowersResp `mir:"/follower/list"`
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebFriendship))
|
||||
}
|
||||
|
||||
// // routeFriendship register Friendship feature releated routes
|
||||
// func routeFriendship(authApi gin.IRoutes) {
|
||||
// // 请求添加朋友
|
||||
// authApi.POST("/friend/requesting", api.RequestingFriend)
|
||||
|
||||
// // 同意添加好友
|
||||
// authApi.POST("/friend/add", api.AddFriend)
|
||||
|
||||
// // 拒绝添加好友
|
||||
// authApi.POST("/friend/reject", api.RejectFriend)
|
||||
|
||||
// // 删除好友
|
||||
// authApi.POST("/friend/delete", api.DeleteFriend)
|
||||
|
||||
// // 获取好友列表
|
||||
// authApi.GET("/user/contacts", api.GetContacts)
|
||||
// }
|
||||
|
||||
type WebFriendship struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// RequestingFriend 请求添加朋友
|
||||
RequestingFriend func(Post) `mir:"/friend/requesting"`
|
||||
|
||||
// AddFriend 同意添加好友
|
||||
AddFriend func(Post) `mir:"/friend/add"`
|
||||
|
||||
// RejectFriend 拒绝添加好友
|
||||
RejectFriend func(Post) `mir:"/friend/reject"`
|
||||
|
||||
// DeleteFriend 删除好友
|
||||
DeleteFriend func(Post) `mir:"/friend/delete"`
|
||||
|
||||
// GetContacts 获取好友列表
|
||||
GetContacts func(Get, web.GetContactsReq) web.GetContactsResp `mir:"/user/contacts"`
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(LocalOSS))
|
||||
}
|
||||
|
||||
type LocalOSS struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebLoose))
|
||||
}
|
||||
|
||||
// // 宽松鉴权路由组
|
||||
// looseApi := r.Group("/").Use(chain.JwtLoose())
|
||||
// {
|
||||
// // 获取广场流
|
||||
// looseApi.GET("/posts", api.GetPostList)
|
||||
|
||||
// // 获取用户动态列表
|
||||
// looseApi.GET("/user/posts", api.GetUserPosts)
|
||||
|
||||
// // 获取用户基本信息
|
||||
// looseApi.GET("/user/profile", api.GetUserProfile)
|
||||
// }
|
||||
|
||||
type WebLoose struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// Timeline 获取广场流
|
||||
Timeline func(Get, web.TimelineReq) web.TimelineResp `mir:"/Posts"`
|
||||
// GetUserTweets 获取用户动态列表
|
||||
GetUserTweets func(Get) `mir:"/user/posts"`
|
||||
// GetUserProfile 获取用户基本信息
|
||||
GetUserProfile func(Get) `mir:"/user/profile"`
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebPriv))
|
||||
}
|
||||
|
||||
// // 上传资源
|
||||
// privApi.POST("/attachment", api.UploadAttachment)
|
||||
|
||||
// // 下载资源预检
|
||||
// privApi.GET("/attachment/precheck", api.DownloadAttachmentPrecheck)
|
||||
|
||||
// // 下载资源
|
||||
// privApi.GET("/attachment", api.DownloadAttachment)
|
||||
|
||||
// // 发布动态
|
||||
// privApi.POST("/post", api.CreatePost)
|
||||
|
||||
// // 删除动态
|
||||
// privApi.DELETE("/post", api.DeletePost)
|
||||
|
||||
// // 动态点赞操作
|
||||
// privApi.POST("/post/star", api.PostStar)
|
||||
|
||||
// // 动态收藏操作
|
||||
// privApi.POST("/post/collection", api.PostCollection)
|
||||
|
||||
// // 锁定动态
|
||||
// privApi.POST("/post/lock", api.LockPost)
|
||||
|
||||
// // 置顶动态
|
||||
// privApi.POST("/post/stick", api.StickPost)
|
||||
|
||||
// // 修改动态可见度
|
||||
// privApi.POST("/post/visibility", api.VisiblePost)
|
||||
|
||||
// // 发布动态评论
|
||||
// privApi.POST("/post/comment", api.CreatePostComment)
|
||||
|
||||
// // 删除动态评论
|
||||
// privApi.DELETE("/post/comment", api.DeletePostComment)
|
||||
|
||||
// // 发布评论回复
|
||||
// privApi.POST("/post/comment/reply", api.CreatePostCommentReply)
|
||||
|
||||
// // 删除评论回复
|
||||
// privApi.DELETE("/post/comment/reply", api.DeletePostCommentReply)
|
||||
|
||||
type WebPriv struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// UploadAttachment 上传资源
|
||||
UploadAttachment func(Post) `mir:"/attachment"`
|
||||
// DownloadAttachmentPrecheck 下载资源预检
|
||||
DownloadAttachmentPrecheck func(Get) `mir:"/attachment/precheck"`
|
||||
// DownloadAttachment 下载资源
|
||||
DownloadAttachment func(Get) `mir:"/attachment"`
|
||||
// CreateTweet 发布动态
|
||||
CreateTweet func(Post, web.CreateTweetReq)web.CreateTweetResp `mir:"/post"`
|
||||
// DeleteTweet 删除动态
|
||||
DeleteTweet func(Delete) `mir:"/post"`
|
||||
// StarTweet 动态点赞操作
|
||||
StarTweet func(Post) `mir:"/post/start"`
|
||||
// CollectionTweet 动态收藏操作
|
||||
CollectionTweet func(Post) `mir:"/post/collection"`
|
||||
// LockTweet 锁定动态
|
||||
LockTweet func(Post) `mir:"/post/lock"`
|
||||
// StickTweet 置顶动态
|
||||
StickTweet func(Post) `mir:"/post/stick"`
|
||||
// VisiblePost 修改动态可见度
|
||||
VisiblePost func(Post) `mir:"/post/visibility"`
|
||||
// CreateTweetComment 发布动态评论
|
||||
CreateComment func(Post) `mir:"/post/comment"`
|
||||
// DeletePostComment 删除动态评论
|
||||
DeleteComment func(Delete) `mir:"/post/comment"`
|
||||
// CreateCommentReply 发布评论回复
|
||||
CreateCommentReply func(Post) `mir:"/post/comment/reply"`
|
||||
// DeleteCommentReply 删除评论回复
|
||||
DeleteCommentReply func(Delete) `mir:"/post/comment/reply"`
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
"github.com/rocboss/paopao-ce/internal/model/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebPub))
|
||||
}
|
||||
|
||||
// // v1 group api
|
||||
// r := e.Group("/v1")
|
||||
|
||||
// // 获取version
|
||||
// r.GET("/", api.Version)
|
||||
|
||||
// // 用户登录
|
||||
// r.POST("/auth/login", api.Login)
|
||||
|
||||
// // 用户注册
|
||||
// r.POST("/auth/register", api.Register)
|
||||
|
||||
// // 获取验证码
|
||||
// r.GET("/captcha", api.GetCaptcha)
|
||||
|
||||
// // 发送验证码
|
||||
// r.POST("/captcha", api.PostCaptcha)
|
||||
|
||||
// // 无鉴权路由组
|
||||
// noAuthApi := r.Group("/")
|
||||
// {
|
||||
// // 获取动态详情
|
||||
// noAuthApi.GET("/post", api.GetPost)
|
||||
|
||||
// // 获取动态评论
|
||||
// noAuthApi.GET("/post/comments", api.GetPostComments)
|
||||
|
||||
// // 获取话题列表
|
||||
// noAuthApi.GET("/tags", api.GetPostTags)
|
||||
// }
|
||||
|
||||
type WebPub struct {
|
||||
Group Group `mir:"v1"`
|
||||
|
||||
// Version 获取后台版本信息
|
||||
Version func(Get) `mir:"/"`
|
||||
// Login 用户登录
|
||||
Login func(Post) `mir:"/auth/login"`
|
||||
// Register 用户注册
|
||||
Register func(Post) `mir:"/auth/register"`
|
||||
// GetCaptcha 获取验证码
|
||||
GetCaptcha func(Get) `mir:"/captcha"`
|
||||
// PostCaptcha 发送验证码
|
||||
SendCaptcha func(Post) `mir:"/captcha"`
|
||||
// TweetDetail 获取动态详情
|
||||
TweetDetail func(Get, web.TweetDetailReq) web.TweetDetailResp `mir:"/post"`
|
||||
// TweetComments 获取动态评论
|
||||
TweetComments func(Get) `mir:"/post/comments"`
|
||||
// TopicList 获取话题列表
|
||||
TopicList func(Get) `mir:"/tags"`
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebAdmin))
|
||||
}
|
||||
|
||||
type WebAdmin struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebAlipay))
|
||||
}
|
||||
|
||||
type WebAlipay struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebCore))
|
||||
}
|
||||
|
||||
type AgentInfo struct {
|
||||
Platform string `json:"platform"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
}
|
||||
|
||||
type ServerInfo struct {
|
||||
ApiVer string `json:"api_ver"`
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
BaseInfo `json:"-"`
|
||||
AgentInfo AgentInfo `json:"agent_info"`
|
||||
Name string `json:"name"`
|
||||
Passwd string `json:"passwd"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
UserInfo
|
||||
ServerInfo ServerInfo `json:"server_info"`
|
||||
JwtToken string `json:"jwt_token"`
|
||||
}
|
||||
|
||||
type WebCore struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
Index func(Get) `mir:"/index/"`
|
||||
Articles func(Get, Head) `mir:"/articles/:category/"`
|
||||
Login func(Post, LoginReq) LoginResp `mir:"/user/login/"`
|
||||
Logout func(Post) `mir:"/user/logout/"`
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebFollowship))
|
||||
}
|
||||
|
||||
type WebFollowship struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebFriendship))
|
||||
}
|
||||
|
||||
type WebFriendship struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebLoose))
|
||||
}
|
||||
|
||||
type WebLoose struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebPriv))
|
||||
}
|
||||
|
||||
type WebPriv struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
. "github.com/alimy/mir/v3"
|
||||
. "github.com/alimy/mir/v3/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AddEntry(new(WebPub))
|
||||
}
|
||||
|
||||
type WebPub struct {
|
||||
Chain Chain `mir:"-"`
|
||||
Group Group `mir:"v1"`
|
||||
}
|
Loading…
Reference in new issue