liuxiaolong
2019-05-06 71af9c46c24b562acc00a71ec6c97c04eb048d9c
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?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.cloud.device.dao.OrgDao">
    <resultMap id="BaseResultMap" type="com.cloud.device.model.Org">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="orgId" jdbcType="INTEGER" property="orgId" />
        <result column="parentId" jdbcType="INTEGER" property="parentId" />
        <result column="name" jdbcType="VARCHAR" property="name" />
        <result column="parentIds" jdbcType="VARCHAR" property="parentIds" />
        <result column="sort" jdbcType="INTEGER" property="sort" />
        <result column="createBy" jdbcType="VARCHAR" property="createBy" />
        <result column="createTime" jdbcType="TIMESTAMP" property="createTime" />
        <result column="updateBy" jdbcType="VARCHAR" property="updateBy" />
        <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
        <result column="delFlag" jdbcType="VARCHAR" property="delFlag" />
    </resultMap>
    <sql id="Base_Column_List">
        id, orgId, parentId, name, parentIds, sort, createBy, createTime, updateBy, updateTime,
        delFlag
    </sql>
    <delete id="deleteById">
        update org set delFlag = '1'
        where id = #{id}
    </delete>
    <insert id="insert" parameterType="com.cloud.device.model.Org">
        insert into org (orgId, parentId,
        name, parentIds, sort,
        createBy, createTime, updateBy,
        updateTime, delFlag)
        values (#{orgId,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER},
        #{name,jdbcType=VARCHAR}, #{parentIds,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER},
        #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
        #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.cloud.device.model.Org">
        insert into org
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orgId != null">
                orgId,
            </if>
            <if test="parentId != null">
                parentId,
            </if>
            <if test="name != null">
                name,
            </if>
            <if test="parentIds != null">
                parentIds,
            </if>
            <if test="sort != null">
                sort,
            </if>
            <if test="createBy != null">
                createBy,
            </if>
            <if test="createTime != null">
                createTime,
            </if>
            <if test="updateBy != null">
                updateBy,
            </if>
            <if test="updateTime != null">
                updateTime,
            </if>
            <if test="delFlag != null">
                delFlag,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orgId != null">
                #{orgId,jdbcType=INTEGER},
            </if>
            <if test="parentId != null">
                #{parentId,jdbcType=INTEGER},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="parentIds != null">
                #{parentIds,jdbcType=VARCHAR},
            </if>
            <if test="sort != null">
                #{sort,jdbcType=INTEGER},
            </if>
            <if test="createBy != null">
                #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByIdSelective" parameterType="com.cloud.device.model.Org">
        update org
        <set>
            <if test="orgId != null">
                orgId = #{orgId,jdbcType=INTEGER},
            </if>
            <if test="parentId != null">
                parentId = #{parentId,jdbcType=INTEGER},
            </if>
            <if test="name != null">
                name = #{name,jdbcType=VARCHAR},
            </if>
            <if test="parentIds != null">
                parentIds = #{parentIds,jdbcType=VARCHAR},
            </if>
            <if test="sort != null">
                sort = #{sort,jdbcType=INTEGER},
            </if>
            <if test="createBy != null">
                createBy = #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                createTime = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                updateBy = #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                updateTime = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="delFlag != null">
                delFlag = #{delFlag,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateById" parameterType="com.cloud.device.model.Org">
        update org
        set orgId = #{orgId,jdbcType=INTEGER},
        parentId = #{parentId,jdbcType=INTEGER},
        name = #{name,jdbcType=VARCHAR},
        parentIds = #{parentIds,jdbcType=VARCHAR},
        sort = #{sort,jdbcType=INTEGER},
        createBy = #{createBy,jdbcType=VARCHAR},
        createTime = #{createTime,jdbcType=TIMESTAMP},
        updateBy = #{updateBy,jdbcType=VARCHAR},
        updateTime = #{updateTime,jdbcType=TIMESTAMP},
        delFlag = #{delFlag,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="selectById" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" />
        from org
        where id=#{id,jdbcType=INTEGER}
    </select>
    <select id="findAll" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" />
        from org where delFlag = '0'
        <if test="name !=null and name !=''">
            and name like concat('%',#{name},'%')
        </if>
        order by sort
    </select>
    <select id="findChildById" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" />
        from org where delFlag = '0' and parentId = #{id}
    </select>
</mapper>