package com.yanzhu.manage.controller;

import com.yanzhu.common.core.utils.poi.ExcelUtil;
import com.yanzhu.common.core.web.controller.BaseController;
import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.common.core.web.page.TableDataInfo;
import com.yanzhu.common.log.annotation.Log;
import com.yanzhu.common.log.enums.BusinessType;
import com.yanzhu.common.security.annotation.RequiresPermissions;
import com.yanzhu.manage.domain.ProProjectInfoDepts;
import com.yanzhu.manage.service.IProProjectInfoDeptsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 参建单位Controller
 * 
 * @author JiangYuQi
 * @date 2024-08-25
 */
@RestController
@RequestMapping("/proProjectInfoDepts")
public class ProProjectInfoDeptsController extends BaseController
{
    @Autowired
    private IProProjectInfoDeptsService proProjectInfoDeptsService;

    /**
     * 查询参建单位列表
     */
    @RequiresPermissions("manage:proProjectInfoDepts:list")
    @GetMapping("/list")
    public TableDataInfo list(ProProjectInfoDepts proProjectInfoDepts)
    {
        startPage();
        List<ProProjectInfoDepts> list = proProjectInfoDeptsService.selectProProjectInfoDeptsList(proProjectInfoDepts);
        return getDataTable(list);
    }

    /**
     * 导出参建单位列表
     */
    @RequiresPermissions("manage:proProjectInfoDepts:export")
    @Log(title = "建设单位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProProjectInfoDepts proProjectInfoDepts)
    {
        List<ProProjectInfoDepts> list = proProjectInfoDeptsService.selectProProjectInfoDeptsList(proProjectInfoDepts);
        ExcelUtil<ProProjectInfoDepts> util = new ExcelUtil<ProProjectInfoDepts>(ProProjectInfoDepts.class);
        util.exportExcel(response, list, "参建单位数据");
    }

    /**
     * 获取参建单位详细信息
     */
    @RequiresPermissions("manage:proProjectInfoDepts:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(proProjectInfoDeptsService.selectProProjectInfoDeptsById(id));
    }

    /**
     * 新增参建单位
     */
    @RequiresPermissions("manage:proProjectInfoDepts:add")
    @Log(title = "建设单位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProProjectInfoDepts proProjectInfoDepts)
    {
        return toAjax(proProjectInfoDeptsService.insertProProjectInfoDepts(proProjectInfoDepts));
    }

    /**
     * 修改参建单位
     */
    @RequiresPermissions("manage:proProjectInfoDepts:edit")
    @Log(title = "建设单位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProProjectInfoDepts proProjectInfoDepts)
    {
        return toAjax(proProjectInfoDeptsService.updateProProjectInfoDepts(proProjectInfoDepts));
    }

    /**
     * 删除参建单位
     */
    @RequiresPermissions("manage:proProjectInfoDepts:remove")
    @Log(title = "建设单位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(proProjectInfoDeptsService.deleteProProjectInfoDeptsByIds(ids));
    }
}
