package com.test.bijihoudaun.controller; import com.test.bijihoudaun.common.response.R; import com.test.bijihoudaun.service.ImageCleanupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * 图片清理控制器 * 提供手动触发清理冗余图片的API端点 */ @RestController @RequestMapping("/api/admin") public class ImageCleanupController { @Autowired private ImageCleanupService imageCleanupService; /** * 手动触发清理冗余图片 * @return 清理结果 */ @PostMapping("/cleanup-images") @PreAuthorize("hasRole('ADMIN')") public R cleanupImages() { int deletedCount = imageCleanupService.cleanupRedundantImages(); return R.success("成功清理 " + deletedCount + " 个冗余图片"); } }