package com.ruoyi.web.controller.investigate;

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

import com.ruoyi.common.core.domain.entity.SysDept;
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.common.core.domain.entity.InvestigateDisposition;
import com.ruoyi.system.service.IInvestigateDispositionService;
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")
public class InvestigateDispositionController extends BaseController
{
    @Autowired
    private IInvestigateDispositionService investigateDispositionService;

    /**
     * 查询考察配置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(InvestigateDisposition investigateDisposition)
    {
        List<InvestigateDisposition> list = investigateDispositionService.selectInvestigateDispositionList(investigateDisposition);
        return getDataTable(list);
    }

    /**
     * 导出考察配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:disposition:export')")
    @Log(title = "考察配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvestigateDisposition investigateDisposition)
    {
        List<InvestigateDisposition> list = investigateDispositionService.selectInvestigateDispositionList(investigateDisposition);
        ExcelUtil<InvestigateDisposition> util = new ExcelUtil<InvestigateDisposition>(InvestigateDisposition.class);
        util.exportExcel(response, list, "考察配置数据");
    }

    /**
     * 获取考察配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:disposition:query')")
    @GetMapping(value = "/{investigateDispositionId}")
    public AjaxResult getInfo(@PathVariable("investigateDispositionId") Long investigateDispositionId)
    {
        return success(investigateDispositionService.selectInvestigateDispositionByInvestigateDispositionId(investigateDispositionId));
    }

    /**
     * 新增考察配置
     */
    @PreAuthorize("@ss.hasPermi('system:disposition:add')")
    @Log(title = "考察配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvestigateDisposition investigateDisposition)
    {
        investigateDisposition.setCreateBy(getUsername());
        return toAjax(investigateDispositionService.insertInvestigateDisposition(investigateDisposition));
    }

    /**
     * 考察配置是否启用
     */
    @PreAuthorize("@ss.hasPermi('system:disposition:edit')")
    @Log(title = "考察配置", businessType = BusinessType.UPDATE)
    @PostMapping("/status")
    public AjaxResult status(@RequestBody InvestigateDisposition investigateDisposition)
    {
        return toAjax(investigateDispositionService.updateInvestigateDispositionStatus(investigateDisposition));
    }

    /**
     * 修改考察配置
     */
    @PreAuthorize("@ss.hasPermi('system:disposition:edit')")
    @Log(title = "考察配置", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody InvestigateDisposition investigateDisposition)
    {
        return toAjax(investigateDispositionService.updateInvestigateDisposition(investigateDisposition));
    }

    /**
     * 删除考察配置
     */
    @PreAuthorize("@ss.hasPermi('system:disposition:remove')")
    @Log(title = "考察配置", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{investigateDispositionIds}")
    public AjaxResult remove(@PathVariable Long[] investigateDispositionIds)
    {
        return toAjax(investigateDispositionService.deleteInvestigateDispositionByInvestigateDispositionIds(investigateDispositionIds));
    }

    /**
     * 获取考察配置树列表
     */

    @GetMapping("/investigateDispositionTree")
    public AjaxResult investigateDispositionTree(InvestigateDisposition investigateDisposition)
    {
        return success(investigateDispositionService.selectInvestigateDispositionTreeList(investigateDisposition));
    }
}
