package com.yanzhu.jh.project.controller;

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

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.SysRoleEnum;
import com.ruoyi.system.service.ISysDeptService;
import com.yanzhu.jh.project.domain.SurProjectUnitInfo;
import com.yanzhu.jh.project.service.ISurProjectUnitInfoService;
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.yanzhu.jh.project.domain.SurProjectDeptWroks;
import com.yanzhu.jh.project.service.ISurProjectDeptWroksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目部门在册人员Controller
 * 
 * @author JiangYuQi
 * @date 2023-08-15
 */
@RestController
@RequestMapping("/project/projectDeptWroks")
public class SurProjectDeptWroksController extends BaseController
{
    @Autowired
    private ISurProjectDeptWroksService surProjectDeptWroksService;

    @Autowired
    private ISysDeptService sysDeptService;

    /**
     * 查询项目部门在册人员列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectDeptWroks:list')")
    @GetMapping("/list")
    public TableDataInfo list(SurProjectDeptWroks surProjectDeptWroks)
    {
        startPage();
        List<SurProjectDeptWroks> list = surProjectDeptWroksService.selectSurProjectDeptWroksList(surProjectDeptWroks);
        return getDataTable(list);
    }

    /**
     * 查询项目部门在册人员列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectDeptWroks:list')")
    @GetMapping("/viewData")
    public TableDataInfo viewData(SurProjectDeptWroks surProjectDeptWroks)
    {
        List<SurProjectDeptWroks> list = surProjectDeptWroksService.selectSurProjectDeptWroksListv2(surProjectDeptWroks);
        return getDataTable(list);
    }

    /**
     * 导出项目部门在册人员列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectDeptWroks:export')")
    @Log(title = "项目部门在册人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SurProjectDeptWroks surProjectDeptWroks)
    {
        List<SurProjectDeptWroks> list = surProjectDeptWroksService.selectSurProjectDeptWroksList(surProjectDeptWroks);
        ExcelUtil<SurProjectDeptWroks> util = new ExcelUtil<SurProjectDeptWroks>(SurProjectDeptWroks.class);
        util.exportExcel(response, list, "项目部门在册人员数据");
    }

    /**
     * 获取项目部门在册人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:projectDeptWroks:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(surProjectDeptWroksService.selectSurProjectDeptWroksById(id));
    }

    /**
     * 新增项目部门在册人员
     */
    @PreAuthorize("@ss.hasPermi('project:projectDeptWroks:add')")
    @Log(title = "项目部门在册人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SurProjectDeptWroks surProjectDeptWroks)
    {
        return toAjax(surProjectDeptWroksService.insertSurProjectDeptWroks(surProjectDeptWroks));
    }

    /**
     * 修改项目部门在册人员
     */
    @PreAuthorize("@ss.hasPermi('project:projectDeptWroks:edit')")
    @Log(title = "项目部门在册人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SurProjectDeptWroks surProjectDeptWroks)
    {
        return toAjax(surProjectDeptWroksService.updateSurProjectDeptWroks(surProjectDeptWroks));
    }

    /**
     * 删除项目部门在册人员
     */
    @PreAuthorize("@ss.hasPermi('project:projectDeptWroks:remove')")
    @Log(title = "项目部门在册人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(surProjectDeptWroksService.deleteSurProjectDeptWroksByIds(ids));
    }
}
