package com.zehong.web.controller.supervision;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TPublicSentiment;
import com.zehong.system.domain.vo.ComplainDealSummaryAnalysisTableVo;
import com.zehong.system.service.ITPublicSentimentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 舆情处置Controller
 * 
 * @author zehong
 * @date 2025-08-15
 */
@RestController
@RequestMapping("/system/sentiment")
public class TPublicSentimentController extends BaseController
{
    @Autowired
    private ITPublicSentimentService tPublicSentimentService;

    /**
     * 查询舆情处置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TPublicSentiment tPublicSentiment)
    {
        startPage();
        List<TPublicSentiment> list = tPublicSentimentService.selectTPublicSentimentList(tPublicSentiment);
        return getDataTable(list);
    }

    /**
     * 导出舆情处置列表
     */
    @Log(title = "舆情处置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TPublicSentiment tPublicSentiment)
    {
        List<TPublicSentiment> list = tPublicSentimentService.selectTPublicSentimentList(tPublicSentiment);
        ExcelUtil<TPublicSentiment> util = new ExcelUtil<TPublicSentiment>(TPublicSentiment.class);
        return util.exportExcel(list, "舆情处置数据");
    }

    /**
     * 获取舆情处置详细信息
     */
    @GetMapping(value = "/{sentimentId}")
    public AjaxResult getInfo(@PathVariable("sentimentId") Long sentimentId)
    {
        return AjaxResult.success(tPublicSentimentService.selectTPublicSentimentById(sentimentId));
    }

    /**
     * 新增舆情处置
     */
    @Log(title = "舆情处置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPublicSentiment tPublicSentiment)
    {
        return toAjax(tPublicSentimentService.insertTPublicSentiment(tPublicSentiment));
    }

    /**
     * 修改舆情处置
     */
    @Log(title = "舆情处置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPublicSentiment tPublicSentiment)
    {
        return toAjax(tPublicSentimentService.updateTPublicSentiment(tPublicSentiment));
    }

    /**
     * 删除舆情处置
     */
    @Log(title = "舆情处置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sentimentIds}")
    public AjaxResult remove(@PathVariable Long[] sentimentIds)
    {
        return toAjax(tPublicSentimentService.deleteTPublicSentimentByIds(sentimentIds));
    }

    @GetMapping("/sentimentSummaryAnalysisMethodTableViews")
    public AjaxResult sentimentSummaryAnalysisMethodTableViews(ComplainDealSummaryAnalysisTableVo complainDealSummaryAnalysisTableVo) {
        return AjaxResult.success(tPublicSentimentService.sentimentSummaryAnalysisMethodTableViews(complainDealSummaryAnalysisTableVo));
    }

    /**
     * 导出投诉处置列表
     */
    @Log(title = "投诉处置", businessType = BusinessType.EXPORT)
    @PostMapping("/sentimentSummaryAnalysisExport")
    public void sentimentSummaryAnalysisExport(HttpServletResponse httpServletResponse,
                                                  @RequestBody ComplainDealSummaryAnalysisTableVo complainDealSummaryAnalysisTableVo) throws Exception
    {
        tPublicSentimentService.sentimentSummaryAnalysisExport(httpServletResponse,complainDealSummaryAnalysisTableVo);
    }
}
