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

import java.util.*;

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 com.yolo.keyboard.dal.dataobject.appversions.AppVersionsDO;
import org.apache.ibatis.annotations.Mapper;
import com.yolo.keyboard.controller.admin.appversions.vo.*;

/**
 * App 版本发布与更新检查表：区分 Android/iOS、渠道，支持最低支持版本与强更策略。 Mapper
 *
 * @author ziin
 */
@Mapper
public interface AppVersionsMapper extends BaseMapperX<AppVersionsDO> {

    default PageResult<AppVersionsDO> selectPage(AppVersionsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AppVersionsDO>()
                .eqIfPresent(AppVersionsDO::getAppId, reqVO.getAppId())
                .eqIfPresent(AppVersionsDO::getPlatform, reqVO.getPlatform())
                .eqIfPresent(AppVersionsDO::getChannel, reqVO.getChannel())
                .likeIfPresent(AppVersionsDO::getVersionName, reqVO.getVersionName())
                .eqIfPresent(AppVersionsDO::getVersionCode, reqVO.getVersionCode())
                .eqIfPresent(AppVersionsDO::getBuildNumber, reqVO.getBuildNumber())
                .eqIfPresent(AppVersionsDO::getMinSupportedCode, reqVO.getMinSupportedCode())
                .betweenIfPresent(AppVersionsDO::getIsForceUpdate, reqVO.getIsForceUpdate())
                .eqIfPresent(AppVersionsDO::getIsActive, reqVO.getIsActive())
                .eqIfPresent(AppVersionsDO::getReleaseNotes, reqVO.getReleaseNotes())
                .eqIfPresent(AppVersionsDO::getDownloadUrl, reqVO.getDownloadUrl())
                .eqIfPresent(AppVersionsDO::getStoreUrl, reqVO.getStoreUrl())
                .eqIfPresent(AppVersionsDO::getMetadata, reqVO.getMetadata())
                .eqIfPresent(AppVersionsDO::getReleasedAt, reqVO.getReleasedAt())
                .eqIfPresent(AppVersionsDO::getCreatedAt, reqVO.getCreatedAt())
                .eqIfPresent(AppVersionsDO::getUpdatedAt, reqVO.getUpdatedAt())
                .orderByDesc(AppVersionsDO::getId));
    }

}