<?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.yunfeiyun.agmp.common.web.system.mapper.SysZoneMapper">
    
    <resultMap type="SysZone" id="SysZoneResult">
        <result property="zoneId"    column="zoneId"    />
        <result property="zoneCode"    column="zoneCode"    />
        <result property="zoneCityen"    column="zoneCityen"    />
        <result property="zoneCityzh"    column="zoneCityzh"    />
        <result property="zoneProvinceen"    column="zoneProvinceen"    />
        <result property="zoneProvincezh"    column="zoneProvincezh"    />
        <result property="zoneCountryen"    column="zoneCountryen"    />
        <result property="zoneCountryzh"    column="zoneCountryzh"    />
        <result property="zoneCapitalen"    column="zoneCapitalen"    />
        <result property="zoneCapitalzh"    column="zoneCapitalzh"    />
        <result property="zoneLatitude"    column="zoneLatitude"    />
        <result property="zoneLongitude"    column="zoneLongitude"    />
    </resultMap>

    <sql id="selectSysZoneVo">
        select zoneId, zoneCode, zoneCityen, zoneCityzh, zoneProvinceen, zoneProvincezh, zoneCountryen, zoneCountryzh, zoneCapitalen, zoneCapitalzh, zoneLatitude, zoneLongitude from SysZone
    </sql>

    <select id="selectSysZoneList" parameterType="SysZone" resultMap="SysZoneResult">
        <include refid="selectSysZoneVo"/>
        <where>
            <if test="zoneCode != null  and zoneCode != ''"> and zoneCode = #{zoneCode}</if>
            <if test="zoneCityen != null  and zoneCityen != ''"> and zoneCityen = #{zoneCityen}</if>
            <if test="zoneCityzh != null  and zoneCityzh != ''"> and zoneCityzh = #{zoneCityzh}</if>
            <if test="zoneProvinceen != null  and zoneProvinceen != ''"> and zoneProvinceen = #{zoneProvinceen}</if>
            <if test="zoneProvincezh != null  and zoneProvincezh != ''"> and zoneProvincezh = #{zoneProvincezh}</if>
            <if test="zoneCountryen != null  and zoneCountryen != ''"> and zoneCountryen = #{zoneCountryen}</if>
            <if test="zoneCountryzh != null  and zoneCountryzh != ''"> and zoneCountryzh = #{zoneCountryzh}</if>
            <if test="zoneCapitalen != null  and zoneCapitalen != ''"> and zoneCapitalen = #{zoneCapitalen}</if>
            <if test="zoneCapitalzh != null  and zoneCapitalzh != ''"> and zoneCapitalzh = #{zoneCapitalzh}</if>
            <if test="zoneLatitude != null  and zoneLatitude != ''"> and zoneLatitude = #{zoneLatitude}</if>
            <if test="zoneLongitude != null  and zoneLongitude != ''"> and zoneLongitude = #{zoneLongitude}</if>
        </where>
    </select>


    <select id="selectSysZoneListProvincezh" parameterType="SysZone" resultMap="SysZoneResult">
        SELECT zoneProvincezh FROM SysZone group by zoneProvincezh;
    </select>

    <select id="selectSysZoneListCapitalzh" parameterType="SysZone" resultMap="SysZoneResult">
        SELECT zoneCapitalzh, zoneProvincezh FROM SysZone group by zoneCapitalzh, zoneProvincezh;
    </select>

    <select id="selectSysZoneByZoneId" parameterType="String" resultMap="SysZoneResult">
        <include refid="selectSysZoneVo"/>
        where zoneId = #{zoneId}
    </select>
        
    <insert id="insertSysZone" parameterType="SysZone">
        insert into SysZone
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="zoneId != null">zoneId,</if>
            <if test="zoneCode != null">zoneCode,</if>
            <if test="zoneCityen != null">zoneCityen,</if>
            <if test="zoneCityzh != null">zoneCityzh,</if>
            <if test="zoneProvinceen != null">zoneProvinceen,</if>
            <if test="zoneProvincezh != null">zoneProvincezh,</if>
            <if test="zoneCountryen != null">zoneCountryen,</if>
            <if test="zoneCountryzh != null">zoneCountryzh,</if>
            <if test="zoneCapitalen != null">zoneCapitalen,</if>
            <if test="zoneCapitalzh != null">zoneCapitalzh,</if>
            <if test="zoneLatitude != null">zoneLatitude,</if>
            <if test="zoneLongitude != null">zoneLongitude,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="zoneId != null">#{zoneId},</if>
            <if test="zoneCode != null">#{zoneCode},</if>
            <if test="zoneCityen != null">#{zoneCityen},</if>
            <if test="zoneCityzh != null">#{zoneCityzh},</if>
            <if test="zoneProvinceen != null">#{zoneProvinceen},</if>
            <if test="zoneProvincezh != null">#{zoneProvincezh},</if>
            <if test="zoneCountryen != null">#{zoneCountryen},</if>
            <if test="zoneCountryzh != null">#{zoneCountryzh},</if>
            <if test="zoneCapitalen != null">#{zoneCapitalen},</if>
            <if test="zoneCapitalzh != null">#{zoneCapitalzh},</if>
            <if test="zoneLatitude != null">#{zoneLatitude},</if>
            <if test="zoneLongitude != null">#{zoneLongitude},</if>
         </trim>
    </insert>

    <update id="updateSysZone" parameterType="SysZone">
        update SysZone
        <trim prefix="SET" suffixOverrides=",">
            <if test="zoneCode != null">zoneCode = #{zoneCode},</if>
            <if test="zoneCityen != null">zoneCityen = #{zoneCityen},</if>
            <if test="zoneCityzh != null">zoneCityzh = #{zoneCityzh},</if>
            <if test="zoneProvinceen != null">zoneProvinceen = #{zoneProvinceen},</if>
            <if test="zoneProvincezh != null">zoneProvincezh = #{zoneProvincezh},</if>
            <if test="zoneCountryen != null">zoneCountryen = #{zoneCountryen},</if>
            <if test="zoneCountryzh != null">zoneCountryzh = #{zoneCountryzh},</if>
            <if test="zoneCapitalen != null">zoneCapitalen = #{zoneCapitalen},</if>
            <if test="zoneCapitalzh != null">zoneCapitalzh = #{zoneCapitalzh},</if>
            <if test="zoneLatitude != null">zoneLatitude = #{zoneLatitude},</if>
            <if test="zoneLongitude != null">zoneLongitude = #{zoneLongitude},</if>
        </trim>
        where zoneId = #{zoneId}
    </update>

    <delete id="deleteSysZoneByZoneId" parameterType="String">
        delete from SysZone where zoneId = #{zoneId}
    </delete>

    <delete id="deleteSysZoneByZoneIds" parameterType="String">
        delete from SysZone where zoneId in 
        <foreach item="zoneId" collection="array" open="(" separator="," close=")">
            #{zoneId}
        </foreach>
    </delete>
</mapper>