package com.ruoyi.web.controller.sqmy;

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

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.ProposalInfo;
import com.ruoyi.system.domain.sqmy.SqmyInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.ISqmyInfoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社情民意信息Controller
 *
 * @author boman
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/sqmyInfo/info")
public class SqmyInfoController extends BaseController
{
    @Autowired
    private ISqmyInfoService sqmyInfoService;

    /**
     * 查询社情民意信息列表
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(SqmyInfo sqmyInfo)
    {
        startPage();
        List<SqmyInfo> list = sqmyInfoService.selectSqmyInfoList(sqmyInfo);
        return getDataTable(list);
    }

    /**
     * 列表页统计
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:statistics')")
    @GetMapping("/list/statistics")
    public AjaxResult statistics(SqmyInfo sqmyInfo)
    {
        return sqmyInfoService.statistics(sqmyInfo);
    }

    /**
     * 根据单位查询
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:unitList')")
    @GetMapping("/unitList")
    public TableDataInfo unitList(SqmyInfo sqmyInfo)
    {
        startPage();
        List<SqmyInfo> list = sqmyInfoService.unitList(sqmyInfo);
        return getDataTable(list);
    }

    /**
     * 导出社情民意信息列表
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:export')")
    @Log(title = "社情民意信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SqmyInfo sqmyInfo)
    {
        List<SqmyInfo> list = sqmyInfoService.selectSqmyInfoList(sqmyInfo);
        ExcelUtil<SqmyInfo> util = new ExcelUtil<SqmyInfo>(SqmyInfo.class);
        util.exportExcel(response, list, "社情民意信息数据");
    }

    /**
     * 获取社情民意信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:query')")
    @GetMapping(value = "/{sqmyId}")
    public AjaxResult getInfo(@PathVariable("sqmyId") Long sqmyId)
    {
        return success(sqmyInfoService.selectSqmyInfoBySqmyId(sqmyId));
    }

    /**
     * 新增社情民意信息
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:add')")
    @Log(title = "社情民意信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SqmyInfo sqmyInfo)
    {
        return toAjax(sqmyInfoService.insertSqmyInfo(sqmyInfo));
    }

    /**
     * 修改社情民意信息
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:edit')")
    @Log(title = "社情民意信息", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody SqmyInfo sqmyInfo)
    {
        return toAjax(sqmyInfoService.updateSqmyInfo(sqmyInfo));
    }

    /**
     * 删除社情民意信息
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:remove')")
    @Log(title = "社情民意信息", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{sqmyIds}")
    public AjaxResult remove(@PathVariable Long[] sqmyIds)
    {
        return toAjax(sqmyInfoService.deleteSqmyInfoBySqmyIds(sqmyIds));
    }

    /***
     * 是否立案
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:isRecord')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/isRecord")
    public AjaxResult isRecord(@RequestBody SqmyInfo sqmyInfo)
    {
        return sqmyInfoService.isRecord(sqmyInfo);
    }

    /***
     * 交办
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:assign')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/assign")
    public AjaxResult assign(@RequestBody SqmyInfo sqmyInfo)
    {
        return sqmyInfoService.assign(sqmyInfo);
    }

    /***
     * 交办审核
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:assignsh')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/assignsh")
    public AjaxResult assignsh(@RequestBody SqmyInfo sqmyInfo)
    {
        return sqmyInfoService.assignsh(sqmyInfo);
    }


    /***
     * 委员意见
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:idea')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/idea")
    public AjaxResult idea(@RequestBody SqmyInfo sqmyInfo)
    {
        return sqmyInfoService.idea(sqmyInfo);
    }

    /***
     * 政协意见
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:zxIdea')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/zxIdea")
    public AjaxResult zxIdea(@RequestBody SqmyInfo sqmyInfo)
    {
        return sqmyInfoService.zxIdea(sqmyInfo);
    }

    /***
     * 推荐重点
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:keyPoint')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/keyPoint")
    public AjaxResult keyPoint(@RequestBody SqmyInfo sqmyInfo)
    {
        return sqmyInfoService.keyPoint(sqmyInfo);
    }

    /***
     * 推荐优秀
     */
    @PreAuthorize("@ss.hasPermi('sqmyInfo:info:outstanding')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/outstanding")
    public AjaxResult outstanding(@RequestBody SqmyInfo sqmyInfo)
    {
        return sqmyInfoService.outstanding(sqmyInfo);
    }
}
