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

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.loan.LoanApplicationFj;
import com.ruoyi.system.service.loan.ILoanApplicationFjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.LoanApplicationFjMapper;

/**
 * 贷款申请_附件Service业务层处理
 * 
 * @author boman
 * @date 2024-04-24
 */
@Service
public class LoanApplicationFjServiceImpl implements ILoanApplicationFjService
{
    @Autowired
    private LoanApplicationFjMapper loanApplicationFjMapper;

    /**
     * 查询贷款申请_附件
     * 
     * @param fjId 贷款申请_附件主键
     * @return 贷款申请_附件
     */
    @Override
    public LoanApplicationFj selectLoanApplicationFjByFjId(Long fjId)
    {
        return loanApplicationFjMapper.selectLoanApplicationFjByFjId(fjId);
    }

    /**
     * 查询贷款申请_附件列表
     * 
     * @param loanApplicationFj 贷款申请_附件
     * @return 贷款申请_附件
     */
    @Override
    public List<LoanApplicationFj> selectLoanApplicationFjList(LoanApplicationFj loanApplicationFj)
    {
        return loanApplicationFjMapper.selectLoanApplicationFjList(loanApplicationFj);
    }

    /**
     * 新增贷款申请_附件
     * 
     * @param loanApplicationFj 贷款申请_附件
     * @return 结果
     */
    @Override
    public int insertLoanApplicationFj(List<LoanApplicationFj> loanApplicationFj)
    {
        if (loanApplicationFj != null && loanApplicationFj.size() > 0){
            for (LoanApplicationFj applicationFj : loanApplicationFj) {
                applicationFj.setCreateTime(DateUtils.getNowDate());
            }
        }
        return loanApplicationFjMapper.batchLoanApplicationFj(loanApplicationFj);
    }

    /**
     * 修改贷款申请_附件
     * 
     * @param loanApplicationFj 贷款申请_附件
     * @return 结果
     */
    @Override
    public int updateLoanApplicationFj(List<LoanApplicationFj> loanApplicationFj)
    {
        int i = 0;
        for (LoanApplicationFj applicationFj : loanApplicationFj) {
            applicationFj.setUpdateTime(DateUtils.getNowDate());
            i = loanApplicationFjMapper.updateLoanApplicationFj(applicationFj);

        }
        return i;
    }

    /**
     * 批量删除贷款申请_附件
     * 
     * @param fjIds 需要删除的贷款申请_附件主键
     * @return 结果
     */
    @Override
    public int deleteLoanApplicationFjByFjIds(Long[] fjIds)
    {
        return loanApplicationFjMapper.deleteLoanApplicationFjByFjIds(fjIds);
    }

    /**
     * 删除贷款申请_附件信息
     * 
     * @param fjId 贷款申请_附件主键
     * @return 结果
     */
    @Override
    public int deleteLoanApplicationFjByFjId(Long fjId)
    {
        return loanApplicationFjMapper.deleteLoanApplicationFjByFjId(fjId);
    }

    @Override
    public int deleteLoanApplicationFj(LoanApplicationFj loanApplicationFj) {
        return loanApplicationFjMapper.deleteLoanApplicationFj(loanApplicationFj);
    }

    @Override
    public AjaxResult ewmList(LoanApplicationFj loanApplicationFj) {
        LoanApplicationFj applicationFj = loanApplicationFjMapper.ewmList(loanApplicationFj);
        if(applicationFj==null){
            return AjaxResult.error("请上传文件或保存后扫码查看");
        }
        return AjaxResult.success(applicationFj);
    }
}
