package com.ruoyi.web.controller.projectV2;

import java.util.List;

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

/**
 * 招商引资_项目和部门关联Controller
 * 
 * @author boman
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/projectV2/dept")
public class ZsyzProjectDeptController extends BaseController
{
    @Autowired
    private IZsyzProjectDeptService zsyzProjectDeptService;

    /**
     * 查询招商引资_项目和部门关联列表
     */
    @PreAuthorize("@ss.hasPermi('projectV2:dept:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZsyzProjectDept zsyzProjectDept)
    {
        startPage();
        List<ZsyzProjectDept> list = zsyzProjectDeptService.selectZsyzProjectDeptList(zsyzProjectDept);
        return getDataTable(list);
    }

    /**
     * 导出招商引资_项目和部门关联列表
     */
    @PreAuthorize("@ss.hasPermi('projectV2:dept:export')")
    @Log(title = "招商引资_项目和部门关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZsyzProjectDept zsyzProjectDept)
    {
        List<ZsyzProjectDept> list = zsyzProjectDeptService.selectZsyzProjectDeptList(zsyzProjectDept);
        ExcelUtil<ZsyzProjectDept> util = new ExcelUtil<ZsyzProjectDept>(ZsyzProjectDept.class);
        return util.exportExcel(list, "dept");
    }

    /**
     * 获取招商引资_项目和部门关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectV2:dept:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zsyzProjectDeptService.selectZsyzProjectDeptById(id));
    }

    /**
     * 新增招商引资_项目和部门关联
     */
    @PreAuthorize("@ss.hasPermi('projectV2:dept:add')")
    @Log(title = "招商引资_项目和部门关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZsyzProjectDept zsyzProjectDept)
    {
        return toAjax(zsyzProjectDeptService.insertZsyzProjectDept(zsyzProjectDept));
    }

    /**
     * 修改招商引资_项目和部门关联
     */
    @PreAuthorize("@ss.hasPermi('projectV2:dept:edit')")
    @Log(title = "招商引资_项目和部门关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZsyzProjectDept zsyzProjectDept)
    {
        return toAjax(zsyzProjectDeptService.updateZsyzProjectDept(zsyzProjectDept));
    }

    /**
     * 删除招商引资_项目和部门关联
     */
    @PreAuthorize("@ss.hasPermi('projectV2:dept:remove')")
    @Log(title = "招商引资_项目和部门关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zsyzProjectDeptService.deleteZsyzProjectDeptByIds(ids));
    }
}
