Files
schisandra-album-cloud-micr…/app/community/api/internal/handler/comment/submit_comment_handler.go
2024-12-24 00:38:41 +08:00

29 lines
870 B
Go

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