add simple go-mir define file for web api

pull/196/head
Michael Li 2 years ago
parent 8139e4dbe2
commit 989d79080e
No known key found for this signature in database

@ -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() {}

@ -7,62 +7,58 @@ import (
"github.com/alimy/mir/v3" "github.com/alimy/mir/v3"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr" "github.com/rocboss/paopao-ce/internal/model/web"
) )
type LoginReq struct {
BaseInfo `json:"-"`
AgentInfo AgentInfo `json:"agent_info"`
Name string `json:"name"`
Passwd string `json:"passwd"`
}
type AgentInfo struct {
Platform string `json:"platform"`
UserAgent string `json:"user_agent"`
}
type BaseInfo struct {
User *dbr.User
}
type LoginResp struct {
UserInfo
ServerInfo ServerInfo `json:"server_info"`
JwtToken string `json:"jwt_token"`
}
type ServerInfo struct {
ApiVer string `json:"api_ver"`
}
type UserInfo struct {
Name string `json:"name"`
}
type WebCore interface { type WebCore interface {
// Chain provide handlers chain for gin // Chain provide handlers chain for gin
Chain() gin.HandlersChain Chain() gin.HandlersChain
Logout() mir.Error TweetCollectionStatus() mir.Error
Login(*LoginReq) (*LoginResp, mir.Error) TweetStarStatus() mir.Error
Articles() mir.Error SuggestTags() mir.Error
Index() mir.Error SuggestUsers() mir.Error
ChangeAvatar(*web.ChangeAvatarReq) mir.Error
ChangeNickname() mir.Error
ChangePassword() mir.Error
UserPhoneBind() mir.Error
GetStars() mir.Error
GetCollections() mir.Error
SendUserWhisper() mir.Error
ReadMessage() mir.Error
GetMessages() mir.Error
GetUnreadMsgCount() mir.Error
GetUserInfo(*web.UserInfoReq) (*web.UserInfoResp, mir.Error)
SyncSearchIndex() mir.Error
mustEmbedUnimplementedWebCoreServant() mustEmbedUnimplementedWebCoreServant()
} }
type WebCoreBinding interface { type WebCoreBinding interface {
BindLogin(*gin.Context) (*LoginReq, mir.Error) BindChangeAvatar(*gin.Context) (*web.ChangeAvatarReq, mir.Error)
BindGetUserInfo(*gin.Context) (*web.UserInfoReq, mir.Error)
mustEmbedUnimplementedWebCoreBinding() mustEmbedUnimplementedWebCoreBinding()
} }
type WebCoreRender interface { type WebCoreRender interface {
RenderLogout(*gin.Context, mir.Error) RenderTweetCollectionStatus(*gin.Context, mir.Error)
RenderLogin(*gin.Context, *LoginResp, mir.Error) RenderTweetStarStatus(*gin.Context, mir.Error)
RenderArticles(*gin.Context, mir.Error) RenderSuggestTags(*gin.Context, mir.Error)
RenderIndex(*gin.Context, mir.Error) RenderSuggestUsers(*gin.Context, mir.Error)
RenderChangeAvatar(*gin.Context, mir.Error)
RenderChangeNickname(*gin.Context, mir.Error)
RenderChangePassword(*gin.Context, mir.Error)
RenderUserPhoneBind(*gin.Context, mir.Error)
RenderGetStars(*gin.Context, mir.Error)
RenderGetCollections(*gin.Context, mir.Error)
RenderSendUserWhisper(*gin.Context, mir.Error)
RenderReadMessage(*gin.Context, mir.Error)
RenderGetMessages(*gin.Context, mir.Error)
RenderGetUnreadMsgCount(*gin.Context, mir.Error)
RenderGetUserInfo(*gin.Context, *web.UserInfoResp, mir.Error)
RenderSyncSearchIndex(*gin.Context, mir.Error)
mustEmbedUnimplementedWebCoreRender() mustEmbedUnimplementedWebCoreRender()
} }
@ -75,54 +71,175 @@ func RegisterWebCoreServant(e *gin.Engine, s WebCore, b WebCoreBinding, r WebCor
router.Use(middlewares...) router.Use(middlewares...)
// register routes info to router // register routes info to router
router.Handle("POST", "/user/logout/", func(c *gin.Context) { router.Handle("GET", "/post/collection", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderTweetCollectionStatus(c, s.TweetCollectionStatus())
})
router.Handle("GET", "/post/star", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderTweetStarStatus(c, s.TweetStarStatus())
})
router.Handle("GET", "/suggest/tags", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderSuggestTags(c, s.SuggestTags())
})
router.Handle("GET", "/suggest/users", func(c *gin.Context) {
select { select {
case <-c.Request.Context().Done(): case <-c.Request.Context().Done():
return return
default: default:
} }
r.RenderLogout(c, s.Logout()) r.RenderSuggestUsers(c, s.SuggestUsers())
}) })
router.Handle("POST", "/user/login/", func(c *gin.Context) { router.Handle("POST", "/user/avatar", func(c *gin.Context) {
select { select {
case <-c.Request.Context().Done(): case <-c.Request.Context().Done():
return return
default: default:
} }
req, err := b.BindLogin(c) req, err := b.BindChangeAvatar(c)
if err != nil { if err != nil {
r.RenderLogin(c, nil, err) r.RenderChangeAvatar(c, err)
return
}
r.RenderChangeAvatar(c, s.ChangeAvatar(req))
})
router.Handle("POST", "/user/nickname", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderChangeNickname(c, s.ChangeNickname())
})
router.Handle("POST", "/user/password", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderChangePassword(c, s.ChangePassword())
})
router.Handle("POST", "/user/phone", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderUserPhoneBind(c, s.UserPhoneBind())
})
router.Handle("GET", "/user/stars", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderGetStars(c, s.GetStars())
})
router.Handle("GET", "/user/collections", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return return
default:
} }
resp, err := s.Login(req)
r.RenderLogin(c, resp, err) r.RenderGetCollections(c, s.GetCollections())
}) })
{ router.Handle("POST", "/user/whisper", func(c *gin.Context) {
h := func(c *gin.Context) {
select { select {
case <-c.Request.Context().Done(): case <-c.Request.Context().Done():
return return
default: default:
} }
r.RenderArticles(c, s.Articles()) r.RenderSendUserWhisper(c, s.SendUserWhisper())
})
router.Handle("POST", "/user/message/read", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
} }
router.Handle("GET", "/articles/:category/", h)
router.Handle("HEAD", "/articles/:category/", h) r.RenderReadMessage(c, s.ReadMessage())
})
router.Handle("GET", "/user/messages", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
} }
router.Handle("GET", "/index/", func(c *gin.Context) { r.RenderGetMessages(c, s.GetMessages())
})
router.Handle("GET", "/user/msgcount/unread", func(c *gin.Context) {
select { select {
case <-c.Request.Context().Done(): case <-c.Request.Context().Done():
return return
default: default:
} }
r.RenderIndex(c, s.Index()) r.RenderGetUnreadMsgCount(c, s.GetUnreadMsgCount())
})
router.Handle("GET", "/user/info", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
req, err := b.BindGetUserInfo(c)
if err != nil {
r.RenderGetUserInfo(c, nil, err)
return
}
resp, err := s.GetUserInfo(req)
r.RenderGetUserInfo(c, resp, err)
})
router.Handle("GET", "/sync/index", func(c *gin.Context) {
select {
case <-c.Request.Context().Done():
return
default:
}
r.RenderSyncSearchIndex(c, s.SyncSearchIndex())
}) })
} }
@ -135,19 +252,67 @@ func (UnimplementedWebCoreServant) Chain() gin.HandlersChain {
return nil return nil
} }
func (UnimplementedWebCoreServant) Logout() mir.Error { func (UnimplementedWebCoreServant) TweetCollectionStatus() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
} }
func (UnimplementedWebCoreServant) Login(req *LoginReq) (*LoginResp, mir.Error) { func (UnimplementedWebCoreServant) TweetStarStatus() mir.Error {
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) SuggestTags() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) SuggestUsers() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) ChangeAvatar(req *web.ChangeAvatarReq) mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) ChangeNickname() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) ChangePassword() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) UserPhoneBind() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) GetStars() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) GetCollections() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) SendUserWhisper() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) ReadMessage() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
} }
func (UnimplementedWebCoreServant) Articles() mir.Error { func (UnimplementedWebCoreServant) GetMessages() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
} }
func (UnimplementedWebCoreServant) Index() mir.Error { func (UnimplementedWebCoreServant) GetUnreadMsgCount() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) GetUserInfo(req *web.UserInfoReq) (*web.UserInfoResp, mir.Error) {
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
}
func (UnimplementedWebCoreServant) SyncSearchIndex() mir.Error {
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented)) return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
} }
@ -158,19 +323,67 @@ type UnimplementedWebCoreRender struct {
RenderAny func(*gin.Context, any, mir.Error) RenderAny func(*gin.Context, any, mir.Error)
} }
func (r *UnimplementedWebCoreRender) RenderLogout(c *gin.Context, err mir.Error) { func (r *UnimplementedWebCoreRender) RenderTweetCollectionStatus(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err) r.RenderAny(c, nil, err)
} }
func (r *UnimplementedWebCoreRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) { func (r *UnimplementedWebCoreRender) RenderTweetStarStatus(c *gin.Context, err mir.Error) {
r.RenderAny(c, data, err) r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderSuggestTags(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderSuggestUsers(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderChangeAvatar(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderChangeNickname(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderChangePassword(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
} }
func (r *UnimplementedWebCoreRender) RenderArticles(c *gin.Context, err mir.Error) { func (r *UnimplementedWebCoreRender) RenderUserPhoneBind(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err) r.RenderAny(c, nil, err)
} }
func (r *UnimplementedWebCoreRender) RenderIndex(c *gin.Context, err mir.Error) { func (r *UnimplementedWebCoreRender) RenderGetStars(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderGetCollections(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderSendUserWhisper(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderReadMessage(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderGetMessages(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderGetUnreadMsgCount(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err)
}
func (r *UnimplementedWebCoreRender) RenderGetUserInfo(c *gin.Context, data *web.UserInfoResp, err mir.Error) {
r.RenderAny(c, data, err)
}
func (r *UnimplementedWebCoreRender) RenderSyncSearchIndex(c *gin.Context, err mir.Error) {
r.RenderAny(c, nil, err) r.RenderAny(c, nil, err)
} }
@ -181,8 +394,14 @@ type UnimplementedWebCoreBinding struct {
BindAny func(*gin.Context, any) mir.Error BindAny func(*gin.Context, any) mir.Error
} }
func (b *UnimplementedWebCoreBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) { func (b *UnimplementedWebCoreBinding) BindChangeAvatar(c *gin.Context) (*web.ChangeAvatarReq, mir.Error) {
obj := new(LoginReq) obj := new(web.ChangeAvatarReq)
err := b.BindAny(c, obj)
return obj, err
}
func (b *UnimplementedWebCoreBinding) BindGetUserInfo(c *gin.Context) (*web.UserInfoReq, mir.Error) {
obj := new(web.UserInfoReq)
err := b.BindAny(c, obj) err := b.BindAny(c, obj)
return obj, err return obj, err
} }

@ -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() {}

@ -6,7 +6,7 @@ require (
github.com/Masterminds/semver/v3 v3.1.1 github.com/Masterminds/semver/v3 v3.1.1
github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868 github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868
github.com/alimy/cfg v0.3.0 github.com/alimy/cfg v0.3.0
github.com/alimy/mir/v3 v3.0.0-alpha.8 github.com/alimy/mir/v3 v3.0.0-beta.2
github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible
github.com/allegro/bigcache/v3 v3.0.2 github.com/allegro/bigcache/v3 v3.0.2
github.com/bytedance/sonic v1.5.0 github.com/bytedance/sonic v1.5.0
@ -132,3 +132,5 @@ require (
modernc.org/strutil v1.1.1 // indirect modernc.org/strutil v1.1.1 // indirect
modernc.org/token v1.0.0 // indirect modernc.org/token v1.0.0 // indirect
) )
replace github.com/alimy/mir/v3 => ../../alimy/mir

@ -147,8 +147,6 @@ github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:C
github.com/alexflint/go-filemutex v1.1.0/go.mod h1:7P4iRhttt/nUvUOrYIhcpMzv2G6CY9UnI16Z+UJqRyk= github.com/alexflint/go-filemutex v1.1.0/go.mod h1:7P4iRhttt/nUvUOrYIhcpMzv2G6CY9UnI16Z+UJqRyk=
github.com/alimy/cfg v0.3.0 h1:9xgA0QWVCPSq9fFNRcYahVCAX22IL9ts2wrTQPfAStY= github.com/alimy/cfg v0.3.0 h1:9xgA0QWVCPSq9fFNRcYahVCAX22IL9ts2wrTQPfAStY=
github.com/alimy/cfg v0.3.0/go.mod h1:rOxbasTH2srl6StAjNF5Vyi8bfrdkl3fLGmOYtSw81c= github.com/alimy/cfg v0.3.0/go.mod h1:rOxbasTH2srl6StAjNF5Vyi8bfrdkl3fLGmOYtSw81c=
github.com/alimy/mir/v3 v3.0.0-alpha.8 h1:Zz94oefYkYXA/IuXrjRT7LrQ6LdsZi5z9+IWmXuPdUw=
github.com/alimy/mir/v3 v3.0.0-alpha.8/go.mod h1:ybhT2ijOiDn0lLwWzIY6vXdv+uzZrctS7VFfczcXBWU=
github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible h1:9gWa46nstkJ9miBReJcN8Gq34cBFbzSpQZVVT9N09TM= github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible h1:9gWa46nstkJ9miBReJcN8Gq34cBFbzSpQZVVT9N09TM=
github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=

@ -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
}

@ -31,7 +31,7 @@ type JsonResp struct {
Data any `json:",omitempty"` Data any `json:",omitempty"`
} }
func (BaseServant) UserFrom(c *gin.Context) (*core.User, bool) { func UserFrom(c *gin.Context) (*core.User, bool) {
if u, exists := c.Get("USER"); exists { if u, exists := c.Get("USER"); exists {
user, ok := u.(*core.User) user, ok := u.(*core.User)
return user, ok return user, ok

@ -4,6 +4,54 @@
package web package web
import (
"github.com/gin-gonic/gin"
api "github.com/rocboss/paopao-ce/auto/api/v1"
"github.com/rocboss/paopao-ce/internal/servants/base"
"github.com/rocboss/paopao-ce/internal/servants/chain"
)
var (
_ api.WebAdmin = (*webAdminSrv)(nil)
_ api.WebAdminBinding = (*webAdminBinding)(nil)
_ api.WebAdminRender = (*webAdminRender)(nil)
)
type webAdminSrv struct { type webAdminSrv struct {
// TODO base.BaseServant
api.UnimplementedWebAdminServant
}
type webAdminBinding struct {
base.BaseBinding
*api.UnimplementedWebAdminBinding
}
type webAdminRender struct {
base.BaseRender
*api.UnimplementedWebAdminRender
}
func (s *webAdminSrv) Chain() gin.HandlersChain {
return gin.HandlersChain{chain.JWT(), chain.Admin()}
}
func newWebAdminSrv() api.WebAdmin {
return &webAdminSrv{}
}
func newWebAdminBinding() api.WebAdminBinding {
return &webAdminBinding{
UnimplementedWebAdminBinding: &api.UnimplementedWebAdminBinding{
BindAny: base.BindAny,
},
}
}
func newWebAdminRender() api.WebAdminRender {
return &webAdminRender{
UnimplementedWebAdminRender: &api.UnimplementedWebAdminRender{
RenderAny: base.RenderAny,
},
}
} }

@ -5,8 +5,10 @@
package web package web
import ( import (
"github.com/gin-gonic/gin"
api "github.com/rocboss/paopao-ce/auto/api/v1" api "github.com/rocboss/paopao-ce/auto/api/v1"
"github.com/rocboss/paopao-ce/internal/servants/base" "github.com/rocboss/paopao-ce/internal/servants/base"
"github.com/rocboss/paopao-ce/internal/servants/chain"
) )
var ( var (
@ -30,6 +32,10 @@ type webCoreRender struct {
*api.UnimplementedWebCoreRender *api.UnimplementedWebCoreRender
} }
func (s *webCoreSrv) Chain() gin.HandlersChain {
return gin.HandlersChain{chain.JWT()}
}
func newWebCoreSrv() api.WebCore { func newWebCoreSrv() api.WebCore {
return &webCoreSrv{} return &webCoreSrv{}
} }

@ -12,4 +12,5 @@ import (
// RouteWeb register web route // RouteWeb register web route
func RouteWeb(e *gin.Engine) { func RouteWeb(e *gin.Engine) {
api.RegisterWebCoreServant(e, newWebCoreSrv(), newWebCoreBinding(), newWebCoreRender()) api.RegisterWebCoreServant(e, newWebCoreSrv(), newWebCoreBinding(), newWebCoreRender())
api.RegisterWebAdminServant(e, newWebAdminSrv(), newWebAdminBinding(), newWebAdminRender())
} }

@ -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…
Cancel
Save