<?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.ZxUrgeMapper">
    
    <resultMap type="ZxUrge" id="ZxUrgeResult">
        <result property="zxUrgeId"    column="zx_urge_id"    />
        <result property="scoreId"    column="score_id"    />
        <result property="urgeTitle"    column="urge_title"    />
        <result property="urgeType"    column="urge_type"    />
        <result property="urgeContent"    column="urge_content"    />
        <result property="status"    column="status"    />
        <result property="issuer"    column="issuer"    />
        <result property="issuerId"    column="issuer_id"    />
        <result property="issuerDept"    column="issuer_dept"    />
        <result property="issuerDeptId"    column="issuer_dept_id"    />
        <result property="acceptUser"    column="accept_user"    />
        <result property="acceptUserId"    column="accept_user_id"    />
        <result property="acceptDept"    column="accept_dept"    />
        <result property="acceptDeptId"    column="accept_dept_id"    />
        <result property="urgeTime"    column="urge_time"    />
        <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="selectZxUrgeVo">
        select zx_urge_id, score_id, urge_title, urge_type, urge_content, status, issuer, issuer_id, issuer_dept, issuer_dept_id, accept_user, accept_user_id, accept_dept, accept_dept_id, urge_time, create_by, create_time, update_by, update_time, remark from zx_urge
    </sql>

    <select id="selectZxUrgeList" parameterType="ZxUrge" resultMap="ZxUrgeResult">
        <include refid="selectZxUrgeVo"/>
        <where>  
            <if test="scoreId != null "> and score_id = #{scoreId}</if>
            <if test="urgeTitle != null  and urgeTitle != ''"> and urge_title = #{urgeTitle}</if>
            <if test="urgeType != null  and urgeType != ''"> and urge_type = #{urgeType}</if>
            <if test="urgeContent != null  and urgeContent != ''"> and urge_content = #{urgeContent}</if>
            <if test="issuer != null  and issuer != ''"> and issuer = #{issuer}</if>
            <if test="issuerId != null "> and issuer_id = #{issuerId}</if>
            <if test="issuerDept != null  and issuerDept != ''"> and issuer_dept = #{issuerDept}</if>
            <if test="issuerDeptId != null "> and issuer_dept_id = #{issuerDeptId}</if>
            <if test="acceptUser != null  and acceptUser != ''"> and accept_user = #{acceptUser}</if>
            <if test="acceptUserId != null "> and accept_user_id = #{acceptUserId}</if>
            <if test="acceptDept != null  and acceptDept != ''"> and accept_dept = #{acceptDept}</if>
            <if test="acceptDeptId != null "> and accept_dept_id = #{acceptDeptId}</if>
            <if test="urgeTime != null "> and urge_time = #{urgeTime}</if>
        </where>
        order by urge_time DESC
    </select>
    
    <select id="selectZxUrgeByZxUrgeId" parameterType="Long" resultMap="ZxUrgeResult">
        <include refid="selectZxUrgeVo"/>
        where zx_urge_id = #{zxUrgeId}
    </select>
        
    <insert id="insertZxUrge" parameterType="ZxUrge" useGeneratedKeys="true" keyProperty="zxUrgeId">
        insert into zx_urge
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="scoreId != null">score_id,</if>
            <if test="urgeTitle != null and urgeTitle != ''">urge_title,</if>
            <if test="urgeType != null and urgeType != ''">urge_type,</if>
            <if test="urgeContent != null">urge_content,</if>
            <if test="status != null">status,</if>
            <if test="issuer != null">issuer,</if>
            <if test="issuerId != null">issuer_id,</if>
            <if test="issuerDept != null">issuer_dept,</if>
            <if test="issuerDeptId != null">issuer_dept_id,</if>
            <if test="acceptUser != null">accept_user,</if>
            <if test="acceptUserId != null">accept_user_id,</if>
            <if test="acceptDept != null">accept_dept,</if>
            <if test="acceptDeptId != null">accept_dept_id,</if>
            <if test="urgeTime != null">urge_time,</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="scoreId != null">#{scoreId},</if>
            <if test="urgeTitle != null and urgeTitle != ''">#{urgeTitle},</if>
            <if test="urgeType != null and urgeType != ''">#{urgeType},</if>
            <if test="urgeContent != null">#{urgeContent},</if>
            <if test="status != null">#{status},</if>
            <if test="issuer != null">#{issuer},</if>
            <if test="issuerId != null">#{issuerId},</if>
            <if test="issuerDept != null">#{issuerDept},</if>
            <if test="issuerDeptId != null">#{issuerDeptId},</if>
            <if test="acceptUser != null">#{acceptUser},</if>
            <if test="acceptUserId != null">#{acceptUserId},</if>
            <if test="acceptDept != null">#{acceptDept},</if>
            <if test="acceptDeptId != null">#{acceptDeptId},</if>
            <if test="urgeTime != null">#{urgeTime},</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="updateZxUrge" parameterType="ZxUrge">
        update zx_urge
        <trim prefix="SET" suffixOverrides=",">
            <if test="scoreId != null">score_id = #{scoreId},</if>
            <if test="urgeTitle != null and urgeTitle != ''">urge_title = #{urgeTitle},</if>
            <if test="urgeType != null and urgeType != ''">urge_type = #{urgeType},</if>
            <if test="urgeContent != null">urge_content = #{urgeContent},</if>
            <if test="status != null">status = #{status},</if>
            <if test="issuer != null">issuer = #{issuer},</if>
            <if test="issuerId != null">issuer_id = #{issuerId},</if>
            <if test="issuerDept != null">issuer_dept = #{issuerDept},</if>
            <if test="issuerDeptId != null">issuer_dept_id = #{issuerDeptId},</if>
            <if test="acceptUser != null">accept_user = #{acceptUser},</if>
            <if test="acceptUserId != null">accept_user_id = #{acceptUserId},</if>
            <if test="acceptDept != null">accept_dept = #{acceptDept},</if>
            <if test="acceptDeptId != null">accept_dept_id = #{acceptDeptId},</if>
            <if test="urgeTime != null">urge_time = #{urgeTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where zx_urge_id = #{zxUrgeId}
    </update>

    <delete id="deleteZxUrgeByZxUrgeId" parameterType="Long">
        delete from zx_urge where zx_urge_id = #{zxUrgeId}
    </delete>

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