<?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.xrtygis.mapper.RxknowledgeMapper">

    <resultMap id="rxknowledgeMap" type="com.tofly.xrtygis.entity.Rxknowledge">
        <id property="id" column="ID"/>
        <result property="pid" column="PID"/>
        <result property="mid" column="MID"/>
        <result property="title" column="TITLE"/>
        <result property="content" column="CONTENT"/>
        <result property="fileid" column="FILEID"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createDate" column="CREATE_DATE"/>
        <result property="yxbz" column="YXBZ"/>
        <association property="yxbzName" column="YXBZ" select="getYxBzName"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"></association>
        <collection property="fileName" column="FILEID" select="getFileByIds"/>
    </resultMap>
    <resultMap id="fileInfoMap" type="com.tofly.xrtygis.custom.entity.FileInfo">
        <result property="fileName" column="FILE_NAME"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="filePath" column="FILE_PATH"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"/>
    </resultMap>
    <select id="getFileByIds" resultMap="fileInfoMap">
        select FILE_PATH , FILE_NAME , CREATE_USER , CREATE_TIME from TF_YWPN_FILE_W where ID in
        <if test="fileIds != null and fileIds != '' ">
            <foreach collection="fileIds.split(',')" item="id"  open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
    <select id="getYxBzName" resultType="string">
        select decode(#{yxbz}, '1', '启用', '0', '停用')
        from dual
    </select>

</mapper>
