package com.yolo.keyboard.dal.mysql.user;



import com.yolo.keyboard.dal.dataobject.user.KeyboardUserDO;
import com.yolo.keyboard.controller.admin.user.vo.KeyboardUserPageReqVO;
import com.yolo.keyboard.framework.common.pojo.PageResult;
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;

/**
 * 键盘用户 Mapper
 *
 * @author ziin
 */
@Mapper
public interface KeyboardUserMapper extends BaseMapperX<KeyboardUserDO> {

    default PageResult<KeyboardUserDO> selectPage(KeyboardUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardUserDO>()
                .eqIfPresent(KeyboardUserDO::getUid, reqVO.getUid())
                .likeIfPresent(KeyboardUserDO::getNickName, reqVO.getNickName())
                .eqIfPresent(KeyboardUserDO::getGender, reqVO.getGender())
                .eqIfPresent(KeyboardUserDO::getAvatarUrl, reqVO.getAvatarUrl())
                .eqIfPresent(KeyboardUserDO::getCreatedAt, reqVO.getCreatedAt())
                .eqIfPresent(KeyboardUserDO::getUpdatedAt, reqVO.getUpdatedAt())
                .eqIfPresent(KeyboardUserDO::getEmail, reqVO.getEmail())
                .eqIfPresent(KeyboardUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(KeyboardUserDO::getPassword, reqVO.getPassword())
                .eqIfPresent(KeyboardUserDO::getSubjectId, reqVO.getSubjectId())
                .eqIfPresent(KeyboardUserDO::getEmailVerified, reqVO.getEmailVerified())
                .eqIfPresent(KeyboardUserDO::getIsVip, reqVO.getIsVip())
                .eqIfPresent(KeyboardUserDO::getVipExpiry, reqVO.getVipExpiry())
                .orderByDesc(KeyboardUserDO::getId));
    }

}