AdministrationAreaMapper.xml 4.55 KB
<?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.lhcredit.project.business.Administration.mapper.AdministrationAreaMapper">
    
    <resultMap type="AdministrationArea" id="AdministrationAreaResult">
        <result property="id"    column="id"    />
        <result property="areaCode"    column="area_code"    />
        <result property="areaName"    column="area_name"    />
        <result property="areaAbbreviation"    column="area_abbreviation"    />
        <result property="rank"    column="rank"    />
        <result property="postcode"    column="postcode"    />
        <result property="areaMark"    column="area_mark"    />
    </resultMap>
	
	<sql id="selectAdministrationAreaVo">
        select id, area_code, area_name, area_abbreviation, rank, postcode, area_mark from administration_area
    </sql>
	
    <select id="selectAdministrationAreaList" parameterType="AdministrationArea" resultMap="AdministrationAreaResult">
        <include refid="selectAdministrationAreaVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="areaCode != null  and areaCode != '' "> and area_code = #{areaCode}</if>
            <if test="areaName != null  and areaName != '' "> and area_name = #{areaName}</if>
            <if test="areaAbbreviation != null  and areaAbbreviation != '' "> and area_abbreviation = #{areaAbbreviation}</if>
            <if test="rank != null  and rank != '' "> and rank = #{rank}</if>
            <if test="postcode != null  and postcode != '' "> and postcode = #{postcode}</if>
            <if test="areaMark != null  and areaMark != '' "> and area_mark = #{areaMark}</if>
        </where>
    </select>
    
    <select id="selectAdministrationAreaById" parameterType="Long" resultMap="AdministrationAreaResult">
        <include refid="selectAdministrationAreaVo"/>
        where id = #{id}
    </select>

    <insert id="insertAdministrationArea" parameterType="AdministrationArea" useGeneratedKeys="true" keyProperty="id">
        insert into administration_area
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="areaCode != null  and areaCode != ''  ">area_code,</if>
			<if test="areaName != null  and areaName != ''  ">area_name,</if>
			<if test="areaAbbreviation != null  and areaAbbreviation != ''  ">area_abbreviation,</if>
			<if test="rank != null  and rank != ''  ">rank,</if>
			<if test="postcode != null  and postcode != ''  ">postcode,</if>
			<if test="areaMark != null  and areaMark != ''  ">area_mark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="areaCode != null  and areaCode != ''  ">#{areaCode},</if>
			<if test="areaName != null  and areaName != ''  ">#{areaName},</if>
			<if test="areaAbbreviation != null  and areaAbbreviation != ''  ">#{areaAbbreviation},</if>
			<if test="rank != null  and rank != ''  ">#{rank},</if>
			<if test="postcode != null  and postcode != ''  ">#{postcode},</if>
			<if test="areaMark != null  and areaMark != ''  ">#{areaMark},</if>
         </trim>
    </insert>
	 
    <update id="updateAdministrationArea" parameterType="AdministrationArea">
        update administration_area
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaCode != null  and areaCode != ''  ">area_code = #{areaCode},</if>
            <if test="areaName != null  and areaName != ''  ">area_name = #{areaName},</if>
            <if test="areaAbbreviation != null  and areaAbbreviation != ''  ">area_abbreviation = #{areaAbbreviation},</if>
            <if test="rank != null  and rank != ''  ">rank = #{rank},</if>
            <if test="postcode != null  and postcode != ''  ">postcode = #{postcode},</if>
            <if test="areaMark != null  and areaMark != ''  ">area_mark = #{areaMark},</if>
        </trim>
        where id = #{id}
    </update>

	<delete id="deleteAdministrationAreaById" parameterType="Long">
        delete from administration_area where id = #{id}
    </delete>
	
    <delete id="deleteAdministrationAreaByIds" parameterType="String">
        delete from administration_area where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>


    <select id="queryByAreaCode" resultType="com.lhcredit.project.business.Administration.domain.AdministrationArea" resultMap="AdministrationAreaResult">
        <include refid="selectAdministrationAreaVo"/>
        where area_code = #{newareaCode}
    </select>
    
</mapper>