|
@@ -1,49 +1,70 @@
|
|
|
<?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">
|
|
|
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.ruoyi.system.mapper.TRegionMapper">
|
|
|
-
|
|
|
+
|
|
|
<resultMap type="TRegion" id="TRegionResult">
|
|
|
- <result property="id" column="id" />
|
|
|
- <result property="parentId" column="parent_id" />
|
|
|
- <result property="ancestors" column="ancestors" />
|
|
|
- <result property="deptName" column="dept_name" />
|
|
|
- <result property="deptNum" column="dept_num" />
|
|
|
- <result property="zoneName" column="zone_name" />
|
|
|
- <result property="zoneNum" column="zone_num" />
|
|
|
- <result property="kind" column="kind" />
|
|
|
- <result property="orderNum" column="order_num" />
|
|
|
- <result property="remarks" column="remarks" />
|
|
|
- <result property="gpsLng" column="gps_lng" />
|
|
|
- <result property="gpsLat" column="gps_lat" />
|
|
|
- <result property="createBy" column="create_by" />
|
|
|
- <result property="createTime" column="create_time" />
|
|
|
- <result property="updateBy" column="update_by" />
|
|
|
- <result property="updateTime" column="update_time" />
|
|
|
+ <result property="id" column="id"/>
|
|
|
+ <result property="parentId" column="parent_id"/>
|
|
|
+ <result property="ancestors" column="ancestors"/>
|
|
|
+ <result property="deptName" column="dept_name"/>
|
|
|
+ <result property="deptNum" column="dept_num"/>
|
|
|
+ <result property="zoneName" column="zone_name"/>
|
|
|
+ <result property="zoneNum" column="zone_num"/>
|
|
|
+ <result property="kind" column="kind"/>
|
|
|
+ <result property="orderNum" column="order_num"/>
|
|
|
+ <result property="remarks" column="remarks"/>
|
|
|
+ <result property="gpsLng" column="gps_lng"/>
|
|
|
+ <result property="gpsLat" column="gps_lat"/>
|
|
|
+ <result property="createBy" column="create_by"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ <result property="updateBy" column="update_by"/>
|
|
|
+ <result property="updateTime" column="update_time"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <resultMap type="TRegionVo" id="TRegionVoResult">
|
|
|
+ <result property="code" column="code"/>
|
|
|
+ <result property="name" column="name"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectTRegionVo">
|
|
|
- select id, parent_id, ancestors, dept_name, dept_num, zone_name, zone_num, kind, order_num, remarks, gps_lng, gps_lat, create_by, create_time, update_by, update_time from t_region
|
|
|
+ select id,
|
|
|
+ parent_id,
|
|
|
+ ancestors,
|
|
|
+ dept_name,
|
|
|
+ dept_num,
|
|
|
+ zone_name,
|
|
|
+ zone_num,
|
|
|
+ kind,
|
|
|
+ order_num,
|
|
|
+ remarks,
|
|
|
+ gps_lng,
|
|
|
+ gps_lat,
|
|
|
+ create_by,
|
|
|
+ create_time,
|
|
|
+ update_by,
|
|
|
+ update_time
|
|
|
+ from t_region
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectTRegionList" parameterType="TRegion" resultMap="TRegionResult">
|
|
|
<include refid="selectTRegionVo"/>
|
|
|
- <where>
|
|
|
- <if test="parentId != null "> and parent_id = #{parentId}</if>
|
|
|
- <if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
|
|
|
- <if test="deptName != null and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
|
|
|
- <if test="deptNum != null and deptNum != ''"> and dept_num = #{deptNum}</if>
|
|
|
- <if test="zoneName != null and zoneName != ''"> and zone_name like concat('%', #{zoneName}, '%')</if>
|
|
|
- <if test="zoneNum != null and zoneNum != ''"> and zone_num = #{zoneNum}</if>
|
|
|
- <if test="kind != null "> and kind = #{kind}</if>
|
|
|
- <if test="orderNum != null "> and order_num = #{orderNum}</if>
|
|
|
- <if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
|
|
|
- <if test="gpsLng != null "> and gps_lng = #{gpsLng}</if>
|
|
|
- <if test="gpsLat != null "> and gps_lat = #{gpsLat}</if>
|
|
|
+ <where>
|
|
|
+ <if test="parentId != null ">and parent_id = #{parentId}</if>
|
|
|
+ <if test="ancestors != null and ancestors != ''">and ancestors = #{ancestors}</if>
|
|
|
+ <if test="deptName != null and deptName != ''">and dept_name like concat('%', #{deptName}, '%')</if>
|
|
|
+ <if test="deptNum != null and deptNum != ''">and dept_num = #{deptNum}</if>
|
|
|
+ <if test="zoneName != null and zoneName != ''">and zone_name like concat('%', #{zoneName}, '%')</if>
|
|
|
+ <if test="zoneNum != null and zoneNum != ''">and zone_num = #{zoneNum}</if>
|
|
|
+ <if test="kind != null ">and kind = #{kind}</if>
|
|
|
+ <if test="orderNum != null ">and order_num = #{orderNum}</if>
|
|
|
+ <if test="remarks != null and remarks != ''">and remarks = #{remarks}</if>
|
|
|
+ <if test="gpsLng != null ">and gps_lng = #{gpsLng}</if>
|
|
|
+ <if test="gpsLat != null ">and gps_lat = #{gpsLat}</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
-
|
|
|
+
|
|
|
<select id="selectTRegionById" parameterType="Integer" resultMap="TRegionResult">
|
|
|
<include refid="selectTRegionVo"/>
|
|
|
where id = #{id}
|
|
@@ -53,7 +74,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<include refid="selectTRegionVo"/>
|
|
|
where parent_id = #{parentId}
|
|
|
</select>
|
|
|
-
|
|
|
+ <select id="selectTRegionListV1" resultMap="TRegionVoResult">
|
|
|
+ SELECT DISTINCT SUBSTRING(province_code, 1, 2) AS code,
|
|
|
+ province_name AS name
|
|
|
+ FROM position_village;
|
|
|
+ </select>
|
|
|
+ <select id="selectTRegionListV2" parameterType="string" resultMap="TRegionVoResult">
|
|
|
+ SELECT DISTINCT SUBSTRING(city_code, 1, 4) AS code,
|
|
|
+ city_name AS name
|
|
|
+ FROM position_village
|
|
|
+ WHERE SUBSTRING(position_village.city_code, 1, 2) = #{province_code}
|
|
|
+ </select>
|
|
|
+ <select id="selectTRegionListV3" parameterType="string" resultMap="TRegionVoResult">
|
|
|
+ SELECT DISTINCT SUBSTRING(county_code, 1,6) AS code,
|
|
|
+ county_name AS name
|
|
|
+ FROM position_village
|
|
|
+ WHERE SUBSTRING(position_village.city_code, 1, 4) = #{city_code}
|
|
|
+ </select>
|
|
|
+ <select id="selectTRegionListV4" parameterType="string" resultMap="TRegionVoResult">
|
|
|
+ SELECT DISTINCT SUBSTRING(town_code, 1,8) AS code,
|
|
|
+ town_name AS name
|
|
|
+ FROM position_village
|
|
|
+ WHERE SUBSTRING(position_village.county_code, 1, 6) = #{county_code}
|
|
|
+ </select>
|
|
|
+ <select id="selectTRegionListV5" parameterType="string" resultMap="TRegionVoResult">
|
|
|
+ SELECT DISTINCT SUBSTRING(village_code, 1, 10) AS code,
|
|
|
+ village_name AS name
|
|
|
+ FROM position_village
|
|
|
+ WHERE SUBSTRING(position_village.county_code, 1, 8) = #{county_code}
|
|
|
+ </select>
|
|
|
+
|
|
|
<insert id="insertTRegion" parameterType="TRegion" useGeneratedKeys="true" keyProperty="id">
|
|
|
insert into t_region
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
@@ -72,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
- </trim>
|
|
|
+ </trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="parentId != null">#{parentId},</if>
|
|
|
<if test="ancestors != null">#{ancestors},</if>
|
|
@@ -89,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
- </trim>
|
|
|
+ </trim>
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateTRegion" parameterType="TRegion">
|
|
@@ -115,11 +165,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</update>
|
|
|
|
|
|
<delete id="deleteTRegionById" parameterType="Integer">
|
|
|
- delete from t_region where id = #{id}
|
|
|
+ delete
|
|
|
+ from t_region
|
|
|
+ where id = #{id}
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteTRegionByIds" parameterType="String">
|
|
|
- delete from t_region where id in
|
|
|
+ delete from t_region where id in
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
#{id}
|
|
|
</foreach>
|