<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qmth.themis.business.dao.TBAppVersionMapper">

    <select id="appVersionQuery" resultType="com.qmth.themis.business.entity.TBAppVersion">
        select * from t_b_app_version t
    </select>

    <select id="getMaxAppVersion" resultType="com.qmth.themis.business.entity.TBAppVersion">
        select
        t.*
        from
        t_b_app_version t
        <where>
            EXISTS (
            select
            t1.id
            from
            (
            select
            max(tbav.id) as id
            from
            t_b_app_version tbav
            <where>1 = 1
                <if test="type != null and type != ''">
                    and tbav.type = #{type}
                </if>
                and tbav.enable = 1
            </where>
            ) t1
            where t1.id = t.id)
        </where>
    </select>
</mapper>
