<?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.tofly.base.mapper.AppMapper">

  <resultMap id="appMap" type="com.tofly.base.entity.App">
                <id property="id" column="ID"/>
      <result property="version" column="VERSION"/>
                      <result property="filename" column="FILENAME"/>
                      <result property="othername" column="OTHERNAME"/>
                      <result property="appPath" column="APP_PATH"/>
                      <result property="versionstate" column="VERSIONSTATE"/>
                      <result property="sort" column="SORT"/>
                      <result property="createTime" column="CREATE_TIME"/>
                      <result property="createUser" column="CREATE_USER"/>
                      <result property="releasetime" column="RELEASETIME"/>
                      <result property="releaser" column="RELEASER"/>
                      <result property="releasestatus" column="RELEASESTATUS"/>
                        <result property="appType" column="APP_TYPE"/>
                        <result property="appSize" column="APP_SIZE"/>
      <result property="versionsub" column="VERSIONSUB"/>
<!--                        <result property="createUserName" column="CREATE_USER_NAME"/>-->
      <association property="releaserName" column="releaser" select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName" />
      <association property="createUserName" column="CREATE_USER" select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName" />
  </resultMap>
    <select id="listAppPage" resultMap="appMap" databaseId="oracle">
        select *
        from TF_SMPN_APP_X
        where
        1=1
        <if test="map.type != null and map.type.trim() != ''">
            and APP_TYPE = #{map.type}
        </if>
        <if test="map.releaseStatus != null and map.releaseStatus.trim() != ''">
            and RELEASESTATUS = #{map.releaseStatus}
        </if>
        <if test="map.startDate != null and map.startDate.trim() != ''">
            and to_char(CREATE_TIME,'yyyy-MM-dd hh:mm:ss') >= #{map.startDate}
        </if>
        <if test="map.endDate != null and map.endDate.trim() != ''">
            <![CDATA[ and to_char(CREATE_TIME,'yyyy-MM-dd hh:mm:ss') <= #{map.endDate}]]>
        </if>
        order by CREATE_TIME desc
    </select>

    <select id="selectOldApp" resultType="com.tofly.base.entity.App" databaseId="oracle">
        select *
        from TF_SMPN_APP_X t
        where t.CREATE_TIME =(select max(CREATE_TIME) from TF_SMPN_APP_X where APP_TYPE = #{type} and RELEASESTATUS = '2')
    </select>

    <select id="getNewVersionInformation" resultType="com.tofly.base.entity.App" databaseId="oracle">
        select *
        from TF_SMPN_APP_X t
        where t.CREATE_TIME =(select max(CREATE_TIME) from TF_SMPN_APP_X where APP_TYPE = #{type} and RELEASESTATUS = '2')
    </select>

</mapper>
