<?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.InfoPinglunMapper">
    
    <resultMap type="InfoPinglun" id="InfoPinglunResult">
        <result property="infoPinglunId"    column="info_pinglun_id"    />
        <result property="annexId"    column="annex_id"    />
        <result property="infoPingLunParent"    column="info_ping_lun_parent"    />
        <result property="infoPingLunContent"    column="info_ping_lun_content"    />
        <result property="infoPingLunUserId"    column="info_ping_lun_user_id"    />
        <result property="infoPingLunUserName"    column="info_ping_lun_user_name"    />
        <result property="infoPingLunQuiltUserId"    column="info_ping_lun_quilt_user_id"    />
        <result property="infoPingLunQuiltUserName"    column="info_ping_lun_quilt_user_name"    />
        <result property="pingLunTime"    column="ping_lun_time"    />
        <result property="infoPingLunType"    column="info_ping_lun_type"    />
        <result property="infoPingLunExamine"    column="info_ping_lun_examine"    />
        <result property="createDept"    column="create_dept"    />
        <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="selectInfoPinglunVo">
        select info_pinglun_id, annex_id, info_ping_lun_parent, info_ping_lun_content, info_ping_lun_user_id, info_ping_lun_user_name, info_ping_lun_quilt_user_id, info_ping_lun_quilt_user_name, ping_lun_time, info_ping_lun_type, info_ping_lun_examine, create_dept, create_by, create_time, update_by, update_time, remark from info_pinglun
    </sql>

    <select id="selectInfoPinglunList" parameterType="InfoPinglun" resultMap="InfoPinglunResult">
        <include refid="selectInfoPinglunVo"/>
        <where>  
            <if test="annexId != null "> and annex_id = #{annexId}</if>
            <if test="infoPingLunParent != null "> and info_ping_lun_parent = #{infoPingLunParent}</if>
            <if test="infoPingLunContent != null  and infoPingLunContent != ''"> and info_ping_lun_content = #{infoPingLunContent}</if>
            <if test="infoPingLunUserId != null "> and info_ping_lun_user_id = #{infoPingLunUserId}</if>
            <if test="infoPingLunUserName != null  and infoPingLunUserName != ''"> and info_ping_lun_user_name like concat('%', #{infoPingLunUserName}, '%')</if>
            <if test="infoPingLunQuiltUserId != null "> and info_ping_lun_quilt_user_id = #{infoPingLunQuiltUserId}</if>
            <if test="infoPingLunQuiltUserName != null  and infoPingLunQuiltUserName != ''"> and info_ping_lun_quilt_user_name like concat('%', #{infoPingLunQuiltUserName}, '%')</if>
            <if test="pingLunTime != null "> and ping_lun_time = #{pingLunTime}</if>
            <if test="infoPingLunType != null  and infoPingLunType != ''"> and info_ping_lun_type = #{infoPingLunType}</if>
            <if test="infoPingLunExamine != null  and infoPingLunExamine != ''"> and info_ping_lun_examine = #{infoPingLunExamine}</if>
            <if test="createDept != null "> and create_dept = #{createDept}</if>
        </where>
        order by create_time DESC
    </select>
    
    <select id="selectInfoPinglunByInfoPinglunId" parameterType="Long" resultMap="InfoPinglunResult">
        <include refid="selectInfoPinglunVo"/>
        where info_pinglun_id = #{infoPinglunId}
    </select>
    <select id="selectInfoPinglunByAnnexId" parameterType="Long" resultMap="InfoPinglunResult">
        <include refid="selectInfoPinglunVo"/>
        where annex_id = #{annexId} and info_ping_lun_examine = 'Y'
    </select>

    <insert id="insertInfoPinglun" parameterType="InfoPinglun" useGeneratedKeys="true" keyProperty="infoPinglunId">
        insert into info_pinglun
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="annexId != null">annex_id,</if>
            <if test="infoPingLunParent != null">info_ping_lun_parent,</if>
            <if test="infoPingLunContent != null">info_ping_lun_content,</if>
            <if test="infoPingLunUserId != null">info_ping_lun_user_id,</if>
            <if test="infoPingLunUserName != null">info_ping_lun_user_name,</if>
            <if test="infoPingLunQuiltUserId != null">info_ping_lun_quilt_user_id,</if>
            <if test="infoPingLunQuiltUserName != null">info_ping_lun_quilt_user_name,</if>
            <if test="pingLunTime != null">ping_lun_time,</if>
            <if test="infoPingLunType != null">info_ping_lun_type,</if>
            <if test="infoPingLunExamine != null">info_ping_lun_examine,</if>
            <if test="createDept != null">create_dept,</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="annexId != null">#{annexId},</if>
            <if test="infoPingLunParent != null">#{infoPingLunParent},</if>
            <if test="infoPingLunContent != null">#{infoPingLunContent},</if>
            <if test="infoPingLunUserId != null">#{infoPingLunUserId},</if>
            <if test="infoPingLunUserName != null">#{infoPingLunUserName},</if>
            <if test="infoPingLunQuiltUserId != null">#{infoPingLunQuiltUserId},</if>
            <if test="infoPingLunQuiltUserName != null">#{infoPingLunQuiltUserName},</if>
            <if test="pingLunTime != null">#{pingLunTime},</if>
            <if test="infoPingLunType != null">#{infoPingLunType},</if>
            <if test="infoPingLunExamine != null">#{infoPingLunExamine},</if>
            <if test="createDept != null">#{createDept},</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>

    <update id="updateInfoPinglun" parameterType="InfoPinglun">
        update info_pinglun
        <trim prefix="SET" suffixOverrides=",">

            <if test="infoPingLunExamine != null">info_ping_lun_examine = #{infoPingLunExamine},</if>

        </trim>
        where info_pinglun_id = #{infoPinglunId}
    </update>

    <delete id="deleteInfoPinglunByInfoPinglunId" parameterType="Long">
        delete from info_pinglun where info_pinglun_id = #{infoPinglunId}
    </delete>

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