<?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.model.mapper.ServiceRecordMapper">
    
    <resultMap type="ServiceRecord" id="ServiceRecordResult">
        <result property="id"    column="id"    />
        <result property="petTeacherId"    column="pet_teacher_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="imagesRecord"    column="images_record"    />
        <result property="remark"    column="remark"    />
        <result property="serviceTime"    column="service_time"    />
        <result property="serviceType"    column="service_type"    />
        <result property="textRecord"    column="text_record"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectServiceRecordVo">
        select id, pet_teacher_id, create_by, create_time, del_flag, images_record, remark, service_time, service_type, text_record, update_by, update_time from service_record
    </sql>

    <select id="selectServiceRecordList" parameterType="ServiceRecord" resultMap="ServiceRecordResult">
        <include refid="selectServiceRecordVo"/>
        <where>  
            <if test="petTeacherId != null "> and pet_teacher_id = #{petTeacherId}</if>
            <if test="imagesRecord != null  and imagesRecord != ''"> and images_record = #{imagesRecord}</if>
            <if test="serviceTime != null "> and service_time = #{serviceTime}</if>
            <if test="serviceType != null "> and service_type = #{serviceType}</if>
            <if test="textRecord != null  and textRecord != ''"> and text_record = #{textRecord}</if>
        </where>
    </select>
    
    <select id="selectServiceRecordById" parameterType="Long" resultMap="ServiceRecordResult">
        <include refid="selectServiceRecordVo"/>
        where id = #{id}
    </select>
    <select id="getServiceRecordList" resultType="com.ruoyi.model.domain.ServiceRecord">
        <include refid="selectServiceRecordVo"/>
    </select>

    <insert id="insertServiceRecord" parameterType="ServiceRecord">
        insert into service_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="petTeacherId != null">pet_teacher_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="imagesRecord != null">images_record,</if>
            <if test="remark != null">remark,</if>
            <if test="serviceTime != null">service_time,</if>
            <if test="serviceType != null">service_type,</if>
            <if test="textRecord != null">text_record,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="petTeacherId != null">#{petTeacherId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="imagesRecord != null">#{imagesRecord},</if>
            <if test="remark != null">#{remark},</if>
            <if test="serviceTime != null">#{serviceTime},</if>
            <if test="serviceType != null">#{serviceType},</if>
            <if test="textRecord != null">#{textRecord},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateServiceRecord" parameterType="ServiceRecord">
        update service_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="petTeacherId != null">pet_teacher_id = #{petTeacherId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="imagesRecord != null">images_record = #{imagesRecord},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="serviceTime != null">service_time = #{serviceTime},</if>
            <if test="serviceType != null">service_type = #{serviceType},</if>
            <if test="textRecord != null">text_record = #{textRecord},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteServiceRecordById" parameterType="Long">
        delete from service_record where id = #{id}
    </delete>

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