package cn.reghao.tnb.search.app.comment.controller;

import cn.reghao.jutil.jdk.web.db.PageList;
import cn.reghao.tnb.common.web.WebResult;
import cn.reghao.tnb.search.app.comment.model.vo.NewsPost;
import cn.reghao.tnb.search.app.comment.service.NewsPostService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

/**
 * @author reghao
 * @date 2025-07-29 14:10:28
 */
@Tag(name = "新闻稿件接口")
@RestController
@RequestMapping("/api/search1/post/news")
public class NewsPostController {
    private final NewsPostService newsPostService;

    public NewsPostController(NewsPostService newsPostService) {
        this.newsPostService = newsPostService;
    }

    @Operation(summary = "发布新闻稿件", description = "N")
    @PostMapping("/publish")
    public String publishVideoPost() {
        return WebResult.success();
    }

    @Operation(summary = "获取新闻稿件列表", description = "N")
    @GetMapping("/list")
    public String getNewsPosts(@RequestParam("pn") Integer pn) {
        PageList<NewsPost> pageList = newsPostService.getByPage(pn);
        return WebResult.success(pageList);
    }

    @Operation(summary = "获取新闻稿件", description = "N")
    @GetMapping("/detail/{newsId}")
    public String getNewsPost(@PathVariable("newsId") Long newsId) {
        NewsPost newsPost = newsPostService.getById(newsId);
        return WebResult.success(newsPost);
    }
}
