<?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.fateverse.query.mapper.DynamicEchartsMapper">

    <resultMap id="DynamicEchartsResult" type="cn.fateverse.query.entity.DynamicEcharts">
        <id column="echarts_id" property="echartsId"/>
        <result column="adapter_id" property="adapterId"/>
        <result column="echarts_name" property="echartsName"/>
        <result column="echarts_config" property="echartsConfig"/>
        <result column="publish" property="publish"/>
        <result column="remark" property="remark"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="selectDynamicEchartsVo">
        select echarts_id, adapter_id, echarts_name, echarts_config, publish, remark, create_by, create_time, update_by, update_time        from dynamic_echarts
    </sql>



    <select id="selectList" resultMap="DynamicEchartsResult">
        <include refid="selectDynamicEchartsVo"/>
        <where>
            <if test="echartsName != null  and echartsName != ''"> and echarts_name like concat('%', #{echartsName}, '%')</if>
            <if test="publish != null "> and publish = #{publish}</if>
        </where>
    </select>

    <select id="selectById" resultMap="DynamicEchartsResult">
        <include refid="selectDynamicEchartsVo"/>
        where echarts_id = #{echartsId}
    </select>

    <insert id="insert" >
        insert into dynamic_echarts
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="adapterId != null">adapter_id,</if>
            <if test="echartsName != null">echarts_name,</if>
            <if test="echartsConfig != null">echarts_config,</if>
            <if test="publish != null">publish,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null ">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="adapterId != null">#{adapterId},</if>
            <if test="echartsName != null">#{echartsName},</if>
            <if test="echartsConfig != null">#{echartsConfig},</if>
            <if test="publish != null">#{publish},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
        </trim>
    </insert>
    
    <update id="update">
        update dynamic_echarts
        <set>
            <if test="adapterId != null">adapter_id = #{adapterId},</if>
            <if test="echartsName != null">echarts_name = #{echartsName},</if>
            <if test="echartsConfig != null">echarts_config = #{echartsConfig},</if>
            <if test="publish != null">publish = #{publish},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null ">update_time = #{updateTime},</if>
        </set>
        where echarts_id = #{echartsId}
    </update>

    <delete id="deleteById">
        delete from dynamic_echarts
        where echarts_id = #{echartsId}
    </delete>

    <delete id="deleteBatchByIdList" parameterType="Long">
        delete from dynamic_echarts
        where echarts_id in
        <foreach collection="list" open="(" close=")" separator="," item="echartsId">
            #{echartsId}
        </foreach>
    </delete>

</mapper>