Implement CRUD operations for blog posts with Create, Edit, and Delete handlers
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 52s

This commit is contained in:
2025-10-25 11:34:59 +08:00
parent 166382ffa8
commit b05f797eb1
9 changed files with 371 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
package handler
import (
"net/http"
"git.cialloo.com/CiallooWeb/Blog/app/internal/logic"
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// Edit an existing blog post
func EditPostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.EditPostReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewEditPostLogic(r.Context(), svcCtx)
resp, err := l.EditPost(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}