mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
409 lines
11 KiB
409 lines
11 KiB
2 years ago
|
// Code generated by go-mir. DO NOT EDIT.
|
||
|
|
||
|
package v1
|
||
|
|
||
|
import (
|
||
2 years ago
|
"net/http"
|
||
2 years ago
|
|
||
2 years ago
|
"github.com/alimy/mir/v3"
|
||
2 years ago
|
"github.com/gin-gonic/gin"
|
||
2 years ago
|
"github.com/rocboss/paopao-ce/internal/model/web"
|
||
2 years ago
|
)
|
||
|
|
||
2 years ago
|
type Core interface {
|
||
2 years ago
|
// Chain provide handlers chain for gin
|
||
|
Chain() gin.HandlersChain
|
||
|
|
||
2 years ago
|
TweetCollectionStatus() mir.Error
|
||
|
TweetStarStatus() mir.Error
|
||
|
SuggestTags() 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
|
||
2 years ago
|
|
||
2 years ago
|
mustEmbedUnimplementedCoreServant()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
type CoreBinding interface {
|
||
2 years ago
|
BindChangeAvatar(*gin.Context) (*web.ChangeAvatarReq, mir.Error)
|
||
|
BindGetUserInfo(*gin.Context) (*web.UserInfoReq, mir.Error)
|
||
2 years ago
|
|
||
2 years ago
|
mustEmbedUnimplementedCoreBinding()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
type CoreRender interface {
|
||
2 years ago
|
RenderTweetCollectionStatus(*gin.Context, mir.Error)
|
||
|
RenderTweetStarStatus(*gin.Context, mir.Error)
|
||
|
RenderSuggestTags(*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)
|
||
2 years ago
|
|
||
2 years ago
|
mustEmbedUnimplementedCoreRender()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
// RegisterCoreServant register Core servant to gin
|
||
|
func RegisterCoreServant(e *gin.Engine, s Core, b CoreBinding, r CoreRender) {
|
||
2 years ago
|
router := e.Group("v1")
|
||
|
// use chain for router
|
||
|
middlewares := s.Chain()
|
||
|
router.Use(middlewares...)
|
||
|
|
||
|
// register routes info to router
|
||
2 years ago
|
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) {
|
||
2 years ago
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
2 years ago
|
r.RenderSuggestTags(c, s.SuggestTags())
|
||
2 years ago
|
})
|
||
2 years ago
|
|
||
2 years ago
|
router.Handle("GET", "/suggest/users", func(c *gin.Context) {
|
||
2 years ago
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
2 years ago
|
r.RenderSuggestUsers(c, s.SuggestUsers())
|
||
|
})
|
||
|
|
||
|
router.Handle("POST", "/user/avatar", func(c *gin.Context) {
|
||
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
|
req, err := b.BindChangeAvatar(c)
|
||
2 years ago
|
if err != nil {
|
||
2 years ago
|
r.RenderChangeAvatar(c, err)
|
||
2 years ago
|
return
|
||
2 years ago
|
}
|
||
2 years ago
|
r.RenderChangeAvatar(c, s.ChangeAvatar(req))
|
||
2 years ago
|
})
|
||
|
|
||
2 years ago
|
router.Handle("POST", "/user/nickname", func(c *gin.Context) {
|
||
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
|
r.RenderChangeNickname(c, s.ChangeNickname())
|
||
|
})
|
||
2 years ago
|
|
||
2 years ago
|
router.Handle("POST", "/user/password", func(c *gin.Context) {
|
||
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
r.RenderChangePassword(c, s.ChangePassword())
|
||
|
})
|
||
|
|
||
|
router.Handle("POST", "/user/phone", func(c *gin.Context) {
|
||
2 years ago
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
2 years ago
|
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
|
||
|
default:
|
||
|
}
|
||
|
|
||
|
r.RenderGetCollections(c, s.GetCollections())
|
||
|
})
|
||
|
|
||
|
router.Handle("POST", "/user/whisper", func(c *gin.Context) {
|
||
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
|
r.RenderSendUserWhisper(c, s.SendUserWhisper())
|
||
|
})
|
||
|
|
||
|
router.Handle("POST", "/user/message/read", func(c *gin.Context) {
|
||
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
|
r.RenderReadMessage(c, s.ReadMessage())
|
||
|
})
|
||
|
|
||
|
router.Handle("GET", "/user/messages", func(c *gin.Context) {
|
||
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
|
r.RenderGetMessages(c, s.GetMessages())
|
||
|
})
|
||
|
|
||
|
router.Handle("GET", "/user/msgcount/unread", func(c *gin.Context) {
|
||
|
select {
|
||
|
case <-c.Request.Context().Done():
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
|
||
|
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())
|
||
2 years ago
|
})
|
||
2 years ago
|
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
// UnimplementedCoreServant can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedCoreServant struct {
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
func (UnimplementedCoreServant) Chain() gin.HandlersChain {
|
||
2 years ago
|
return nil
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) TweetCollectionStatus() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) TweetStarStatus() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) SuggestTags() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) SuggestUsers() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) ChangeAvatar(req *web.ChangeAvatarReq) mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) ChangeNickname() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) ChangePassword() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) UserPhoneBind() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) GetStars() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) GetCollections() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) SendUserWhisper() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) ReadMessage() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) GetMessages() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) GetUnreadMsgCount() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) GetUserInfo(req *web.UserInfoReq) (*web.UserInfoResp, mir.Error) {
|
||
2 years ago
|
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) SyncSearchIndex() mir.Error {
|
||
2 years ago
|
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (UnimplementedCoreServant) mustEmbedUnimplementedCoreServant() {}
|
||
2 years ago
|
|
||
2 years ago
|
// UnimplementedCoreRender can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedCoreRender struct {
|
||
2 years ago
|
RenderAny func(*gin.Context, any, mir.Error)
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderTweetCollectionStatus(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderTweetStarStatus(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderSuggestTags(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderSuggestUsers(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderChangeAvatar(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderChangeNickname(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderChangePassword(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderUserPhoneBind(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderGetStars(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderGetCollections(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderSendUserWhisper(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderReadMessage(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderGetMessages(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderGetUnreadMsgCount(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderGetUserInfo(c *gin.Context, data *web.UserInfoResp, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, data, err)
|
||
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) RenderSyncSearchIndex(c *gin.Context, err mir.Error) {
|
||
2 years ago
|
r.RenderAny(c, nil, err)
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
func (r *UnimplementedCoreRender) mustEmbedUnimplementedCoreRender() {}
|
||
2 years ago
|
|
||
2 years ago
|
// UnimplementedCoreBinding can be embedded to have forward compatible implementations.
|
||
|
type UnimplementedCoreBinding struct {
|
||
2 years ago
|
BindAny func(*gin.Context, any) mir.Error
|
||
|
}
|
||
|
|
||
2 years ago
|
func (b *UnimplementedCoreBinding) BindChangeAvatar(c *gin.Context) (*web.ChangeAvatarReq, mir.Error) {
|
||
2 years ago
|
obj := new(web.ChangeAvatarReq)
|
||
|
err := b.BindAny(c, obj)
|
||
|
return obj, err
|
||
|
}
|
||
|
|
||
2 years ago
|
func (b *UnimplementedCoreBinding) BindGetUserInfo(c *gin.Context) (*web.UserInfoReq, mir.Error) {
|
||
2 years ago
|
obj := new(web.UserInfoReq)
|
||
2 years ago
|
err := b.BindAny(c, obj)
|
||
|
return obj, err
|
||
|
}
|
||
|
|
||
2 years ago
|
func (b *UnimplementedCoreBinding) mustEmbedUnimplementedCoreBinding() {}
|