<?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.yccrc.kede.mapper.EnterpriseLogMapper">
    
    <resultMap type="EnterpriseLog" id="EnterpriseLogResult">
        <result property="id"    column="id"    />
        <result property="enterpriseId"    column="enterprise_id"    />
        <result property="operName"    column="oper_name"    />
        <result property="operMsg"    column="oper_msg"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectEnterpriseLogVo">
        select id, enterprise_id, oper_name, oper_msg, create_time from enterprise_log
    </sql>

    <select id="selectEnterpriseLogList" parameterType="EnterpriseLog" resultMap="EnterpriseLogResult">
        <include refid="selectEnterpriseLogVo"/>
        <where>  
            <if test="enterpriseId != null "> and enterprise_id = #{enterpriseId}</if>
            <if test="operName != null  and operName != ''"> and oper_name like concat('%', #{operName}, '%')</if>
            <if test="operMsg != null  and operMsg != ''"> and oper_msg = #{operMsg}</if>
        </where>
    </select>
    
    <select id="selectEnterpriseLogById" parameterType="Integer" resultMap="EnterpriseLogResult">
        <include refid="selectEnterpriseLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertEnterpriseLog" parameterType="EnterpriseLog" useGeneratedKeys="true" keyProperty="id">
        insert into enterprise_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="enterpriseId != null">enterprise_id,</if>
            <if test="operName != null">oper_name,</if>
            <if test="operMsg != null">oper_msg,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="enterpriseId != null">#{enterpriseId},</if>
            <if test="operName != null">#{operName},</if>
            <if test="operMsg != null">#{operMsg},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateEnterpriseLog" parameterType="EnterpriseLog">
        update enterprise_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
            <if test="operName != null">oper_name = #{operName},</if>
            <if test="operMsg != null">oper_msg = #{operMsg},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEnterpriseLogById" parameterType="Integer">
        delete from enterprise_log where id = #{id}
    </delete>

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