mirror of https://github.com/rocboss/paopao-ce
commit
e0d0e254c6
@ -0,0 +1,140 @@
|
||||
// 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 User interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
Logout() mir.Error
|
||||
Login(*LoginReq) (*LoginResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserServant()
|
||||
}
|
||||
|
||||
type UserBinding interface {
|
||||
BindLogin(*gin.Context) (*LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserBinding()
|
||||
}
|
||||
|
||||
type UserRender interface {
|
||||
RenderLogout(*gin.Context, mir.Error)
|
||||
RenderLogin(*gin.Context, *LoginResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserRender()
|
||||
}
|
||||
|
||||
// RegisterUserServant register User servant to gin
|
||||
func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) {
|
||||
router := e.Group("m/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)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedUserServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Logout() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) mustEmbedUnimplementedUserServant() {}
|
||||
|
||||
// UnimplementedUserRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogout(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) mustEmbedUnimplementedUserRender() {}
|
||||
|
||||
// UnimplementedUserBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
||||
obj := new(LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) mustEmbedUnimplementedUserBinding() {}
|
@ -0,0 +1,140 @@
|
||||
// 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 User interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
Logout() mir.Error
|
||||
Login(*LoginReq) (*LoginResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserServant()
|
||||
}
|
||||
|
||||
type UserBinding interface {
|
||||
BindLogin(*gin.Context) (*LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserBinding()
|
||||
}
|
||||
|
||||
type UserRender interface {
|
||||
RenderLogout(*gin.Context, mir.Error)
|
||||
RenderLogin(*gin.Context, *LoginResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserRender()
|
||||
}
|
||||
|
||||
// RegisterUserServant register User servant to gin
|
||||
func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) {
|
||||
router := e.Group("r/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)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedUserServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Logout() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) mustEmbedUnimplementedUserServant() {}
|
||||
|
||||
// UnimplementedUserRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogout(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) mustEmbedUnimplementedUserRender() {}
|
||||
|
||||
// UnimplementedUserBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
||||
obj := new(LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) mustEmbedUnimplementedUserBinding() {}
|
@ -0,0 +1,150 @@
|
||||
// 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 User interface {
|
||||
Logout() mir.Error
|
||||
Login(*LoginReq) (*LoginResp, mir.Error)
|
||||
Index() mir.Error
|
||||
|
||||
mustEmbedUnimplementedUserServant()
|
||||
}
|
||||
|
||||
type UserBinding interface {
|
||||
BindLogin(*gin.Context) (*LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserBinding()
|
||||
}
|
||||
|
||||
type UserRender interface {
|
||||
RenderLogout(*gin.Context, mir.Error)
|
||||
RenderLogin(*gin.Context, *LoginResp, mir.Error)
|
||||
RenderIndex(*gin.Context, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserRender()
|
||||
}
|
||||
|
||||
// RegisterUserServant register User servant to gin
|
||||
func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) {
|
||||
router := e.Group("s/v1")
|
||||
|
||||
// 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)
|
||||
})
|
||||
|
||||
router.Handle("GET", "/index/", func(c *gin.Context) {
|
||||
select {
|
||||
case <-c.Request.Context().Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
r.RenderIndex(c, s.Index())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedUserServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Logout() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Index() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) mustEmbedUnimplementedUserServant() {}
|
||||
|
||||
// UnimplementedUserRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogout(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderIndex(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) mustEmbedUnimplementedUserRender() {}
|
||||
|
||||
// UnimplementedUserBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
||||
obj := new(LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) mustEmbedUnimplementedUserBinding() {}
|
@ -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)
|
||||
VisibleTweet(*web.VisibleTweetReq) (*web.VisibleTweetResp, 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)
|
||||
BindVisibleTweet(*gin.Context) (*web.VisibleTweetReq, 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)
|
||||
RenderVisibleTweet(*gin.Context, *web.VisibleTweetResp, 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.BindVisibleTweet(c)
|
||||
if err != nil {
|
||||
r.RenderVisibleTweet(c, nil, err)
|
||||
return
|
||||
}
|
||||
resp, err := s.VisibleTweet(req)
|
||||
r.RenderVisibleTweet(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) VisibleTweet(req *web.VisibleTweetReq) (*web.VisibleTweetResp, 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) RenderVisibleTweet(c *gin.Context, data *web.VisibleTweetResp, 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) BindVisibleTweet(c *gin.Context) (*web.VisibleTweetReq, mir.Error) {
|
||||
obj := new(web.VisibleTweetReq)
|
||||
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,140 @@
|
||||
// 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 User interface {
|
||||
// Chain provide handlers chain for gin
|
||||
Chain() gin.HandlersChain
|
||||
|
||||
Logout() mir.Error
|
||||
Login(*LoginReq) (*LoginResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserServant()
|
||||
}
|
||||
|
||||
type UserBinding interface {
|
||||
BindLogin(*gin.Context) (*LoginReq, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserBinding()
|
||||
}
|
||||
|
||||
type UserRender interface {
|
||||
RenderLogout(*gin.Context, mir.Error)
|
||||
RenderLogin(*gin.Context, *LoginResp, mir.Error)
|
||||
|
||||
mustEmbedUnimplementedUserRender()
|
||||
}
|
||||
|
||||
// RegisterUserServant register User servant to gin
|
||||
func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) {
|
||||
router := e.Group("x/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)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// UnimplementedUserServant can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserServant struct {
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Chain() gin.HandlersChain {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Logout() mir.Error {
|
||||
return mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) Login(req *LoginReq) (*LoginResp, mir.Error) {
|
||||
return nil, mir.Errorln(http.StatusNotImplemented, http.StatusText(http.StatusNotImplemented))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServant) mustEmbedUnimplementedUserServant() {}
|
||||
|
||||
// UnimplementedUserRender can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserRender struct {
|
||||
RenderAny func(*gin.Context, any, mir.Error)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogout(c *gin.Context, err mir.Error) {
|
||||
r.RenderAny(c, nil, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) RenderLogin(c *gin.Context, data *LoginResp, err mir.Error) {
|
||||
r.RenderAny(c, data, err)
|
||||
}
|
||||
|
||||
func (r *UnimplementedUserRender) mustEmbedUnimplementedUserRender() {}
|
||||
|
||||
// UnimplementedUserBinding can be embedded to have forward compatible implementations.
|
||||
type UnimplementedUserBinding struct {
|
||||
BindAny func(*gin.Context, any) mir.Error
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) BindLogin(c *gin.Context) (*LoginReq, mir.Error) {
|
||||
obj := new(LoginReq)
|
||||
err := b.BindAny(c, obj)
|
||||
return obj, err
|
||||
}
|
||||
|
||||
func (b *UnimplementedUserBinding) mustEmbedUnimplementedUserBinding() {}
|
@ -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,24 +1,36 @@
|
||||
// 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 core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
)
|
||||
|
||||
type (
|
||||
Comment = dbr.Comment
|
||||
CommentFormated = dbr.CommentFormated
|
||||
CommentReply = dbr.CommentReply
|
||||
CommentContent = dbr.CommentContent
|
||||
CommentReplyFormated = dbr.CommentReplyFormated
|
||||
)
|
||||
|
||||
// CommentService 评论检索服务
|
||||
type CommentService interface {
|
||||
GetComments(conditions *model.ConditionsT, offset, limit int) ([]*model.Comment, error)
|
||||
GetCommentByID(id int64) (*model.Comment, error)
|
||||
GetCommentCount(conditions *model.ConditionsT) (int64, error)
|
||||
GetCommentReplyByID(id int64) (*model.CommentReply, error)
|
||||
GetCommentContentsByIDs(ids []int64) ([]*model.CommentContent, error)
|
||||
GetCommentRepliesByID(ids []int64) ([]*model.CommentReplyFormated, error)
|
||||
GetComments(conditions *ConditionsT, offset, limit int) ([]*Comment, error)
|
||||
GetCommentByID(id int64) (*Comment, error)
|
||||
GetCommentCount(conditions *ConditionsT) (int64, error)
|
||||
GetCommentReplyByID(id int64) (*CommentReply, error)
|
||||
GetCommentContentsByIDs(ids []int64) ([]*CommentContent, error)
|
||||
GetCommentRepliesByID(ids []int64) ([]*CommentReplyFormated, error)
|
||||
}
|
||||
|
||||
// CommentManageService 评论管理服务
|
||||
type CommentManageService interface {
|
||||
DeleteComment(comment *model.Comment) error
|
||||
CreateComment(comment *model.Comment) (*model.Comment, error)
|
||||
CreateCommentReply(reply *model.CommentReply) (*model.CommentReply, error)
|
||||
DeleteCommentReply(reply *model.CommentReply) error
|
||||
CreateCommentContent(content *model.CommentContent) (*model.CommentContent, error)
|
||||
DeleteComment(comment *Comment) error
|
||||
CreateComment(comment *Comment) (*Comment, error)
|
||||
CreateCommentReply(reply *CommentReply) (*CommentReply, error)
|
||||
DeleteCommentReply(reply *CommentReply) error
|
||||
CreateCommentContent(content *CommentContent) (*CommentContent, error)
|
||||
}
|
||||
|
@ -1,15 +1,36 @@
|
||||
// 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 core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
)
|
||||
|
||||
const (
|
||||
MsgTypePost = dbr.MsgTypePost
|
||||
MsgtypeComment = dbr.MsgtypeComment
|
||||
MsgTypeReply = dbr.MsgTypeReply
|
||||
MsgTypeWhisper = dbr.MsgTypeWhisper
|
||||
MsgTypeRequestingFriend = dbr.MsgTypeRequestingFriend
|
||||
MsgTypeSystem = dbr.MsgTypeSystem
|
||||
|
||||
MsgStatusUnread = dbr.MsgStatusUnread
|
||||
MsgStatusReaded = dbr.MsgStatusReaded
|
||||
)
|
||||
|
||||
type (
|
||||
Message = dbr.Message
|
||||
MessageFormated = dbr.MessageFormated
|
||||
)
|
||||
|
||||
// MessageService 消息服务
|
||||
type MessageService interface {
|
||||
CreateMessage(msg *model.Message) (*model.Message, error)
|
||||
CreateMessage(msg *Message) (*Message, error)
|
||||
GetUnreadCount(userID int64) (int64, error)
|
||||
GetMessageByID(id int64) (*model.Message, error)
|
||||
ReadMessage(message *model.Message) error
|
||||
GetMessages(conditions *model.ConditionsT, offset, limit int) ([]*model.MessageFormated, error)
|
||||
GetMessageCount(conditions *model.ConditionsT) (int64, error)
|
||||
GetMessageByID(id int64) (*Message, error)
|
||||
ReadMessage(message *Message) error
|
||||
GetMessages(conditions *ConditionsT, offset, limit int) ([]*MessageFormated, error)
|
||||
GetMessageCount(conditions *ConditionsT) (int64, error)
|
||||
}
|
||||
|
@ -1,13 +1,22 @@
|
||||
// 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 core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
)
|
||||
|
||||
type (
|
||||
Tag = dbr.Tag
|
||||
TagFormated = dbr.TagFormated
|
||||
)
|
||||
|
||||
// TopicService 话题服务
|
||||
type TopicService interface {
|
||||
CreateTag(tag *model.Tag) (*model.Tag, error)
|
||||
DeleteTag(tag *model.Tag) error
|
||||
GetTags(conditions *model.ConditionsT, offset, limit int) ([]*model.Tag, error)
|
||||
GetTagsByKeyword(keyword string) ([]*model.Tag, error)
|
||||
CreateTag(tag *Tag) (*Tag, error)
|
||||
DeleteTag(tag *Tag) error
|
||||
GetTags(conditions *ConditionsT, offset, limit int) ([]*Tag, error)
|
||||
GetTagsByKeyword(keyword string) ([]*Tag, error)
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
// 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 core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
)
|
||||
|
||||
const (
|
||||
UserStatusNormal = dbr.UserStatusNormal
|
||||
UserStatusClosed = dbr.UserStatusClosed
|
||||
)
|
||||
|
||||
type (
|
||||
User = dbr.User
|
||||
Post = dbr.Post
|
||||
ConditionsT = dbr.ConditionsT
|
||||
PostFormated = dbr.PostFormated
|
||||
UserFormated = dbr.UserFormated
|
||||
PostContentFormated = dbr.PostContentFormated
|
||||
Model = dbr.Model
|
||||
)
|
@ -1,15 +1,24 @@
|
||||
// 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 core
|
||||
|
||||
import (
|
||||
"github.com/rocboss/paopao-ce/internal/model"
|
||||
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
|
||||
)
|
||||
|
||||
type (
|
||||
WalletStatement = dbr.WalletStatement
|
||||
WalletRecharge = dbr.WalletRecharge
|
||||
)
|
||||
|
||||
// WalletService wallet service interface
|
||||
type WalletService interface {
|
||||
GetUserWalletBills(userID int64, offset, limit int) ([]*model.WalletStatement, error)
|
||||
GetUserWalletBills(userID int64, offset, limit int) ([]*WalletStatement, error)
|
||||
GetUserWalletBillCount(userID int64) (int64, error)
|
||||
GetRechargeByID(id int64) (*model.WalletRecharge, error)
|
||||
CreateRecharge(userId, amount int64) (*model.WalletRecharge, error)
|
||||
HandleRechargeSuccess(recharge *model.WalletRecharge, tradeNo string) error
|
||||
HandlePostAttachmentBought(post *model.Post, user *model.User) error
|
||||
GetRechargeByID(id int64) (*WalletRecharge, error)
|
||||
CreateRecharge(userId, amount int64) (*WalletRecharge, error)
|
||||
HandleRechargeSuccess(recharge *WalletRecharge, tradeNo string) error
|
||||
HandlePostAttachmentBought(post *Post, user *User) error
|
||||
}
|
||||
|
@ -1,13 +1,17 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type AttachmentType int
|
||||
|
||||
const (
|
||||
ATTACHMENT_TYPE_IMAGE AttachmentType = iota + 1
|
||||
ATTACHMENT_TYPE_VIDEO
|
||||
ATTACHMENT_TYPE_OTHER
|
||||
AttachmentTypeImage AttachmentType = iota + 1
|
||||
AttachmentTypeVideo
|
||||
AttachmentTypeOther
|
||||
)
|
||||
|
||||
type Attachment struct {
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import (
|
||||
"time"
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import (
|
||||
"time"
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
@ -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 dbr
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
)
|
||||
|
||||
// Model 公共Model
|
||||
type Model struct {
|
||||
ID int64 `gorm:"primary_key" json:"id"`
|
||||
CreatedOn int64 `json:"created_on"`
|
||||
ModifiedOn int64 `json:"modified_on"`
|
||||
DeletedOn int64 `json:"deleted_on"`
|
||||
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag" json:"is_del"`
|
||||
}
|
||||
|
||||
type ConditionsT map[string]any
|
||||
type Predicates map[string][]any
|
||||
|
||||
func (m *Model) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
nowTime := time.Now().Unix()
|
||||
|
||||
tx.Statement.SetColumn("created_on", nowTime)
|
||||
tx.Statement.SetColumn("modified_on", nowTime)
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Model) BeforeUpdate(tx *gorm.DB) (err error) {
|
||||
if !tx.Statement.Changed("modified_on") {
|
||||
tx.Statement.SetColumn("modified_on", time.Now().Unix())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import (
|
||||
"strings"
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import (
|
||||
"time"
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import (
|
||||
"time"
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import (
|
||||
"time"
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
@ -1,4 +1,8 @@
|
||||
package model
|
||||
// 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 dbr
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue