package com.ruoyi.web.controller.project;

import java.util.List;

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

/**
 * 项目投资方-企业Controller
 * 
 * @author ruoyi
 * @date 2021-03-04
 */
@RestController
@RequestMapping("/projectInvestor/investor")
public class BmProjectInvestorController extends BaseController
{
    @Autowired
    private IBmProjectInvestorService bmProjectInvestorService;

    /**
     * 查询项目投资方-企业列表
     */
    @PreAuthorize("@ss.hasPermi('projectInvestor:investor:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmProjectInvestor bmProjectInvestor)
    {
        startPage();
        List<BmProjectInvestor> list = bmProjectInvestorService.selectBmProjectInvestorList(bmProjectInvestor);
        return getDataTable(list);
    }

    /**
     * 导出项目投资方-企业列表
     */
    @PreAuthorize("@ss.hasPermi('projectInvestor:investor:export')")
    @Log(title = "项目投资方-企业", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmProjectInvestor bmProjectInvestor)
    {
        List<BmProjectInvestor> list = bmProjectInvestorService.selectBmProjectInvestorList(bmProjectInvestor);
        ExcelUtil<BmProjectInvestor> util = new ExcelUtil<BmProjectInvestor>(BmProjectInvestor.class);
        return util.exportExcel(list, "investor");
    }

    /**
     * 获取项目投资方-企业详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectInvestor:investor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bmProjectInvestorService.selectBmProjectInvestorById(id));
    }

    /**
     * 新增项目投资方-企业
     */
    @PreAuthorize("@ss.hasPermi('projectInvestor:investor:add')")
    @Log(title = "项目投资方-企业", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@RequestBody BmProjectInvestor bmProjectInvestor)
    {
        return toAjax(bmProjectInvestorService.insertBmProjectInvestor(bmProjectInvestor));
    }

    /**
     * 修改项目投资方-企业
     */
    @PreAuthorize("@ss.hasPermi('projectInvestor:investor:edit')")
    @Log(title = "项目投资方-企业", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmProjectInvestor bmProjectInvestor)
    {
        return toAjax(bmProjectInvestorService.updateBmProjectInvestor(bmProjectInvestor));
    }

    /**
     * 删除项目投资方-企业
     */
    @PreAuthorize("@ss.hasPermi('projectInvestor:investor:remove')")
    @Log(title = "项目投资方-企业", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmProjectInvestorService.deleteBmProjectInvestorByIds(ids));
    }
}
