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

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SystemUserDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.*;

/**
 * 用户 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface SystemUserMapper extends BaseMapperX<SystemUserDO> {

    default PageResult<SystemUserDO> selectPage(SystemUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SystemUserDO>()
                .likeIfPresent(SystemUserDO::getName, reqVO.getName())
                .eqIfPresent(SystemUserDO::getSex1, reqVO.getSex1())
                .eqIfPresent(SystemUserDO::getSex2, reqVO.getSex2())
                .eqIfPresent(SystemUserDO::getBirthday, reqVO.getBirthday())
                .betweenIfPresent(SystemUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SystemUserDO::getId));
    }

    default List<SystemUserDO> selectList(SystemUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SystemUserDO>()
                .likeIfPresent(SystemUserDO::getName, reqVO.getName())
                .eqIfPresent(SystemUserDO::getSex1, reqVO.getSex1())
                .eqIfPresent(SystemUserDO::getSex2, reqVO.getSex2())
                .eqIfPresent(SystemUserDO::getBirthday, reqVO.getBirthday())
                .betweenIfPresent(SystemUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SystemUserDO::getId));
    }

}