HandleAffairsMapper.xml 6.25 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="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="opinion"    column="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"    />
        <result property="sendObject"    column="send_object"    />
        <result property="userNames"    column="user_names"    />
        <result property="userNamesDone"    column="user_names_done"    />
    </resultMap>

    <sql id="selectHandleAffairsVo">
        select id, company, receive_time, title, type, appeal,send_object, send_person,send_date, dept_id,dept_name,opinion, status, create_time, create_by, update_time, update_by,user_names,user_names_done from office_handle_affairs
    </sql>

    <select id="selectHandleAffairsList" parameterType="HandleAffairs" resultMap="HandleAffairsResult">
        <include refid="selectHandleAffairsVo"/>
        <where>
            <if test="company != null  and company != ''"> and company like concat('%',#{company},'%')</if>
            <if test="receiveTime != null "> and receive_time like concat('%',SUBSTRING(#{receiveTime},1,10),'%')</if>
            <if test="title != null  and title != ''"> and title like concat('%',#{title},'%') </if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="sendPerson != null  and sendPerson != ''"> and send_person like concat('%',#{sendPerson},'%')</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="deptName != null "> and dept_name = #{deptName}</if>
             <if test="sendDate != null "> and send_date = #{sendDate}</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="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</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="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</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="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="status != null">status = #{status},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="opinion != null">opinion = #{opinion},</if>
            <if test="sendObject != null">send_object = #{sendObject},</if>
            <if test="userNames != null">user_names = #{userNames},</if>
            <if test="userNamesDone != null">user_names_done = #{userNamesDone},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateHandleAffairsNull">
        update office_handle_affairs
        set
            update_time = now(),dept_id = null,dept_name = null,opinion = null,send_object = null
        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>