UserAddressInfoMapper.xml 4.7 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.zhonglai.luhui.user.mapper.UserAddressInfoMapper">
    
    <resultMap type="UserAddressInfo" id="UserAddressInfoResult">
        <result property="id"    column="id"    />
        <result property="provinceId"    column="province_id"    />
        <result property="cityId"    column="city_id"    />
        <result property="countyId"    column="county_id"    />
        <result property="provinceName"    column="province_name"    />
        <result property="cityName"    column="city_name"    />
        <result property="countyName"    column="county_name"    />
        <result property="address"    column="address"    />
        <result property="search"    column="search"    />
    </resultMap>

    <sql id="selectUserAddressInfoVo">
        select id, province_id, city_id, county_id, province_name, city_name, county_name, address, search from user_address_info
    </sql>

    <select id="selectUserAddressInfoList" parameterType="UserAddressInfo" resultMap="UserAddressInfoResult">
        <include refid="selectUserAddressInfoVo"/>
        <where>  
            <if test="provinceId != null  and provinceId != ''"> and province_id = #{provinceId}</if>
            <if test="cityId != null  and cityId != ''"> and city_id = #{cityId}</if>
            <if test="countyId != null  and countyId != ''"> and county_id = #{countyId}</if>
            <if test="provinceName != null  and provinceName != ''"> and province_name = #{provinceName}</if>
            <if test="cityName != null  and cityName != ''"> and city_name like concat('%', #{cityName}, '%')</if>
            <if test="countyName != null  and countyName != ''"> and county_name like concat('%', #{countyName}, '%')</if>
            <if test="address != null  and address != ''"> and address like concat('%', #{address}, '%')</if>
            <if test="search != null  and search != ''"> and search = #{search}</if>
        </where>
    </select>
    
    <select id="selectUserAddressInfoById" parameterType="Integer" resultMap="UserAddressInfoResult">
        <include refid="selectUserAddressInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertUserAddressInfo" parameterType="UserAddressInfo">
        insert into user_address_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="provinceId != null">province_id,</if>
            <if test="cityId != null">city_id,</if>
            <if test="countyId != null">county_id,</if>
            <if test="provinceName != null">province_name,</if>
            <if test="cityName != null">city_name,</if>
            <if test="countyName != null">county_name,</if>
            <if test="address != null">address,</if>
            <if test="search != null">search,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="provinceId != null">#{provinceId},</if>
            <if test="cityId != null">#{cityId},</if>
            <if test="countyId != null">#{countyId},</if>
            <if test="provinceName != null">#{provinceName},</if>
            <if test="cityName != null">#{cityName},</if>
            <if test="countyName != null">#{countyName},</if>
            <if test="address != null">#{address},</if>
            <if test="search != null">#{search},</if>
         </trim>
    </insert>

    <update id="updateUserAddressInfo" parameterType="UserAddressInfo">
        update user_address_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="provinceId != null">province_id = #{provinceId},</if>
            <if test="cityId != null">city_id = #{cityId},</if>
            <if test="countyId != null">county_id = #{countyId},</if>
            <if test="provinceName != null">province_name = #{provinceName},</if>
            <if test="cityName != null">city_name = #{cityName},</if>
            <if test="countyName != null">county_name = #{countyName},</if>
            <if test="address != null">address = #{address},</if>
            <if test="search != null">search = #{search},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUserAddressInfoById" parameterType="Integer">
        delete from user_address_info where id = #{id}
    </delete>

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