package com.ruoyi.web.controller.project;

import java.util.List;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.project.BmProjectShareholder;
import com.ruoyi.system.service.project.IBmProjectShareholderService;
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-12-20
 */
@RestController
@RequestMapping("/projectShareholder/shareholder")
public class BmProjectShareholderController extends BaseController
{
    @Autowired
    private IBmProjectShareholderService bmProjectShareholderService;

    /**
     * 查询签约信息-添加股东构成列表
     */
    @PreAuthorize("@ss.hasPermi('projectShareholder:shareholder:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmProjectShareholder bmProjectShareholder)
    {
        startPage();
        List<BmProjectShareholder> list = bmProjectShareholderService.selectBmProjectShareholderList(bmProjectShareholder);
        return getDataTable(list);
    }

    /**
     * 导出签约信息-添加股东构成列表
     */
    @PreAuthorize("@ss.hasPermi('projectShareholder:shareholder:export')")
    @Log(title = "签约信息-添加股东构成", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmProjectShareholder bmProjectShareholder)
    {
        List<BmProjectShareholder> list = bmProjectShareholderService.selectBmProjectShareholderList(bmProjectShareholder);
        ExcelUtil<BmProjectShareholder> util = new ExcelUtil<BmProjectShareholder>(BmProjectShareholder.class);
        return util.exportExcel(list, "shareholder");
    }

    /**
     * 获取签约信息-添加股东构成详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectShareholder:shareholder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bmProjectShareholderService.selectBmProjectShareholderById(id));
    }

    /**
     * 新增签约信息-添加股东构成
     */
    @PreAuthorize("@ss.hasPermi('projectShareholder:shareholder:add')")
    @Log(title = "签约信息-添加股东构成", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmProjectShareholder bmProjectShareholder)
    {
        return toAjax(bmProjectShareholderService.insertBmProjectShareholder(bmProjectShareholder));
    }

    /**
     * 修改签约信息-添加股东构成
     */
    @PreAuthorize("@ss.hasPermi('projectShareholder:shareholder:edit')")
    @Log(title = "签约信息-添加股东构成", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmProjectShareholder bmProjectShareholder)
    {
        return toAjax(bmProjectShareholderService.updateBmProjectShareholder(bmProjectShareholder));
    }

    /**
     * 删除签约信息-添加股东构成
     */
    @PreAuthorize("@ss.hasPermi('projectShareholder:shareholder:remove')")
    @Log(title = "签约信息-添加股东构成", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmProjectShareholderService.deleteBmProjectShareholderByIds(ids));
    }
}
