package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.system.domain.project.BmConstructionPayInfo;
import com.ruoyi.system.service.project.IBmConstructionPayInfoService;
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("/constructionPayInfo/payInfo")
public class BmConstructionPayInfoController extends BaseController
{
    @Autowired
    private IBmConstructionPayInfoService bmConstructionPayInfoService;

    /**
     * 查询项目入统列表
     */
    @PreAuthorize("@ss.hasPermi('constructionPayInfo:payInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmConstructionPayInfo bmConstructionPayInfo)
    {
        startPage();
        List<BmConstructionPayInfo> list = bmConstructionPayInfoService.selectBmConstructionPayInfoList(bmConstructionPayInfo);
        return getDataTable(list);
    }

    /**
     * 导出项目入统列表
     */
    @PreAuthorize("@ss.hasPermi('constructionPayInfo:payInfo:export')")
    @Log(title = "项目入统", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmConstructionPayInfo bmConstructionPayInfo)
    {
        List<BmConstructionPayInfo> list = bmConstructionPayInfoService.selectBmConstructionPayInfoList(bmConstructionPayInfo);
        ExcelUtil<BmConstructionPayInfo> util = new ExcelUtil<BmConstructionPayInfo>(BmConstructionPayInfo.class);
        return util.exportExcel(list, "payInfo");
    }

    /**
     * 获取项目入统详细信息
     */
    @PreAuthorize("@ss.hasPermi('constructionPayInfo:payInfo:query')")
    @GetMapping(value = "/{bmProjectId}")
    public AjaxResult getInfo(@PathVariable("bmProjectId") Long id)
    {
        return AjaxResult.success(bmConstructionPayInfoService.selectBmConstructionPayInfoById(id));
    }

    /**
     * 新增项目入统
     */
    @PreAuthorize("@ss.hasPermi('constructionPayInfo:payInfo:add')")
    @Log(title = "项目入统", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmConstructionPayInfo bmConstructionPayInfo)
    {
        return bmConstructionPayInfoService.insertBmConstructionPayInfo(bmConstructionPayInfo);
    }

    /**
     * 修改项目入统
     */
    @PreAuthorize("@ss.hasPermi('constructionPayInfo:payInfo:edit')")
    @Log(title = "项目入统", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmConstructionPayInfo bmConstructionPayInfo)
    {
        return bmConstructionPayInfoService.updateBmConstructionPayInfo(bmConstructionPayInfo);
    }

    /**
     * 删除项目入统
     */
    @PreAuthorize("@ss.hasPermi('constructionPayInfo:payInfo:remove')")
    @Log(title = "项目入统", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmConstructionPayInfoService.deleteBmConstructionPayInfoByIds(ids));
    }
}
