package com.ruoyi.web.controller.project;

import java.util.List;

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

/**
 * 注册企业股东构成Controller
 * 
 * @author ruoyi
 * @date 2021-03-05
 */
@RestController
@RequestMapping("/shareholder/shareholder")
public class BmCompanyShareholderController extends BaseController
{
    @Autowired
    private IBmCompanyShareholderService bmCompanyShareholderService;

    /**
     * 查询注册企业股东构成列表
     */
    @PreAuthorize("@ss.hasPermi('shareholder:shareholder:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmCompanyShareholder bmCompanyShareholder)
    {
        startPage();
        List<BmCompanyShareholder> list = bmCompanyShareholderService.selectBmCompanyShareholderList(bmCompanyShareholder);
        return getDataTable(list);
    }

    /**
     * 导出注册企业股东构成列表
     */
    @PreAuthorize("@ss.hasPermi('shareholder:shareholder:export')")
    @Log(title = "注册企业股东构成", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmCompanyShareholder bmCompanyShareholder)
    {
        List<BmCompanyShareholder> list = bmCompanyShareholderService.selectBmCompanyShareholderList(bmCompanyShareholder);
        ExcelUtil<BmCompanyShareholder> util = new ExcelUtil<BmCompanyShareholder>(BmCompanyShareholder.class);
        return util.exportExcel(list, "shareholder");
    }

    /**
     * 获取注册企业股东构成详细信息
     */
    @PreAuthorize("@ss.hasPermi('shareholder:shareholder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bmCompanyShareholderService.selectBmCompanyShareholderById(id));
    }

    /**
     * 新增注册企业股东构成
     */
    @PreAuthorize("@ss.hasPermi('shareholder:shareholder:add')")
    @Log(title = "注册企业股东构成", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmCompanyShareholder bmCompanyShareholder)
    {
        return toAjax(bmCompanyShareholderService.insertBmCompanyShareholder(bmCompanyShareholder));
    }

    /**
     * 修改注册企业股东构成
     */
    @PreAuthorize("@ss.hasPermi('shareholder:shareholder:edit')")
    @Log(title = "注册企业股东构成", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmCompanyShareholder bmCompanyShareholder)
    {
        return toAjax(bmCompanyShareholderService.updateBmCompanyShareholder(bmCompanyShareholder));
    }

    /**
     * 删除注册企业股东构成
     */
    @PreAuthorize("@ss.hasPermi('shareholder:shareholder:remove')")
    @Log(title = "注册企业股东构成", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bmCompanyShareholderService.deleteBmCompanyShareholderByIds(ids));
    }
}
