package com.ruoyi.web.controller.proposal;

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

import com.ruoyi.system.domain.ProposalInfo;
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.ProposalUnitReply;
import com.ruoyi.system.service.IProposalUnitReplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提案单位答复Controller
 *
 * @author boman
 * @date 2024-03-07
 */
@RestController
@RequestMapping("/proposal/unit")
public class ProposalUnitReplyController extends BaseController
{
    @Autowired
    private IProposalUnitReplyService proposalUnitReplyService;

/**
 * 查询提案单位答复列表
 */
@PreAuthorize("@ss.hasPermi('proposal:unit:list')")
@GetMapping("/list")
    public TableDataInfo list(ProposalUnitReply proposalUnitReply)
    {
        startPage();
        List<ProposalUnitReply> list = proposalUnitReplyService.selectProposalUnitReplyList(proposalUnitReply);
        return getDataTable(list);
    }

    /**
     * 导出提案单位答复列表
     */
    @PreAuthorize("@ss.hasPermi('proposal:unit:export')")
    @Log(title = "提案单位答复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProposalUnitReply proposalUnitReply)
    {
        List<ProposalUnitReply> list = proposalUnitReplyService.selectProposalUnitReplyList(proposalUnitReply);
        ExcelUtil<ProposalUnitReply> util = new ExcelUtil<ProposalUnitReply>(ProposalUnitReply.class);
        util.exportExcel(response, list, "提案单位答复数据");
    }

    /**
     * 获取提案单位答复详细信息
     */
    @PreAuthorize("@ss.hasPermi('proposal:unit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(proposalUnitReplyService.selectProposalUnitReplyById(id));
    }

    /**
     * 新增提案单位答复
     */
    @PreAuthorize("@ss.hasPermi('proposal:unit:add')")
    @Log(title = "提案单位答复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProposalUnitReply proposalUnitReply)
    {
        return toAjax(proposalUnitReplyService.insertProposalUnitReply(proposalUnitReply));
    }

    /**
     * 修改提案单位答复
     */
    @PreAuthorize("@ss.hasPermi('proposal:unit:edit')")
    @Log(title = "提案单位答复", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ProposalUnitReply proposalUnitReply)
    {
        return toAjax(proposalUnitReplyService.updateProposalUnitReply(proposalUnitReply));
    }

    /**
     * 删除提案单位答复
     */
    @PreAuthorize("@ss.hasPermi('proposal:unit:remove')")
    @Log(title = "提案单位答复", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(proposalUnitReplyService.deleteProposalUnitReplyByIds(ids));
    }

    /***
     * 提案答复
     */
    @PreAuthorize("@ss.hasPermi('proposal:unit:reply')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/reply")
    public AjaxResult reply(@RequestBody ProposalUnitReply proposalUnitReply)
    {
        return proposalUnitReplyService.reply(proposalUnitReply);
    }

}
