| New file | 
|  |  |  | 
|---|
|  |  |  | <?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.BaDistrictMapper"> | 
|---|
|  |  |  | <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | <!--@Table ba_district--> | 
|---|
|  |  |  | <id column="id" jdbcType="BIGINT" property="id" /> | 
|---|
|  |  |  | <id column="supperId" jdbcType="BIGINT" property="supperId" /> | 
|---|
|  |  |  | <result column="name" jdbcType="VARCHAR" property="name" /> | 
|---|
|  |  |  | <result column="num" jdbcType="VARCHAR" property="num" /> | 
|---|
|  |  |  | <result property="level" column="level" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.pipIrrGlobal.util.DistrictLevel"/> | 
|---|
|  |  |  | <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, supperId, `name`, num, `level`, deleted | 
|---|
|  |  |  | </sql> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List" /> | 
|---|
|  |  |  | from ba_district | 
|---|
|  |  |  | where id = #{id,jdbcType=BIGINT} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectByLevel" parameterType="java.lang.Byte" resultMap="BaseResultMap"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List" /> | 
|---|
|  |  |  | from ba_district | 
|---|
|  |  |  | where deleted != 1 and level = #{level,jdbcType=TINYINT} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectBySupperId" parameterType="java.lang.Long" resultMap="BaseResultMap"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List" /> | 
|---|
|  |  |  | from ba_district | 
|---|
|  |  |  | where deleted != 1 and supperId = #{supperId,jdbcType=BIGINT} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | insert into ba_district (id, supperId, `name`, num, `level`, deleted) | 
|---|
|  |  |  | values (#{id,jdbcType=BIGINT}, | 
|---|
|  |  |  | #{supperId,jdbcType=BIGINT}, | 
|---|
|  |  |  | #{name,jdbcType=VARCHAR}, | 
|---|
|  |  |  | #{num,jdbcType=VARCHAR}, | 
|---|
|  |  |  | #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}, | 
|---|
|  |  |  | #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | </insert> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | insert into ba_district | 
|---|
|  |  |  | <trim prefix="(" suffix=")" suffixOverrides=","> | 
|---|
|  |  |  | <if test="id != null"> | 
|---|
|  |  |  | id, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="supperId != null"> | 
|---|
|  |  |  | supperId, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="name != null"> | 
|---|
|  |  |  | `name`, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="num != null"> | 
|---|
|  |  |  | num, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="level != null"> | 
|---|
|  |  |  | `level`, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="deleted != null"> | 
|---|
|  |  |  | deleted, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | <trim prefix="values (" suffix=")" suffixOverrides=","> | 
|---|
|  |  |  | <if test="id != null"> | 
|---|
|  |  |  | #{id,jdbcType=BIGINT}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="supperId != null"> | 
|---|
|  |  |  | #{supperId,jdbcType=BIGINT}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="name != null"> | 
|---|
|  |  |  | #{name,jdbcType=VARCHAR}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="num != null"> | 
|---|
|  |  |  | #{num,jdbcType=VARCHAR}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="level != null"> | 
|---|
|  |  |  | #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}, | 
|---|
|  |  |  | </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.BaDistrict"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | update ba_district | 
|---|
|  |  |  | <set> | 
|---|
|  |  |  | <if test="name != null"> | 
|---|
|  |  |  | `name` = #{name,jdbcType=VARCHAR}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="num != null"> | 
|---|
|  |  |  | num = #{num,jdbcType=VARCHAR}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="supperId != null"> | 
|---|
|  |  |  | supperId = #{supperId,jdbcType=BIGINT}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="level != null"> | 
|---|
|  |  |  | `level` = #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}, | 
|---|
|  |  |  | </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.BaDistrict"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | update ba_district | 
|---|
|  |  |  | set supperId = #{supperId,jdbcType=BIGINT}, | 
|---|
|  |  |  | `name` = #{name,jdbcType=VARCHAR}, | 
|---|
|  |  |  | num = #{num,jdbcType=VARCHAR}, | 
|---|
|  |  |  | `level` = #{level,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}, | 
|---|
|  |  |  | 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_district | 
|---|
|  |  |  | where id = #{id,jdbcType=BIGINT} | 
|---|
|  |  |  | </delete> | 
|---|
|  |  |  | <delete id="deleteLogicById" parameterType="java.lang.Long"> | 
|---|
|  |  |  | <!--@mbg.generated--> | 
|---|
|  |  |  | update ba_district set deleted = 1 | 
|---|
|  |  |  | where id = #{id,jdbcType=BIGINT} | 
|---|
|  |  |  | </delete> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--根据村编号获取5级区划信息--> | 
|---|
|  |  |  | <select id="getDistrictsByVillageId" resultType="java.util.Map"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | pro.id AS provinceId, | 
|---|
|  |  |  | pro.num AS provinceNum, | 
|---|
|  |  |  | pro.name AS provinceName, | 
|---|
|  |  |  | cit.id AS cityId, | 
|---|
|  |  |  | cit.num AS cityNum, | 
|---|
|  |  |  | cit.name AS cityName, | 
|---|
|  |  |  | con.id AS countryId, | 
|---|
|  |  |  | con.num AS countyNum, | 
|---|
|  |  |  | con.name AS countryName, | 
|---|
|  |  |  | tow.id AS townId, | 
|---|
|  |  |  | tow.num AS townNum, | 
|---|
|  |  |  | tow.name AS townName, | 
|---|
|  |  |  | vil.id AS villageId, | 
|---|
|  |  |  | vil.num AS villageNum, | 
|---|
|  |  |  | vil.name AS villageName | 
|---|
|  |  |  | FROM ba_district vil | 
|---|
|  |  |  | INNER JOIN ba_district tow ON vil.supperId = tow.id | 
|---|
|  |  |  | INNER JOIN ba_district con ON tow.supperId = con.id | 
|---|
|  |  |  | INNER JOIN ba_district cit ON con.supperId = cit.id | 
|---|
|  |  |  | INNER JOIN ba_district pro ON cit.supperId = pro.id | 
|---|
|  |  |  | WHERE vil.id = #{villageId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--根据级别获取行政区划列表--> | 
|---|
|  |  |  | <select id="getDistrictgsByLevel" resultType="java.util.Map"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | CAST(id AS char) AS id, | 
|---|
|  |  |  | name | 
|---|
|  |  |  | FROM ba_district WHERE `level` = #{level} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--根据父ID获取行政区划列表--> | 
|---|
|  |  |  | <select id="getDistrictsBySupperId" resultType="java.util.Map"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | CAST(id AS char) AS id, | 
|---|
|  |  |  | name | 
|---|
|  |  |  | FROM ba_district WHERE supperId = #{supperId} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|