<?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="cn.iocoder.yudao.module.knowledge.mapper.RRfeuTaskFileMapper">

    <resultMap type="cn.iocoder.yudao.module.knowledge.entity.RRfeuTaskFile" id="rRfeuTaskFileMap">
            <result property="id" column="id"/>
            <result property="rRfeuTaskContentId" column="r_rfeu_task_content_id"/>
            <result property="fileName" column="file_name"/>
            <result property="fileUrl" column="file_url"/>
            <result property="tenantId" column="tenant_id"/>
            <result property="creator" column="creator"/>
            <result property="creatorId" column="creator_id"/>
            <result property="createTime" column="create_time"/>
            <result property="updateTime" column="update_time"/>
            <result property="deptId" column="dept_id"/>
            <result property="identityId" column="identity_id"/>
            <result property="fileSize" column="file_size"/>
    </resultMap>

    <!-- 用于select查询公用抽取的列 -->
    <sql id="columns">
        id,r_rfeu_task_content_id,file_name,file_url,tenant_id,creator,creator_id,create_time,update_time,dept_id,identity_id,file_size
    </sql>
    <select id="findList" resultMap="rRfeuTaskFileMap">
        select
        <include refid="columns"/>
        from r_rfeu_task_file
        <where>
                    <if test="id != null">
                        id = #{id}
                    </if>
                    <if test="rRfeuTaskContentId != null">
                        r_rfeu_task_content_id = #{rRfeuTaskContentId}
                    </if>
                    <if test="fileName != null and fileName != ''">
                            file_name = #{fileName}
                    </if>
                    <if test="fileUrl != null and fileUrl != ''">
                            file_url = #{fileUrl}
                    </if>
                    <if test="tenantId != null">
                        tenant_id = #{tenantId}
                    </if>
                    <if test="creator != null and creator != ''">
                            creator = #{creator}
                    </if>
                    <if test="creatorId != null and creatorId != ''">
                            creator_id = #{creatorId}
                    </if>
                    <if test="createTime != null">
                        create_time = #{createTime}
                    </if>
                    <if test="updateTime != null">
                        update_time = #{updateTime}
                    </if>
                    <if test="deptId != null and deptId != ''">
                            dept_id = #{deptId}
                    </if>
                    <if test="identityId != null and identityId != ''">
                            identity_id = #{identityId}
                    </if>
                    <if test="fileSize != null">
                        file_size = #{fileSize}
                    </if>
        </where>
    </select>

    <delete id="deleteByTaskContentId">
        delete from r_rfeu_task_file where r_rfeu_task_content_id = #{id}
    </delete>

    <select id="selectByTaskContentId" parameterType="long" resultMap="rRfeuTaskFileMap">
        select * from r_rfeu_task_file where r_rfeu_task_content_id = #{id}
    </select>
</mapper>
