<?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.pnkx.mapper.PxLikeRecordMapper">

    <resultMap type="PxLikeRecord" id="PxLikeRecordResult">
        <result property="id" column="id"/>
        <result property="itemId" column="item_id"/>
        <result property="type" column="type"/>
        <result property="delFlag" column="del_flag"/>
        <result property="version" column="version"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectPxLikeRecordVo">
        select id, item_id, type, del_flag, version, create_by, create_time, update_by, update_time, remark        from px_like_record
    </sql>

    <select id="selectPxLikeRecordList" parameterType="PxLikeRecord" resultMap="PxLikeRecordResult">
        <include refid="selectPxLikeRecordVo"/>
        <where>
            <if test="itemId != null ">
                and item_id = #{itemId}
            </if>
            <if test="type != null  and type != ''">
                and type = #{type}
            </if>
            <if test="version != null  and version != ''">
                and version = #{version}
            </if>
        </where>
    </select>

    <select id="selectPxLikeRecord" parameterType="Long"
            resultMap="PxLikeRecordResult">
        <include refid="selectPxLikeRecordVo"/>
        <where>
            <if test="itemId != null ">
                and item_id = #{itemId}
            </if>
            <if test="type != null  and type != ''">
                and type = #{type}
            </if>
        </where>
        limit 1
    </select>

    <insert id="insertPxLikeRecord" parameterType="PxLikeRecord" useGeneratedKeys="true"
            keyProperty="id">
        insert into px_like_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="itemId != null">item_id,
            </if>
            <if test="type != null">type,
            </if>
            <if test="delFlag != null">del_flag,
            </if>
            <if test="version != null">version,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </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="itemId != null">#{itemId},
            </if>
            <if test="type != null">#{type},
            </if>
            <if test="delFlag != null">#{delFlag},
            </if>
            <if test="version != null">#{version},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="remark != null">#{remark},
            </if>
        </trim>
    </insert>

    <delete id="deletePxLikeRecordById" parameterType="Long">
        delete
        from px_like_record where id = #{id}
    </delete>
</mapper>
