package com.ruoyi.system.service.loan.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.loan.ShareholderFj;
import com.ruoyi.system.service.loan.IShareholderFjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ShareholderFjMapper;


/**
 * 全体股东附件Service业务层处理
 * 
 * @author boman
 * @date 2024-04-24
 */
@Service
public class ShareholderFjServiceImpl implements IShareholderFjService
{
    @Autowired
    private ShareholderFjMapper shareholderFjMapper;

    /**
     * 查询全体股东附件
     * 
     * @param shareholderFjId 全体股东附件主键
     * @return 全体股东附件
     */
    @Override
    public ShareholderFj selectShareholderFjByShareholderFjId(Long shareholderFjId)
    {
        return shareholderFjMapper.selectShareholderFjByShareholderFjId(shareholderFjId);
    }

    /**
     * 查询全体股东附件列表
     * 
     * @param shareholderFj 全体股东附件
     * @return 全体股东附件
     */
    @Override
    public List<ShareholderFj> selectShareholderFjList(ShareholderFj shareholderFj)
    {
        return shareholderFjMapper.selectShareholderFjList(shareholderFj);
    }

    @Override
    public List<ShareholderFj> selectShareholderFjListNoPage(ShareholderFj shareholderFj) {
        List<ShareholderFj> shareholderFjs = shareholderFjMapper.selectShareholderFjList(shareholderFj);
        if (shareholderFjs != null && shareholderFjs.size() > 0){
            shareholderFjs = shareholderFjs.stream().filter(e -> StringUtils.isNotEmpty(e.getShareholderBusinessUrl())).collect(Collectors.toList());
        }
        return shareholderFjs;
    }

    /**
     * 新增全体股东附件
     * 
     * @param shareholderFj 全体股东附件
     * @return 结果
     */
    @Override
    public int insertShareholderFj(ShareholderFj shareholderFj)
    {
        shareholderFj.setCreateTime(DateUtils.getNowDate());
        return shareholderFjMapper.insertShareholderFj(shareholderFj);
    }

    /**
     * 修改全体股东附件
     * 
     * @param shareholderFj 全体股东附件
     * @return 结果
     */
    @Override
    public int updateShareholderFj(ShareholderFj shareholderFj)
    {
        shareholderFj.setUpdateTime(DateUtils.getNowDate());
        return shareholderFjMapper.updateShareholderFj(shareholderFj);
    }

    /**
     * 批量删除全体股东附件
     * 
     * @param shareholderFjIds 需要删除的全体股东附件主键
     * @return 结果
     */
    @Override
    public int deleteShareholderFjByShareholderFjIds(Long[] shareholderFjIds)
    {
        return shareholderFjMapper.deleteShareholderFjByShareholderFjIds(shareholderFjIds);
    }

    /**
     * 删除全体股东附件信息
     * 
     * @param shareholderFjId 全体股东附件主键
     * @return 结果
     */
    @Override
    public int deleteShareholderFjByShareholderFjId(Long shareholderFjId)
    {
        return shareholderFjMapper.deleteShareholderFjByShareholderFjId(shareholderFjId);
    }

}
