package com.ruoyi.web.controller.project;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.project.BmProjectPersion;
import com.ruoyi.system.service.project.IBmProjectPersionService;
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("/projectPersion/persion")
public class BmProjectPersionController extends BaseController
{
    @Autowired
    private IBmProjectPersionService bmProjectPersionService;

    /**
     * 查询项目投资方-自然人列表
     */
    @PreAuthorize("@ss.hasPermi('projectPersion:persion:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmProjectPersion bmProjectPersion)
    {
        startPage();
        List<BmProjectPersion> list = bmProjectPersionService.selectBmProjectPersionList(bmProjectPersion);
        return getDataTable(list);
    }

    /**
     * 导出项目投资方-自然人列表
     */
    @PreAuthorize("@ss.hasPermi('projectPersion:persion:export')")
    @Log(title = "项目投资方-自然人", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmProjectPersion bmProjectPersion)
    {
        List<BmProjectPersion> list = bmProjectPersionService.selectBmProjectPersionList(bmProjectPersion);
        ExcelUtil<BmProjectPersion> util = new ExcelUtil<BmProjectPersion>(BmProjectPersion.class);
        return util.exportExcel(list, "persion");
    }

    /**
     * 获取项目投资方-自然人详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectPersion:persion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bmProjectPersionService.selectBmProjectPersionById(id));
    }

    /**
     * 新增项目投资方-自然人
     */
    @PreAuthorize("@ss.hasPermi('projectPersion:persion:add')")
    @Log(title = "项目投资方-自然人", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@RequestBody BmProjectPersion bmProjectPersion)
    {
        return toAjax(bmProjectPersionService.insertBmProjectPersion(bmProjectPersion));
    }

    /**
     * 修改项目投资方-自然人
     */
    @PreAuthorize("@ss.hasPermi('projectPersion:persion:edit')")
    @Log(title = "项目投资方-自然人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmProjectPersion bmProjectPersion)
    {
        return toAjax(bmProjectPersionService.updateBmProjectPersion(bmProjectPersion));
    }

    /**
     * 删除项目投资方-自然人
     */
    @PreAuthorize("@ss.hasPermi('projectPersion:persion:remove')")
    @Log(title = "项目投资方-自然人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmProjectPersionService.deleteBmProjectPersionByIds(ids));
    }
}
