CountryNameMapper.xml 2.46 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.country.mapper.CountryNameMapper">
    
    <resultMap type="CountryName" id="CountryResult">
        <result property="jc"    column="jc"    />
        <result property="gj"    column="gj"    />
        <result property="en"    column="en"    />
        <result property="jcCode"    column="jc_code"    />
    </resultMap>
	
	<sql id="selectCountryVo">
        select jc, gj, en,jc_code from country
    </sql>
	
    <select id="selectCountryList" parameterType="CountryName" resultMap="CountryResult">
        <include refid="selectCountryVo"/>
        <where>  
            <if test="jc != null  and jc != '' "> and jc = #{jc}</if>
            <if test="gj != null  and gj != '' "> and gj = #{gj}</if>
            <if test="en != null  and en != '' "> and en = #{en}</if>
            <if test="jcCode != null  and jcCode != '' "> and jc_code = #{jcCode}</if>
        </where>
    </select>
    
    <select id="selectCountryById" parameterType="String" resultMap="CountryResult">
        <include refid="selectCountryVo"/>
        where jc = #{jc}
    </select>


        
    <insert id="insertCountry" parameterType="CountryName">
        insert into country
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="jc != null  and jc != ''  ">jc,</if>
			<if test="gj != null  and gj != ''  ">gj,</if>
			<if test="en != null  and en != ''  ">en,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="jc != null  and jc != ''  ">#{jc},</if>
			<if test="gj != null  and gj != ''  ">#{gj},</if>
			<if test="en != null  and en != ''  ">#{en},</if>
         </trim>
    </insert>
	 
    <update id="updateCountry" parameterType="CountryName">
        update country
        <trim prefix="SET" suffixOverrides=",">
            <if test="gj != null  and gj != ''  ">gj = #{gj},</if>
            <if test="en != null  and en != ''  ">en = #{en},</if>
        </trim>
        where jc = #{jc}
    </update>

	<delete id="deleteCountryById" parameterType="String">
        delete from country where jc = #{jc}
    </delete>
	
    <delete id="deleteCountryByIds" parameterType="String">
        delete from country where jc in 
        <foreach item="jc" collection="array" open="(" separator="," close=")">
            #{jc}
        </foreach>
    </delete>
    
</mapper>