<?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.hssx.pcbms.mapper.InstitutionMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hssx.pcbms.entity.Institution">
        <id column="id" property="id" />
        <result column="title" property="title" />
        <result column="content" property="content" />
        <result column="indate" property="indate" />
    </resultMap>
    <resultMap id="BaseResultMapVO" type="com.hssx.pcbms.entity.vo.InstitutionVO">
        <id column="id" property="id" />
        <result column="title" property="title" />
        <result column="content" property="content" />
        <result column="indate" property="indate" />
        <collection property="institutionFiles" ofType="com.hssx.pcbms.entity.InstitutionFile">
            <result column="name" property="name" />
            <result column="url" property="url" />
        </collection>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, title, content, indate
    </sql>

    <select id="getDetail" resultMap="BaseResultMapVO">
        select i.id, i.title, i.content, i.indate,isf.name,isf.url
            from institution i
            left join institution_file isf
            on i.id = isf.institution_id
            where i.id = #{institution.id}
    </select>
</mapper>
