HandleAffairsMapper.xml 5.54 KB
<?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.trash.office.mapper.HandleAffairsMapper">

    <resultMap type="HandleAffairs" id="HandleAffairsResult">
        <result property="id"    column="id"    />
        <result property="company"    column="company"    />
        <result property="receiveTime"    column="receive_time"    />
        <result property="title"    column="title"    />
        <result property="type"    column="type"    />
        <result property="appeal"    column="appeal"    />
        <result property="sendPerson"    column="send_person"    />
        <result property="sendDate"    column="send_date"    />
        <result property="isRead"    column="is_read"    />
        <result property="opinion"    column="opinion"    />
        <result property="deptOpinion"    column="dept_opinion"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectHandleAffairsVo">
        select id, company, receive_time, title, type, appeal, send_person,send_date, is_read, opinion, dept_opinion, status, create_time, create_by, update_time, update_by from office_handle_affairs
    </sql>

    <select id="selectHandleAffairsList" parameterType="HandleAffairs" resultMap="HandleAffairsResult">
        <include refid="selectHandleAffairsVo"/>
        <where>
            <if test="company != null  and company != ''"> and company = #{company}</if>
            <if test="receiveTime != null "> and receive_time = #{receiveTime}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="appeal != null  and appeal != ''"> and appeal = #{appeal}</if>
            <if test="sendPerson != null  and sendPerson != ''"> and send_person = #{sendPerson}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>

    <select id="selectHandleAffairsById" parameterType="Long" resultMap="HandleAffairsResult">
        <include refid="selectHandleAffairsVo"/>
        where id = #{id}
    </select>

    <insert id="insertHandleAffairs" parameterType="HandleAffairs" useGeneratedKeys="true" keyProperty="id">
        insert into office_handle_affairs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            create_time,
            <if test="company != null">company,</if>
            <if test="receiveTime != null">receive_time,</if>
            <if test="title != null">title,</if>
            <if test="type != null">`type`,</if>
            <if test="appeal != null">appeal,</if>
            <if test="sendPerson != null">send_person,</if>
            <if test="sendDate != null">send_date,</if>
            <if test="isRead != null">is_read,</if>
            <if test="opinion != null">opinion,</if>
            <if test="deptOpinion != null">dept_opinion,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            now(),
            <if test="company != null">#{company},</if>
            <if test="receiveTime != null">#{receiveTime},</if>
            <if test="title != null">#{title},</if>
            <if test="type != null">#{type},</if>
            <if test="appeal != null">#{appeal},</if>
            <if test="sendPerson != null">#{sendPerson},</if>
            <if test="sendDate != null">#{sendDate},</if>
            <if test="isRead != null">#{isRead},</if>
            <if test="opinion != null">#{opinion},</if>
            <if test="deptOpinion != null">#{deptOpinion},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateHandleAffairs" parameterType="HandleAffairs">
        update office_handle_affairs
        <trim prefix="SET" suffixOverrides=",">
            update_time = now(),
            <if test="company != null">company = #{company},</if>
            <if test="receiveTime != null">receive_time = #{receiveTime},</if>
            <if test="title != null">title = #{title},</if>
            <if test="type != null">`type` = #{type},</if>
            <if test="appeal != null">appeal = #{appeal},</if>
            <if test="sendPerson != null">send_person = #{sendPerson},</if>
            <if test="sendDate != null">send_date = #{sendDate},</if>
            <if test="isRead != null">is_read = #{isRead},</if>
            <if test="opinion != null">opinion = #{opinion},</if>
            <if test="deptOpinion != null">dept_opinion = #{deptOpinion},</if>
            <if test="status != null">status = #{status},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteHandleAffairsById" parameterType="Long">
        delete from office_handle_affairs where id = #{id}
    </delete>

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

</mapper>