package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.system.domain.project.BmProjectProduct;
import com.ruoyi.system.service.project.IBmProjectProductService;
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("/projectProduct/product")
public class BmProjectProductController extends BaseController
{
    @Autowired
    private IBmProjectProductService bmProjectProductService;

    /**
     * 查询项目投产列表
     */
    @PreAuthorize("@ss.hasPermi('projectProduct:product:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmProjectProduct bmProjectProduct)
    {
        startPage();
        List<BmProjectProduct> list = bmProjectProductService.selectBmProjectProductList(bmProjectProduct);
        return getDataTable(list);
    }

    /**
     * 导出项目投产列表
     */
    @PreAuthorize("@ss.hasPermi('projectProduct:product:export')")
    @Log(title = "项目投产", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmProjectProduct bmProjectProduct)
    {
        List<BmProjectProduct> list = bmProjectProductService.selectBmProjectProductList(bmProjectProduct);
        ExcelUtil<BmProjectProduct> util = new ExcelUtil<BmProjectProduct>(BmProjectProduct.class);
        return util.exportExcel(list, "product");
    }

    /**
     * 获取项目投产详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectProduct:product:query')")
    @GetMapping(value = "/{bmProjectId}")
    public AjaxResult getInfo(@PathVariable("bmProjectId") Long id)
    {
        return AjaxResult.success(bmProjectProductService.selectBmProjectProductById(id));
    }

    /**
     * 新增项目投产
     */
    @PreAuthorize("@ss.hasPermi('projectProduct:product:add')")
    @Log(title = "项目投产", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@RequestBody BmProjectProduct bmProjectProduct)
    {
        return toAjax(bmProjectProductService.insertBmProjectProduct(bmProjectProduct));
    }

    /**
     * 修改项目投产
     */
    @PreAuthorize("@ss.hasPermi('projectProduct:product:edit')")
    @Log(title = "项目投产", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmProjectProduct bmProjectProduct)
    {
        return toAjax(bmProjectProductService.updateBmProjectProduct(bmProjectProduct));
    }

    /**
     * 删除项目投产
     */
    @PreAuthorize("@ss.hasPermi('projectProduct:product:remove')")
    @Log(title = "项目投产", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmProjectProductService.deleteBmProjectProductByIds(ids));
    }
}
