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.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: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));
    }
}
