package com.fjhx.account.service.account.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.account.entity.account.dto.AccountRequestFundsDetailDto;
import com.fjhx.account.entity.account.dto.AccountRequestFundsDetailSelectDto;
import com.fjhx.account.entity.account.po.AccountRequestFundsDetail;
import com.fjhx.account.entity.account.vo.AccountRequestFundsDetailVo;
import com.fjhx.account.mapper.account.AccountRequestFundsDetailMapper;
import com.fjhx.account.service.account.AccountRequestFundsDetailService;
import com.ruoyi.common.utils.wrapper.IWrapper;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author
 * @since 2023-04-10
 */
@Service
public class AccountRequestFundsDetailServiceImpl extends ServiceImpl<AccountRequestFundsDetailMapper, AccountRequestFundsDetail> implements AccountRequestFundsDetailService {

    @Override
    public Page<AccountRequestFundsDetailVo> getPage(AccountRequestFundsDetailSelectDto dto) {
        IWrapper<AccountRequestFundsDetail> wrapper = getWrapper();
        wrapper.orderByDesc("arfd", AccountRequestFundsDetail::getId);
        Page<AccountRequestFundsDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

    @Override
    public AccountRequestFundsDetailVo detail(Long id) {
        AccountRequestFundsDetail AccountRequestFundsDetail = this.getById(id);
        AccountRequestFundsDetailVo result = BeanUtil.toBean(AccountRequestFundsDetail, AccountRequestFundsDetailVo.class);
        return result;
    }

    @Override
    public void add(AccountRequestFundsDetailDto accountRequestFundsDetailDto) {
        this.save(accountRequestFundsDetailDto);
    }

    @Override
    public void edit(AccountRequestFundsDetailDto accountRequestFundsDetailDto) {
        this.updateById(accountRequestFundsDetailDto);
    }

    @Override
    public void delete(Long id) {
        this.removeById(id);
    }

    /**
     * 获取列表根据合同ID
     *
     * @param contractId
     * @return
     */
    @Override
    public List<AccountRequestFundsDetailVo> getListByContractId(Long contractId) {
        return baseMapper.getListByContractId(contractId);
    }

    /**
     * 获取列表根据合同ID集合
     *
     * @param contractIds
     * @return
     */
    @Override
    public List<AccountRequestFundsDetailVo> getListByContractIds(List<Long> contractIds) {
        return baseMapper.getListByContractIds(contractIds);
    }

    /**
     * 获取到请款明细信息
     *
     * @param eq
     * @return
     */
    @Override
    public List<AccountRequestFundsDetail> getList(LambdaQueryWrapper<AccountRequestFundsDetail> eq) {
        return baseMapper.getList(eq);
    }

    @Override
    public List<AccountRequestFundsDetailVo> listByAccountRequestFundsId(Long accountRequestFundsId) {
        return baseMapper.listByAccountRequestFundsId(accountRequestFundsId);
    }

}
