package com.ruoyi.web.controller.sqmy;

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

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

/**
 * 社情民意单位答复Controller
 *
 * @author boman
 * @date 2024-03-15
 */
@RestController
@RequestMapping("/sqmy/unit")
public class SqmyUnitReplyController extends BaseController
{
    @Autowired
    private ISqmyUnitReplyService sqmyUnitReplyService;

/**
 * 查询社情民意单位答复列表
 */
@PreAuthorize("@ss.hasPermi('sqmy:unit:list')")
@GetMapping("/list")
    public TableDataInfo list(SqmyUnitReply sqmyUnitReply)
    {
        startPage();
        List<SqmyUnitReply> list = sqmyUnitReplyService.selectSqmyUnitReplyList(sqmyUnitReply);
        return getDataTable(list);
    }

    /**
     * 导出社情民意单位答复列表
     */
    @PreAuthorize("@ss.hasPermi('sqmy:unit:export')")
    @Log(title = "社情民意单位答复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SqmyUnitReply sqmyUnitReply)
    {
        List<SqmyUnitReply> list = sqmyUnitReplyService.selectSqmyUnitReplyList(sqmyUnitReply);
        ExcelUtil<SqmyUnitReply> util = new ExcelUtil<SqmyUnitReply>(SqmyUnitReply.class);
        util.exportExcel(response, list, "社情民意单位答复数据");
    }

    /**
     * 获取社情民意单位答复详细信息
     */
    @PreAuthorize("@ss.hasPermi('sqmy:unit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sqmyUnitReplyService.selectSqmyUnitReplyById(id));
    }

    /**
     * 新增社情民意单位答复
     */
    @PreAuthorize("@ss.hasPermi('sqmy:unit:add')")
    @Log(title = "社情民意单位答复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SqmyUnitReply sqmyUnitReply)
    {
        return toAjax(sqmyUnitReplyService.insertSqmyUnitReply(sqmyUnitReply));
    }

    /**
     * 修改社情民意单位答复
     */
    @PreAuthorize("@ss.hasPermi('sqmy:unit:edit')")
    @Log(title = "社情民意单位答复", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody SqmyUnitReply sqmyUnitReply)
    {
        return toAjax(sqmyUnitReplyService.updateSqmyUnitReply(sqmyUnitReply));
    }

    /**
     * 删除社情民意单位答复
     */
    @PreAuthorize("@ss.hasPermi('sqmy:unit:remove')")
    @Log(title = "社情民意单位答复", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sqmyUnitReplyService.deleteSqmyUnitReplyByIds(ids));
    }

    /***
     * 社情民意答复
     */
    @PreAuthorize("@ss.hasPermi('sqmy:unit:reply')")
    @Log(title = "提案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/reply")
    public AjaxResult reply(@RequestBody SqmyUnitReply sqmyUnitReply)
    {
        return sqmyUnitReplyService.reply(sqmyUnitReply);
    }
}
