地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
<?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.javaweb.cms.mapper.MaterialGroupMapper">
 
    <resultMap type="MaterialGroup" id="MaterialGroupResult">
        <result property="groupId" column="group_id" />
        <result property="parentId" column="parent_id" />
        <result property="deptId" column="dept_id" />
        <result property="groupName" column="group_name" />
        <result property="description" column="description" />
        <result property="sort" column="sort" />
        <result property="userId" column="user_id" />
        <result property="createBy" column="create_by" />
        <result property="createTime" column="create_time" />
        <result property="parentName" column="parent_name" />
    </resultMap>
 
    <sql id="selectMaterialGroupVo">
        select group_id, parent_id, dept_id, group_name, description, sort, user_id,
        create_by, create_time from cms_material_group
    </sql>
 
    <select id="selectMaterialGroupList" parameterType="MaterialGroup"
        resultMap="MaterialGroupResult">
        <include refid="selectMaterialGroupVo" />
        <where>
            <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
        </where>
        order by parent_id
    </select>
 
    <select id="selectMaterialGroupById" parameterType="Long"
        resultMap="MaterialGroupResult">
        select t.group_id, t.parent_id, t.dept_id, t.group_name, t.description,
        t.sort, t.user_id, t.create_by, t.create_time, p.group_name as
        parent_name
        from cms_material_group t
        left join cms_material_group p on p.group_id = t.parent_id
        where t.group_id = #{groupId}
    </select>
 
    <insert id="insertMaterialGroup" parameterType="MaterialGroup">
        insert into cms_material_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="groupId != null ">group_id,</if>
            <if test="parentId != null ">parent_id,</if>
            <if test="deptId != null  and deptId != ''">dept_id,</if>
            <if test="groupName != null  and groupName != ''">group_name,</if>
            <if test="description != null  and description != ''">description,</if>
            <if test="sort != null ">sort,</if>
            <if test="userId != null  and userId != ''">user_id,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="createTime != null ">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="groupId != null ">#{groupId},</if>
            <if test="parentId != null ">#{parentId},</if>
            <if test="deptId != null  and deptId != ''">#{deptId},</if>
            <if test="groupName != null  and groupName != ''">#{groupName},</if>
            <if test="description != null  and description != ''">#{description},</if>
            <if test="sort != null ">#{sort},</if>
            <if test="userId != null  and userId != ''">#{userId},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
        </trim>
    </insert>
 
    <update id="updateMaterialGroup" parameterType="MaterialGroup">
        update cms_material_group
        <trim prefix="SET" suffixOverrides=",">
            <if test="parentId != null ">parent_id = #{parentId},</if>
            <if test="deptId != null  and deptId != ''">dept_id = #{deptId},</if>
            <if test="groupName != null  and groupName != ''">group_name = #{groupName},</if>
            <if test="description != null  and description != ''">description = #{description},</if>
            <if test="sort != null ">sort = #{sort},</if>
            <if test="userId != null  and userId != ''">user_id = #{userId},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        where group_id = #{groupId}
    </update>
 
    <delete id="deleteMaterialGroupById" parameterType="Long">
        delete from cms_material_group where group_id = #{groupId}
    </delete>
 
    <delete id="deleteMaterialGroupByIds" parameterType="String">
        delete from cms_material_group where group_id in
        <foreach item="groupId" collection="array" open="(" separator=","
            close=")">
            #{groupId}
        </foreach>
    </delete>
 
</mapper>