package com.ruoyi.web.controller.projectV2;

import java.util.List;
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.system.domain.projectV2.XmProjectPersion;
import com.ruoyi.system.service.projectV2.IXmProjectPersionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目投资方-自然人Controller
 * 
 * @author ruoyi
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/projectV2/persion")
public class XmProjectPersionController extends BaseController
{
    @Autowired
    private IXmProjectPersionService xmProjectPersionService;

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

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

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

    /**
     * 新增项目投资方-自然人
     */
    @PreAuthorize("@ss.hasPermi('system:persion:add')")
    @Log(title = "项目投资方-自然人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XmProjectPersion xmProjectPersion)
    {
        return toAjax(xmProjectPersionService.insertXmProjectPersion(xmProjectPersion));
    }

    /**
     * 修改项目投资方-自然人
     */
    @PreAuthorize("@ss.hasPermi('system:persion:edit')")
    @Log(title = "项目投资方-自然人", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody XmProjectPersion xmProjectPersion)
    {
        return toAjax(xmProjectPersionService.updateXmProjectPersion(xmProjectPersion));
    }

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

    /**
     * 删除项目投资方-自然人
     */
    @PreAuthorize("@ss.hasPermi('system:persion:remove')")
    @Log(title = "项目投资方-自然人", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable("id") Long id)
    {
        return toAjax(xmProjectPersionService.deleteXmProjectPersionById(id));
    }
}
