<?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.postCheck.mapper.PostCheckedProblemRecordMapper">

    <resultMap type="PostCheckedProblemRecord" id="PostCheckedProblemRecordResult">
        <result property="id"    column="id"    />
        <result property="problemId"    column="problem_id"    />
        <result property="userBy"    column="user_by"    />
        <result property="content"    column="content"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectPostCheckedProblemRecordVo">
        select
            id,
            problem_id,
            user_by,
            content,
            create_time
        from post_checked_problem_record t1
    </sql>

    <select id="selectPostCheckedProblemRecordList" parameterType="PostCheckedProblemRecord" resultMap="PostCheckedProblemRecordResult">
        <include refid="selectPostCheckedProblemRecordVo"/>
        <where>
            <if test="problemId != null "> and problem_id = #{problemId}</if>
            <if test="userBy != null  and userBy != ''"> and user_by = #{userBy}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="createTime != null"> and create_time = #{createTime}</if>
        </where>
        order by create_time asc
    </select>

    <!--
    <select id="selectPostCheckedProblemRecordById" parameterType="Long" resultMap="PostCheckedProblemRecordResult">
        <include refid="selectPostCheckedProblemRecordVo"/>
        where id = #{id}
    </select>
    -->

    <insert id="insertPostCheckedProblemRecord" parameterType="PostCheckedProblemRecord">
        insert into post_checked_problem_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="problemId != null">problem_id,</if>
            <if test="userBy != null and userBy != ''">user_by,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="problemId != null">#{problemId},</if>
            <if test="userBy != null and userBy != ''">#{userBy},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <!--
    <update id="updatePostCheckedProblemRecord" parameterType="PostCheckedProblemRecord">
        update post_checked_problem_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="problemId != null">problem_id = #{problemId},</if>
            <if test="userBy != null and userBy != ''">user_by = #{userBy},</if>
            <if test="content != null and content != ''">content = #{content},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostCheckedProblemRecordById" parameterType="Long">
        delete from post_checked_problem_record where id = #{id}
    </delete>

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