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

    <select id="selectListMedicalBoardCount" parameterType="hashmap" resultType="hashmap">
        SELECT COUNT(*)  AS "totalCount"
        FROM MU_APP_BOARD AS MAB
        WHERE MAB.USE_YN = 'Y'
        <if test="exposedYn != null and exposedYn != ''">
            AND MAB.EXPOSED_YN= #{exposedYn}
        </if>
    </select>

    <select id="selectListMedicalBoard" parameterType="hashmap" resultType="hashmap">
       SELECT MAB.MU_APP_BOARD_ID                     AS "muAppBoardId"
             ,MAB.TITLE                               AS "boardTitle"
             ,MAB.CONTENT                             AS "boardContent"
             ,MAB.EXPOSED_YN                          AS "exposedYn"
             ,MBC.MU_BOARD_CONTENT_ID                 AS "muBoardContentId"
             ,MBC.MU_APP_CONTENT_ID                   AS "muAppContentId"
             ,MBC.TITLE                               AS "title"
             ,MBC.CONTENT                             AS "content"
             ,MBC.FILE_PATH                           AS "filePath"
             ,MBC.FILE_NAME                           AS "fileName"
             ,MBC.ORIGINAL_FILE_NAME                  AS "originalFileName"
             ,MBC.FILE_PATH2                           AS "filePath2"
             ,MBC.FILE_NAME2                           AS "fileName2"
             ,MBC.ORIGINAL_FILE_NAME2                  AS "originalFileName2"
             ,MBC.CATEGORY_NAME                       AS "appContentCategoryName"
             ,DATE_FORMAT(MBC.CONTENT_WRITE_DATE, '%Y-%m-%d') AS "writeDate"
         FROM MU_APP_BOARD MAB
         JOIN MU_BOARD_CONTENT MBC
           ON MAB.MU_APP_BOARD_ID = MBC.MU_APP_BOARD_ID
          AND MBC.USE_YN='Y'
        WHERE MAB.USE_YN        = 'Y'
        <if test="exposedYn != null and exposedYn != ''">
          AND MAB.EXPOSED_YN= #{exposedYn}
        </if>
     ORDER BY MAB.WRITE_DATE DESC
             ,MAB.WRITE_TIME DESC
             ,MBC.WRITE_DATE DESC
             ,MBC.WRITE_TIME DESC
             ,MBC.MU_APP_CONTENT_ID ASC
    </select>

    <select id="selectListMedical" parameterType="hashmap" resultType="hashmap">
        SELECT MAC.MU_APP_CONTENT_ID                    AS "muAppContentId"
              ,MAC.TITLE                                AS "title"
              ,MAC.CONTENT                              AS "content"
              ,MAC.FILE_PATH						    AS "filePath"
              ,MAC.FILE_NAME						    AS "fileName"
              ,MAC.ORIGINAL_FILE_NAME				    AS "originalFileName"
              ,MAC.FILE_PATH2						    AS "filePath2"
              ,MAC.FILE_NAME2						    AS "fileName2"
              ,MAC.ORIGINAL_FILE_NAME2				    AS "originalFileName2"
              ,MAC.CATEGORY_NAME                        AS "appContentCategoryName"
          FROM MU_APP_CONTENT   AS MAC
         WHERE MAC.USE_YN        = 'Y'
           AND MAC.CATEGORY_CODE  = #{categoryCode}
      ORDER BY MAC.WRITE_DATE DESC
              ,MAC.WRITE_TIME DESC
    </select>

    <select id="selectMedical" parameterType="hashmap" resultType="hashmap">
        SELECT MAC.MU_APP_CONTENT_ID                    AS "muAppContentId"
             , MAC.TITLE                                AS "title"
             , MAC.CONTENT                              AS "content"
             , MAC.DETAIL                               AS "detail"
             , MAC.FILE_PATH						    AS "filePath"
             , MAC.FILE_NAME						    AS "fileName"
             , MAC.ORIGINAL_FILE_NAME				    AS "originalFileName"
             , MAC.CATEGORY_NAME                        AS "appContentCategoryName"
          FROM MU_APP_CONTENT   AS MAC
         WHERE MAC.USE_YN        = 'Y'
           AND MAC.MU_APP_CONTENT_ID  = #{muAppContentId}
         LIMIT 0, 1
    </select>
</mapper>