TMaterialInfoMapper.xml 6.35 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5
<?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.zehong.system.mapper.TMaterialInfoMapper">
6

耿迪迪's avatar
耿迪迪 committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
    <resultMap type="TMaterialInfo" id="TMaterialInfoResult">
        <result property="id"    column="id"    />
        <result property="materialName"    column="material_name"    />
        <result property="materialType"    column="material_type"    />
        <result property="num"    column="num"    />
        <result property="performance"    column="performance"    />
        <result property="purpose"    column="purpose"    />
        <result property="validityTime"    column="validity_time"    />
        <result property="deptId"    column="dept_id"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="address"    column="address"    />
        <result property="contacts"    column="contacts"    />
        <result property="phone"    column="phone"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDelete"    column="is_delete"    />
24
        <result property="deptName"    column="dept_name"    />
耿迪迪's avatar
耿迪迪 committed
25 26 27 28 29 30 31
    </resultMap>

    <sql id="selectTMaterialInfoVo">
        select id, material_name, material_type, num, performance, purpose, validity_time, dept_id, longitude, latitude, address, contacts, phone, create_time, update_time, is_delete from t_material_info
    </sql>

    <select id="selectTMaterialInfoList" parameterType="TMaterialInfo" resultMap="TMaterialInfoResult">
32 33 34 35 36 37
        select d.dept_name,a.id, a.material_name, a.material_type, a.num, a.performance, a.purpose, a.validity_time, a.dept_id, a.longitude, a.latitude, a.address, a.contacts, a.phone, a.create_time, a.update_time, a.is_delete
        from t_material_info a
        LEFT JOIN sys_dept d ON d.`dept_id` = a.`dept_id`
        <where>
            <if test="materialName != null  and materialName != ''"> and a.material_name like concat('%', #{materialName}, '%')</if>
            <if test="materialType != null "> and a.material_type = #{materialType}</if>
耿迪迪's avatar
耿迪迪 committed
38 39
        </where>
    </select>
40

耿迪迪's avatar
耿迪迪 committed
41 42 43 44
    <select id="selectTMaterialInfoById" parameterType="Long" resultMap="TMaterialInfoResult">
        <include refid="selectTMaterialInfoVo"/>
        where id = #{id}
    </select>
45

耿迪迪's avatar
耿迪迪 committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
    <insert id="insertTMaterialInfo" parameterType="TMaterialInfo" useGeneratedKeys="true" keyProperty="id">
        insert into t_material_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="materialName != null and materialName != ''">material_name,</if>
            <if test="materialType != null">material_type,</if>
            <if test="num != null">num,</if>
            <if test="performance != null">performance,</if>
            <if test="purpose != null">purpose,</if>
            <if test="validityTime != null">validity_time,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="longitude != null and longitude != ''">longitude,</if>
            <if test="latitude != null and latitude != ''">latitude,</if>
            <if test="address != null">address,</if>
            <if test="contacts != null and contacts != ''">contacts,</if>
            <if test="phone != null and phone != ''">phone,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDelete != null">is_delete,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="materialName != null and materialName != ''">#{materialName},</if>
            <if test="materialType != null">#{materialType},</if>
            <if test="num != null">#{num},</if>
            <if test="performance != null">#{performance},</if>
            <if test="purpose != null">#{purpose},</if>
            <if test="validityTime != null">#{validityTime},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="longitude != null and longitude != ''">#{longitude},</if>
            <if test="latitude != null and latitude != ''">#{latitude},</if>
            <if test="address != null">#{address},</if>
            <if test="contacts != null and contacts != ''">#{contacts},</if>
            <if test="phone != null and phone != ''">#{phone},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDelete != null">#{isDelete},</if>
         </trim>
    </insert>

    <update id="updateTMaterialInfo" parameterType="TMaterialInfo">
        update t_material_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="materialName != null and materialName != ''">material_name = #{materialName},</if>
            <if test="materialType != null">material_type = #{materialType},</if>
            <if test="num != null">num = #{num},</if>
            <if test="performance != null">performance = #{performance},</if>
            <if test="purpose != null">purpose = #{purpose},</if>
            <if test="validityTime != null">validity_time = #{validityTime},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="longitude != null and longitude != ''">longitude = #{longitude},</if>
            <if test="latitude != null and latitude != ''">latitude = #{latitude},</if>
            <if test="address != null">address = #{address},</if>
            <if test="contacts != null and contacts != ''">contacts = #{contacts},</if>
            <if test="phone != null and phone != ''">phone = #{phone},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDelete != null">is_delete = #{isDelete},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTMaterialInfoById" parameterType="Long">
        delete from t_material_info where id = #{id}
    </delete>

    <delete id="deleteTMaterialInfoByIds" parameterType="String">
111
        delete from t_material_info where id in
耿迪迪's avatar
耿迪迪 committed
112 113 114 115
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
116
</mapper>