UserAddressInfoMapper.xml
4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?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="id != null "> and id = #{id}</if>
<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>