package v1 import ( "git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/internal/dto" "git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/internal/middleware" "git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/internal/service" "git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/pkg/app" "git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/pkg/errcode" "github.com/gin-gonic/gin" ) // ContentHandler 内容审核接口(穿搭/衣物/分享)。 type ContentHandler struct { svc *service.ContentService } // NewContentHandler 创建内容审核 handler。 func NewContentHandler() *ContentHandler { return &ContentHandler{svc: service.NewContentService()} } // OutfitList 穿搭列表。 func (h *ContentHandler) OutfitList(c *gin.Context) { response := app.NewResponse(c) var request dto.OutfitListRequest if err := c.ShouldBindQuery(&request); err != nil { response.ToErrorResponse(errcode.InvalidParams.WithDetails(err.Error())) return } out, e := h.svc.OutfitList(c.Request.Context(), &request) if e != nil { response.ToErrorResponse(e) return } response.ToResponse(out) } // OutfitDetail 穿搭详情。 func (h *ContentHandler) OutfitDetail(c *gin.Context) { response := app.NewResponse(c) out, e := h.svc.OutfitDetail(c.Request.Context(), c.Param("uuid")) if e != nil { response.ToErrorResponse(e) return } response.ToResponse(out) } // OutfitAudit 穿搭审核(通过/驳回)。 func (h *ContentHandler) OutfitAudit(c *gin.Context) { response := app.NewResponse(c) var request dto.OutfitAuditRequest if err := c.ShouldBindJSON(&request); err != nil { response.ToErrorResponse(errcode.InvalidParams.WithDetails(err.Error())) return } adminID, _ := middleware.GetAdminID(c.Request.Context()) if e := h.svc.OutfitAudit(c.Request.Context(), adminID, c.Param("uuid"), &request); e != nil { response.ToErrorResponse(e) return } response.ToResponse(nil) } // OutfitBan 封禁穿搭。 func (h *ContentHandler) OutfitBan(c *gin.Context) { response := app.NewResponse(c) var request dto.OutfitBanRequest if err := c.ShouldBindJSON(&request); err != nil { response.ToErrorResponse(errcode.InvalidParams.WithDetails(err.Error())) return } adminID, _ := middleware.GetAdminID(c.Request.Context()) if e := h.svc.OutfitBan(c.Request.Context(), adminID, c.Param("uuid"), &request); e != nil { response.ToErrorResponse(e) return } response.ToResponse(nil) } // OutfitUnban 解封穿搭。 func (h *ContentHandler) OutfitUnban(c *gin.Context) { response := app.NewResponse(c) adminID, _ := middleware.GetAdminID(c.Request.Context()) if e := h.svc.OutfitUnban(c.Request.Context(), adminID, c.Param("uuid")); e != nil { response.ToErrorResponse(e) return } response.ToResponse(nil) } // ClothesList 衣物列表。 func (h *ContentHandler) ClothesList(c *gin.Context) { response := app.NewResponse(c) var request dto.ClothesListRequest if err := c.ShouldBindQuery(&request); err != nil { response.ToErrorResponse(errcode.InvalidParams.WithDetails(err.Error())) return } out, e := h.svc.ClothesList(c.Request.Context(), &request) if e != nil { response.ToErrorResponse(e) return } response.ToResponse(out) } // ClothesDetail 衣物详情。 func (h *ContentHandler) ClothesDetail(c *gin.Context) { response := app.NewResponse(c) out, e := h.svc.ClothesDetail(c.Request.Context(), c.Param("uuid")) if e != nil { response.ToErrorResponse(e) return } response.ToResponse(out) } // ShareList 衣柜分享列表。 func (h *ContentHandler) ShareList(c *gin.Context) { response := app.NewResponse(c) var request dto.ClosetShareListRequest if err := c.ShouldBindQuery(&request); err != nil { response.ToErrorResponse(errcode.InvalidParams.WithDetails(err.Error())) return } out, e := h.svc.ShareList(c.Request.Context(), &request) if e != nil { response.ToErrorResponse(e) return } response.ToResponse(out) } // ShareBan 封禁分享。 func (h *ContentHandler) ShareBan(c *gin.Context) { response := app.NewResponse(c) adminID, _ := middleware.GetAdminID(c.Request.Context()) if e := h.svc.ShareBan(c.Request.Context(), adminID, c.Param("uuid")); e != nil { response.ToErrorResponse(e) return } response.ToResponse(nil) } // ShareUnban 解封分享。 func (h *ContentHandler) ShareUnban(c *gin.Context) { response := app.NewResponse(c) adminID, _ := middleware.GetAdminID(c.Request.Context()) if e := h.svc.ShareUnban(c.Request.Context(), adminID, c.Param("uuid")); e != nil { response.ToErrorResponse(e) return } response.ToResponse(nil) }