package com.ruoyi.web.controller.proposal;

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

import com.ruoyi.system.domain.ProposalUnitReply;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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.domain.ProposalInfo;
import com.ruoyi.system.service.IProposalInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提案信息Controller
 *
 * @author boman
 * @date 2024-03-07
 */
@RestController
@RequestMapping("/proposalInfo/info")
public class ProposalInfoController extends BaseController
{
    @Autowired
    private IProposalInfoService proposalInfoService;

    /**
     * 查询提案信息列表
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProposalInfo proposalInfo)
    {
        startPage();
        List<ProposalInfo> list = proposalInfoService.selectProposalInfoList(proposalInfo);
        return getDataTable(list);
    }

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

    /**
     * 查询联名提案信息列表(只查询附议)
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:jointlyList')")
    @GetMapping("/jointlyList")
    public TableDataInfo jointlyList(ProposalInfo proposalInfo)
    {
        startPage();
        List<ProposalInfo> list = proposalInfoService.jointlyList(proposalInfo);
        return getDataTable(list);
    }

    /**
     * 联名提案信息列表导出(只查询附议)
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:jointlyExport')")
    @Log(title = "提案信息", businessType = BusinessType.EXPORT)
    @PostMapping("/jointlyExport")
    public void jointlyExport(HttpServletResponse response, ProposalInfo proposalInfo)
    {
        List<ProposalInfo> list = proposalInfoService.jointlyList(proposalInfo);
        ExcelUtil<ProposalInfo> util = new ExcelUtil<ProposalInfo>(ProposalInfo.class);
        util.exportExcel(response, list, "提案信息数据");
    }

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

    /**
     * 联名提案信息列表导出(只查询附议)
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:unitListExport')")
    @Log(title = "提案信息", businessType = BusinessType.EXPORT)
    @PostMapping("/unitListExport")
    public void unitListExport(HttpServletResponse response, ProposalInfo proposalInfo)
    {
        List<ProposalInfo> list = proposalInfoService.unitList(proposalInfo);
        ExcelUtil<ProposalInfo> util = new ExcelUtil<ProposalInfo>(ProposalInfo.class);
        util.exportExcel(response, list, "提案信息数据");
    }


    /**
     * 导出提案信息列表
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:export')")
    @Log(title = "提案信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProposalInfo proposalInfo)
    {
        List<ProposalInfo> list = proposalInfoService.selectProposalInfoList(proposalInfo);
        ExcelUtil<ProposalInfo> util = new ExcelUtil<ProposalInfo>(ProposalInfo.class);
        util.exportExcel(response, list, "提案信息数据");
    }

    /**
     * 获取提案信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:query')")
    @GetMapping(value = "/{proposalId}")
    public AjaxResult getInfo(@PathVariable("proposalId") Long proposalId)
    {
        return success(proposalInfoService.selectProposalInfoByProposalId(proposalId));
    }

    /**
     * 新增提案信息
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:add')")
    @Log(title = "提案信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProposalInfo proposalInfo)
    {
        return toAjax(proposalInfoService.insertProposalInfo(proposalInfo));
    }

    /**
     * 修改提案信息
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:edit')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ProposalInfo proposalInfo)
    {
        return toAjax(proposalInfoService.updateProposalInfo(proposalInfo));
    }

    /**
     * 删除提案信息
     */
    @PreAuthorize("@ss.hasPermi('proposalInfo:info:remove')")
    @Log(title = "提案信息", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{proposalIds}")
    public AjaxResult remove(@PathVariable Long[] proposalIds)
    {
        return toAjax(proposalInfoService.deleteProposalInfoByProposalIds(proposalIds));
    }

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

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


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


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

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

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

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



}
