@ -0,0 +1,30 @@
|
||||
## Roadmap for paopao-ce
|
||||
paopao-ce roadmap.
|
||||
|
||||
### v0.2.0
|
||||
* [x] add `Friendship` feature
|
||||
* [ ] add `Lightship` feature
|
||||
* [ ] add `Sqlx` feature
|
||||
* [ ] add new `Web` service
|
||||
* [x] add `Deprecated:OldWeb` feature
|
||||
* [x] support run multiple service in single paopao-ce instance
|
||||
* [x] use [go-mir](https://github.com/alimy/mir) optimize paopao-ce source code architecture
|
||||
|
||||
### Next
|
||||
* [ ] add `Followship` feature
|
||||
* [ ] add `Bleve` feature
|
||||
* [ ] add `SpaceX` feature
|
||||
* [ ] add `Bot` feature
|
||||
* [ ] add `Admin` feature
|
||||
* [ ] add `NativeOBS` feature
|
||||
* [ ] add `Mobile` gRPC API service feature
|
||||
* [ ] add admin web frontend
|
||||
* [ ] add tweet forwarding support
|
||||
* [ ] add tweet resource access control base on simple RBAC support
|
||||
* [ ] add user's `Activation Code` feature support
|
||||
* [ ] add user block feature support
|
||||
* [ ] optimize current message push logic service use `ims` module
|
||||
* [ ] optimize media tweet submit logic
|
||||
* [ ] optimize topics service
|
||||
* [ ] optimize backend data logic service(optimize database CRUD operate)
|
||||
* [ ] optimize search logic service
|
@ -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 Admin interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
ChangeUserStatus(*web.ChangeUserStatusReq) mir.Error
|
||||
|
||||
mustEmbedUnimplementedAdminServant()
|
||||
}
|
||||
|
||||
type AdminBinding interface {
|
||||
BindChangeUserStatus(*gin.Context) (*web.ChangeUserStatusReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedAdminBinding()
|
||||
}
|
||||
|
||||
type AdminRender interface {
|
||||
RenderChangeUserStatus(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedAdminRender()
|
||||
}
|
||||
|
||||
// RegisterAdminServant register Admin servant to gin
|
||||
func RegisterAdminServant(e *gin.Engine, s Admin, b AdminBinding, r AdminRender) {
|
||||
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))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedAdminServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAdminServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedAdminServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedAdminServant) ChangeUserStatus(req *web.ChangeUserStatusReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedAdminServant) mustEmbedUnimplementedAdminServant() {}
|
||||
|
||||
// UnimplementedAdminRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAdminRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedAdminRender) RenderChangeUserStatus(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedAdminRender) mustEmbedUnimplementedAdminRender() {}
|
||||
|
||||
// UnimplementedAdminBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAdminBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedAdminBinding) BindChangeUserStatus(c *gin.Context) (*web.ChangeUserStatusReq, mir.Error) {
|
||||
obj := new(web.ChangeUserStatusReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedAdminBinding) mustEmbedUnimplementedAdminBinding() {}
|
@ -0,0 +1,162 @@
|
||||
// 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 AlipayPriv interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
UserWalletBills(*web.UserWalletBillsReq) (*web.UserWalletBillsResp, mir.Error)
|
||||
UserRechargeResult(*web.UserRechargeResultReq) (*web.UserRechargeResultResp, mir.Error)
|
||||
UserRechargeLink(*web.UserRechargeLinkReq) (*web.UserRechargeLinkResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedAlipayPrivServant()
|
||||
}
|
||||
|
||||
type AlipayPrivBinding interface {
|
||||
BindUserWalletBills(*gin.Context) (*web.UserWalletBillsReq, mir.Error)
|
||||
BindUserRechargeResult(*gin.Context) (*web.UserRechargeResultReq, mir.Error)
|
||||
BindUserRechargeLink(*gin.Context) (*web.UserRechargeLinkReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedAlipayPrivBinding()
|
||||
}
|
||||
|
||||
type AlipayPrivRender interface {
|
||||
RenderUserWalletBills(*gin.Context, *web.UserWalletBillsResp, mir.Error)
|
||||
RenderUserRechargeResult(*gin.Context, *web.UserRechargeResultResp, mir.Error)
|
||||
RenderUserRechargeLink(*gin.Context, *web.UserRechargeLinkResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedAlipayPrivRender()
|
||||
}
|
||||
|
||||
// RegisterAlipayPrivServant register AlipayPriv servant to gin
|
||||
func RegisterAlipayPrivServant(e *gin.Engine, s AlipayPriv, b AlipayPrivBinding, r AlipayPrivRender) {
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindUserRechargeResult(c)
|
||||
if err != nil {
|
||||
r.RenderUserRechargeResult(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.UserRechargeResult(req)
|
||||
r.RenderUserRechargeResult(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/recharge", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindUserRechargeLink(c)
|
||||
if err != nil {
|
||||
r.RenderUserRechargeLink(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.UserRechargeLink(req)
|
||||
r.RenderUserRechargeLink(c, resp, err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedAlipayPrivServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAlipayPrivServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedAlipayPrivServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedAlipayPrivServant) UserWalletBills(req *web.UserWalletBillsReq) (*web.UserWalletBillsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedAlipayPrivServant) UserRechargeResult(req *web.UserRechargeResultReq) (*web.UserRechargeResultResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedAlipayPrivServant) UserRechargeLink(req *web.UserRechargeLinkReq) (*web.UserRechargeLinkResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedAlipayPrivServant) mustEmbedUnimplementedAlipayPrivServant() {}
|
||||
|
||||
// UnimplementedAlipayPrivRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAlipayPrivRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedAlipayPrivRender) RenderUserWalletBills(c *gin.Context, data *web.UserWalletBillsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedAlipayPrivRender) RenderUserRechargeResult(c *gin.Context, data *web.UserRechargeResultResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedAlipayPrivRender) RenderUserRechargeLink(c *gin.Context, data *web.UserRechargeLinkResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedAlipayPrivRender) mustEmbedUnimplementedAlipayPrivRender() {}
|
||||
|
||||
// UnimplementedAlipayPrivBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAlipayPrivBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedAlipayPrivBinding) BindUserWalletBills(c *gin.Context) (*web.UserWalletBillsReq, mir.Error) {
|
||||
obj := new(web.UserWalletBillsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedAlipayPrivBinding) BindUserRechargeResult(c *gin.Context) (*web.UserRechargeResultReq, mir.Error) {
|
||||
obj := new(web.UserRechargeResultReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedAlipayPrivBinding) BindUserRechargeLink(c *gin.Context) (*web.UserRechargeLinkReq, mir.Error) {
|
||||
obj := new(web.UserRechargeLinkReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedAlipayPrivBinding) mustEmbedUnimplementedAlipayPrivBinding() {}
|
@ -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 AlipayPub interface {
|
||||
AlipayNotify(*web.AlipayNotifyReq) mir.Error
|
||||
|
||||
mustEmbedUnimplementedAlipayPubServant()
|
||||
}
|
||||
|
||||
type AlipayPubBinding interface {
|
||||
BindAlipayNotify(*gin.Context) (*web.AlipayNotifyReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedAlipayPubBinding()
|
||||
}
|
||||
|
||||
type AlipayPubRender interface {
|
||||
RenderAlipayNotify(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedAlipayPubRender()
|
||||
}
|
||||
|
||||
// RegisterAlipayPubServant register AlipayPub servant to gin
|
||||
func RegisterAlipayPubServant(e *gin.Engine, s AlipayPub, b AlipayPubBinding, r AlipayPubRender) {
|
||||
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))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedAlipayPubServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAlipayPubServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedAlipayPubServant) AlipayNotify(req *web.AlipayNotifyReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedAlipayPubServant) mustEmbedUnimplementedAlipayPubServant() {}
|
||||
|
||||
// UnimplementedAlipayPubRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAlipayPubRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedAlipayPubRender) RenderAlipayNotify(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedAlipayPubRender) mustEmbedUnimplementedAlipayPubRender() {}
|
||||
|
||||
// UnimplementedAlipayPubBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAlipayPubBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedAlipayPubBinding) BindAlipayNotify(c *gin.Context) (*web.AlipayNotifyReq, mir.Error) {
|
||||
obj := new(web.AlipayNotifyReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedAlipayPubBinding) mustEmbedUnimplementedAlipayPubBinding() {}
|
@ -0,0 +1,584 @@
|
||||
// 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 Core interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
TweetCollectionStatus(*web.TweetCollectionStatusReq) (*web.TweetCollectionStatusResp, mir.Error)
|
||||
TweetStarStatus(*web.TweetStarStatusReq) (*web.TweetStarStatusResp, mir.Error)
|
||||
SuggestTags(*web.SuggestTagsReq) (*web.SuggestTagsResp, mir.Error)
|
||||
SuggestUsers(*web.SuggestUsersReq) (*web.SuggestUsersResp, mir.Error)
|
||||
ChangeAvatar(*web.ChangeAvatarReq) mir.Error
|
||||
ChangeNickname(*web.ChangeNicknameReq) mir.Error
|
||||
ChangePassword(*web.ChangePasswordReq) mir.Error
|
||||
UserPhoneBind(*web.UserPhoneBindReq) mir.Error
|
||||
GetStars(*web.GetStarsReq) (*web.GetStarsResp, mir.Error)
|
||||
GetCollections(*web.GetCollectionsReq) (*web.GetCollectionsResp, mir.Error)
|
||||
SendUserWhisper(*web.SendWhisperReq) mir.Error
|
||||
ReadMessage(*web.ReadMessageReq) mir.Error
|
||||
GetMessages(*web.GetMessagesReq) (*web.GetMessagesResp, mir.Error)
|
||||
GetUnreadMsgCount(*web.GetUnreadMsgCountReq) (*web.GetUnreadMsgCountResp, mir.Error)
|
||||
GetUserInfo(*web.UserInfoReq) (*web.UserInfoResp, mir.Error)
|
||||
SyncSearchIndex(*web.SyncSearchIndexReq) mir.Error
|
||||
|
||||
mustEmbedUnimplementedCoreServant()
|
||||
}
|
||||
|
||||
type CoreBinding interface {
|
||||
BindTweetCollectionStatus(*gin.Context) (*web.TweetCollectionStatusReq, mir.Error)
|
||||
BindTweetStarStatus(*gin.Context) (*web.TweetStarStatusReq, mir.Error)
|
||||
BindSuggestTags(*gin.Context) (*web.SuggestTagsReq, mir.Error)
|
||||
BindSuggestUsers(*gin.Context) (*web.SuggestUsersReq, mir.Error)
|
||||
BindChangeAvatar(*gin.Context) (*web.ChangeAvatarReq, mir.Error)
|
||||
BindChangeNickname(*gin.Context) (*web.ChangeNicknameReq, mir.Error)
|
||||
BindChangePassword(*gin.Context) (*web.ChangePasswordReq, mir.Error)
|
||||
BindUserPhoneBind(*gin.Context) (*web.UserPhoneBindReq, mir.Error)
|
||||
BindGetStars(*gin.Context) (*web.GetStarsReq, mir.Error)
|
||||
BindGetCollections(*gin.Context) (*web.GetCollectionsReq, mir.Error)
|
||||
BindSendUserWhisper(*gin.Context) (*web.SendWhisperReq, mir.Error)
|
||||
BindReadMessage(*gin.Context) (*web.ReadMessageReq, mir.Error)
|
||||
BindGetMessages(*gin.Context) (*web.GetMessagesReq, mir.Error)
|
||||
BindGetUnreadMsgCount(*gin.Context) (*web.GetUnreadMsgCountReq, mir.Error)
|
||||
BindGetUserInfo(*gin.Context) (*web.UserInfoReq, mir.Error)
|
||||
BindSyncSearchIndex(*gin.Context) (*web.SyncSearchIndexReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedCoreBinding()
|
||||
}
|
||||
|
||||
type CoreRender interface {
|
||||
RenderTweetCollectionStatus(*gin.Context, *web.TweetCollectionStatusResp, mir.Error)
|
||||
RenderTweetStarStatus(*gin.Context, *web.TweetStarStatusResp, mir.Error)
|
||||
RenderSuggestTags(*gin.Context, *web.SuggestTagsResp, mir.Error)
|
||||
RenderSuggestUsers(*gin.Context, *web.SuggestUsersResp, 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, *web.GetStarsResp, mir.Error)
|
||||
RenderGetCollections(*gin.Context, *web.GetCollectionsResp, mir.Error)
|
||||
RenderSendUserWhisper(*gin.Context, mir.Error)
|
||||
RenderReadMessage(*gin.Context, mir.Error)
|
||||
RenderGetMessages(*gin.Context, *web.GetMessagesResp, mir.Error)
|
||||
RenderGetUnreadMsgCount(*gin.Context, *web.GetUnreadMsgCountResp, mir.Error)
|
||||
RenderGetUserInfo(*gin.Context, *web.UserInfoResp, mir.Error)
|
||||
RenderSyncSearchIndex(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedCoreRender()
|
||||
}
|
||||
|
||||
// RegisterCoreServant register Core servant to gin
|
||||
func RegisterCoreServant(e *gin.Engine, s Core, b CoreBinding, r CoreRender) {
|
||||
router := e.Group("v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("GET", "/post/collection", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindTweetCollectionStatus(c)
|
||||
if err != nil {
|
||||
r.RenderTweetCollectionStatus(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.TweetCollectionStatus(req)
|
||||
r.RenderTweetCollectionStatus(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/post/star", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindTweetStarStatus(c)
|
||||
if err != nil {
|
||||
r.RenderTweetStarStatus(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.TweetStarStatus(req)
|
||||
r.RenderTweetStarStatus(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/suggest/tags", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindSuggestTags(c)
|
||||
if err != nil {
|
||||
r.RenderSuggestTags(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.SuggestTags(req)
|
||||
r.RenderSuggestTags(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/suggest/users", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindSuggestUsers(c)
|
||||
if err != nil {
|
||||
r.RenderSuggestUsers(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.SuggestUsers(req)
|
||||
r.RenderSuggestUsers(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/avatar", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindChangeAvatar(c)
|
||||
if err != nil {
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindChangeNickname(c)
|
||||
if err != nil {
|
||||
r.RenderChangeNickname(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderChangeNickname(c, s.ChangeNickname(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/password", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindChangePassword(c)
|
||||
if err != nil {
|
||||
r.RenderChangePassword(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderChangePassword(c, s.ChangePassword(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/phone", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindUserPhoneBind(c)
|
||||
if err != nil {
|
||||
r.RenderUserPhoneBind(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderUserPhoneBind(c, s.UserPhoneBind(req))
|
||||
})
|
||||
|
||||
router.Handle("GET", "/user/stars", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindGetStars(c)
|
||||
if err != nil {
|
||||
r.RenderGetStars(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.GetStars(req)
|
||||
r.RenderGetStars(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/user/collections", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindGetCollections(c)
|
||||
if err != nil {
|
||||
r.RenderGetCollections(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.GetCollections(req)
|
||||
r.RenderGetCollections(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/whisper", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindSendUserWhisper(c)
|
||||
if err != nil {
|
||||
r.RenderSendUserWhisper(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderSendUserWhisper(c, s.SendUserWhisper(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/message/read", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindReadMessage(c)
|
||||
if err != nil {
|
||||
r.RenderReadMessage(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderReadMessage(c, s.ReadMessage(req))
|
||||
})
|
||||
|
||||
router.Handle("GET", "/user/messages", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindGetMessages(c)
|
||||
if err != nil {
|
||||
r.RenderGetMessages(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.GetMessages(req)
|
||||
r.RenderGetMessages(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/user/msgcount/unread", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindGetUnreadMsgCount(c)
|
||||
if err != nil {
|
||||
r.RenderGetUnreadMsgCount(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.GetUnreadMsgCount(req)
|
||||
r.RenderGetUnreadMsgCount(c, resp, err)
|
||||
})
|
||||
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindSyncSearchIndex(c)
|
||||
if err != nil {
|
||||
r.RenderSyncSearchIndex(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderSyncSearchIndex(c, s.SyncSearchIndex(req))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedCoreServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedCoreServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) TweetCollectionStatus(req *web.TweetCollectionStatusReq) (*web.TweetCollectionStatusResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) TweetStarStatus(req *web.TweetStarStatusReq) (*web.TweetStarStatusResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) SuggestTags(req *web.SuggestTagsReq) (*web.SuggestTagsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) SuggestUsers(req *web.SuggestUsersReq) (*web.SuggestUsersResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) ChangeAvatar(req *web.ChangeAvatarReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) ChangeNickname(req *web.ChangeNicknameReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) ChangePassword(req *web.ChangePasswordReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) UserPhoneBind(req *web.UserPhoneBindReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) GetStars(req *web.GetStarsReq) (*web.GetStarsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) GetCollections(req *web.GetCollectionsReq) (*web.GetCollectionsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) SendUserWhisper(req *web.SendWhisperReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) ReadMessage(req *web.ReadMessageReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) GetMessages(req *web.GetMessagesReq) (*web.GetMessagesResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) GetUnreadMsgCount(req *web.GetUnreadMsgCountReq) (*web.GetUnreadMsgCountResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) GetUserInfo(req *web.UserInfoReq) (*web.UserInfoResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) SyncSearchIndex(req *web.SyncSearchIndexReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedCoreServant) mustEmbedUnimplementedCoreServant() {}
|
||||
|
||||
// UnimplementedCoreRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedCoreRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderTweetCollectionStatus(c *gin.Context, data *web.TweetCollectionStatusResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderTweetStarStatus(c *gin.Context, data *web.TweetStarStatusResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderSuggestTags(c *gin.Context, data *web.SuggestTagsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderSuggestUsers(c *gin.Context, data *web.SuggestUsersResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderChangeAvatar(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderChangeNickname(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderChangePassword(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderUserPhoneBind(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderGetStars(c *gin.Context, data *web.GetStarsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderGetCollections(c *gin.Context, data *web.GetCollectionsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderSendUserWhisper(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderReadMessage(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderGetMessages(c *gin.Context, data *web.GetMessagesResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderGetUnreadMsgCount(c *gin.Context, data *web.GetUnreadMsgCountResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderGetUserInfo(c *gin.Context, data *web.UserInfoResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) RenderSyncSearchIndex(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedCoreRender) mustEmbedUnimplementedCoreRender() {}
|
||||
|
||||
// UnimplementedCoreBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedCoreBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindTweetCollectionStatus(c *gin.Context) (*web.TweetCollectionStatusReq, mir.Error) {
|
||||
obj := new(web.TweetCollectionStatusReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindTweetStarStatus(c *gin.Context) (*web.TweetStarStatusReq, mir.Error) {
|
||||
obj := new(web.TweetStarStatusReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindSuggestTags(c *gin.Context) (*web.SuggestTagsReq, mir.Error) {
|
||||
obj := new(web.SuggestTagsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindSuggestUsers(c *gin.Context) (*web.SuggestUsersReq, mir.Error) {
|
||||
obj := new(web.SuggestUsersReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindChangeAvatar(c *gin.Context) (*web.ChangeAvatarReq, mir.Error) {
|
||||
obj := new(web.ChangeAvatarReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindChangeNickname(c *gin.Context) (*web.ChangeNicknameReq, mir.Error) {
|
||||
obj := new(web.ChangeNicknameReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindChangePassword(c *gin.Context) (*web.ChangePasswordReq, mir.Error) {
|
||||
obj := new(web.ChangePasswordReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindUserPhoneBind(c *gin.Context) (*web.UserPhoneBindReq, mir.Error) {
|
||||
obj := new(web.UserPhoneBindReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindGetStars(c *gin.Context) (*web.GetStarsReq, mir.Error) {
|
||||
obj := new(web.GetStarsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindGetCollections(c *gin.Context) (*web.GetCollectionsReq, mir.Error) {
|
||||
obj := new(web.GetCollectionsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindSendUserWhisper(c *gin.Context) (*web.SendWhisperReq, mir.Error) {
|
||||
obj := new(web.SendWhisperReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindReadMessage(c *gin.Context) (*web.ReadMessageReq, mir.Error) {
|
||||
obj := new(web.ReadMessageReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindGetMessages(c *gin.Context) (*web.GetMessagesReq, mir.Error) {
|
||||
obj := new(web.GetMessagesReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindGetUnreadMsgCount(c *gin.Context) (*web.GetUnreadMsgCountReq, mir.Error) {
|
||||
obj := new(web.GetUnreadMsgCountReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindGetUserInfo(c *gin.Context) (*web.UserInfoReq, mir.Error) {
|
||||
obj := new(web.UserInfoReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) BindSyncSearchIndex(c *gin.Context) (*web.SyncSearchIndexReq, mir.Error) {
|
||||
obj := new(web.SyncSearchIndexReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedCoreBinding) mustEmbedUnimplementedCoreBinding() {}
|
@ -0,0 +1,193 @@
|
||||
// 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 Followship interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
ListFollowers(*web.ListFollowersReq) (*web.ListFollowersResp, mir.Error)
|
||||
ListFollowings(*web.ListFollowingsReq) (*web.ListFollowingsResp, mir.Error)
|
||||
DeleteFollowing(*web.DeleteFollowingReq) mir.Error
|
||||
AddFollowing(*web.AddFollowingReq) mir.Error
|
||||
|
||||
mustEmbedUnimplementedFollowshipServant()
|
||||
}
|
||||
|
||||
type FollowshipBinding interface {
|
||||
BindListFollowers(*gin.Context) (*web.ListFollowersReq, mir.Error)
|
||||
BindListFollowings(*gin.Context) (*web.ListFollowingsReq, mir.Error)
|
||||
BindDeleteFollowing(*gin.Context) (*web.DeleteFollowingReq, mir.Error)
|
||||
BindAddFollowing(*gin.Context) (*web.AddFollowingReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedFollowshipBinding()
|
||||
}
|
||||
|
||||
type FollowshipRender interface {
|
||||
RenderListFollowers(*gin.Context, *web.ListFollowersResp, mir.Error)
|
||||
RenderListFollowings(*gin.Context, *web.ListFollowingsResp, mir.Error)
|
||||
RenderDeleteFollowing(*gin.Context, mir.Error)
|
||||
RenderAddFollowing(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedFollowshipRender()
|
||||
}
|
||||
|
||||
// RegisterFollowshipServant register Followship servant to gin
|
||||
func RegisterFollowshipServant(e *gin.Engine, s Followship, b FollowshipBinding, r FollowshipRender) {
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindListFollowings(c)
|
||||
if err != nil {
|
||||
r.RenderListFollowings(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.ListFollowings(req)
|
||||
r.RenderListFollowings(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/following/delete", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindDeleteFollowing(c)
|
||||
if err != nil {
|
||||
r.RenderDeleteFollowing(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderDeleteFollowing(c, s.DeleteFollowing(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/following/add", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindAddFollowing(c)
|
||||
if err != nil {
|
||||
r.RenderAddFollowing(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderAddFollowing(c, s.AddFollowing(req))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedFollowshipServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedFollowshipServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedFollowshipServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedFollowshipServant) ListFollowers(req *web.ListFollowersReq) (*web.ListFollowersResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFollowshipServant) ListFollowings(req *web.ListFollowingsReq) (*web.ListFollowingsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFollowshipServant) DeleteFollowing(req *web.DeleteFollowingReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFollowshipServant) AddFollowing(req *web.AddFollowingReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFollowshipServant) mustEmbedUnimplementedFollowshipServant() {}
|
||||
|
||||
// UnimplementedFollowshipRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedFollowshipRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFollowshipRender) RenderListFollowers(c *gin.Context, data *web.ListFollowersResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFollowshipRender) RenderListFollowings(c *gin.Context, data *web.ListFollowingsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFollowshipRender) RenderDeleteFollowing(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFollowshipRender) RenderAddFollowing(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFollowshipRender) mustEmbedUnimplementedFollowshipRender() {}
|
||||
|
||||
// UnimplementedFollowshipBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedFollowshipBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedFollowshipBinding) BindListFollowers(c *gin.Context) (*web.ListFollowersReq, mir.Error) {
|
||||
obj := new(web.ListFollowersReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFollowshipBinding) BindListFollowings(c *gin.Context) (*web.ListFollowingsReq, mir.Error) {
|
||||
obj := new(web.ListFollowingsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFollowshipBinding) BindDeleteFollowing(c *gin.Context) (*web.DeleteFollowingReq, mir.Error) {
|
||||
obj := new(web.DeleteFollowingReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFollowshipBinding) BindAddFollowing(c *gin.Context) (*web.AddFollowingReq, mir.Error) {
|
||||
obj := new(web.AddFollowingReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFollowshipBinding) mustEmbedUnimplementedFollowshipBinding() {}
|
@ -0,0 +1,224 @@
|
||||
// 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 Friendship interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
GetContacts(*web.GetContactsReq) (*web.GetContactsResp, mir.Error)
|
||||
DeleteFriend(*web.DeleteFriendReq) mir.Error
|
||||
RejectFriend(*web.RejectFriendReq) mir.Error
|
||||
AddFriend(*web.AddFriendReq) mir.Error
|
||||
RequestingFriend(*web.RequestingFriendReq) mir.Error
|
||||
|
||||
mustEmbedUnimplementedFriendshipServant()
|
||||
}
|
||||
|
||||
type FriendshipBinding interface {
|
||||
BindGetContacts(*gin.Context) (*web.GetContactsReq, mir.Error)
|
||||
BindDeleteFriend(*gin.Context) (*web.DeleteFriendReq, mir.Error)
|
||||
BindRejectFriend(*gin.Context) (*web.RejectFriendReq, mir.Error)
|
||||
BindAddFriend(*gin.Context) (*web.AddFriendReq, mir.Error)
|
||||
BindRequestingFriend(*gin.Context) (*web.RequestingFriendReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedFriendshipBinding()
|
||||
}
|
||||
|
||||
type FriendshipRender 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)
|
||||
|
||||
mustEmbedUnimplementedFriendshipRender()
|
||||
}
|
||||
|
||||
// RegisterFriendshipServant register Friendship servant to gin
|
||||
func RegisterFriendshipServant(e *gin.Engine, s Friendship, b FriendshipBinding, r FriendshipRender) {
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindDeleteFriend(c)
|
||||
if err != nil {
|
||||
r.RenderDeleteFriend(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderDeleteFriend(c, s.DeleteFriend(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/friend/reject", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindRejectFriend(c)
|
||||
if err != nil {
|
||||
r.RenderRejectFriend(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderRejectFriend(c, s.RejectFriend(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/friend/add", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindAddFriend(c)
|
||||
if err != nil {
|
||||
r.RenderAddFriend(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderAddFriend(c, s.AddFriend(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/friend/requesting", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindRequestingFriend(c)
|
||||
if err != nil {
|
||||
r.RenderRequestingFriend(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderRequestingFriend(c, s.RequestingFriend(req))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedFriendshipServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedFriendshipServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedFriendshipServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedFriendshipServant) GetContacts(req *web.GetContactsReq) (*web.GetContactsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFriendshipServant) DeleteFriend(req *web.DeleteFriendReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFriendshipServant) RejectFriend(req *web.RejectFriendReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFriendshipServant) AddFriend(req *web.AddFriendReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFriendshipServant) RequestingFriend(req *web.RequestingFriendReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedFriendshipServant) mustEmbedUnimplementedFriendshipServant() {}
|
||||
|
||||
// UnimplementedFriendshipRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedFriendshipRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFriendshipRender) RenderGetContacts(c *gin.Context, data *web.GetContactsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFriendshipRender) RenderDeleteFriend(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFriendshipRender) RenderRejectFriend(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFriendshipRender) RenderAddFriend(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFriendshipRender) RenderRequestingFriend(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedFriendshipRender) mustEmbedUnimplementedFriendshipRender() {}
|
||||
|
||||
// UnimplementedFriendshipBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedFriendshipBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedFriendshipBinding) BindGetContacts(c *gin.Context) (*web.GetContactsReq, mir.Error) {
|
||||
obj := new(web.GetContactsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFriendshipBinding) BindDeleteFriend(c *gin.Context) (*web.DeleteFriendReq, mir.Error) {
|
||||
obj := new(web.DeleteFriendReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFriendshipBinding) BindRejectFriend(c *gin.Context) (*web.RejectFriendReq, mir.Error) {
|
||||
obj := new(web.RejectFriendReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFriendshipBinding) BindAddFriend(c *gin.Context) (*web.AddFriendReq, mir.Error) {
|
||||
obj := new(web.AddFriendReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFriendshipBinding) BindRequestingFriend(c *gin.Context) (*web.RequestingFriendReq, mir.Error) {
|
||||
obj := new(web.RequestingFriendReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedFriendshipBinding) mustEmbedUnimplementedFriendshipBinding() {}
|
@ -0,0 +1,162 @@
|
||||
// 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 Loose interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
GetUserProfile(*web.GetUserProfileReq) (*web.GetUserProfileResp, mir.Error)
|
||||
GetUserTweets(*web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error)
|
||||
Timeline(*web.TimelineReq) (*web.TimelineResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedLooseServant()
|
||||
}
|
||||
|
||||
type LooseBinding interface {
|
||||
BindGetUserProfile(*gin.Context) (*web.GetUserProfileReq, mir.Error)
|
||||
BindGetUserTweets(*gin.Context) (*web.GetUserTweetsReq, mir.Error)
|
||||
BindTimeline(*gin.Context) (*web.TimelineReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedLooseBinding()
|
||||
}
|
||||
|
||||
type LooseRender interface {
|
||||
RenderGetUserProfile(*gin.Context, *web.GetUserProfileResp, mir.Error)
|
||||
RenderGetUserTweets(*gin.Context, *web.GetUserTweetsResp, mir.Error)
|
||||
RenderTimeline(*gin.Context, *web.TimelineResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedLooseRender()
|
||||
}
|
||||
|
||||
// RegisterLooseServant register Loose servant to gin
|
||||
func RegisterLooseServant(e *gin.Engine, s Loose, b LooseBinding, r LooseRender) {
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindGetUserProfile(c)
|
||||
if err != nil {
|
||||
r.RenderGetUserProfile(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.GetUserProfile(req)
|
||||
r.RenderGetUserProfile(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/user/posts", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindGetUserTweets(c)
|
||||
if err != nil {
|
||||
r.RenderGetUserTweets(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.GetUserTweets(req)
|
||||
r.RenderGetUserTweets(c, resp, err)
|
||||
})
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedLooseServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedLooseServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedLooseServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedLooseServant) GetUserProfile(req *web.GetUserProfileReq) (*web.GetUserProfileResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedLooseServant) GetUserTweets(req *web.GetUserTweetsReq) (*web.GetUserTweetsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedLooseServant) Timeline(req *web.TimelineReq) (*web.TimelineResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedLooseServant) mustEmbedUnimplementedLooseServant() {}
|
||||
|
||||
// UnimplementedLooseRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedLooseRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedLooseRender) RenderGetUserProfile(c *gin.Context, data *web.GetUserProfileResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedLooseRender) RenderGetUserTweets(c *gin.Context, data *web.GetUserTweetsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedLooseRender) RenderTimeline(c *gin.Context, data *web.TimelineResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedLooseRender) mustEmbedUnimplementedLooseRender() {}
|
||||
|
||||
// UnimplementedLooseBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedLooseBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedLooseBinding) BindGetUserProfile(c *gin.Context) (*web.GetUserProfileReq, mir.Error) {
|
||||
obj := new(web.GetUserProfileReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedLooseBinding) BindGetUserTweets(c *gin.Context) (*web.GetUserTweetsReq, mir.Error) {
|
||||
obj := new(web.GetUserTweetsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedLooseBinding) BindTimeline(c *gin.Context) (*web.TimelineReq, mir.Error) {
|
||||
obj := new(web.TimelineReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedLooseBinding) mustEmbedUnimplementedLooseBinding() {}
|
@ -0,0 +1,522 @@
|
||||
// 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 Priv interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
DeleteCommentReply(*web.DeleteCommentReplyReq) mir.Error
|
||||
CreateCommentReply(*web.CreateCommentReplyReq) (*web.CreateCommentReplyResp, mir.Error)
|
||||
DeleteComment(*web.DeleteCommentReq) mir.Error
|
||||
CreateComment(*web.CreateCommentReq) (*web.CreateCommentResp, mir.Error)
|
||||
VisiblePost(*web.VisiblePostReq) (*web.VisiblePostResp, mir.Error)
|
||||
StickTweet(*web.StickTweetReq) (*web.StickTweetResp, mir.Error)
|
||||
LockTweet(*web.LockTweetReq) (*web.LockTweetResp, mir.Error)
|
||||
CollectionTweet(*web.CollectionTweetReq) (*web.CollectionTweetResp, mir.Error)
|
||||
StarTweet(*web.StarTweetReq) (*web.StarTweetResp, mir.Error)
|
||||
DeleteTweet(*web.DeleteTweetReq) mir.Error
|
||||
CreateTweet(*web.CreateTweetReq) (*web.CreateTweetResp, mir.Error)
|
||||
DownloadAttachment(*web.DownloadAttachmentReq) (*web.DownloadAttachmentResp, mir.Error)
|
||||
DownloadAttachmentPrecheck(*web.DownloadAttachmentPrecheckReq) (*web.DownloadAttachmentPrecheckResp, mir.Error)
|
||||
UploadAttachment(*web.UploadAttachmentReq) (*web.UploadAttachmentResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedPrivServant()
|
||||
}
|
||||
|
||||
type PrivBinding interface {
|
||||
BindDeleteCommentReply(*gin.Context) (*web.DeleteCommentReplyReq, mir.Error)
|
||||
BindCreateCommentReply(*gin.Context) (*web.CreateCommentReplyReq, mir.Error)
|
||||
BindDeleteComment(*gin.Context) (*web.DeleteCommentReq, mir.Error)
|
||||
BindCreateComment(*gin.Context) (*web.CreateCommentReq, mir.Error)
|
||||
BindVisiblePost(*gin.Context) (*web.VisiblePostReq, mir.Error)
|
||||
BindStickTweet(*gin.Context) (*web.StickTweetReq, mir.Error)
|
||||
BindLockTweet(*gin.Context) (*web.LockTweetReq, mir.Error)
|
||||
BindCollectionTweet(*gin.Context) (*web.CollectionTweetReq, mir.Error)
|
||||
BindStarTweet(*gin.Context) (*web.StarTweetReq, mir.Error)
|
||||
BindDeleteTweet(*gin.Context) (*web.DeleteTweetReq, mir.Error)
|
||||
BindCreateTweet(*gin.Context) (*web.CreateTweetReq, mir.Error)
|
||||
BindDownloadAttachment(*gin.Context) (*web.DownloadAttachmentReq, mir.Error)
|
||||
BindDownloadAttachmentPrecheck(*gin.Context) (*web.DownloadAttachmentPrecheckReq, mir.Error)
|
||||
BindUploadAttachment(*gin.Context) (*web.UploadAttachmentReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedPrivBinding()
|
||||
}
|
||||
|
||||
type PrivRender interface {
|
||||
RenderDeleteCommentReply(*gin.Context, mir.Error)
|
||||
RenderCreateCommentReply(*gin.Context, *web.CreateCommentReplyResp, mir.Error)
|
||||
RenderDeleteComment(*gin.Context, mir.Error)
|
||||
RenderCreateComment(*gin.Context, *web.CreateCommentResp, mir.Error)
|
||||
RenderVisiblePost(*gin.Context, *web.VisiblePostResp, mir.Error)
|
||||
RenderStickTweet(*gin.Context, *web.StickTweetResp, mir.Error)
|
||||
RenderLockTweet(*gin.Context, *web.LockTweetResp, mir.Error)
|
||||
RenderCollectionTweet(*gin.Context, *web.CollectionTweetResp, mir.Error)
|
||||
RenderStarTweet(*gin.Context, *web.StarTweetResp, mir.Error)
|
||||
RenderDeleteTweet(*gin.Context, mir.Error)
|
||||
RenderCreateTweet(*gin.Context, *web.CreateTweetResp, mir.Error)
|
||||
RenderDownloadAttachment(*gin.Context, *web.DownloadAttachmentResp, mir.Error)
|
||||
RenderDownloadAttachmentPrecheck(*gin.Context, *web.DownloadAttachmentPrecheckResp, mir.Error)
|
||||
RenderUploadAttachment(*gin.Context, *web.UploadAttachmentResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedPrivRender()
|
||||
}
|
||||
|
||||
// RegisterPrivServant register Priv servant to gin
|
||||
func RegisterPrivServant(e *gin.Engine, s Priv, b PrivBinding, r PrivRender) {
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindDeleteCommentReply(c)
|
||||
if err != nil {
|
||||
r.RenderDeleteCommentReply(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderDeleteCommentReply(c, s.DeleteCommentReply(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/comment/reply", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindCreateCommentReply(c)
|
||||
if err != nil {
|
||||
r.RenderCreateCommentReply(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.CreateCommentReply(req)
|
||||
r.RenderCreateCommentReply(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("DELETE", "/post/comment", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindDeleteComment(c)
|
||||
if err != nil {
|
||||
r.RenderDeleteComment(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderDeleteComment(c, s.DeleteComment(req))
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/comment", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindCreateComment(c)
|
||||
if err != nil {
|
||||
r.RenderCreateComment(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.CreateComment(req)
|
||||
r.RenderCreateComment(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/visibility", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindVisiblePost(c)
|
||||
if err != nil {
|
||||
r.RenderVisiblePost(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.VisiblePost(req)
|
||||
r.RenderVisiblePost(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/stick", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindStickTweet(c)
|
||||
if err != nil {
|
||||
r.RenderStickTweet(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.StickTweet(req)
|
||||
r.RenderStickTweet(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/lock", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindLockTweet(c)
|
||||
if err != nil {
|
||||
r.RenderLockTweet(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.LockTweet(req)
|
||||
r.RenderLockTweet(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/collection", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindCollectionTweet(c)
|
||||
if err != nil {
|
||||
r.RenderCollectionTweet(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.CollectionTweet(req)
|
||||
r.RenderCollectionTweet(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/post/start", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindStarTweet(c)
|
||||
if err != nil {
|
||||
r.RenderStarTweet(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.StarTweet(req)
|
||||
r.RenderStarTweet(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("DELETE", "/post", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindDeleteTweet(c)
|
||||
if err != nil {
|
||||
r.RenderDeleteTweet(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderDeleteTweet(c, s.DeleteTweet(req))
|
||||
})
|
||||
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindDownloadAttachment(c)
|
||||
if err != nil {
|
||||
r.RenderDownloadAttachment(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.DownloadAttachment(req)
|
||||
r.RenderDownloadAttachment(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/attachment/precheck", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindDownloadAttachmentPrecheck(c)
|
||||
if err != nil {
|
||||
r.RenderDownloadAttachmentPrecheck(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.DownloadAttachmentPrecheck(req)
|
||||
r.RenderDownloadAttachmentPrecheck(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/attachment", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindUploadAttachment(c)
|
||||
if err != nil {
|
||||
r.RenderUploadAttachment(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.UploadAttachment(req)
|
||||
r.RenderUploadAttachment(c, resp, err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedPrivServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedPrivServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) DeleteCommentReply(req *web.DeleteCommentReplyReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) CreateCommentReply(req *web.CreateCommentReplyReq) (*web.CreateCommentReplyResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) DeleteComment(req *web.DeleteCommentReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) CreateComment(req *web.CreateCommentReq) (*web.CreateCommentResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) VisiblePost(req *web.VisiblePostReq) (*web.VisiblePostResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) StickTweet(req *web.StickTweetReq) (*web.StickTweetResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) LockTweet(req *web.LockTweetReq) (*web.LockTweetResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) CollectionTweet(req *web.CollectionTweetReq) (*web.CollectionTweetResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) StarTweet(req *web.StarTweetReq) (*web.StarTweetResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) DeleteTweet(req *web.DeleteTweetReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) CreateTweet(req *web.CreateTweetReq) (*web.CreateTweetResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) DownloadAttachment(req *web.DownloadAttachmentReq) (*web.DownloadAttachmentResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) DownloadAttachmentPrecheck(req *web.DownloadAttachmentPrecheckReq) (*web.DownloadAttachmentPrecheckResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAttachmentResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPrivServant) mustEmbedUnimplementedPrivServant() {}
|
||||
|
||||
// UnimplementedPrivRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedPrivRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderDeleteCommentReply(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderCreateCommentReply(c *gin.Context, data *web.CreateCommentReplyResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderDeleteComment(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderCreateComment(c *gin.Context, data *web.CreateCommentResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderVisiblePost(c *gin.Context, data *web.VisiblePostResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderStickTweet(c *gin.Context, data *web.StickTweetResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderLockTweet(c *gin.Context, data *web.LockTweetResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderCollectionTweet(c *gin.Context, data *web.CollectionTweetResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderStarTweet(c *gin.Context, data *web.StarTweetResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderDeleteTweet(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderCreateTweet(c *gin.Context, data *web.CreateTweetResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderDownloadAttachment(c *gin.Context, data *web.DownloadAttachmentResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderDownloadAttachmentPrecheck(c *gin.Context, data *web.DownloadAttachmentPrecheckResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) RenderUploadAttachment(c *gin.Context, data *web.UploadAttachmentResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPrivRender) mustEmbedUnimplementedPrivRender() {}
|
||||
|
||||
// UnimplementedPrivBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedPrivBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindDeleteCommentReply(c *gin.Context) (*web.DeleteCommentReplyReq, mir.Error) {
|
||||
obj := new(web.DeleteCommentReplyReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindCreateCommentReply(c *gin.Context) (*web.CreateCommentReplyReq, mir.Error) {
|
||||
obj := new(web.CreateCommentReplyReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindDeleteComment(c *gin.Context) (*web.DeleteCommentReq, mir.Error) {
|
||||
obj := new(web.DeleteCommentReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindCreateComment(c *gin.Context) (*web.CreateCommentReq, mir.Error) {
|
||||
obj := new(web.CreateCommentReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindVisiblePost(c *gin.Context) (*web.VisiblePostReq, mir.Error) {
|
||||
obj := new(web.VisiblePostReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindStickTweet(c *gin.Context) (*web.StickTweetReq, mir.Error) {
|
||||
obj := new(web.StickTweetReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindLockTweet(c *gin.Context) (*web.LockTweetReq, mir.Error) {
|
||||
obj := new(web.LockTweetReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindCollectionTweet(c *gin.Context) (*web.CollectionTweetReq, mir.Error) {
|
||||
obj := new(web.CollectionTweetReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindStarTweet(c *gin.Context) (*web.StarTweetReq, mir.Error) {
|
||||
obj := new(web.StarTweetReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindDeleteTweet(c *gin.Context) (*web.DeleteTweetReq, mir.Error) {
|
||||
obj := new(web.DeleteTweetReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindCreateTweet(c *gin.Context) (*web.CreateTweetReq, mir.Error) {
|
||||
obj := new(web.CreateTweetReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindDownloadAttachment(c *gin.Context) (*web.DownloadAttachmentReq, mir.Error) {
|
||||
obj := new(web.DownloadAttachmentReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindDownloadAttachmentPrecheck(c *gin.Context) (*web.DownloadAttachmentPrecheckReq, mir.Error) {
|
||||
obj := new(web.DownloadAttachmentPrecheckReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) BindUploadAttachment(c *gin.Context) (*web.UploadAttachmentReq, mir.Error) {
|
||||
obj := new(web.UploadAttachmentReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPrivBinding) mustEmbedUnimplementedPrivBinding() {}
|
@ -0,0 +1,292 @@
|
||||
// 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 Pub interface {
|
||||
TopicList(*web.TopicListReq) (*web.TopicListResp, mir.Error)
|
||||
TweetComments(*web.TweetCommentsReq) (*web.TweetCommentsResp, mir.Error)
|
||||
TweetDetail(*web.TweetDetailReq) (*web.TweetDetailResp, mir.Error)
|
||||
SendCaptcha(*web.SendCaptchaReq) mir.Error
|
||||
GetCaptcha() (*web.GetCaptchaResp, mir.Error)
|
||||
Register(*web.RegisterReq) (*web.RegisterResp, mir.Error)
|
||||
Login(*web.LoginReq) (*web.LoginResp, mir.Error)
|
||||
Version() (*web.VersionResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedPubServant()
|
||||
}
|
||||
|
||||
type PubBinding interface {
|
||||
BindTopicList(*gin.Context) (*web.TopicListReq, mir.Error)
|
||||
BindTweetComments(*gin.Context) (*web.TweetCommentsReq, mir.Error)
|
||||
BindTweetDetail(*gin.Context) (*web.TweetDetailReq, mir.Error)
|
||||
BindSendCaptcha(*gin.Context) (*web.SendCaptchaReq, mir.Error)
|
||||
BindRegister(*gin.Context) (*web.RegisterReq, mir.Error)
|
||||
BindLogin(*gin.Context) (*web.LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedPubBinding()
|
||||
}
|
||||
|
||||
type PubRender interface {
|
||||
RenderTopicList(*gin.Context, *web.TopicListResp, mir.Error)
|
||||
RenderTweetComments(*gin.Context, *web.TweetCommentsResp, mir.Error)
|
||||
RenderTweetDetail(*gin.Context, *web.TweetDetailResp, mir.Error)
|
||||
RenderSendCaptcha(*gin.Context, mir.Error)
|
||||
RenderGetCaptcha(*gin.Context, *web.GetCaptchaResp, mir.Error)
|
||||
RenderRegister(*gin.Context, *web.RegisterResp, mir.Error)
|
||||
RenderLogin(*gin.Context, *web.LoginResp, mir.Error)
|
||||
RenderVersion(*gin.Context, *web.VersionResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedPubRender()
|
||||
}
|
||||
|
||||
// RegisterPubServant register Pub servant to gin
|
||||
func RegisterPubServant(e *gin.Engine, s Pub, b PubBinding, r PubRender) {
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindTopicList(c)
|
||||
if err != nil {
|
||||
r.RenderTopicList(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.TopicList(req)
|
||||
r.RenderTopicList(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/post/comments", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindTweetComments(c)
|
||||
if err != nil {
|
||||
r.RenderTweetComments(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.TweetComments(req)
|
||||
r.RenderTweetComments(c, resp, err)
|
||||
})
|
||||
|
||||
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:
|
||||
}
|
||||
|
||||
req, err := b.BindSendCaptcha(c)
|
||||
if err != nil {
|
||||
r.RenderSendCaptcha(c, err)
|
||||
return
|
||||
}
|
||||
r.RenderSendCaptcha(c, s.SendCaptcha(req))
|
||||
})
|
||||
|
||||
router.Handle("GET", "/captcha", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
resp, err := s.GetCaptcha()
|
||||
r.RenderGetCaptcha(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/auth/register", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindRegister(c)
|
||||
if err != nil {
|
||||
r.RenderRegister(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.Register(req)
|
||||
r.RenderRegister(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("POST", "/auth/login", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindLogin(c)
|
||||
if err != nil {
|
||||
r.RenderLogin(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.Login(req)
|
||||
r.RenderLogin(c, resp, err)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
resp, err := s.Version()
|
||||
r.RenderVersion(c, resp, err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedPubServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedPubServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) TopicList(req *web.TopicListReq) (*web.TopicListResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) TweetComments(req *web.TweetCommentsReq) (*web.TweetCommentsResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) TweetDetail(req *web.TweetDetailReq) (*web.TweetDetailResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) SendCaptcha(req *web.SendCaptchaReq) mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) GetCaptcha() (*web.GetCaptchaResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) Register(req *web.RegisterReq) (*web.RegisterResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) Login(req *web.LoginReq) (*web.LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) Version() (*web.VersionResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedPubServant) mustEmbedUnimplementedPubServant() {}
|
||||
|
||||
// UnimplementedPubRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedPubRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) RenderTopicList(c *gin.Context, data *web.TopicListResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) RenderTweetComments(c *gin.Context, data *web.TweetCommentsResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) RenderTweetDetail(c *gin.Context, data *web.TweetDetailResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) RenderSendCaptcha(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) RenderGetCaptcha(c *gin.Context, data *web.GetCaptchaResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) RenderRegister(c *gin.Context, data *web.RegisterResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) RenderLogin(c *gin.Context, data *web.LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) RenderVersion(c *gin.Context, data *web.VersionResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedPubRender) mustEmbedUnimplementedPubRender() {}
|
||||
|
||||
// UnimplementedPubBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedPubBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedPubBinding) BindTopicList(c *gin.Context) (*web.TopicListReq, mir.Error) {
|
||||
obj := new(web.TopicListReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPubBinding) BindTweetComments(c *gin.Context) (*web.TweetCommentsReq, mir.Error) {
|
||||
obj := new(web.TweetCommentsReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPubBinding) BindTweetDetail(c *gin.Context) (*web.TweetDetailReq, mir.Error) {
|
||||
obj := new(web.TweetDetailReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPubBinding) BindSendCaptcha(c *gin.Context) (*web.SendCaptchaReq, mir.Error) {
|
||||
obj := new(web.SendCaptchaReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPubBinding) BindRegister(c *gin.Context) (*web.RegisterReq, mir.Error) {
|
||||
obj := new(web.RegisterReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPubBinding) BindLogin(c *gin.Context) (*web.LoginReq, mir.Error) {
|
||||
obj := new(web.LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedPubBinding) mustEmbedUnimplementedPubBinding() {}
|
@ -0,0 +1,371 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc (unknown)
|
||||
// source: v1/auth.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type User struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
PhoneNum string `protobuf:"bytes,1,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"`
|
||||
}
|
||||
|
||||
func (x *User) Reset() {
|
||||
*x = User{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_v1_auth_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *User) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*User) ProtoMessage() {}
|
||||
|
||||
func (x *User) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_v1_auth_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use User.ProtoReflect.Descriptor instead.
|
||||
func (*User) Descriptor() ([]byte, []int) {
|
||||
return file_v1_auth_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *User) GetPhoneNum() string {
|
||||
if x != nil {
|
||||
return x.PhoneNum
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UserVerify struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
PhoneNum string `protobuf:"bytes,1,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"`
|
||||
VerificationCode string `protobuf:"bytes,2,opt,name=VerificationCode,proto3" json:"VerificationCode,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UserVerify) Reset() {
|
||||
*x = UserVerify{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_v1_auth_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UserVerify) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UserVerify) ProtoMessage() {}
|
||||
|
||||
func (x *UserVerify) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_v1_auth_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UserVerify.ProtoReflect.Descriptor instead.
|
||||
func (*UserVerify) Descriptor() ([]byte, []int) {
|
||||
return file_v1_auth_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *UserVerify) GetPhoneNum() string {
|
||||
if x != nil {
|
||||
return x.PhoneNum
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserVerify) GetVerificationCode() string {
|
||||
if x != nil {
|
||||
return x.VerificationCode
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type LoginReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
StatuCode int32 `protobuf:"varint,1,opt,name=statuCode,proto3" json:"statuCode,omitempty"`
|
||||
Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
|
||||
}
|
||||
|
||||
func (x *LoginReply) Reset() {
|
||||
*x = LoginReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_v1_auth_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *LoginReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LoginReply) ProtoMessage() {}
|
||||
|
||||
func (x *LoginReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_v1_auth_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use LoginReply.ProtoReflect.Descriptor instead.
|
||||
func (*LoginReply) Descriptor() ([]byte, []int) {
|
||||
return file_v1_auth_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *LoginReply) GetStatuCode() int32 {
|
||||
if x != nil {
|
||||
return x.StatuCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *LoginReply) GetToken() string {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ActionReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
StatusCode int32 `protobuf:"varint,1,opt,name=statusCode,proto3" json:"statusCode,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ActionReply) Reset() {
|
||||
*x = ActionReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_v1_auth_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ActionReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ActionReply) ProtoMessage() {}
|
||||
|
||||
func (x *ActionReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_v1_auth_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ActionReply.ProtoReflect.Descriptor instead.
|
||||
func (*ActionReply) Descriptor() ([]byte, []int) {
|
||||
return file_v1_auth_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ActionReply) GetStatusCode() int32 {
|
||||
if x != nil {
|
||||
return x.StatusCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_v1_auth_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_v1_auth_proto_rawDesc = []byte{
|
||||
0x0a, 0x0d, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x04, 0x61, 0x75, 0x74, 0x68, 0x22, 0x22, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x0a,
|
||||
0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x22, 0x54, 0x0a, 0x0a, 0x55, 0x73, 0x65,
|
||||
0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65,
|
||||
0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65,
|
||||
0x4e, 0x75, 0x6d, 0x12, 0x2a, 0x0a, 0x10, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x56,
|
||||
0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x22,
|
||||
0x40, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1c, 0x0a,
|
||||
0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65,
|
||||
0x6e, 0x22, 0x2d, 0x0a, 0x0b, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79,
|
||||
0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65,
|
||||
0x32, 0x89, 0x01, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74,
|
||||
0x65, 0x12, 0x29, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0a, 0x2e,
|
||||
0x61, 0x75, 0x74, 0x68, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x1a, 0x11, 0x2e, 0x61, 0x75, 0x74, 0x68,
|
||||
0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x25, 0x0a, 0x05,
|
||||
0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0a, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x55, 0x73, 0x65,
|
||||
0x72, 0x1a, 0x10, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65,
|
||||
0x70, 0x6c, 0x79, 0x12, 0x27, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x0a, 0x2e,
|
||||
0x61, 0x75, 0x74, 0x68, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x1a, 0x11, 0x2e, 0x61, 0x75, 0x74, 0x68,
|
||||
0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x6f, 0x0a, 0x08,
|
||||
0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x42, 0x09, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x72, 0x6f, 0x63, 0x62, 0x6f, 0x73, 0x73, 0x2f, 0x70, 0x61, 0x6f, 0x70, 0x61, 0x6f,
|
||||
0x2d, 0x63, 0x65, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0xa2,
|
||||
0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x41, 0x75, 0x74, 0x68, 0xca, 0x02, 0x04, 0x41,
|
||||
0x75, 0x74, 0x68, 0xe2, 0x02, 0x10, 0x41, 0x75, 0x74, 0x68, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65,
|
||||
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x41, 0x75, 0x74, 0x68, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_v1_auth_proto_rawDescOnce sync.Once
|
||||
file_v1_auth_proto_rawDescData = file_v1_auth_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_v1_auth_proto_rawDescGZIP() []byte {
|
||||
file_v1_auth_proto_rawDescOnce.Do(func() {
|
||||
file_v1_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_auth_proto_rawDescData)
|
||||
})
|
||||
return file_v1_auth_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_v1_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_v1_auth_proto_goTypes = []interface{}{
|
||||
(*User)(nil), // 0: auth.User
|
||||
(*UserVerify)(nil), // 1: auth.UserVerify
|
||||
(*LoginReply)(nil), // 2: auth.LoginReply
|
||||
(*ActionReply)(nil), // 3: auth.ActionReply
|
||||
}
|
||||
var file_v1_auth_proto_depIdxs = []int32{
|
||||
0, // 0: auth.Authenticate.preLogin:input_type -> auth.User
|
||||
0, // 1: auth.Authenticate.login:input_type -> auth.User
|
||||
0, // 2: auth.Authenticate.logout:input_type -> auth.User
|
||||
3, // 3: auth.Authenticate.preLogin:output_type -> auth.ActionReply
|
||||
2, // 4: auth.Authenticate.login:output_type -> auth.LoginReply
|
||||
3, // 5: auth.Authenticate.logout:output_type -> auth.ActionReply
|
||||
3, // [3:6] is the sub-list for method output_type
|
||||
0, // [0:3] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_v1_auth_proto_init() }
|
||||
func file_v1_auth_proto_init() {
|
||||
if File_v1_auth_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_v1_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*User); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_v1_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserVerify); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_v1_auth_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*LoginReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_v1_auth_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ActionReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_v1_auth_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_v1_auth_proto_goTypes,
|
||||
DependencyIndexes: file_v1_auth_proto_depIdxs,
|
||||
MessageInfos: file_v1_auth_proto_msgTypes,
|
||||
}.Build()
|
||||
File_v1_auth_proto = out.File
|
||||
file_v1_auth_proto_rawDesc = nil
|
||||
file_v1_auth_proto_goTypes = nil
|
||||
file_v1_auth_proto_depIdxs = nil
|
||||
}
|
@ -0,0 +1,177 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc (unknown)
|
||||
// source: v1/auth.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// AuthenticateClient is the client API for Authenticate service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type AuthenticateClient interface {
|
||||
PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error)
|
||||
Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error)
|
||||
Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error)
|
||||
}
|
||||
|
||||
type authenticateClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAuthenticateClient(cc grpc.ClientConnInterface) AuthenticateClient {
|
||||
return &authenticateClient{cc}
|
||||
}
|
||||
|
||||
func (c *authenticateClient) PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) {
|
||||
out := new(ActionReply)
|
||||
err := c.cc.Invoke(ctx, "/auth.Authenticate/preLogin", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authenticateClient) Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error) {
|
||||
out := new(LoginReply)
|
||||
err := c.cc.Invoke(ctx, "/auth.Authenticate/login", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authenticateClient) Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) {
|
||||
out := new(ActionReply)
|
||||
err := c.cc.Invoke(ctx, "/auth.Authenticate/logout", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AuthenticateServer is the server API for Authenticate service.
|
||||
// All implementations must embed UnimplementedAuthenticateServer
|
||||
// for forward compatibility
|
||||
type AuthenticateServer interface {
|
||||
PreLogin(context.Context, *User) (*ActionReply, error)
|
||||
Login(context.Context, *User) (*LoginReply, error)
|
||||
Logout(context.Context, *User) (*ActionReply, error)
|
||||
mustEmbedUnimplementedAuthenticateServer()
|
||||
}
|
||||
|
||||
// UnimplementedAuthenticateServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedAuthenticateServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedAuthenticateServer) PreLogin(context.Context, *User) (*ActionReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PreLogin not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) Login(context.Context, *User) (*LoginReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) Logout(context.Context, *User) (*ActionReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) mustEmbedUnimplementedAuthenticateServer() {}
|
||||
|
||||
// UnsafeAuthenticateServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AuthenticateServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAuthenticateServer interface {
|
||||
mustEmbedUnimplementedAuthenticateServer()
|
||||
}
|
||||
|
||||
func RegisterAuthenticateServer(s grpc.ServiceRegistrar, srv AuthenticateServer) {
|
||||
s.RegisterService(&Authenticate_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Authenticate_PreLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(User)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthenticateServer).PreLogin(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/auth.Authenticate/preLogin",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).PreLogin(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Authenticate_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(User)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthenticateServer).Login(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/auth.Authenticate/login",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).Login(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Authenticate_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(User)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthenticateServer).Logout(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/auth.Authenticate/logout",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).Logout(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Authenticate_ServiceDesc is the grpc.ServiceDesc for Authenticate service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Authenticate_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "auth.Authenticate",
|
||||
HandlerType: (*AuthenticateServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "preLogin",
|
||||
Handler: _Authenticate_PreLogin_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "login",
|
||||
Handler: _Authenticate_Login_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "logout",
|
||||
Handler: _Authenticate_Logout_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "v1/auth.proto",
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
version: v1
|
||||
managed:
|
||||
enabled: true
|
||||
go_package_prefix:
|
||||
default: github.com/rocboss/paopao-ce/auto/rpc
|
||||
except:
|
||||
- buf.build/googleapis/googleapis
|
||||
plugins:
|
||||
- plugin: go
|
||||
out: auto/rpc
|
||||
opt: paths=source_relative
|
||||
- plugin: go-grpc
|
||||
out: auto/rpc
|
||||
opt:
|
||||
- paths=source_relative
|
||||
- require_unimplemented_servers=true
|
@ -0,0 +1,3 @@
|
||||
version: v1
|
||||
directories:
|
||||
- proto
|
@ -1,2 +1,9 @@
|
||||
## 部署文档
|
||||
TODO
|
||||
本目录包含一些paopao-ce部署相关的帮助文档
|
||||
|
||||
* [core](./core) - paopao-ce部署帮助文档
|
||||
* [aliyun](./aliyun) - Aliyun平台部署文档
|
||||
* [huawei](./huawei) - Huawei Cloud平台部署文档
|
||||
* [tencnet](./tencent) - Tencent Cloud平台部署文档
|
||||
* [local](./local) - 本地部署文档
|
||||
* [k8s](./k8s) - 使用Kubernetes部署paopao-ce相关文档
|
||||
|
@ -0,0 +1,2 @@
|
||||
### Aliyun平台部署文档
|
||||
本目录包含一些阿里云平台部署paopao-ce的一些帮助文档。
|
@ -0,0 +1,4 @@
|
||||
### paopao-ce部署帮助文档
|
||||
本目录包含一些部署paopao-ce的一些帮助文档。
|
||||
|
||||
* [001-配置文件说明](./001-配置文件说明.md '001-配置文件说明')
|
@ -0,0 +1,2 @@
|
||||
### Huawei Cloud平台部署文档
|
||||
本目录包含一些华为云平台部署paopao-ce的一些帮助文档。
|
@ -0,0 +1,2 @@
|
||||
### 使用Kubernetes部署paopao-ce相关文档
|
||||
本目录包含一些k8s环境部署paopao-ce的一些帮助文档。
|
@ -0,0 +1,4 @@
|
||||
### 本地部署文档
|
||||
本目录包含一些本地开发环境部署paopao-ce的一些帮助文档。
|
||||
|
||||
* [001-本地开发依赖环境部署](001-本地开发依赖环境部署.md '001-本地开发依赖环境部署')
|
@ -0,0 +1,2 @@
|
||||
### Tencent Cloud平台部署文档
|
||||
本目录包含一些腾讯云平台部署paopao-ce的一些帮助文档。
|
@ -0,0 +1,26 @@
|
||||
### <主题标题>
|
||||
====== <这里写主题描述> =====
|
||||
|
||||
#### <话题标题>
|
||||
====== <这里写话题描述> =====
|
||||
* [北野](https://alimy.me) - 2022/12/14 10:07
|
||||
> 这里就是你的观点论述了
|
||||
|
||||
* [北野](https://alimy.me) - 2022/12/14 10:07
|
||||
> 这里就是你的观点论述了
|
||||
|
||||
* [北野](https://alimy.me) - 2022/12/14 10:07
|
||||
> 这里就是你的观点论述了
|
||||
|
||||
* [北野](https://alimy.me) - 2022/12/14 10:07
|
||||
> 这里就是你的观点论述了
|
||||
|
||||
* [北野](https://alimy.me) - 2022/12/14 10:07
|
||||
> 这里就是你的回复
|
||||
>> 这里就是你的观点论述了
|
||||
|
||||
* [北野](https://alimy.me) - 2022/12/14 10:07
|
||||
> 你的回复
|
||||
>> 这里就是你的回复
|
||||
>>> 这里就是你的观点论述了
|
||||
|
@ -0,0 +1,5 @@
|
||||
### Discuss 开发者交流
|
||||
本目录包含一些开发相关的问题交流论述。
|
||||
|
||||
* [0000-讨论样式模版](./0000-讨论样式模版.md "讨论样式模版")
|
||||
* [0001-FAQs](./0001-FAQs.md "FAQs")
|
Before Width: | Height: | Size: 598 KiB After Width: | Height: | Size: 598 KiB |
Before Width: | Height: | Size: 211 KiB After Width: | Height: | Size: 211 KiB |
After Width: | Height: | Size: 228 KiB |
@ -0,0 +1 @@
|
||||
<mxfile host="Electron" modified="2022-12-18T02:37:17.424Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/20.3.0 Chrome/104.0.5112.114 Electron/20.1.3 Safari/537.36" etag="wuUvG6m6S7FGdLUCFJyX" version="20.3.0" type="device"><diagram id="VpmZCMjdPAEy3pG4oY4d" name="Page-1">7Ztbc6M2FIB/jWbah2SQhAA/+rbdmaZNut6Zbh4xyDYNRh4ir+3++kpGYJDkeNPgS2s7mQQdXYDznSN0DjLA/fn6lzxczH5jMU0BcuI1wAOAEPRdV/yTkk0h6WAlmOZJrBrtBKPkb6qEjpIuk5i+NhpyxlKeLJrCiGUZjXhDFuY5WzWbTVjaPOsinFJDMIrC1JT+mcR8VkgD5O/kn2kynZVnhl6nqJmHZWN1J6+zMGarmggPAe7njPHiaL7u01Qqr9RL0e/TntrqwnKa8R/p8OUJr1d3vz4/Pj0PvqGHh8Fw9eWuo2h8D9OlumN1tXxTqiBnyyymchQH4N5qlnA6WoSRrF0J6EI24/NUlKA4fH2hPJqptpMkTUdqoHDJmRSxjCvK0FNN+ixluRBkLKNyCJ6zF6oJ1WXSnNP1XgXASq3CHimbU55vRJOyA1RolCkiR5FZ7cCSjpLNalCJr4ShMqZpNfZO3+JAqfw96ieG+hchE793Qr0f4lDTM3LKshqrwQlqEADCFMaE+gYJUdPxfBx6drItEMLEbRByPWgQgshCyD0aIM/0jyEBAQE9DIa+/NvrgaEHBMmeIw+CAegOZZteF3RwS84ELZ4jNZ2IiaqbJtNMCDlbaJyJKIeqNqUT3pIb4aYbkcCERIgFEjyeG/kGpdEfD4buxQy8kIfRJk0EhBwfJjAucD2MK0EYvUy3EB+XXAxT+ZMiQzRSwV5SJlx1pagNSKQJyUMWT8IWSJ2jMQoMRr+HPPne3jwHkaHIt+e5OKTBJLLNc14U0PFEm+deWSrvsBUfCjQ8pXZqeHwLHUSORadz8yDtWeSigx6ET+pBsFyv1CAJhWyW2flcaDKZoMjqQrE39oi+VGjRhbAPL8uFoAMNPF9pFsn7ucIpzi3XZJfDBxl8Pi/DFU3O6D5BRO3uMw6IS/QYqkU8BF4cHmzgud9+2sPjaXjwITxE/qhONXnxsXrV9rMHm/4UmydxnLYU3Far8MvhaUktiLCo+wn0OmAYgB4EXbiVDIC4WBlVIdANPkb7PxExIctS4sQRE3TMzMNjb3TNCz49ZEL+uUMm6JjZh1vMVPLB7tlnODPt8Dga/fQ4/ktmopEz4iyX6WVxtHnldP7zNbuXHk/Z3OvU8ZSZkjhLPKU7y/tjrDb4aPHUBbiXmZO4xVMXxAea6YhbPHVBeMx0xMnjqb0Rz3EDrTZ4BhfH00xfbF88OaDT376KckF3G2H1+vJtlKzCIBh+jPZFxlNEe5HrQstK3QYHHu09IYRm9mILpS8pVEHu/4+FHttaWXgnZmFmHkY0zIXukDPMpnKJfMULcaItxF0X3xOT2WmX4tBMR5wl0j2wFP+B5V8bhPwmITHfWQid+OljpiL6YTS7ak+CRPckdAGeZCYlrjlnpHtScH5PMrMOBhqaxV25eRFU+99qKJrc9I1eQjP55pusvCdl8Vn13BYGa9WzKG3K0jrhtW6i9Fyr2XWShbJPcd00NrZQanzEvbFlHtE31FLuhONhPqX8Lf0V7xVM5PVkum0Tn5LlNC3coX55NsrqDE8skQmHKgzX1juepw1R3KnqtbMVcyB9CwjUBio0YQy0Nbrqtj9ih2Z65WaH1Ya/g3ZYGOzNDD9qhsjMIrVqhsqcYN2YKtOym9POdOuGW7PjPabbohlW8eTNDk9lh2a67DjT4fts6t/Y71key0V66maHe+1QFHdf9iia774yg4f/AA==</diagram></mxfile>
|
After Width: | Height: | Size: 97 KiB |
@ -0,0 +1 @@
|
||||
<mxfile host="Electron" modified="2022-12-18T03:08:45.142Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/20.3.0 Chrome/104.0.5112.114 Electron/20.1.3 Safari/537.36" etag="5KgVRO2EoCvSEdzXInGm" version="20.3.0" type="device"><diagram id="WArqh_x3Gwkc2ZFlfPv4" name="Page-1">7Vxdc5s4FP01zOw+JAMS4uPRjp3tzrZNd/LQ7dOObGSbDQYX48Tur18JJBAI2ySBGCdOOwm6ErK45+j66iDQ4M1y+0eMV4svkUcCDejeVoMjDQADIUD/MMsus7jQzAzz2Pd4o8Jw7/8i3Khz68b3yLrUMImiIPFXZeM0CkMyTUo2HMfRU7nZLArKn7rCc6IY7qc4UK3ffS9ZZFYH2IX9E/HnC/HJhuVmNUssGvMrWS+wFz1JJjjW4E0cRUl2tNzekIA5T/glO+92T20+sJiESZMTfv5aPPl/TR7n/66mzv1/Xx6/bu+uLD64Rxxs+BXz0SY74YI42oQeYb3oGhw+LfyE3K/wlNU+UdCpbZEsA1oy6GGAJyQY4unDPD3tJgqimFaFUUjbD9cPJJkueE/rJI4ecq+yk2dRmHAKGBYr+0FQ7SE9qWLk10DihGz3esfIfU7JSqIlSeIdbZIzlXuC89TkxacCdCRsCwlwSxAVc6LN864LLOgBh+M50BgKNN/iaLt7HT6Si4EuyrwvJCNkVPyvAegh4nimAgKtccAEWgIx0R3eJBE1MVh8OqEGgT8PqTmJ2JAwL00pPiRuB0Mg5h7HEECggAj1GhDtzjAECoYrHNH/VxSeznA0juBIDIqkXYeja9kQ78GxjUnmlgGCDlQAMkANQGZnAMELQBJAEPUOIFMB6Dr9+YDoIL136KDj6QMJvQFLxIqvawmHMmhk6yf/sONrxEs/pJrRVi7sRCGkF5KdBJAo/+Ddp4XivLQkTswGSjwl/6vAQS8m2sRT0iDMJziek+Tod7oKsJxl1OAnbDEJcOI/lgdcByr/hG+RTy+lmN1uOcdBeoUX2YXys+RUstKRaVaSJVTpKHOE0lHKsfyyX0E7q0+0Oxnr4IV1b8o6u0+ss09GO/NCuzelnaPQboQTPMFrmqHe3g3v6e97gmOaroDbGzxddJi4HlshzmbEmk7rUiPPdie6fvIVom6WSQHUDMqEhkpKt7MMylXQvf/7s4LgeoFX7HC6C3wKZQyP4zjJQP88yQ25KnO3SWg3ea7LFRcF3DYcDsopK3JUXcWqk1W68rdY6kv+TqeQFSTs8lc4LDne+rlh+txwmjF5wOLSfIJ/o73Qz9crf35PnaazGXM1w0s/2GWnLKMwWmdA5fWZ11mtvtpmdurm5IrTfpAOA8dJWiWGQY/m2V9U1VwRdQKzpoJiXhJOQalbqGXEjtkaATE3IOrLY22NvK3A/UXdgKKbzPd5Tcp3UZe5Pq/LeM+KBfNpSeY+q0zZz+wp/5nFSIvSHJCMyjwo6lJU0iLKytl8KBpIV5HNiyZ+yqtyFxUzBbG5UnhJ8qm+K+zIluzZ3MnrLKmKz6HaOjqXcvtc+vwqgGkxR1E2lrnF2ykkzKYSnZ3ZbBKMfScRDRp6zyKaqhPXZwFn63EX9MzjqqorEjB9HM7TiPJOfG8KdvXG96pgu0cPPFeXI9Q3l6sSrOLs56x7X6icFOtl0HzBrLW47uXrsOPrXlCP74nWvdUblC9e91YJ1vG6125ZW3417XrOOnhhXRusa1lafjXr7J7TzrzQrg3aqdryV5pIbhXuPUvKa13NcZySl4DIhCW03Rq0YWepiaqNfhq0sEumrHFKAqjeghehiDG98aKqQbZxj32vE40WnGhaPXOiyNIPfXGIJclmGQymCRMUc+37M9s39y1a+4kfMdV7EiVJtNwrjktujrKVyU2+AVJXvoXyrYesMA/wei0qFIi48N9WwIBlvd1SlzLwLZcyjqqVXECiX34lkOxTg6TKKxeQACqDVCMKvC1Iqg5zAamqVJ483DVQbj4cSKZeBunk4a6BzvHxQDLKIJ083DWQBT4cSMgs5+AnD3cNNmh9PJBQGaSThzt1yX4BCYmN1H0Jd6oisBck6tSHQxJovbuOq5QHNUVD7OZ7pYAIxIN83PGGaZe7aCogAhce7miPgDiIY7yTmq1Yg/X+AUO9/nP2jss+2J4eZCNoVc10n6GFnDV9oGMdRr2x/iyek+2YPqZV/zl7xwUPtu+IPs9Qac6aPgi2FH2sPVGhbfpYxvOiD3JOEX0a6Ee0G3+1JsdFbLxeZdnCzN8yUvUlYwCoGnn4Wr9EU01JGTp7XNltIAidvddNw+yZ15vszTl3ryOrynV0Yq9ftqZILyg4ukfA7dXWFOX5nRfvEag+UdTxHgG3ToM68txC5VEDw+LPGlQfKPDv2GNEg9CLI7Zpv9kWbsaidD1eCSPVB3eqS/Ol73msj2FM6NDwhN9Zh0OeftDO0VBDo0PRg7/vhZ+s5W9ZkYl8YO7ujTX6tY7cyq3l19FQNIlmszXphhgtP5h4rhs0G8cjcIlHbdCuTslrKR59J5P3HYXsI1HIMPXy2vAKtsK+q8oZHUalBhriR9hJ2Tgq9Won5dlGpVyb6SIs/cliSYjZIAbe0g/fd4xyj8UoB5h9z40MvYGYmD3ZU/NCurrdjMz9Hl4v0sjU0grXcN3r8h0gKO73yE+m172ArrNFriH2SfTcc+WvSbPm/uZb+62BEtYDv1UZB/TTe65GzRrbGv1mHDja2NIcRxvaii/78X5K9vYLxP7lZ0o1Vvqjqe8ZY2WpXfbTGsIlfI2am8ri6U4ZXhHTO4C3RjYbI8251ZwRO6ApiGtoY1MbDrUBTJHXNXGHrY+AN3khZsv73pVXKBonR7VGlhq7mgPTSWtrw5E2THEejDV3nMI71hw1R+oNqk3e79c6quVYnGffp0O1RlOiEZiOc6inoXjE8GSojjTXSacxYID3FtXZbAb2vJrImljoTVC11btFLaGq8ZdzSLlz8VoOOP4f</diagram></mxfile>
|
After Width: | Height: | Size: 153 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
@ -0,0 +1,66 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/conf"
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/pkg/json"
|
||||
"gopkg.in/resty.v1"
|
||||
)
|
||||
|
||||
var (
|
||||
_ core.PhoneVerifyService = (*juheSmsServant)(nil)
|
||||
)
|
||||
|
||||
type juhePhoneCaptchaRsp struct {
|
||||
ErrorCode int `json:"error_code"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
type juheSmsServant struct {
|
||||
gateway string
|
||||
key string
|
||||
tplID string
|
||||
tplVal string
|
||||
}
|
||||
|
||||
// SendPhoneCaptcha 发送短信验证码
|
||||
func (s *juheSmsServant) SendPhoneCaptcha(phone string, captcha string, expire time.Duration) error {
|
||||
client := resty.New()
|
||||
client.DisableWarn = true
|
||||
resp, err := client.R().
|
||||
SetFormData(map[string]string{
|
||||
"mobile": phone,
|
||||
"tpl_id": s.tplID,
|
||||
"tpl_value": fmt.Sprintf(s.tplVal, captcha, expire),
|
||||
"key": s.key,
|
||||
}).Post(s.gateway)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.StatusCode() != http.StatusOK {
|
||||
return errors.New(resp.Status())
|
||||
}
|
||||
|
||||
result := &juhePhoneCaptchaRsp{}
|
||||
if err = json.Unmarshal(resp.Body(), result); err != nil {
|
||||
return err
|
||||
}
|
||||
if result.ErrorCode != 0 {
|
||||
return errors.New(result.Reason)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func newJuheSmsServant() *juheSmsServant {
|
||||
return &juheSmsServant{
|
||||
gateway: conf.SmsJuheSetting.Gateway,
|
||||
key: conf.SmsJuheSetting.Key,
|
||||
tplID: conf.SmsJuheSetting.TplID,
|
||||
tplVal: conf.SmsJuheSetting.TplVal,
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/alimy/cfg"
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
)
|
||||
|
||||
func NewPhoneVerifyService() core.PhoneVerifyService {
|
||||
smsVendor, _ := cfg.Val("sms")
|
||||
switch strings.ToLower(smsVendor) {
|
||||
case "smsjuhe":
|
||||
return newJuheSmsServant()
|
||||
default:
|
||||
return newJuheSmsServant()
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
### Mirc for paopao-ce
|
||||
RESTful API for paopao-ce use [go-mir](https://github.com/alimy/mir) to generate service interface code automatic.
|
@ -1,184 +0,0 @@
|
||||
// Code generated by go-mir. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/alimy/mir/v3"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type LoginReq struct {
|
||||
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 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 {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
Logout() mir.Error
|
||||
Login(*LoginReq) (*LoginResp, mir.Error)
|
||||
Articles() mir.Error
|
||||
Index() mir.Error
|
||||
|
||||
mustEmbedUnimplementedWebCoreServant()
|
||||
}
|
||||
|
||||
type WebCoreBinding interface {
|
||||
BindLogin(*gin.Context) (*LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebCoreBinding()
|
||||
}
|
||||
|
||||
type WebCoreRender interface {
|
||||
RenderLogout(*gin.Context, mir.Error)
|
||||
RenderLogin(*gin.Context, *LoginResp, mir.Error)
|
||||
RenderArticles(*gin.Context, mir.Error)
|
||||
RenderIndex(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedWebCoreRender()
|
||||
}
|
||||
|
||||
// RegisterWebCoreServant register WebCore servant to gin
|
||||
func RegisterWebCoreServant(e *gin.Engine, s WebCore, b WebCoreBinding, r WebCoreRender) {
|
||||
router := e.Group("v1")
|
||||
// use chain for router
|
||||
middlewares := s.Chain()
|
||||
router.Use(middlewares...)
|
||||
|
||||
// register routes info to router
|
||||
router.Handle("POST", "/user/logout/", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderLogout(c, s.Logout())
|
||||
})
|
||||
|
||||
router.Handle("POST", "/user/login/", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
req, err := b.BindLogin(c)
|
||||
if err != nil {
|
||||
r.RenderLogin(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.Login(req)
|
||||
r.RenderLogin(c, resp, err)
|
||||
})
|
||||
|
||||
{
|
||||
h := func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderArticles(c, s.Articles())
|
||||
}
|
||||
router.Handle("HEAD", "/articles/:category/", h)
|
||||
router.Handle("GET", "/articles/:category/", h)
|
||||
}
|
||||
|
||||
router.Handle("GET", "/index/", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderIndex(c, s.Index())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedWebCoreServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebCoreServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedWebCoreServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedWebCoreServant) Logout() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebCoreServant) Login(req *LoginReq) (*LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebCoreServant) Articles() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebCoreServant) Index() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedWebCoreServant) mustEmbedUnimplementedWebCoreServant() {}
|
||||
|
||||
// UnimplementedWebCoreRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebCoreRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebCoreRender) RenderLogout(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebCoreRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebCoreRender) RenderArticles(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebCoreRender) RenderIndex(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedWebCoreRender) mustEmbedUnimplementedWebCoreRender() {}
|
||||
|
||||
// UnimplementedWebCoreBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedWebCoreBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebCoreBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
||||
obj := new(LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedWebCoreBinding) mustEmbedUnimplementedWebCoreBinding() {}
|
@ -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"`
|
||||
}
|
@ -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,44 +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 {
|
||||
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"`
|
||||
}
|
@ -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,11 @@
|
||||
// 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 ChangeUserStatusReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" form:"id" binding:"required"`
|
||||
Status int `json:"status" form:"status" binding:"required,oneof=1 2"`
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
// 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 (
|
||||
"context"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/servants/base"
|
||||
"github.com/smartwalle/alipay/v3"
|
||||
)
|
||||
|
||||
type UserWalletBillsReq struct {
|
||||
UserId int64
|
||||
Page int
|
||||
PageSize int
|
||||
}
|
||||
|
||||
type UserWalletBillsResp base.PageResp
|
||||
|
||||
type UserRechargeLinkReq struct {
|
||||
BaseInfo `json:"-" form:"-" binding:"-"`
|
||||
Host string `json:"-" form:"-" binding:"-"`
|
||||
Amount int64 `json:"amount" form:"amount" binding:"required"`
|
||||
}
|
||||
|
||||
type UserRechargeLinkResp struct {
|
||||
Id int64 `json:"id"`
|
||||
Pay string `json:"pay"`
|
||||
}
|
||||
|
||||
type UserRechargeResultReq struct {
|
||||
UserId int64
|
||||
Id int64
|
||||
}
|
||||
|
||||
type UserRechargeResultResp struct {
|
||||
Id int64 `json:"id"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type AlipayNotifyReq struct {
|
||||
Ctx context.Context
|
||||
ID int64
|
||||
TradeNo string
|
||||
TradeStatus alipay.TradeStatus
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
// 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/servants/base"
|
||||
)
|
||||
|
||||
type ChangeAvatarReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Avatar string `json:"avatar" form:"avatar" binding:"required"`
|
||||
}
|
||||
|
||||
type SyncSearchIndexReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type UserInfoReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Username string `json:"username" form:"username" binding:"required"`
|
||||
}
|
||||
|
||||
type UserInfoResp struct {
|
||||
Id int64 `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
Username string `json:"username"`
|
||||
Status int `json:"status"`
|
||||
Avatar string `json:"avatar"`
|
||||
Balance int64 `json:"balance"`
|
||||
Phone string `json:"phone"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
}
|
||||
|
||||
type GetUnreadMsgCountReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type GetUnreadMsgCountResp struct {
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
|
||||
type GetMessagesReq BasePageReq
|
||||
|
||||
type GetMessagesResp base.PageResp
|
||||
|
||||
type ReadMessageReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
type SendWhisperReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
UserID int64 `json:"user_id" binding:"required"`
|
||||
Content string `json:"content" binding:"required"`
|
||||
}
|
||||
|
||||
type GetCollectionsReq BasePageReq
|
||||
type GetCollectionsResp base.PageResp
|
||||
|
||||
type GetStarsReq BasePageReq
|
||||
type GetStarsResp base.PageResp
|
||||
|
||||
type UserPhoneBindReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Phone string `json:"phone" form:"phone" binding:"required"`
|
||||
Captcha string `json:"captcha" form:"captcha" binding:"required"`
|
||||
}
|
||||
|
||||
type ChangePasswordReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Password string `json:"password" form:"password" binding:"required"`
|
||||
OldPassword string `json:"old_password" form:"old_password" binding:"required"`
|
||||
}
|
||||
|
||||
type ChangeNicknameReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Nickname string `json:"nickname" form:"nickname" binding:"required"`
|
||||
}
|
||||
|
||||
type SuggestUsersReq struct {
|
||||
Keyword string
|
||||
}
|
||||
|
||||
type SuggestUsersResp struct {
|
||||
Suggests []string `json:"suggests"`
|
||||
}
|
||||
|
||||
type SuggestTagsReq struct {
|
||||
Keyword string
|
||||
}
|
||||
|
||||
type SuggestTagsResp struct {
|
||||
Suggests []string `json:"suggests"`
|
||||
}
|
||||
|
||||
type TweetStarStatusReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
TweetId int64 `form:"id"`
|
||||
}
|
||||
|
||||
type TweetStarStatusResp struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
type TweetCollectionStatusReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
TweetId int64 `form:"id"`
|
||||
}
|
||||
|
||||
type TweetCollectionStatusResp struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// 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/servants/base"
|
||||
|
||||
type AddFollowingReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type DeleteFollowingReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type ListFollowingsReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type ListFollowingsResp base.PageResp
|
||||
|
||||
type ListFollowersReq struct {
|
||||
BaseInfo `form:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type ListFollowersResp base.PageResp
|
@ -0,0 +1,40 @@
|
||||
// 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/servants/base"
|
||||
|
||||
type RequestingFriendReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
UserId int64 `json:"user_id" binding:"required"`
|
||||
Greetings string `json:"greetings" binding:"required"`
|
||||
}
|
||||
|
||||
type AddFriendReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
UserId int64 `json:"user_id" binding:"required"`
|
||||
}
|
||||
|
||||
type RejectFriendReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
UserId int64 `json:"user_id" binding:"required"`
|
||||
}
|
||||
|
||||
type DeleteFriendReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
UserId int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
type GetContactsReq struct {
|
||||
BaseInfo `form:"-" binding:"-"`
|
||||
Page int `form:"-" binding:"-"`
|
||||
PageSize int `form:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type GetContactsResp base.PageResp
|
||||
|
||||
func (r *GetContactsReq) SetPageInfo(page int, pageSize int) {
|
||||
r.Page, r.PageSize = page, pageSize
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
// 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"
|
||||
"github.com/rocboss/paopao-ce/internal/servants/base"
|
||||
)
|
||||
|
||||
type TimelineReq struct {
|
||||
BaseInfo `form:"-" binding:"-"`
|
||||
Query string `form:"query"`
|
||||
Visibility []core.PostVisibleT `form:"query"`
|
||||
Type string `form:"type"`
|
||||
Page int `form:"-" binding:"-"`
|
||||
PageSize int `form:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type TimelineResp base.PageResp
|
||||
|
||||
type GetUserTweetsReq struct {
|
||||
BaseInfo `form:"-" binding:"-"`
|
||||
Username string `form:"username" binding:"required"`
|
||||
Page int `form:"-" binding:"-"`
|
||||
PageSize int `form:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type GetUserTweetsResp base.PageResp
|
||||
|
||||
type GetUserProfileReq struct {
|
||||
BaseInfo `form:"-" binding:"-"`
|
||||
Username string `form:"username" binding:"required"`
|
||||
}
|
||||
|
||||
type GetUserProfileResp struct {
|
||||
ID int64 `json:"id"`
|
||||
Nickname string `json:"nickname"`
|
||||
Username string `json:"username"`
|
||||
Status int `json:"status"`
|
||||
Avatar string `json:"avatar"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
IsFriend bool `json:"is_friend"`
|
||||
}
|
||||
|
||||
func (r *GetUserTweetsReq) SetPageInfo(page int, pageSize int) {
|
||||
r.Page, r.PageSize = page, pageSize
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
// 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 (
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"strings"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
)
|
||||
|
||||
type PostContentItem struct {
|
||||
Content string `json:"content" binding:"required"`
|
||||
Type core.PostContentT `json:"type" binding:"required"`
|
||||
Sort int64 `json:"sort" binding:"required"`
|
||||
}
|
||||
|
||||
type CreateTweetReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
Contents []*PostContentItem `json:"contents" binding:"required"`
|
||||
Tags []string `json:"tags" binding:"required"`
|
||||
Users []string `json:"users" binding:"required"`
|
||||
AttachmentPrice int64 `json:"attachment_price"`
|
||||
Visibility core.PostVisibleT `json:"visibility"`
|
||||
ClientIP string `json:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type CreateTweetResp core.PostFormated
|
||||
|
||||
type DeleteTweetReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type StarTweetReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type StarTweetResp struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
type CollectionTweetReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type CollectionTweetResp struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
||||
|
||||
type LockTweetReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type LockTweetResp struct {
|
||||
LockStatus int `json:"lock_status"`
|
||||
}
|
||||
|
||||
type StickTweetReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type StickTweetResp struct {
|
||||
StickStatus int `json:"top_status"`
|
||||
}
|
||||
|
||||
type VisiblePostReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
Visibility core.PostVisibleT `json:"visibility" binding:"required"`
|
||||
}
|
||||
|
||||
type VisiblePostResp struct {
|
||||
Visibility core.PostVisibleT `json:"visibility"`
|
||||
}
|
||||
|
||||
type CreateCommentReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
PostID int64 `json:"post_id" binding:"required"`
|
||||
Contents []*PostContentItem `json:"contents" binding:"required"`
|
||||
Users []string `json:"users" binding:"required"`
|
||||
ClientIP string `json:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type CreateCommentResp core.Comment
|
||||
|
||||
type CreateCommentReplyReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
CommentID int64 `json:"comment_id" binding:"required"`
|
||||
Content string `json:"content" binding:"required"`
|
||||
AtUserID int64 `json:"at_user_id"`
|
||||
ClientIP string `json:"-" binding:"-"`
|
||||
}
|
||||
|
||||
type CreateCommentReplyResp core.CommentReply
|
||||
|
||||
type DeleteCommentReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
type DeleteCommentReplyReq struct {
|
||||
BaseInfo `json:"-" binding:"-"`
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type UploadAttachmentReq struct {
|
||||
SimpleInfo `json:"-" binding:"-"`
|
||||
UploadType string
|
||||
ContentType string
|
||||
File multipart.File
|
||||
FileSize int64
|
||||
FileExt string
|
||||
}
|
||||
|
||||
type UploadAttachmentResp struct {
|
||||
UserID int64 `json:"user_id"`
|
||||
FileSize int64 `json:"file_size"`
|
||||
ImgWidth int `json:"img_width"`
|
||||
ImgHeight int `json:"img_height"`
|
||||
Type core.AttachmentType `json:"type"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type DownloadAttachmentPrecheckReq struct {
|
||||
BaseInfo `form:"-" binding:"-"`
|
||||
ContentID int64 `form:"id"`
|
||||
}
|
||||
|
||||
type DownloadAttachmentPrecheckResp struct {
|
||||
Paid bool `json:"paid"`
|
||||
}
|
||||
|
||||
type DownloadAttachmentReq struct {
|
||||
BaseInfo `form:"-" binding:"-"`
|
||||
ContentID int64 `form:"id"`
|
||||
}
|
||||
|
||||
type DownloadAttachmentResp struct {
|
||||
SignedURL string `json:"signed_url"`
|
||||
}
|
||||
|
||||
// Check 检查PostContentItem属性
|
||||
func (p *PostContentItem) Check(acs core.AttachmentCheckService) error {
|
||||
// 检查附件是否是本站资源
|
||||
if p.Type == core.ContentTypeImage || p.Type == core.ContentTypeVideo || p.Type == core.ContentTypeAttachment {
|
||||
if err := acs.CheckAttachment(p.Content); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 检查链接是否合法
|
||||
if p.Type == core.ContentTypeLink {
|
||||
if strings.Index(p.Content, "http://") != 0 && strings.Index(p.Content, "https://") != 0 {
|
||||
return fmt.Errorf("链接不合法")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
// 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"
|
||||
"github.com/rocboss/paopao-ce/internal/servants/base"
|
||||
"github.com/rocboss/paopao-ce/pkg/debug"
|
||||
)
|
||||
|
||||
const (
|
||||
TagTypeHot TagType = "hot"
|
||||
TagTypeNew TagType = "new"
|
||||
)
|
||||
|
||||
type TagType string
|
||||
|
||||
type TweetDetailReq struct {
|
||||
TweetId int64 `form:"id"`
|
||||
}
|
||||
|
||||
type TweetDetailResp core.PostFormated
|
||||
|
||||
type TweetCommentsReq struct {
|
||||
TweetId int64 `form:"id"`
|
||||
Page int `form:"-"`
|
||||
PageSize int `form:"-"`
|
||||
}
|
||||
|
||||
type TweetCommentsResp base.PageResp
|
||||
|
||||
type TopicListReq struct {
|
||||
Type TagType `json:"type" form:"type" binding:"required"`
|
||||
Num int `json:"num" form:"num" binding:"required"`
|
||||
}
|
||||
|
||||
// TopicListResp 主题返回值
|
||||
// TODO: 优化内容定义
|
||||
type TopicListResp struct {
|
||||
Topics []*core.TagFormated `json:"topics"`
|
||||
}
|
||||
|
||||
type GetCaptchaResp struct {
|
||||
Id string `json:"id"`
|
||||
Content string `json:"b64s"`
|
||||
}
|
||||
|
||||
type SendCaptchaReq struct {
|
||||
Phone string `json:"phone" form:"phone" binding:"required"`
|
||||
ImgCaptcha string `json:"img_captcha" form:"img_captcha" binding:"required"`
|
||||
ImgCaptchaID string `json:"img_captcha_id" form:"img_captcha_id" binding:"required"`
|
||||
}
|
||||
|
||||
type VersionResp struct {
|
||||
BuildInfo *debug.BuildInfo `json:"build_info"`
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
Username string `json:"username" form:"username" binding:"required"`
|
||||
Password string `json:"password" form:"password" binding:"required"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type RegisterReq struct {
|
||||
Username string `json:"username" form:"username" binding:"required"`
|
||||
Password string `json:"password" form:"password" binding:"required"`
|
||||
}
|
||||
|
||||
type RegisterResp struct {
|
||||
UserId int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
// 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/alimy/mir/v3"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
"github.com/rocboss/paopao-ce/internal/servants/base"
|
||||
"github.com/rocboss/paopao-ce/pkg/app"
|
||||
"github.com/rocboss/paopao-ce/pkg/xerror"
|
||||
)
|
||||
|
||||
type BaseInfo struct {
|
||||
User *core.User
|
||||
}
|
||||
|
||||
type SimpleInfo struct {
|
||||
Uid int64
|
||||
}
|
||||
|
||||
type BasePageReq struct {
|
||||
UserId int64
|
||||
Page int
|
||||
PageSize int
|
||||
}
|
||||
|
||||
func (b *BaseInfo) SetUser(user *core.User) {
|
||||
b.User = user
|
||||
}
|
||||
|
||||
func (s *SimpleInfo) SetUserId(id int64) {
|
||||
s.Uid = id
|
||||
}
|
||||
|
||||
func BasePageReqFrom(c *gin.Context) (*BasePageReq, mir.Error) {
|
||||
uid, ok := base.UserIdFrom(c)
|
||||
if !ok {
|
||||
return nil, xerror.UnauthorizedTokenError
|
||||
}
|
||||
page, pageSize := app.GetPageInfo(c)
|
||||
return &BasePageReq{
|
||||
UserId: uid,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
}, nil
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
### OBS(Object Blob Storage System)
|
||||
简单对象存储模块,目前还没实现,先占个位置~
|
@ -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 obs
|
@ -1,10 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package paopao;
|
||||
|
||||
option go_package = "proto";
|
||||
|
||||
message Tag {
|
||||
string name = 1;
|
||||
int32 type = 2;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// 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 base
|
||||
|
||||
type Pager struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
TotalRows int64 `json:"total_rows"`
|
||||
}
|
||||
|
||||
type PageResp struct {
|
||||
List any `json:"list"`
|
||||
Pager Pager `json:"pager"`
|
||||
}
|
||||
|
||||
func PageRespFrom(list any, page int, pageSize int, totalRows int64) *PageResp {
|
||||
return &PageResp{
|
||||
List: list,
|
||||
Pager: Pager{
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
TotalRows: totalRows,
|
||||
},
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
// 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 localoss
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/pkg/xerror"
|
||||
)
|
||||
|
||||
var (
|
||||
errFileUploadFailed = xerror.NewError(10200, "文件上传失败")
|
||||
errFileInvalidExt = xerror.NewError(10201, "文件类型不合法")
|
||||
errFileInvalidSize = xerror.NewError(10202, "文件大小超限")
|
||||
)
|
@ -0,0 +1,21 @@
|
||||
// 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 mobile
|
||||
|
||||
import (
|
||||
api "github.com/rocboss/paopao-ce/auto/rpc/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
_ api.AuthenticateServer = (*authenticateServant)(nil)
|
||||
)
|
||||
|
||||
type authenticateServant struct {
|
||||
api.UnimplementedAuthenticateServer
|
||||
}
|
||||
|
||||
func newAuthenticateServer() *authenticateServant {
|
||||
return &authenticateServant{}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// 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 mobile
|
||||
|
||||
import (
|
||||
api "github.com/rocboss/paopao-ce/auto/rpc/v1"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func RegisterServants(s *grpc.Server) {
|
||||
api.RegisterAuthenticateServer(s, newAuthenticateServer())
|
||||
}
|