🏗️ microservice fabric splitting

This commit is contained in:
2024-12-24 00:38:41 +08:00
parent 462e811742
commit 89d64336f5
311 changed files with 18384 additions and 2428 deletions

View File

@@ -0,0 +1,24 @@
package comment
import (
"github.com/zeromicro/go-zero/rest/httpx"
"net/http"
"schisandra-album-cloud-microservices/app/community/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/community/api/internal/svc"
"schisandra-album-cloud-microservices/app/community/api/internal/types"
"schisandra-album-cloud-microservices/common/xhttp"
)
func DislikeCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CommentDisLikeRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := comment.NewDislikeCommentLogic(r.Context(), svcCtx)
err := l.DislikeComment(&req)
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
}
}

View File

@@ -0,0 +1,28 @@
package comment
import (
"github.com/zeromicro/go-zero/rest/httpx"
"net/http"
"schisandra-album-cloud-microservices/app/community/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/community/api/internal/svc"
"schisandra-album-cloud-microservices/app/community/api/internal/types"
"schisandra-album-cloud-microservices/common/xhttp"
)
func GetCommentListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CommentListRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := comment.NewGetCommentListLogic(r.Context(), svcCtx)
resp, err := l.GetCommentList(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,28 @@
package comment
import (
"github.com/zeromicro/go-zero/rest/httpx"
"net/http"
"schisandra-album-cloud-microservices/app/community/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/community/api/internal/svc"
"schisandra-album-cloud-microservices/app/community/api/internal/types"
"schisandra-album-cloud-microservices/common/xhttp"
)
func GetReplyListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ReplyListRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := comment.NewGetReplyListLogic(r.Context(), svcCtx)
resp, err := l.GetReplyList(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,24 @@
package comment
import (
"github.com/zeromicro/go-zero/rest/httpx"
"net/http"
"schisandra-album-cloud-microservices/app/community/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/community/api/internal/svc"
"schisandra-album-cloud-microservices/app/community/api/internal/types"
"schisandra-album-cloud-microservices/common/xhttp"
)
func LikeCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CommentLikeRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := comment.NewLikeCommentLogic(r.Context(), svcCtx)
err := l.LikeComment(&req)
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
}
}

View File

@@ -0,0 +1,28 @@
package comment
import (
"github.com/zeromicro/go-zero/rest/httpx"
"net/http"
"schisandra-album-cloud-microservices/app/community/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/community/api/internal/svc"
"schisandra-album-cloud-microservices/app/community/api/internal/types"
"schisandra-album-cloud-microservices/common/xhttp"
)
func SubmitCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CommentRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := comment.NewSubmitCommentLogic(r.Context(), svcCtx)
resp, err := l.SubmitComment(r, &req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,28 @@
package comment
import (
"github.com/zeromicro/go-zero/rest/httpx"
"net/http"
"schisandra-album-cloud-microservices/app/community/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/community/api/internal/svc"
"schisandra-album-cloud-microservices/app/community/api/internal/types"
"schisandra-album-cloud-microservices/common/xhttp"
)
func SubmitReplyCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ReplyCommentRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := comment.NewSubmitReplyCommentLogic(r.Context(), svcCtx)
resp, err := l.SubmitReplyComment(r, &req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,28 @@
package comment
import (
"github.com/zeromicro/go-zero/rest/httpx"
"net/http"
"schisandra-album-cloud-microservices/app/community/api/internal/logic/comment"
"schisandra-album-cloud-microservices/app/community/api/internal/svc"
"schisandra-album-cloud-microservices/app/community/api/internal/types"
"schisandra-album-cloud-microservices/common/xhttp"
)
func SubmitReplyReplyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ReplyReplyRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := comment.NewSubmitReplyReplyLogic(r.Context(), svcCtx)
resp, err := l.SubmitReplyReply(r, &req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,63 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.7.3
package handler
import (
"net/http"
"time"
comment "schisandra-album-cloud-microservices/app/community/api/internal/handler/comment"
"schisandra-album-cloud-microservices/app/community/api/internal/svc"
"github.com/zeromicro/go-zero/rest"
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.SecurityHeadersMiddleware, serverCtx.CasbinVerifyMiddleware, serverCtx.AuthorizationMiddleware, serverCtx.NonceMiddleware},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/dislike",
Handler: comment.DislikeCommentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/like",
Handler: comment.LikeCommentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/list",
Handler: comment.GetCommentListHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/reply/list",
Handler: comment.GetReplyListHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/reply/reply/submit",
Handler: comment.SubmitReplyReplyHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/reply/submit",
Handler: comment.SubmitReplyCommentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/submit",
Handler: comment.SubmitCommentHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
rest.WithPrefix("/api/auth/comment"),
rest.WithTimeout(10000*time.Millisecond),
rest.WithMaxBytes(1048576),
)
}