package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.system.domain.project.BmConstructionRate;
import com.ruoyi.system.service.project.IBmConstructionRateService;
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("/constructionRate/rate")
public class BmConstructionRateController extends BaseController
{
    @Autowired
    private IBmConstructionRateService bmConstructionRateService;

    /**
     * 查询项目施工进度列表
     */
    @PreAuthorize("@ss.hasPermi('constructionRate:rate:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmConstructionRate bmConstructionRate)
    {
        startPage();
        List<BmConstructionRate> list = bmConstructionRateService.selectBmConstructionRateList(bmConstructionRate);
        return getDataTable(list);
    }

    /**
     * 导出项目施工进度列表
     */
    @PreAuthorize("@ss.hasPermi('constructionRate:rate:export')")
    @Log(title = "项目施工进度", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmConstructionRate bmConstructionRate)
    {
        List<BmConstructionRate> list = bmConstructionRateService.selectBmConstructionRateList(bmConstructionRate);
        ExcelUtil<BmConstructionRate> util = new ExcelUtil<BmConstructionRate>(BmConstructionRate.class);
        return util.exportExcel(list, "rate");
    }

    /**
     * 获取项目施工进度详细信息
     */
    @PreAuthorize("@ss.hasPermi('constructionRate:rate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bmConstructionRateService.selectBmConstructionRateById(id));
    }

    /**
     * 新增项目施工进度
     */
    @PreAuthorize("@ss.hasPermi('constructionRate:rate:add')")
    @Log(title = "项目施工进度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmConstructionRate bmConstructionRate)
    {
        return toAjax(bmConstructionRateService.insertBmConstructionRate(bmConstructionRate));
    }

    /**
     * 修改项目施工进度
     */
    @PreAuthorize("@ss.hasPermi('constructionRate:rate:edit')")
    @Log(title = "项目施工进度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmConstructionRate bmConstructionRate)
    {
        return toAjax(bmConstructionRateService.updateBmConstructionRate(bmConstructionRate));
    }

    /**
     * 删除项目施工进度
     */
    @PreAuthorize("@ss.hasPermi('constructionRate:rate:remove')")
    @Log(title = "项目施工进度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmConstructionRateService.deleteBmConstructionRateByIds(ids));
    }
}
