package com.ruoyi.web.controller.investigate;

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.system.domain.InvestigateUser;
import com.ruoyi.system.service.IInvestigateUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考察人员信息Controller
 * 
 * @author ruoyi
 * @date 2023-10-10
 */
@RestController
@RequestMapping("/investigate/user")
public class InvestigateUserController extends BaseController
{
    @Autowired
    private IInvestigateUserService investigateUserService;

    /**
     * 查询考察人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('investigate:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(InvestigateUser investigateUser)
    {
        startPage();
        List<InvestigateUser> list = investigateUserService.selectInvestigateUserList(investigateUser);
        return getDataTable(list);
    }

    /**
     * 导出考察人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('investigate:user:export')")
    @Log(title = "考察人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvestigateUser investigateUser)
    {
        List<InvestigateUser> list = investigateUserService.selectInvestigateUserList(investigateUser);
        ExcelUtil<InvestigateUser> util = new ExcelUtil<InvestigateUser>(InvestigateUser.class);
        util.exportExcel(response, list, "考察人员信息数据");
    }

    /**
     * 获取考察人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('investigate:user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(investigateUserService.selectInvestigateUserById(id));
    }

    /**
     * 新增考察人员信息
     */
    @PreAuthorize("@ss.hasPermi('investigate:user:add')")
    @Log(title = "考察人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvestigateUser investigateUser)
    {
        return toAjax(investigateUserService.insertInvestigateUser(investigateUser));
    }

    /**
     * 修改考察人员信息
     */
    @PreAuthorize("@ss.hasPermi('investigate:user:edit')")
    @Log(title = "考察人员信息", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody InvestigateUser investigateUser)
    {
        return toAjax(investigateUserService.updateInvestigateUser(investigateUser));
    }

    /**
     * 删除考察人员信息
     */
    @PreAuthorize("@ss.hasPermi('investigate:user:remove')")
    @Log(title = "考察人员信息", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(investigateUserService.deleteInvestigateUserByIds(ids));
    }
}
