<?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.fs.aiob.mapper.AiobBaiduCallApiMapper">
    
    <resultMap type="AiobBaiduCallApi" id="AiobBaiduCallApiResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="accessKey"    column="access_key"    />
        <result property="secretKey"    column="secret_key"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectAiobBaiduCallApiVo">
        select id, name, access_key, secret_key, create_time, create_by, update_by, update_time, remark from aiob_baidu_call_api
    </sql>

    <select id="selectAiobBaiduCallApiList" parameterType="AiobBaiduCallApi" resultMap="AiobBaiduCallApiResult">
        <include refid="selectAiobBaiduCallApiVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="accessKey != null  and accessKey != ''"> and access_key = #{accessKey}</if>
            <if test="secretKey != null  and secretKey != ''"> and secret_key = #{secretKey}</if>
        </where>
    </select>
    
    <select id="selectAiobBaiduCallApiById" parameterType="Long" resultMap="AiobBaiduCallApiResult">
        <include refid="selectAiobBaiduCallApiVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAiobBaiduCallApi" parameterType="AiobBaiduCallApi" useGeneratedKeys="true" keyProperty="id">
        insert into aiob_baidu_call_api
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="accessKey != null">access_key,</if>
            <if test="secretKey != null">secret_key,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="accessKey != null">#{accessKey},</if>
            <if test="secretKey != null">#{secretKey},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateAiobBaiduCallApi" parameterType="AiobBaiduCallApi">
        update aiob_baidu_call_api
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="accessKey != null">access_key = #{accessKey},</if>
            <if test="secretKey != null">secret_key = #{secretKey},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAiobBaiduCallApiById" parameterType="Long">
        delete from aiob_baidu_call_api where id = #{id}
    </delete>

    <delete id="deleteAiobBaiduCallApiByIds" parameterType="String">
        delete from aiob_baidu_call_api where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>