<?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="MobileEvent">

    <select id="selectListEventCount" parameterType="hashmap" resultType="hashmap">
        SELECT COUNT(*)  AS "totalCount"
          FROM MU_APP_EVENT AS ME
         WHERE ME.USE_YN = 'Y'
    </select>

    <select id="selectListEvent" parameterType="hashmap" resultType="hashmap">
        SELECT MAE.MU_APP_EVENT_ID                        AS "muAppEventId"
              ,MAE.TITLE                                  AS "title"
              ,MAE.CONTENT                                AS "content"
              ,FILE_PATH                                  AS "filePath"
              ,FILE_NAME                                  AS "fileName"
              ,ORIGINAL_FILE_NAME                         AS "originalFileName"
              ,DATEDIFF(MAE.EVENT_END_DATE, CURDATE())    AS "daysRemaining"
          FROM MU_APP_EVENT MAE
         WHERE MAE.USE_YN = 'Y'
           <if test="exposedYn != null and exposedYn != ''">
           AND MAE.EXPOSED_YN= #{exposedYn}
           </if>
      ORDER BY MAE.WRITE_DATE DESC
              ,MAE.WRITE_TIME DESC
    </select>

    <select id="selectEvent" parameterType="hashmap" resultType="hashmap">
        SELECT MAE.MU_APP_EVENT_ID                              AS "muAppEventId"
             ,MAE.TITLE                                         AS "title"
             ,MAE.CONTENT                                       AS "content"
             ,MAE.DETAIL                                        AS "detail"
             ,MAE.FILE_PATH						                AS "filePath"
             ,MAE.FILE_NAME						                AS "fileName"
             ,MAE.ORIGINAL_FILE_NAME				            AS "originalFileName"
             ,DATE_FORMAT(MAE.EVENT_START_DATE, '%Y-%m-%d')		AS "eventStartDate"
             ,DATE_FORMAT(MAE.EVENT_END_DATE, '%Y-%m-%d')		AS "eventEndDate"
             ,MAE.EXPOSED_YN                                  AS "exposedYn"
          FROM MU_APP_EVENT AS MAE
         WHERE MAE.USE_YN        = 'Y'
           AND MAE.MU_APP_EVENT_ID  = #{muAppEventId}
         LIMIT 0, 1
    </select>
</mapper>