<?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.system.mapper.WorkerLevelLogMapper">
    
    <resultMap type="WorkerLevelLog" id="WorkerLevelLogResult">
        <result property="id"    column="id"    />
        <result property="uid"    column="uid"    />
        <result property="levelId"    column="level_id"    />
        <result property="title"    column="title"    />
        <result property="level"    column="level"    />
        <result property="ar"    column="ar"    />
        <result property="price"    column="price"    />
        <result property="time"    column="time"    />
        <result property="createdAt"    column="created_at"    />
        <result property="updatedAt"    column="updated_at"    />
    </resultMap>

    <sql id="selectWorkerLevelLogVo">
        select id, uid, level_id, title, level, ar, price, time, created_at, updated_at from worker_level_log
    </sql>

    <select id="selectWorkerLevelLogList" parameterType="WorkerLevelLog" resultMap="WorkerLevelLogResult">
        <include refid="selectWorkerLevelLogVo"/>
        <where>  
            <if test="uid != null "> and uid = #{uid}</if>
            <if test="levelId != null "> and level_id = #{levelId}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="level != null "> and level = #{level}</if>
            <if test="ar != null "> and ar = #{ar}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="time != null "> and time = #{time}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
            <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
        </where>
    </select>
    
    <select id="selectWorkerLevelLogById" parameterType="Integer" resultMap="WorkerLevelLogResult">
        <include refid="selectWorkerLevelLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertWorkerLevelLog" parameterType="WorkerLevelLog" useGeneratedKeys="true" keyProperty="id">
        insert into worker_level_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uid != null">uid,</if>
            <if test="levelId != null">level_id,</if>
            <if test="title != null">title,</if>
            <if test="level != null">level,</if>
            <if test="ar != null">ar,</if>
            <if test="price != null">price,</if>
            <if test="time != null">time,</if>
            <if test="createdAt != null">created_at,</if>
            <if test="updatedAt != null">updated_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="uid != null">#{uid},</if>
            <if test="levelId != null">#{levelId},</if>
            <if test="title != null">#{title},</if>
            <if test="level != null">#{level},</if>
            <if test="ar != null">#{ar},</if>
            <if test="price != null">#{price},</if>
            <if test="time != null">#{time},</if>
            <if test="createdAt != null">#{createdAt},</if>
            <if test="updatedAt != null">#{updatedAt},</if>
         </trim>
    </insert>

    <update id="updateWorkerLevelLog" parameterType="WorkerLevelLog">
        update worker_level_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="uid != null">uid = #{uid},</if>
            <if test="levelId != null">level_id = #{levelId},</if>
            <if test="title != null">title = #{title},</if>
            <if test="level != null">level = #{level},</if>
            <if test="ar != null">ar = #{ar},</if>
            <if test="price != null">price = #{price},</if>
            <if test="time != null">time = #{time},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
            <if test="updatedAt != null">updated_at = #{updatedAt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWorkerLevelLogById" parameterType="Integer">
        delete from worker_level_log where id = #{id}
    </delete>

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