package com.ruoyi.szxc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.szxc.domain.SzxcCsResponse;
import com.ruoyi.szxc.service.ISzxcCsResponseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场所负责人Controller
 * 
 * @author hs
 * @date 2024-03-28
 */
@RestController
@RequestMapping("/szxc/response")
public class SzxcCsResponseController extends BaseController
{
    @Autowired
    private ISzxcCsResponseService szxcCsResponseService;

    /**
     * 查询场所负责人列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:response:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzxcCsResponse szxcCsResponse)
    {
        startPage();
        List<SzxcCsResponse> list = szxcCsResponseService.selectSzxcCsResponseList(szxcCsResponse);
        return getDataTable(list);
    }

    /**
     * 导出场所负责人列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:response:export')")
    @Log(title = "场所负责人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SzxcCsResponse szxcCsResponse)
    {
        List<SzxcCsResponse> list = szxcCsResponseService.selectSzxcCsResponseList(szxcCsResponse);
        ExcelUtil<SzxcCsResponse> util = new ExcelUtil<SzxcCsResponse>(SzxcCsResponse.class);
        util.exportExcel(response, list, "场所负责人数据");
    }

    /**
     * 获取场所负责人详细信息
     */
    @PreAuthorize("@ss.hasPermi('szxc:response:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(szxcCsResponseService.selectSzxcCsResponseById(id));
    }

    /**
     * 新增场所负责人
     */
    @PreAuthorize("@ss.hasPermi('szxc:response:add')")
    @Log(title = "场所负责人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzxcCsResponse szxcCsResponse)
    {
        return toAjax(szxcCsResponseService.insertSzxcCsResponse(szxcCsResponse));
    }

    /**
     * 修改场所负责人
     */
    @PreAuthorize("@ss.hasPermi('szxc:response:edit')")
    @Log(title = "场所负责人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzxcCsResponse szxcCsResponse)
    {
        return toAjax(szxcCsResponseService.updateSzxcCsResponse(szxcCsResponse));
    }

    /**
     * 删除场所负责人
     */
    @PreAuthorize("@ss.hasPermi('szxc:response:remove')")
    @Log(title = "场所负责人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szxcCsResponseService.deleteSzxcCsResponseByIds(ids));
    }
}
