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

import java.util.*;

import com.yolo.keyboard.controller.admin.themes.vo.KeyboardThemesPageReqVO;
import com.yolo.keyboard.dal.dataobject.themes.KeyboardThemesDO;
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 KeyboardThemesMapper extends BaseMapperX<KeyboardThemesDO> {

    default PageResult<KeyboardThemesDO> selectPage(KeyboardThemesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardThemesDO>()
                .likeIfPresent(KeyboardThemesDO::getThemeName, reqVO.getThemeName())
                .eqIfPresent(KeyboardThemesDO::getThemePrice, reqVO.getThemePrice())
                .eqIfPresent(KeyboardThemesDO::getThemeTag, reqVO.getThemeTag())
                .eqIfPresent(KeyboardThemesDO::getThemeDownload, reqVO.getThemeDownload())
                .eqIfPresent(KeyboardThemesDO::getThemeStyle, reqVO.getThemeStyle())
                .eqIfPresent(KeyboardThemesDO::getThemeStatus, reqVO.getThemeStatus())
                .eqIfPresent(KeyboardThemesDO::getThemePurchasesNumber, reqVO.getThemePurchasesNumber())
                .eqIfPresent(KeyboardThemesDO::getCreatedAt, reqVO.getCreatedAt())
                .eqIfPresent(KeyboardThemesDO::getUpdatedAt, reqVO.getUpdatedAt())
                .eqIfPresent(KeyboardThemesDO::getThemePreviewImageUrl, reqVO.getThemePreviewImageUrl())
                .eqIfPresent(KeyboardThemesDO::getIsFree, reqVO.getIsFree())
                .eqIfPresent(KeyboardThemesDO::getThemeDownloadUrl, reqVO.getThemeDownloadUrl())
                .eqIfPresent(KeyboardThemesDO::getSort, reqVO.getSort())
                .eqIfPresent(KeyboardThemesDO::getRealDownloadCount, reqVO.getRealDownloadCount())
                .eqIfPresent(KeyboardThemesDO::getLocal,reqVO.getLocal())
                .orderByDesc(KeyboardThemesDO::getId));
    }

}