package com.ruoyi.cms.controller.app;

import com.ruoyi.cms.domain.policy.PolicyInfo;
import com.ruoyi.cms.domain.policy.PolicyInfoQuery;
import com.ruoyi.cms.service.policy.IPolicyInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 政策信息移动端Controller
 * @author kiro
 * @date 2026-01-11
 */
@Slf4j
@RestController
@RequestMapping("/app/policyInfo")
@Api(tags = "移动端接口：政策信息")
public class AppPolicyInfoController extends BaseController {

    @Autowired
    private IPolicyInfoService policyInfoService;

    /**
     * 获取政策列表
     */
    @ApiOperation("获取政策列表")
    @GetMapping("/portalList")
    public TableDataInfo portalList(PolicyInfoQuery query) {
        return policyInfoService.getPortalList(query);
    }

    /**
     * 获取政策详情
     */
    @ApiOperation("获取政策详情")
    @GetMapping("/detail/{id}")
    public AjaxResult detail(@ApiParam("政策ID") @PathVariable Long id) {
        PolicyInfo policyInfo = policyInfoService.getDetail(id);
        return success(policyInfo);
    }

    /**
     * 浏览数加1
     */
    @ApiOperation("浏览数加1")
    @PostMapping("/addViewNum/{id}")
    public AjaxResult addViewNum(@ApiParam("政策ID") @PathVariable Long id) {
        return toAjax(policyInfoService.addViewNum(id));
    }
}
