<?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.muchinfo.mtp3interface.mapper.IDivisionMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.muchinfo.mtp3pojos.entity.Division">
        <id column="AUTOID" property="autoid" />
        <result column="DIVISIONCODE" property="divisioncode" />
        <result column="SHORTCODE" property="shortcode" />
        <result column="PARENTCODE" property="parentcode" />
        <result column="DIVISIONLEVEL" property="divisionlevel" />
        <result column="DIVISIONNAME" property="divisionname" />
        <result column="PATHNAME" property="pathname" />
        <result column="SEPARABLENAME" property="separablename" />
        <result column="POSTCODE" property="postcode" />
        <result column="MODIFYTIME" property="modifytime" />
        <result column="MODIFIERID" property="modifierid" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        AUTOID, DIVISIONCODE, SHORTCODE, PARENTCODE, DIVISIONLEVEL, DIVISIONNAME, PATHNAME, SEPARABLENAME, POSTCODE, MODIFYTIME, MODIFIERID
    </sql>
    <update id="updateByParentCode">
        UPDATE DIVISION SET PARENTCODE = #{newcode, jdbcType=VARCHAR} WHERE PARENTCODE = #{oldcode, jdbcType=VARCHAR}
    </update>

    <select id="getProvince" resultMap="BaseResultMap">
        select autoid,divisionname from division where 1=1
        <if test="divisionlevel != null and divisionlevel != '' ">
            and divisionlevel=#{divisionlevel}
        </if>
        <if test="autoid != null and autoid != '' ">
            and parentcode =
            (select divisioncode from division where
            autoid= #{autoid})
        </if>
    </select>

    <select id="selectAreaPathName" resultType="string" parameterType="java.lang.Long">
        select pathname from division where autoid = #{districtid}
    </select>

</mapper>
