package com.ruoyi.web.controller.loan;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.loan.ShareholderFj;
import com.ruoyi.system.service.loan.IShareholderFjService;
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 boman
 * @date 2024-04-24
 */
@RestController
@RequestMapping("/shareholderFj")
public class ShareholderFjController extends BaseController {
    @Autowired
    private IShareholderFjService shareholderFjService;

    /**
     * 查询全体股东附件列表
     */
    //@PreAuthorize("@ss.hasPermi('system:shareholderFj:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShareholderFj shareholderFj) {
        startPage();
        List<ShareholderFj> list = shareholderFjService.selectShareholderFjList(shareholderFj);
        return getDataTable(list);
    }

    /**
     * 只查询股东是企业的
     * @param shareholderFj
     * @return
     */
    @PreAuthorize("@ss.hasPermi('system:shareholderFj:listNoPage')")
    @GetMapping("/listNoPage")
    public AjaxResult listNoPage(ShareholderFj shareholderFj) {
        List<ShareholderFj> list = shareholderFjService.selectShareholderFjListNoPage(shareholderFj);
        return AjaxResult.success(list);
    }

    /**
     * 导出全体股东附件列表
     */
    @PreAuthorize("@ss.hasPermi('system:shareholderFj:export')")
    @Log(title = "全体股东附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShareholderFj shareholderFj) {
        List<ShareholderFj> list = shareholderFjService.selectShareholderFjList(shareholderFj);
        ExcelUtil<ShareholderFj> util = new ExcelUtil<ShareholderFj>(ShareholderFj.class);
        util.exportExcel(response, list, "全体股东附件数据");
    }

    /**
     * 获取全体股东附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shareholderFj:query')")
    @GetMapping(value = "/{shareholderFjId}")
    public AjaxResult getInfo(@PathVariable("shareholderFjId") Long shareholderFjId) {
        return success(shareholderFjService.selectShareholderFjByShareholderFjId(shareholderFjId));
    }

    /**
     * 新增全体股东附件
     */
    @PreAuthorize("@ss.hasPermi('system:shareholderFj:add')")
    @Log(title = "全体股东附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShareholderFj shareholderFj) {
        return toAjax(shareholderFjService.insertShareholderFj(shareholderFj));
    }

    /**
     * 修改全体股东附件
     */
    @PreAuthorize("@ss.hasPermi('system:shareholderFj:edit')")
    @Log(title = "全体股东附件", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ShareholderFj shareholderFj) {
        return toAjax(shareholderFjService.updateShareholderFj(shareholderFj));
    }

    /**
     * 删除全体股东附件
     */
    @PreAuthorize("@ss.hasPermi('system:shareholderFj:remove')")
    @Log(title = "全体股东附件", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{shareholderFjIds}")
    public AjaxResult remove(@PathVariable Long[] shareholderFjIds) {
        return toAjax(shareholderFjService.deleteShareholderFjByShareholderFjIds(shareholderFjIds));
    }

}
