package com.ruoyi.web.controller.project;

import java.util.List;
import java.util.Map;

import com.ruoyi.system.domain.project.BmConstructionPay;
import com.ruoyi.system.service.project.IBmConstructionPayService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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("/constructionPay/pay")
public class BmConstructionPayController extends BaseController
{
    @Autowired
    private IBmConstructionPayService bmConstructionPayService;

    /**
     * 查询项目到资(最少一条记录、合计、回写项目单)列表
     */
    @PreAuthorize("@ss.hasPermi('constructionPay:pay:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmConstructionPay bmConstructionPay)
    {
        startPage();
        List<BmConstructionPay> list = bmConstructionPayService.selectBmConstructionPayList(bmConstructionPay);
        return getDataTable(list);
    }

    /**
     * 导出项目到资(最少一条记录、合计、回写项目单)列表
     */
    @PreAuthorize("@ss.hasPermi('constructionPay:pay:export')")
    @Log(title = "导出", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmConstructionPay bmConstructionPay)
    {
        List<BmConstructionPay> list = bmConstructionPayService.selectBmConstructionPayList(bmConstructionPay);
        ExcelUtil<BmConstructionPay> util = new ExcelUtil<BmConstructionPay>(BmConstructionPay.class);
        return util.exportExcel(list, "pay");
    }

    /**
     * 获取项目到资(最少一条记录、合计、回写项目单)详细信息
     */
    @PreAuthorize("@ss.hasPermi('constructionPay:pay:query')")
    @GetMapping(value = "/{bmProjectId}")
    public AjaxResult getInfo(@PathVariable("bmProjectId") Long id)
    {
        return AjaxResult.success(bmConstructionPayService.selectBmConstructionPayById(id));
    }

    /**
     * 新增项目到资(最少一条记录、合计、回写项目单)
     */
    @PreAuthorize("@ss.hasPermi('constructionPay:pay:add')")
    @Log(title = "新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmConstructionPay bmConstructionPay)
    {
        return toAjax(bmConstructionPayService.insertBmConstructionPay(bmConstructionPay));
    }

    /**
     * 修改项目到资(最少一条记录、合计、回写项目单)
     */
    @PreAuthorize("@ss.hasPermi('constructionPay:pay:edit')")
    @Log(title = "修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmConstructionPay bmConstructionPay)
    {
        return toAjax(bmConstructionPayService.updateBmConstructionPay(bmConstructionPay));
    }

    /**
     * 删除项目到资(最少一条记录、合计、回写项目单)
     */
    @PreAuthorize("@ss.hasPermi('constructionPay:pay:remove')")
    @Log(title = "删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmConstructionPayService.deleteBmConstructionPayByIds(ids));
    }


    /**
     * 首页柱状图
     */
    //@PreAuthorize("@ss.hasPermi('constructionPay:pay:remove')")
    @GetMapping("/indexEharts")
    public AjaxResult indexEharts(String year)
    {
        Map<String, Object> stringObjectMap = bmConstructionPayService.selectIndexEharts(year);
        return AjaxResult.success(stringObjectMap);
    }

}
