<?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.ruoyi.frequency.klkaccounattach.mapper.KlkAccountAttachMapper">

    <resultMap type="com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach" id="KlkAccountAttachResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="lakalaAccountId"    column="lakala_account_id"    />
        <result property="attachName"    column="attach_name"    />
        <result property="attachStorePath"    column="attach_store_path"    />
        <result property="httpPath"    column="http_path"    />
        <result property="attachType"    column="attach_type"    />
        </resultMap>

    
    
    <sql id="selectKlkAccountAttachVo">
        select
            t.id ,
            t.del_flag ,
            t.create_by ,
            t.create_time ,
            t.update_by ,
            t.update_time ,
            t.lakala_account_id ,
            t.attach_name ,
            t.attach_store_path ,
            t.http_path ,
            t.attach_type 
        from t_klk_account_attach AS t
                
    </sql>

    <select id="selectKlkAccountAttachList" parameterType="com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach" resultMap="KlkAccountAttachResult">
        <include refid="selectKlkAccountAttachVo"/>
        <where> AND t.del_flag != 2
            <if test="lakalaAccountId != null "> and t.lakala_account_id = #{lakalaAccountId}</if>
            <if test="attachName != null  and attachName != ''"> and t.attach_name like concat('%', #{attachName}, '%')</if>
            <if test="attachStorePath != null  and attachStorePath != ''"> and t.attach_store_path = #{attachStorePath}</if>
            <if test="httpPath != null  and httpPath != ''"> and t.http_path = #{httpPath}</if>
            <if test="attachType != null  and attachType != ''"> and t.attach_type = #{attachType}</if>
            <if test="delFlag != null and delFlag != ''"> and t.del_flag = #{delFlag}</if>
        </where>
        order by t.create_time desc
    </select>

    <select id="selectKlkAccountAttachById" parameterType="Long" resultMap="KlkAccountAttachResult">
        <include refid="selectKlkAccountAttachVo"/>
        where t.id = #{id}
    </select>

    <insert id="insertKlkAccountAttach" parameterType="com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach">
        insert into t_klk_account_attach
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="lakalaAccountId != null">lakala_account_id,</if>
            <if test="attachName != null">attach_name,</if>
            <if test="attachStorePath != null">attach_store_path,</if>
            <if test="httpPath != null">http_path,</if>
            <if test="attachType != null">attach_type,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="lakalaAccountId != null">#{lakalaAccountId},</if>
            <if test="attachName != null">#{attachName},</if>
            <if test="attachStorePath != null">#{attachStorePath},</if>
            <if test="httpPath != null">#{httpPath},</if>
            <if test="attachType != null">#{attachType},</if>
        </trim>
    </insert>

    <update id="updateKlkAccountAttach" parameterType="com.ruoyi.frequency.klkaccounattach.entity.KlkAccountAttach">
        update t_klk_account_attach
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="lakalaAccountId != null">lakala_account_id = #{lakalaAccountId},</if>
            <if test="attachName != null">attach_name = #{attachName},</if>
            <if test="attachStorePath != null">attach_store_path = #{attachStorePath},</if>
            <if test="httpPath != null">http_path = #{httpPath},</if>
            <if test="attachType != null">attach_type = #{attachType},</if>
        </trim>
        where id = #{id}
    </update>
                                                                                                                        </mapper>