OtherDataMapper.xml 3.89 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.other.mapper.OtherDataMapper">
    
    <resultMap type="OtherData" id="OtherDataResult">
        <result property="id"    column="id"    />
        <result property="place"    column="place"    />
        <result property="type"    column="type"    />
        <result property="context"    column="context"    />
        <result property="time"    column="time"    />
        <result property="people"    column="people"    />
        <result property="attach"    column="attach"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectOtherDataVo">
        select id, place, type, context, time, people, attach, create_by, create_time, update_time from other_data
    </sql>

    <select id="selectOtherDataList" parameterType="OtherData" resultMap="OtherDataResult">
        <include refid="selectOtherDataVo"/>
        <where>  
            <if test="place != null  and place != ''"> and place = #{place}</if>
            <if test="time != null "> and time = #{time}</if>
        </where>
    </select>
    
    <select id="selectOtherDataById" parameterType="Long" resultMap="OtherDataResult">
        <include refid="selectOtherDataVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOtherData" parameterType="OtherData" useGeneratedKeys="true" keyProperty="id">
        insert into other_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="place != null">place,</if>
            <if test="type != null">type,</if>
            <if test="context != null">context,</if>
            <if test="time != null">time,</if>
            <if test="people != null">people,</if>
            <if test="attach != null">attach,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="place != null">#{place},</if>
            <if test="type != null">#{type},</if>
            <if test="context != null">#{context},</if>
            <if test="time != null">#{time},</if>
            <if test="people != null">#{people},</if>
            <if test="attach != null">#{attach},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateOtherData" parameterType="OtherData">
        update other_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="place != null">place = #{place},</if>
            <if test="type != null">type = #{type},</if>
            <if test="context != null">context = #{context},</if>
            <if test="time != null">time = #{time},</if>
            <if test="people != null">people = #{people},</if>
            <if test="attach != null">attach = #{attach},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOtherDataById" parameterType="Long">
        delete from other_data where id = #{id}
    </delete>

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