优化首页公告与轮播图

This commit is contained in:
yml
2026-05-23 01:50:45 +08:00
parent 96d87483b0
commit c9db34ddda
14 changed files with 797 additions and 91 deletions
+12
View File
@@ -48,6 +48,14 @@ func (h *Handler) Upload(c *gin.Context) {
}
func (h *Handler) Object(c *gin.Context) {
h.writeObject(c, false)
}
func (h *Handler) PublicObject(c *gin.Context) {
h.writeObject(c, true)
}
func (h *Handler) writeObject(c *gin.Context, publicOnly bool) {
if h.storage == nil {
response.ServiceUnavailable(c, "文件存储未连接")
return
@@ -57,6 +65,10 @@ func (h *Handler) Object(c *gin.Context) {
response.BadRequest(c, "文件 key 不正确")
return
}
if publicOnly && !strings.HasPrefix(key, "home-banner/") {
response.Error(c, http.StatusNotFound, "not_found", "文件不存在或暂不可访问")
return
}
object, err := h.storage.Get(c.Request.Context(), key)
if err != nil {
response.Error(c, http.StatusNotFound, "not_found", "文件不存在或暂不可访问")