<?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.panzhihua.service_equipment.dao.UnionShippingAddressMapper">
|
<resultMap type="com.panzhihua.service_equipment.model.dos.UnionShippingAddress" id="ItemMap">
|
<result property="id" column="id"/>
|
<result property="communityId" column="community_id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="userId" column="user_id"/>
|
<result property="address" column="address"/>
|
<result property="lat" column="lat"/>
|
<result property="lng" column="lng"/>
|
<result property="phone" column="phone"/>
|
<result property="name" column="name"/>
|
<result property="isDefault" column="is_default"/>
|
<result property="gender" column="gender"/>
|
<result property="houseNum" column="house_num"/>
|
<result property="city" column="city"/>
|
</resultMap>
|
|
|
<sql id="base_sql">
|
id,
|
address,
|
lat,
|
lng,
|
user_id,
|
phone,
|
`name`,
|
community_id,
|
create_time,
|
update_time,
|
is_default,
|
gender,
|
house_num,
|
city
|
</sql>
|
|
|
<select id="getData" resultMap="ItemMap">
|
select <include refid="base_sql"/>
|
from union_shipping_address
|
where id=#{id}
|
order by create_time desc
|
</select>
|
|
|
<select id="getDefaultData" resultMap="ItemMap">
|
select <include refid="base_sql"/>
|
from union_shipping_address
|
where user_id=#{userId} and is_default='true'
|
order by create_time desc
|
</select>
|
|
|
|
<select id="getList" resultMap="ItemMap">
|
select <include refid="base_sql"/>
|
from union_shipping_address
|
<where>
|
1=1
|
<if test="communityId!=null and communityId!='' ">
|
and community_id=#{communityId}
|
</if>
|
<if test="userId!=null and userId!='' ">
|
and user_id=#{userId}
|
</if>
|
</where>
|
order by create_time desc
|
</select>
|
|
<insert id="insert">
|
insert into union_shipping_address
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="item.userId != null and item.userId != '' ">
|
user_id,
|
</if>
|
<if test="item.communityId != null and item.communityId != '' ">
|
community_id,
|
</if>
|
<if test="item.lat != null and item.lat != '' ">
|
lat,
|
</if>
|
<if test="item.lng != null and item.lng != '' ">
|
lng,
|
</if>
|
<if test="item.address != null and item.address != '' ">
|
address,
|
</if>
|
<if test="item.phone != null and item.phone != '' ">
|
phone,
|
</if>
|
<if test="item.name != null and item.name != '' ">
|
`name`,
|
</if>
|
<if test="item.isDefault != null and item.isDefault != '' ">
|
is_default,
|
</if>
|
<if test="item.gender != null and item.gender != '' ">
|
gender,
|
</if>
|
<if test="item.houseNum != null and item.houseNum != '' ">
|
house_num,
|
</if>
|
<if test="item.city != null and item.city != '' ">
|
city,
|
</if>
|
create_time
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="item.userId != null and item.userId != '' ">
|
#{item.userId},
|
</if>
|
<if test="item.communityId != null and item.communityId != '' ">
|
#{item.communityId},
|
</if>
|
<if test="item.lat != null and item.lat != '' ">
|
#{item.lat},
|
</if>
|
<if test="item.lng != null and item.lng != '' ">
|
#{item.lng},
|
</if>
|
<if test="item.address != null and item.address != '' ">
|
#{item.address},
|
</if>
|
<if test="item.phone != null and item.phone != '' ">
|
#{item.phone},
|
</if>
|
<if test="item.name != null and item.name != '' ">
|
#{item.name},
|
</if>
|
<if test="item.isDefault != null and item.isDefault != '' ">
|
#{item.isDefault},
|
</if>
|
<if test="item.gender != null and item.gender != '' ">
|
#{item.gender},
|
</if>
|
<if test="item.houseNum != null and item.houseNum != '' ">
|
#{item.houseNum},
|
</if>
|
<if test="item.city != null and item.city != '' ">
|
#{item.city},
|
</if>
|
|
sysdate()
|
</trim>
|
</insert>
|
|
<update id="update">
|
update union_shipping_address
|
<set>
|
<if test="item.userId != null and item.userId != '' ">
|
user_id=#{item.userId},
|
</if>
|
<if test="item.communityId != null and item.communityId != '' ">
|
community_id=#{item.communityId},
|
</if>
|
<if test="item.lat != null and item.lat != '' ">
|
lat=#{item.lat},
|
</if>
|
<if test="item.lng != null and item.lng != '' ">
|
lng=#{item.lng},
|
</if>
|
<if test="item.address != null and item.address != '' ">
|
address=#{item.address},
|
</if>
|
<if test="item.phone != null and item.phone != '' ">
|
phone=#{item.phone},
|
</if>
|
<if test="item.name != null and item.name != '' ">
|
`name`=#{item.name},
|
</if>
|
<if test="item.isDefault != null and item.isDefault != '' ">
|
is_default=#{item.isDefault},
|
</if>
|
<if test="item.gender != null and item.gender != '' ">
|
gender=#{item.gender},
|
</if>
|
<if test="item.houseNum != null and item.houseNum != '' ">
|
house_num=#{item.houseNum},
|
</if>
|
<if test="item.city != null and item.city != '' ">
|
city=#{item.city},
|
</if>
|
update_time=sysdate()
|
</set>
|
where id = #{item.id}
|
</update>
|
|
<delete id="delete" parameterType="String">
|
delete from union_shipping_address where id=#{id}
|
</delete>
|
|
|
|
|
</mapper>
|