feat(ECR-025): OpsCMS FeedSlot 只读并 Closed

栏目位目录(ops_feed_slots + /cms),复用 admin.cms.read。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-08 03:08:40 +08:00
co-authored by Cursor
parent f51b2524c5
commit e32466357d
26 changed files with 661 additions and 4 deletions
+29
View File
@@ -16,6 +16,8 @@ func (h *AdminHandler) registerCMS(authed *gin.RouterGroup) {
g := authed.Group("/cms")
g.GET("/banners", middleware.RequireAdminPermission(h.Svc, admin.PermCMSRead), h.ListBanners)
g.GET("/banners/:id", middleware.RequireAdminPermission(h.Svc, admin.PermCMSRead), h.GetBanner)
g.GET("/feed-slots", middleware.RequireAdminPermission(h.Svc, admin.PermCMSRead), h.ListFeedSlots)
g.GET("/feed-slots/:id", middleware.RequireAdminPermission(h.Svc, admin.PermCMSRead), h.GetFeedSlot)
}
func (h *AdminHandler) ListBanners(c *gin.Context) {
@@ -44,3 +46,30 @@ func (h *AdminHandler) GetBanner(c *gin.Context) {
}
response.OK(c, row)
}
func (h *AdminHandler) ListFeedSlots(c *gin.Context) {
items, err := h.Svc.ListFeedSlots(c.Request.Context())
if err != nil {
response.Fail(c, http.StatusInternalServerError, 50042, "list feed slots failed")
return
}
response.OK(c, gin.H{"items": items})
}
func (h *AdminHandler) GetFeedSlot(c *gin.Context) {
id, err := uuid.Parse(c.Param("id"))
if err != nil {
response.Fail(c, http.StatusBadRequest, 40002, "invalid id")
return
}
row, err := h.Svc.GetFeedSlot(c.Request.Context(), id)
if errors.Is(err, admin.ErrFeedSlotNotFound) {
response.Fail(c, http.StatusNotFound, 40411, "feed slot not found")
return
}
if err != nil {
response.Fail(c, http.StatusInternalServerError, 50043, "get feed slot failed")
return
}
response.OK(c, row)
}