package com.dora.controller;

import com.dora.common.Result;
import com.dora.entity.PromotionPoster;
import com.dora.service.PromotionPosterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 推广海报控制器
 */
@RestController
@RequestMapping("/user/promotion-poster")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "推广海报管理", description = "推广海报相关接口")
public class PromotionPosterController {

    private final PromotionPosterService promotionPosterService;

    @GetMapping("/list")
    @Operation(summary = "获取推广海报列表", description = "获取所有启用的推广海报列表，无需登录")
    public Result<List<PromotionPoster>> getPromotionPosterList() {
        try {
            log.info("获取推广海报列表");
            List<PromotionPoster> promotionPosters = promotionPosterService.getAllEnabledPromotionPosters();
            return Result.success(promotionPosters, "获取推广海报列表成功");
        } catch (Exception e) {
            log.error("获取推广海报列表失败", e);
            return Result.error(500, "获取推广海报列表失败");
        }
    }
}
