package com.zhentao.controller;

import com.zhentao.common.Result;
import com.zhentao.service.HomeBannerService;
import com.zhentao.vo.HomeBannerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页轮播图控制器
 */
@RestController
@RequestMapping("/api/home")
public class HomeBannerController {
    
    @Autowired
    private HomeBannerService homeBannerService;
    
    /**
     * 获取轮播图列表
     * 
     * @return 轮播图列表
     */
    @GetMapping("/banners")
    public Result<List<HomeBannerVO>> getBanners() {
        try {
            List<HomeBannerVO> banners = homeBannerService.getActiveBanners();
            return Result.success(banners);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("获取轮播图失败：" + e.getMessage());
        }
    }
}


