package cn.iocoder.yudao.module.pms.dal.mysql.app;

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.pms.controller.admin.app.vo.IotAppPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.app.IotAppDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * app版本更新 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotAppMapper extends BaseMapperX<IotAppDO> {

    default PageResult<IotAppDO> selectPage(IotAppPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotAppDO>()
                .eqIfPresent(IotAppDO::getAppVersion, reqVO.getAppVersion())
                .eqIfPresent(IotAppDO::getUrl, reqVO.getUrl())
                .eqIfPresent(IotAppDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotAppDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(IotAppDO::getAppName, reqVO.getAppName())
                .orderByDesc(IotAppDO::getId));
    }

    default IotAppDO selectNew() {
        return selectOne(new LambdaQueryWrapperX<IotAppDO>()
                .orderByDesc(IotAppDO::getCreateTime)
                .last("LIMIT 1"));
    }
}
