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

    <!--
        화면의 모든 컴포넌트 파일 조회
        target_objid 패턴: screen_files:{screenId}:%
        attach_file_info 테이블은 company_code 컬럼 없음 → companyCodeFilter 미적용
    -->
    <select id="selectScreenComponentFiles" parameterType="map" resultType="map">
        SELECT
            OBJID
            , SAVED_FILE_NAME
            , REAL_FILE_NAME
            , FILE_SIZE
            , FILE_EXT
            , FILE_PATH
            , DOC_TYPE
            , DOC_TYPE_NAME
            , TARGET_OBJID
            , PARENT_TARGET_OBJID
            , WRITER
            , CREATED_DATE
            , STATUS
        FROM ATTACH_FILE_INFO
        WHERE TARGET_OBJID LIKE #{target_objid_pattern}
          AND STATUS = 'ACTIVE'
        ORDER BY CREATED_DATE DESC
    </select>

    <!--
        특정 컴포넌트의 파일 목록 조회
        target_objid 패턴: screen_files:{screenId}:{componentId}:%
    -->
    <select id="selectComponentFiles" parameterType="map" resultType="map">
        SELECT
            OBJID
            , SAVED_FILE_NAME
            , REAL_FILE_NAME
            , FILE_SIZE
            , FILE_EXT
            , FILE_PATH
            , DOC_TYPE
            , DOC_TYPE_NAME
            , TARGET_OBJID
            , PARENT_TARGET_OBJID
            , WRITER
            , CREATED_DATE
            , STATUS
        FROM ATTACH_FILE_INFO
        WHERE TARGET_OBJID LIKE #{target_objid_pattern}
          AND STATUS = 'ACTIVE'
        ORDER BY CREATED_DATE DESC
    </select>

</mapper>
