Stwzhj-Cloud-Plus/stwzhj-modules/wzhj-system/src/main/resources/mapper/system/MapPolygonMapper.xml

125 lines
6.4 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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="org.dromara.system.mapper.MapPolygonMapper">
<!-- 基础结果映射 -->
<resultMap id="BaseResultMap" type="org.dromara.system.domain.vo.MapPolygonVo">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="type" property="type" />
<result column="dept_id" property="deptId" />
<result column="address" property="address" />
<result column="remark" property="remark" />
<result column="geometry_location" property="geometryLocation" />
<result column="layer_id" property="layerId" />
<result column="layer_name" property="layerName" />
<result column="create_user_id" property="createUserId" />
<result column="create_user_name" property="createUserName" />
<result column="style" property="style" />
<result column="status" property="status" />
<result column="center_point" property="centerPoint" />
<result column="dept_name" property="deptName" />
<result column="rule_type" property="ruleType" />
<result column="range" property="range" />
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
id, name, type, dept_id, address, remark,
geometry_location, layer_id, layer_name, create_user_id, create_user_name,
style, status, center_point, dept_name, rule_type, range
</sql>
<!-- 插入电子围栏使用ST_GeomFromText转换geometryLocation -->
<insert id="insertWithGeometry" parameterType="org.dromara.system.domain.MapPolygon">
INSERT INTO map_polygon (
name, type, dept_id, address, remark,
geometry_location, layer_id, layer_name, create_user_id, create_user_name,
style, status, center_point, dept_name, rule_type, range
) VALUES (
#{name}, #{type}, #{deptId}, #{address}, #{remark},
ST_GeomFromText(#{geometryLocation}), #{layerId}, #{layerName}, #{createUserId}, #{createUserName},
#{style}, #{status}, #{centerPoint}, #{deptName}, #{ruleType}, #{range}
)
</insert>
<!-- 更新电子围栏使用ST_GeomFromText转换geometryLocation -->
<update id="updateWithGeometry" parameterType="org.dromara.system.domain.MapPolygon">
UPDATE map_polygon
<set>
<if test="name != null">name = #{name},</if>
<if test="type != null">type = #{type},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="address != null">address = #{address},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="geometryLocation != null">geometry_location = ST_GeomFromText(#{geometryLocation}),</if>
<if test="layerId != null">layer_id = #{layerId},</if>
<if test="layerName != null">layer_name = #{layerName},</if>
<if test="createUserId != null">create_user_id = #{createUserId},</if>
<if test="createUserName != null">create_user_name = #{createUserName},</if>
<if test="style != null">style = #{style},</if>
<if test="status != null">status = #{status},</if>
<if test="centerPoint != null">center_point = #{centerPoint},</if>
<if test="deptName != null">dept_name = #{deptName},</if>
<if test="ruleType != null">rule_type = #{ruleType},</if>
<if test="range != null">range = #{range},</if>
</set>
WHERE id = #{id}
</update>
<!-- 查询电子围栏列表使用ST_AsGeoJSON转换geometryLocation -->
<select id="selectListWithGeometry" resultMap="BaseResultMap">
SELECT
id, name, type, dept_id, address, remark,create_time,update_time,
ST_AsGeoJSON(geometry_location) AS geometry_location,
layer_id, layer_name, create_user_id, create_user_name,
style, status, center_point, dept_name, rule_type, range
FROM map_polygon
<where>
<if test="id != null">AND id = #{id}</if>
<if test="name != null and name != ''">AND name LIKE '%' || #{name,jdbcType=VARCHAR} || '%'</if>
<if test="type != null">AND type = #{type}</if>
<if test="deptId != null and deptId != ''">AND dept_id = #{deptId,jdbcType=VARCHAR}</if>
<if test="layerId != null">AND layer_id = #{layerId}</if>
<if test="status != null">AND status = #{status}</if>
<if test="ruleType != null">AND rule_type = #{ruleType}</if>
</where>
ORDER BY id ASC
</select>
<!-- 分页查询电子围栏列表使用ST_AsGeoJSON转换geometryLocation -->
<select id="selectPageWithGeometry" resultMap="BaseResultMap">
SELECT
id, name, type, dept_id, address, remark,create_time,update_time,
ST_AsGeoJSON(geometry_location) AS geometry_location,
layer_id, layer_name, create_user_id, create_user_name,
style, status, center_point, dept_name, rule_type, range
FROM map_polygon
<where>
<if test="mapPolygon.id != null">AND id = #{mapPolygon.id}</if>
<if test="mapPolygon.name != null and mapPolygon.name != ''">AND name LIKE '%' || #{mapPolygon.name,jdbcType=VARCHAR} || '%'</if>
<if test="mapPolygon.type != null">AND type = #{mapPolygon.type}</if>
<if test="mapPolygon.deptId != null and mapPolygon.deptId != ''">AND dept_id = #{mapPolygon.deptId,jdbcType=VARCHAR}</if>
<if test="mapPolygon.layerId != null">AND layer_id = #{mapPolygon.layerId}</if>
<if test="mapPolygon.status != null">AND status = #{mapPolygon.status}</if>
<if test="mapPolygon.ruleType != null">AND rule_type = #{mapPolygon.ruleType}</if>
</where>
ORDER BY id ASC
</select>
<!-- 根据ID查询电子围栏使用ST_AsGeoJSON转换geometryLocation -->
<select id="selectByIdWithGeometry" resultMap="BaseResultMap">
SELECT
id, name, type, dept_id, address, remark,create_time,update_time,
ST_AsGeoJSON(geometry_location) AS geometry_location,
layer_id, layer_name, create_user_id, create_user_name,
style, status, center_point, dept_name, rule_type, range
FROM map_polygon
WHERE id = #{id}
</select>
</mapper>