package cn.iocoder.yudao.module.system.dal.mysql.biz;

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.system.controller.admin.biz.vo.VolunteerPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.VolunteerDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface VolunteerMapper extends BaseMapperX<VolunteerDO> {

    default PageResult<VolunteerDO> selectPage(VolunteerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VolunteerDO>()
                .eqIfPresent(VolunteerDO::getVolunteerTeamId, reqVO.getVolunteerTeamId())
                .likeIfPresent(VolunteerDO::getName, reqVO.getName())
                .eqIfPresent(VolunteerDO::getPapersType, reqVO.getPapersType())
                .eqIfPresent(VolunteerDO::getPapersNumber, reqVO.getPapersNumber())
                .eqIfPresent(VolunteerDO::getGender, reqVO.getGender())
                .eqIfPresent(VolunteerDO::getAge, reqVO.getAge())
                .eqIfPresent(VolunteerDO::getTelPhone, reqVO.getTelPhone())
                .eqIfPresent(VolunteerDO::getAddress, reqVO.getAddress())
                .eqIfPresent(VolunteerDO::getProfessionalExpertise, reqVO.getProfessionalExpertise())
                .eqIfPresent(VolunteerDO::getServiceExperience, reqVO.getServiceExperience())
                .eqIfPresent(VolunteerDO::getServiceDuration, reqVO.getServiceDuration())
                .betweenIfPresent(VolunteerDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(VolunteerDO::getOrgType, reqVO.getOrgType())
                .in(VolunteerDO::getTenantId, reqVO.getTenantIds())
                .eq(VolunteerDO::getDeleted, false)
                .orderByDesc(VolunteerDO::getId));
    }

    List<VolunteerDO> selectListPage(@Param("page") Page<VolunteerDO> page,
                                     @Param("pageVO") VolunteerPageReqVO pageReqVO);
}
