package com.ruoyi.web.controller.project;

import java.util.List;

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

/**
 * 项目施工Controller
 * 
 * @author ruoyi
 * @date 2021-03-08
 */
@RestController
@RequestMapping("/projectConstruction/construction")
public class BmProjectConstructionController extends BaseController
{
    @Autowired
    private IBmProjectConstructionService bmProjectConstructionService;

    /**
     * 查询项目施工列表
     */
    @PreAuthorize("@ss.hasPermi('projectConstruction:construction:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmProjectConstruction bmProjectConstruction)
    {
        startPage();
        List<BmProjectConstruction> list = bmProjectConstructionService.selectBmProjectConstructionList(bmProjectConstruction);
        return getDataTable(list);
    }

    /**
     * 导出项目施工列表
     */
    @PreAuthorize("@ss.hasPermi('projectConstruction:construction:export')")
    @Log(title = "项目施工", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmProjectConstruction bmProjectConstruction)
    {
        List<BmProjectConstruction> list = bmProjectConstructionService.selectBmProjectConstructionList(bmProjectConstruction);
        ExcelUtil<BmProjectConstruction> util = new ExcelUtil<BmProjectConstruction>(BmProjectConstruction.class);
        return util.exportExcel(list, "construction");
    }

    /**
     * 获取项目施工详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectConstruction:construction:query')")
    @GetMapping(value = "/{bmProjectId}")
    public AjaxResult getInfo(@PathVariable("bmProjectId") Long id)
    {
        return AjaxResult.success(bmProjectConstructionService.selectBmProjectConstructionById(id));
    }

    /**
     * 新增项目施工
     */
    //@PreAuthorize("@ss.hasPermi('projectConstruction:construction:add')")
    @Log(title = "项目施工", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmProjectConstruction bmProjectConstruction)
    {
        return bmProjectConstructionService.insertBmProjectConstruction(bmProjectConstruction);
    }

    /**
     * 修改项目施工
     */
    @PreAuthorize("@ss.hasPermi('projectConstruction:construction:edit')")
    @Log(title = "项目施工", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmProjectConstruction bmProjectConstruction)
    {
        return bmProjectConstructionService.updateBmProjectConstruction(bmProjectConstruction);
    }

    /**
     * 删除项目施工
     */
    @PreAuthorize("@ss.hasPermi('projectConstruction:construction:remove')")
    @Log(title = "项目施工", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmProjectConstructionService.deleteBmProjectConstructionByIds(ids));
    }
}
