package cn.iocoder.yudao.module.order.dal.mysql.batchOrderFeeApply;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.module.order.dal.dataobject.batchOrderFeeApply.BatchOrderFeeApplyDO;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.order.vo.batchOrderFeeApply.*;
import org.apache.ibatis.annotations.Param;

/**
 * 批量费用申请 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface BatchOrderFeeApplyMapper extends AbstractMapper<BatchOrderFeeApplyDO> {
    @Override
    default PageResult<BatchOrderFeeApplyDO> selectPage(PageVO page, Object object) {
        if (object instanceof BatchOrderFeeApplyQueryVO) {
            BatchOrderFeeApplyQueryVO vo = (BatchOrderFeeApplyQueryVO) object;
            return selectPage(page, new LambdaQuery<BatchOrderFeeApplyDO>()
                    .likeIfPresent(BatchOrderFeeApplyDO::getNo, vo.getNo())
                    .eqIfPresent(BatchOrderFeeApplyDO::getState, vo.getState())
                    .inIfPresent(BatchOrderFeeApplyDO::getCreator, vo.getApplicantList())
                    .betweenIfPresent(BatchOrderFeeApplyDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(BatchOrderFeeApplyDO::getId));
        }

        return null;
    }

    @Override
    default List<BatchOrderFeeApplyDO> selectList(Object object) {
        if (object instanceof BatchOrderFeeApplyQueryVO) {
            BatchOrderFeeApplyQueryVO vo = (BatchOrderFeeApplyQueryVO) object;
            return selectList(new LambdaQuery<BatchOrderFeeApplyDO>()
                    .likeIfPresent(BatchOrderFeeApplyDO::getNo, vo.getNo())
                    .eqIfPresent(BatchOrderFeeApplyDO::getState, vo.getState())
                    .inIfPresent(BatchOrderFeeApplyDO::getCreator, vo.getApplicantList())
                    .betweenIfPresent(BatchOrderFeeApplyDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(BatchOrderFeeApplyDO::getId));
        }

        return null;
    }

    long batchOrderFeeApplyCount(@Param("query") BatchOrderFeeApplyQueryVO query);

    List<BatchOrderFeeApplyBackVO> batchOrderFeeApplyList(@Param("start") int start, @Param("size") int size, @Param("query") BatchOrderFeeApplyQueryVO query);
}
