<?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.trade.service.filestorage.mapper.BusinessRelateFileMapper">

    <resultMap type="com.trade.service.filestorage.entity.BusinessRelateFile" id="BusinessRelateFileMap">
        <result property="id" column="id"/>
        <result property="belongId" column="belong_id"/>
        <result property="belongType" column="belong_type"/>
        <result property="fileType" column="file_type"/>
        <result property="fileId" column="file_id"/>
        <result property="deleted" column="deleted"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="gmtCreate" column="gmt_create"/>
        <result property="gmtModified" column="gmt_modified"/>
    </resultMap>

    <sql id="Base_Column_List">
        `id` , `belong_id`, `belong_type`, `file_type`, `file_id`, `deleted`, `create_by`, `update_by`, `gmt_create`, `gmt_modified`
    </sql>

    <select id="selectByCondition" resultMap="BusinessRelateFileMap">
        select
        <include refid="Base_Column_List"/>
        from business_relate_file
        where belong_id = #{belongId} and belong_type = #{belongType}
        and file_type = #{belongType} and deleted = 0
        order by id desc limit 1
    </select>
</mapper>

