wuzeyu
2024-08-28 d65cc4cd967d9c8cbdc8a4dd7c803e952f01098f
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?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.dy.pipIrrGlobal.daoBa.BaBlockMapper">
    <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaBlock">
        <!--@mbg.generated-->
        <!--@Table ba_block-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="header" jdbcType="VARCHAR" property="header"/>
        <result column="phone" jdbcType="VARCHAR" property="phone"/>
        <result column="area" jdbcType="INTEGER" property="area"/>
        <result column="color" jdbcType="VARCHAR" property="color"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler"
                javaType="com.dy.common.mybatis.envm.Deleted"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id,
        `name`,
        `header`,
        phone,
        area,
        color,
        remark,
        deleted
    </sql>
    <sql id="part_Column_List">
        <!--@mbg.generated-->
        id,
        `name`
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from ba_block
        where id = #{id,jdbcType=BIGINT}
          and deleted = 0
    </select>
 
    <select id="selectAll" resultMap="BaseResultMap">
        select
        <!--    <include refid="part_Column_List" />-->
        <include refid="Base_Column_List"/>
        from ba_block
        WHERE deleted = 0
    </select>
 
    <select id="selectTotal" parameterType="java.util.Map" resultType="java.lang.Long">
        select count(*)
        from ba_block
        <trim prefix="where " suffixOverrides="and">
            <if test="name != null and name != ''">
                name like concat('%', #{name}, '%')
                  and
            </if>
            <if test="header != null and header != ''">
                header like concat('%', #{header}, '%')
                  and
            </if>
            <if test="phone != null and phone != ''">
                phone = #{phone,jdbcType=VARCHAR}
                  and
            </if>
            <if test="area != null">
                area = #{area,jdbcType=INTEGER} and
            </if>
        </trim>
    </select>
    <select id="selectSome" parameterType="java.util.Map" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from ba_block
        <trim prefix="where " suffixOverrides="and">
            deleted = 0
              and
            <if test="name != null and name != ''">
                name like concat('%', #{name}, '%')
                  and
            </if>
            <if test="header != null and header != ''">
                header = #{header,jdbcType=VARCHAR}
                  and
            </if>
            <if test="phone != null and phone != ''">
                phone = #{phone,jdbcType=VARCHAR}
                  and
            </if>
            <if test="area != null">
                area = #{area,jdbcType=INTEGER} and
            </if>
        </trim>
        order by id DESC
        <trim prefix="limit ">
            <if test="start != null and count != null">
                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
            </if>
        </trim>
    </select>
 
    <!--根据指定条件获取片区记录数量-->
    <select id="getBlocksCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM ba_block
        <where>
            AND deleted = 0
            <if test="name != null and name != ''">
                AND name LIKE CONCAT('%', #{name}, '%')
            </if>
        </where>
    </select>
 
    <!--根据指定条件获取片区-->
    <select id="getBlocks" resultType="com.dy.pipIrrGlobal.voBa.VoBlock">
        SELECT id,
               name,
               header,
               phone,
               area,
               color,
               remark,
               deleted
        FROM ba_block
        <where>
            AND deleted = 0
            <if test="name != null and name != ''">
                AND name LIKE CONCAT('%', #{name}, '%')
            </if>
        </where>
        ORDER BY id
        LIMIT #{pageCurr}, #{pageSize}
<!--        <trim prefix="limit ">-->
<!--            <if test="start != null and count != null">-->
<!--                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}-->
<!--            </if>-->
<!--        </trim>-->
    </select>
 
    <!--根据片区ID获取地图图形列表-->
    <select id="gertMapGraphsByBlockId" resultType="com.dy.pipIrrGlobal.voBa.VoMapGraph">
        SELECT id      AS graphId,
               CASE
                   WHEN graph_type = 1 THEN 'CircleMarker'
                   WHEN graph_type = 2 THEN 'Polygon'
                   WHEN graph_type = 3 THEN 'Polyline'
                   END AS type
        FROM ba_map_graph
        WHERE block_id = #{blockId}
    </select>
 
    <!--根据地图图形ID获取地图图形坐标列表-->
    <select id="getCoordinatesByGraphId" resultType="com.dy.pipIrrGlobal.voBa.VoMapCoordinates">
        SELECT
            lat,lng
        FROM ba_map_coordinates
        WHERE graph_id = #{graphId}
    </select>
 
    <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaBlock">
        <!--@mbg.generated-->
        insert into ba_block (id, `name`, `header`, phone, area, color, remark, deleted)
        values (#{id,jdbcType=BIGINT},
                #{name,jdbcType=VARCHAR},
                #{header,jdbcType=VARCHAR},
                #{phone,jdbcType=VARCHAR},
                #{area,jdbcType=INTEGER},
                #{color,jdbcType=VARCHAR},
                #{remark,jdbcType=VARCHAR},
                #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT})
    </insert>
    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaBlock">
        <!--@mbg.generated-->
        insert into ba_block
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="name != null">
                `name`,
            </if>
            <if test="header != null">
                `header`,
            </if>
            <if test="phone != null">
                phone,
            </if>
            <if test="area != null">
                area,
            </if>
            <if test="color != null">
                color,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="deleted != null">
                deleted,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="header != null">
                #{header,jdbcType=VARCHAR},
            </if>
            <if test="phone != null">
                #{phone,jdbcType=VARCHAR},
            </if>
            <if test="area != null">
                #{area,jdbcType=INTEGER},
            </if>
            <if test="color != null">
                #{color,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaBlock">
        <!--@mbg.generated-->
        update ba_block
        <set>
            <if test="name != null">
                `name` = #{name,jdbcType=VARCHAR},
            </if>
            <if test="header != null">
                `header` = #{header,jdbcType=VARCHAR},
            </if>
            <if test="phone != null">
                phone = #{phone,jdbcType=VARCHAR},
            </if>
            <if test="area != null">
                area = #{area,jdbcType=INTEGER},
            </if>
            <if test="color != null">
                color = #{color,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="deleted != null">
                deleted = #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.BaBlock">
        <!--@mbg.generated-->
        update ba_block
        set `name`   = #{name,jdbcType=VARCHAR},
            `header` = #{header,jdbcType=VARCHAR},
            phone    = #{phone,jdbcType=VARCHAR},
            area     = #{area,jdbcType=INTEGER},
            color    = #{color,jdbcType=VARCHAR},
            remark   = #{remark,jdbcType=VARCHAR},
            deleted  = #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}
        where id = #{id,jdbcType=BIGINT}
    </update>
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        delete
        from ba_block
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <delete id="deleteLogicById" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        update ba_block
        set deleted = 1
        where id = #{id,jdbcType=BIGINT}
    </delete>
</mapper>