<?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="cn.com.countrygarden.bi.main.dao.VersionMapper">
    <resultMap id="VersionResultMap" type="cn.com.countrygarden.bi.main.model.Version">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="platform" jdbcType="VARCHAR" property="platform"/>
        <result column="version" jdbcType="INTEGER" property="version"/>
        <result column="version_name" jdbcType="VARCHAR" property="versionName"/>
        <result column="version_memo" jdbcType="VARCHAR" property="versionMemo"/>
        <result column="android" jdbcType="VARCHAR" property="android"/>
        <result column="ios" jdbcType="VARCHAR" property="ios"/>
        <result column="is_deleted" jdbcType="VARCHAR" property="isDeleted"/>
    </resultMap>

    <sql id="selectVersionAll">
    <![CDATA[
            SELECT v.id, v.platform, v.version, v.version_name, v.version_memo, v.android, v.ios
            FROM version AS v
        ]]>
    </sql>

    <select id="getLatestVersion" parameterType="string" resultMap="VersionResultMap">
        <include refid="selectVersionAll" />
        <![CDATA[
          WHERE v.is_delete = 0 AND v.platform = #{platform}
          ORDER BY v.version DESC
          LIMIT 1
        ]]>
    </select>
</mapper>