package org.xyzh.news.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xyzh.api.news.recommend.ResourceRecommendService;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.dto.resource.TbResource;
import org.xyzh.common.dto.resource.TbBanner;
import org.xyzh.common.vo.ResourceRecommendVO;

import java.util.Map;

/**
 * @description 首页控制器
 * @filename HomePageController.java
 * @author yslg
 * @copyright xyzh
 * @since 2025-10-15
 */
@RestController
@RequestMapping("/homepage")
public class HomePageController {
    private static final Logger logger = LoggerFactory.getLogger(HomePageController.class);

    @Autowired
    private ResourceRecommendService resourceRecommendService;

    /**
     * 获取热门资源列表
     */
    @GetMapping("/recommend/hot")
    public ResultDomain<ResourceRecommendVO> getHotResources(@RequestParam(required = false, name = "limit") Integer limit) {
        return resourceRecommendService.getRecommendsByType(1, limit); // 1-热门资源
    }


    /**
     * 获取思政资源列表
     */
    @GetMapping("/recommend/ideological")
    public ResultDomain<ResourceRecommendVO> getIdeologicalResources(@RequestParam(required = false, name = "limit") Integer limit) {
        return resourceRecommendService.getRecommendsByType(2, limit); // 2-思政资源
    }
}
