package cn.iocoder.yudao.module.expense.dal.mysql.expenseinfo;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.expense.controller.admin.expenseinfo.vo.ExpenseInfoPageReqVO;
import cn.iocoder.yudao.module.expense.controller.admin.expenseinfo.vo.ExpenseInfoRespVO;
import cn.iocoder.yudao.module.expense.dal.dataobject.expenseinfo.ExpenseInfoDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 报销信息 Mapper
 *
 * @author dp
 */
@Mapper
public interface ExpenseInfoMapper extends BaseMapperX<ExpenseInfoDO> {

    default PageResult<ExpenseInfoDO> selectPage(ExpenseInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExpenseInfoDO>()
                .likeIfPresent(ExpenseInfoDO::getEmployeeName, reqVO.getEmployeeName())
                .eqIfPresent(ExpenseInfoDO::getEmployeePhone, reqVO.getEmployeePhone())
                .eqIfPresent(ExpenseInfoDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(ExpenseInfoDO::getPostId, reqVO.getPostId())
                .eqIfPresent(ExpenseInfoDO::getExpenseTypeId, reqVO.getExpenseTypeId())
                .eqIfPresent(ExpenseInfoDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(ExpenseInfoDO::getInfoSource, reqVO.getInfoSource())
                .betweenIfPresent(ExpenseInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ExpenseInfoDO::getId));
    }

    long selectPageCount(@Param("page") ExpenseInfoPageReqVO pageReqVO);

    List<ExpenseInfoRespVO> selectPageList(@Param("page") ExpenseInfoPageReqVO pageReqVO);
}