<?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.PostCheckedMapper">
    
    <resultMap type="PostChecked" id="PostCheckedResult">
        <result property="id"    column="id"    />
        <result property="checkWorkgroupId"    column="check_workgroup_id"    />
        <result property="checkGroupId"    column="check_group_id"    />
        <result property="checkedDeptId"    column="checked_dept_id"    />
        <result property="checkedPostId"    column="checked_post_id"    />
        <result property="printUserId"    column="print_user_id"    />
        <result property="printTime"    column="print_time"    />
        <result property="checkedImg"    column="checked_img"    />
        <result property="checkedUserName"    column="checked_user_name"    />
        <result property="checkedTime"    column="checked_time"    />
        <result property="uploadUserId"    column="upload_user_id"    />
        <result property="uploadTime"    column="upload_time"    />
        <result property="remark"    column="remark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createUserId"    column="create_user_id"    />
    </resultMap>

    <sql id="selectPostCheckedVo">
        select id, check_workgroup_id, check_group_id, checked_dept_id, checked_post_id, print_user_id, print_time, checked_img, checked_user_name, checked_time, upload_user_id, upload_time, remark, del_flag, create_time, create_by, update_time, update_by, create_user_id from post_checked
    </sql>

    <select id="selectPostCheckedList" parameterType="PostChecked" resultMap="PostCheckedResult">
        <include refid="selectPostCheckedVo"/>
        <where>  
            <if test="checkWorkgroupId != null "> and check_workgroup_id = #{checkWorkgroupId}</if>
            <if test="checkGroupId != null "> and check_group_id = #{checkGroupId}</if>
            <if test="checkedDeptId != null "> and checked_dept_id = #{checkedDeptId}</if>
            <if test="checkedPostId != null "> and checked_post_id = #{checkedPostId}</if>
            <if test="printUserId != null "> and print_user_id = #{printUserId}</if>
            <if test="printTime != null "> and print_time = #{printTime}</if>
            <if test="checkedImg != null  and checkedImg != ''"> and checked_img = #{checkedImg}</if>
            <if test="checkedUserName != null  and checkedUserName != ''"> and checked_user_name like concat('%', #{checkedUserName}, '%')</if>
            <if test="checkedTime != null "> and checked_time = #{checkedTime}</if>
            <if test="uploadUserId != null "> and upload_user_id = #{uploadUserId}</if>
            <if test="uploadTime != null "> and upload_time = #{uploadTime}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
        </where>
    </select>
    
    <select id="selectPostCheckedById" parameterType="Long" resultMap="PostCheckedResult">
        <include refid="selectPostCheckedVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPostChecked" parameterType="PostChecked">
        insert into post_checked
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="checkWorkgroupId != null">check_workgroup_id,</if>
            <if test="checkGroupId != null">check_group_id,</if>
            <if test="checkedDeptId != null">checked_dept_id,</if>
            <if test="checkedPostId != null">checked_post_id,</if>
            <if test="printUserId != null">print_user_id,</if>
            <if test="printTime != null">print_time,</if>
            <if test="checkedImg != null">checked_img,</if>
            <if test="checkedUserName != null">checked_user_name,</if>
            <if test="checkedTime != null">checked_time,</if>
            <if test="uploadUserId != null">upload_user_id,</if>
            <if test="uploadTime != null">upload_time,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="createUserId != null">create_user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="checkWorkgroupId != null">#{checkWorkgroupId},</if>
            <if test="checkGroupId != null">#{checkGroupId},</if>
            <if test="checkedDeptId != null">#{checkedDeptId},</if>
            <if test="checkedPostId != null">#{checkedPostId},</if>
            <if test="printUserId != null">#{printUserId},</if>
            <if test="printTime != null">#{printTime},</if>
            <if test="checkedImg != null">#{checkedImg},</if>
            <if test="checkedUserName != null">#{checkedUserName},</if>
            <if test="checkedTime != null">#{checkedTime},</if>
            <if test="uploadUserId != null">#{uploadUserId},</if>
            <if test="uploadTime != null">#{uploadTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="createUserId != null">#{createUserId},</if>
         </trim>
    </insert>

    <update id="updatePostChecked" parameterType="PostChecked">
        update post_checked
        <trim prefix="SET" suffixOverrides=",">
            <if test="checkWorkgroupId != null">check_workgroup_id = #{checkWorkgroupId},</if>
            <if test="checkGroupId != null">check_group_id = #{checkGroupId},</if>
            <if test="checkedDeptId != null">checked_dept_id = #{checkedDeptId},</if>
            <if test="checkedPostId != null">checked_post_id = #{checkedPostId},</if>
            <if test="printUserId != null">print_user_id = #{printUserId},</if>
            <if test="printTime != null">print_time = #{printTime},</if>
            <if test="checkedImg != null">checked_img = #{checkedImg},</if>
            <if test="checkedUserName != null">checked_user_name = #{checkedUserName},</if>
            <if test="checkedTime != null">checked_time = #{checkedTime},</if>
            <if test="uploadUserId != null">upload_user_id = #{uploadUserId},</if>
            <if test="uploadTime != null">upload_time = #{uploadTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostCheckedById" parameterType="Long">
        delete from post_checked where id = #{id}
    </delete>

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