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.XmProjectInvestor;
import com.ruoyi.system.service.projectV2.IXmProjectInvestorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目投资方 关联project(一对多关系)Controller
 * 
 * @author ruoyi
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/projectV2/investor")
public class XmProjectInvestorController extends BaseController
{
    @Autowired
    private IXmProjectInvestorService xmProjectInvestorService;

    /**
     * 查询项目投资方 关联project(一对多关系)列表
     */
    @PreAuthorize("@ss.hasPermi('system:investor:list')")
    @GetMapping("/list")
    public TableDataInfo list(XmProjectInvestor xmProjectInvestor)
    {
        startPage();
        List<XmProjectInvestor> list = xmProjectInvestorService.selectXmProjectInvestorList(xmProjectInvestor);
        return getDataTable(list);
    }

    /**
     * 导出项目投资方 关联project(一对多关系)列表
     */
    @PreAuthorize("@ss.hasPermi('system:investor:export')")
    @Log(title = "项目投资方 关联project(一对多关系)", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(XmProjectInvestor xmProjectInvestor)
    {
        List<XmProjectInvestor> list = xmProjectInvestorService.selectXmProjectInvestorList(xmProjectInvestor);
        ExcelUtil<XmProjectInvestor> util = new ExcelUtil<XmProjectInvestor>(XmProjectInvestor.class);
        return util.exportExcel(list, "investor");
    }

    /**
     * 获取项目投资方 关联project(一对多关系)详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:investor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(xmProjectInvestorService.selectXmProjectInvestorById(id));
    }

    /**
     * 新增项目投资方 关联project(一对多关系)
     */
    @PreAuthorize("@ss.hasPermi('system:investor:add')")
    @Log(title = "项目投资方 关联project(一对多关系)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XmProjectInvestor xmProjectInvestor)
    {
        return toAjax(xmProjectInvestorService.insertXmProjectInvestor(xmProjectInvestor));
    }

    /**
     * 修改项目投资方 关联project(一对多关系)
     */
    @PreAuthorize("@ss.hasPermi('system:investor:edit')")
    @Log(title = "项目投资方 关联project(一对多关系)", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody XmProjectInvestor xmProjectInvestor)
    {
        return toAjax(xmProjectInvestorService.updateXmProjectInvestor(xmProjectInvestor));
    }

    /**
     * 删除项目投资方 关联project(一对多关系)
     */
/*    @PreAuthorize("@ss.hasPermi('system:investor:remove')")
    @Log(title = "项目投资方 关联project(一对多关系)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xmProjectInvestorService.deleteXmProjectInvestorByIds(ids));
    }*/

    /**
     * 删除项目投资方 关联project(一对多关系)
     */
    @PreAuthorize("@ss.hasPermi('system:investor:remove')")
    @Log(title = "项目投资方 关联project(一对多关系)", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable("id")Long id)
    {
        return toAjax(xmProjectInvestorService.deleteXmProjectInvestorById(id));
    }
}
