package com.ruoyi.web.controller.investigate;

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

import com.ruoyi.framework.config.ServerConfig;
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.InvestigateDispositionTable;
import com.ruoyi.system.service.IInvestigateDispositionTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考察配置与考察主关联Controller
 * 
 * @author ruoyi
 * @date 2023-10-10
 */
@RestController
@RequestMapping("/investigate/disposition/table")
public class InvestigateDispositionTableController extends BaseController
{
    @Autowired
    private IInvestigateDispositionTableService investigateDispositionTableService;

    @Autowired
    private ServerConfig serverConfig;

    /**
     * 查询考察配置与考察主关联列表
     */
    @GetMapping("/list")
    public TableDataInfo list(InvestigateDispositionTable investigateDispositionTable)
    {
        List<InvestigateDispositionTable> list = investigateDispositionTableService.selectInvestigateDispositionTableList(investigateDispositionTable);
        return getDataTable(list);
    }

    /**
     * 导出考察配置与考察主关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:table:export')")
    @Log(title = "考察配置与考察主关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvestigateDispositionTable investigateDispositionTable)
    {
        List<InvestigateDispositionTable> list = investigateDispositionTableService.selectInvestigateDispositionTableList(investigateDispositionTable);
        ExcelUtil<InvestigateDispositionTable> util = new ExcelUtil<InvestigateDispositionTable>(InvestigateDispositionTable.class);
        util.exportExcel(response, list, "考察配置与考察主关联数据");
    }

    /**
     * 获取考察配置与考察主关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:table:query')")
    @GetMapping(value = "/query")
    public AjaxResult getInfo(InvestigateDispositionTable investigateDispositionTable)
    {
        return success(investigateDispositionTableService.selectInvestigateDispositionTableList(investigateDispositionTable));
    }

    /**
     * 新增考察配置与考察主关联
     */
    @PreAuthorize("@ss.hasPermi('system:table:add')")
    @Log(title = "考察配置与考察主关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvestigateDispositionTable investigateDispositionTable)
    {
        investigateDispositionTable.setCreateBy(getUsername());
        investigateDispositionTable.setUrl(serverConfig.getUrl());
        return toAjax(investigateDispositionTableService.insertInvestigateDispositionTable(investigateDispositionTable));
    }

    /**
     * 修改考察配置与考察主关联
     */
    @PreAuthorize("@ss.hasPermi('system:table:edit')")
    @Log(title = "考察配置与考察主关联", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody InvestigateDispositionTable investigateDispositionTable)
    {
        return toAjax(investigateDispositionTableService.updateInvestigateDispositionTable(investigateDispositionTable));
    }

    /**
     * 删除考察配置与考察主关联
     */
    @PreAuthorize("@ss.hasPermi('system:table:remove')")
    @Log(title = "考察配置与考察主关联", businessType = BusinessType.DELETE)
	@GetMapping("/delete")
    public AjaxResult remove(InvestigateDispositionTable investigateDispositionTable)
    {
        return toAjax(investigateDispositionTableService.deleteInvestigateDispositionTableByInvestigateTableIds(investigateDispositionTable));
    }
}
