feat(sip): 添加 CnareaMapper 映射文件
- 新增 CnareaMapper.xml 文件,实现对中国地区信息的 CRUD 操作 - 包含查询、插入、更新和删除地区的 SQL 语句 - 支持通过实体条件查询、ID 查询、批量删除等功能master
parent
37666b4471
commit
67306fe9a1
|
@ -0,0 +1,225 @@
|
||||||
|
<?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.ruoyi.sip.mapper.CnareaMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.ruoyi.sip.domain.Cnarea" id="CnareaMap">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="level" column="level"/>
|
||||||
|
<result property="parentCode" column="parent_code"/>
|
||||||
|
<result property="areaCode" column="area_code"/>
|
||||||
|
<result property="zipCode" column="zip_code"/>
|
||||||
|
<result property="cityCode" column="city_code"/>
|
||||||
|
<result property="name" column="name"/>
|
||||||
|
<result property="shortName" column="short_name"/>
|
||||||
|
<result property="mergerName" column="merger_name"/>
|
||||||
|
<result property="pinyin" column="pinyin"/>
|
||||||
|
<result property="lng" column="lng"/>
|
||||||
|
<result property="lat" column="lat"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 基本字段 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, level, parent_code, area_code, zip_code, city_code, name, short_name, merger_name, pinyin, lng, lat
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!--通过实体作为筛选条件查询-->
|
||||||
|
<select id="queryAll" resultMap="CnareaMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from cnarea
|
||||||
|
<where>
|
||||||
|
<if test="id != null and id != ''">
|
||||||
|
and id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="level != null and level != ''">
|
||||||
|
and level = #{level}
|
||||||
|
</if>
|
||||||
|
<if test="parentCode != null and parentCode != ''">
|
||||||
|
and parent_code = #{parentCode}
|
||||||
|
</if>
|
||||||
|
<if test="areaCode != null and areaCode != ''">
|
||||||
|
and area_code = #{areaCode}
|
||||||
|
</if>
|
||||||
|
<if test="zipCode != null and zipCode != ''">
|
||||||
|
and zip_code = #{zipCode}
|
||||||
|
</if>
|
||||||
|
<if test="cityCode != null and cityCode != ''">
|
||||||
|
and city_code = #{cityCode}
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
and name = #{name}
|
||||||
|
</if>
|
||||||
|
<if test="shortName != null and shortName != ''">
|
||||||
|
and short_name = #{shortName}
|
||||||
|
</if>
|
||||||
|
<if test="mergerName != null and mergerName != ''">
|
||||||
|
and merger_name = #{mergerName}
|
||||||
|
</if>
|
||||||
|
<if test="pinyin != null and pinyin != ''">
|
||||||
|
and pinyin = #{pinyin}
|
||||||
|
</if>
|
||||||
|
<if test="lng != null">
|
||||||
|
and lng = #{lng}
|
||||||
|
</if>
|
||||||
|
<if test="lat != null">
|
||||||
|
and lat = #{lat}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!--根据ID查详情-->
|
||||||
|
<select id="queryById" parameterType="Integer" resultMap="CnareaMap">
|
||||||
|
SELECT id,
|
||||||
|
level,
|
||||||
|
parent_code,
|
||||||
|
area_code,
|
||||||
|
zip_code,
|
||||||
|
city_code,
|
||||||
|
name,
|
||||||
|
short_name,
|
||||||
|
merger_name,
|
||||||
|
pinyin,
|
||||||
|
lng,
|
||||||
|
lat
|
||||||
|
FROM cnarea
|
||||||
|
WHERE id = #{id}
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!--新增所有列-->
|
||||||
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
INSERT INTO cnarea
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="level != null and level != ''">
|
||||||
|
level,
|
||||||
|
</if>
|
||||||
|
<if test="parentCode != null and parentCode != ''">
|
||||||
|
parent_code,
|
||||||
|
</if>
|
||||||
|
<if test="areaCode != null and areaCode != ''">
|
||||||
|
area_code,
|
||||||
|
</if>
|
||||||
|
<if test="zipCode != null and zipCode != ''">
|
||||||
|
zip_code,
|
||||||
|
</if>
|
||||||
|
<if test="cityCode != null and cityCode != ''">
|
||||||
|
city_code,
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name,
|
||||||
|
</if>
|
||||||
|
<if test="shortName != null and shortName != ''">
|
||||||
|
short_name,
|
||||||
|
</if>
|
||||||
|
<if test="mergerName != null and mergerName != ''">
|
||||||
|
merger_name,
|
||||||
|
</if>
|
||||||
|
<if test="pinyin != null and pinyin != ''">
|
||||||
|
pinyin,
|
||||||
|
</if>
|
||||||
|
<if test="lng != null">
|
||||||
|
lng,
|
||||||
|
</if>
|
||||||
|
<if test="lat != null">
|
||||||
|
lat,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="level != null and level != ''">
|
||||||
|
#{level},
|
||||||
|
</if>
|
||||||
|
<if test="parentCode != null and parentCode != ''">
|
||||||
|
#{parentCode},
|
||||||
|
</if>
|
||||||
|
<if test="areaCode != null and areaCode != ''">
|
||||||
|
#{areaCode},
|
||||||
|
</if>
|
||||||
|
<if test="zipCode != null and zipCode != ''">
|
||||||
|
#{zipCode},
|
||||||
|
</if>
|
||||||
|
<if test="cityCode != null and cityCode != ''">
|
||||||
|
#{cityCode},
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
#{name},
|
||||||
|
</if>
|
||||||
|
<if test="shortName != null and shortName != ''">
|
||||||
|
#{shortName},
|
||||||
|
</if>
|
||||||
|
<if test="mergerName != null and mergerName != ''">
|
||||||
|
#{mergerName},
|
||||||
|
</if>
|
||||||
|
<if test="pinyin != null and pinyin != ''">
|
||||||
|
#{pinyin},
|
||||||
|
</if>
|
||||||
|
<if test="lng != null">
|
||||||
|
#{lng},
|
||||||
|
</if>
|
||||||
|
<if test="lat != null">
|
||||||
|
#{lat},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!--通过主键修改数据-->
|
||||||
|
<update id="update">
|
||||||
|
UPDATE cnarea
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="level != null and level != ''">
|
||||||
|
level = #{level},
|
||||||
|
</if>
|
||||||
|
<if test="parentCode != null and parentCode != ''">
|
||||||
|
parent_code = #{parentCode},
|
||||||
|
</if>
|
||||||
|
<if test="areaCode != null and areaCode != ''">
|
||||||
|
area_code = #{areaCode},
|
||||||
|
</if>
|
||||||
|
<if test="zipCode != null and zipCode != ''">
|
||||||
|
zip_code = #{zipCode},
|
||||||
|
</if>
|
||||||
|
<if test="cityCode != null and cityCode != ''">
|
||||||
|
city_code = #{cityCode},
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="shortName != null and shortName != ''">
|
||||||
|
short_name = #{shortName},
|
||||||
|
</if>
|
||||||
|
<if test="mergerName != null and mergerName != ''">
|
||||||
|
merger_name = #{mergerName},
|
||||||
|
</if>
|
||||||
|
<if test="pinyin != null and pinyin != ''">
|
||||||
|
pinyin = #{pinyin},
|
||||||
|
</if>
|
||||||
|
<if test="lng != null">
|
||||||
|
lng = #{lng},
|
||||||
|
</if>
|
||||||
|
<if test="lat != null">
|
||||||
|
lat = #{lat},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!--通过主键删除-->
|
||||||
|
<delete id="deleteById">
|
||||||
|
DELETE
|
||||||
|
FROM cnarea
|
||||||
|
WHERE id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<!--通过id批量删除-->
|
||||||
|
<delete id="batchRemove">
|
||||||
|
delete from cnarea where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue