<?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.matrix.system.shopXcx.dao.ShopReceiveAddressDao">
|
<!-- 定义ShopReceiveAddress 的复杂关联map -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopReceiveAddress" id="ShopReceiveAddressMap">
|
<id property="addrId" column="addr_id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="addrUserid" column="addr_userid" />
|
<result property="addrLiaisonman" column="addr_liaisonman" />
|
<result property="addrTelephone" column="addr_telephone" />
|
<result property="addrProvince" column="addr_province" />
|
<result property="addrCity" column="addr_city" />
|
<result property="addrArea" column="addr_area" />
|
<result property="addrDetailaddr" column="addr_detailaddr" />
|
<result property="addrDefault" column="addr_default" />
|
<result property="addrRegion" column="addr_region" />
|
<result property="addrLongitude" column="addr_longitude" />
|
<result property="addrLatitude" column="addr_latitude" />
|
<result property="dormitory" column="dormitory" />
|
<result property="school" column="school" />
|
</resultMap>
|
|
|
<!-- 定义ShopReceiveAddress 的简单map ,本map不添加其他的关联属性 -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopReceiveAddress" id="ShopReceiveAddressSimpleMap">
|
<id property="addrId" column="addr_id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="addrUserid" column="addr_userid" />
|
<result property="addrLiaisonman" column="addr_liaisonman" />
|
<result property="addrTelephone" column="addr_telephone" />
|
<result property="addrProvince" column="addr_province" />
|
<result property="addrCity" column="addr_city" />
|
<result property="addrArea" column="addr_area" />
|
<result property="addrDetailaddr" column="addr_detailaddr" />
|
<result property="addrDefault" column="addr_default" />
|
<result property="addrRegion" column="addr_region" />
|
<result property="addrLongitude" column="addr_longitude" />
|
<result property="addrLatitude" column="addr_latitude" />
|
<result property="dormitory" column="dormitory" />
|
<result property="school" column="school" />
|
</resultMap>
|
|
<!-- 字段sql -->
|
<sql id="columns">
|
create_by,
|
create_time,
|
update_by,
|
update_time,
|
addr_id,
|
addr_userid,
|
addr_liaisonman,
|
addr_telephone,
|
addr_province,
|
addr_city,
|
addr_area,
|
addr_detailaddr,
|
addr_default,
|
addr_longitude,
|
addr_latitude,
|
addr_region,
|
dormitory,
|
school
|
</sql>
|
|
<!-- 属性sql -->
|
<sql id="propertys">
|
#{item.createBy},
|
now(),
|
#{item.updateBy},
|
now(),
|
#{item.addrId},
|
#{item.addrUserid},
|
#{item.addrLiaisonman},
|
#{item.addrTelephone},
|
#{item.addrProvince},
|
#{item.addrCity},
|
#{item.addrArea},
|
#{item.addrDetailaddr},
|
#{item.addrDefault},
|
#{item.addrLongitude},
|
#{item.addrLatitude},
|
#{item.addrRegion},
|
#{item.dormitory},
|
#{item.school}
|
</sql>
|
|
<!-- where sql -->
|
<sql id="where_sql">
|
|
<if test="record!=null">
|
<if test="(record.addrId!=null and record.addrId!='') or (record.addrId!='' and record.addrId==0) ">
|
and addr_id = #{record.addrId}
|
</if>
|
<if test="(record.addrUserid!=null and record.addrUserid!='') or (record.addrUserid!='' and record.addrUserid==0) ">
|
and addr_userid = #{record.addrUserid}
|
</if>
|
<if test="(record.addrLiaisonman!=null and record.addrLiaisonman!='') or (record.addrLiaisonman!='' and record.addrLiaisonman==0) ">
|
and addr_liaisonman = #{record.addrLiaisonman}
|
</if>
|
<if test="(record.addrTelephone!=null and record.addrTelephone!='') or (record.addrTelephone!='' and record.addrTelephone==0) ">
|
and addr_telephone = #{record.addrTelephone}
|
</if>
|
<if test="(record.addrProvince!=null and record.addrProvince!='') or (record.addrProvince!='' and record.addrProvince==0) ">
|
and addr_province = #{record.addrProvince}
|
</if>
|
<if test="(record.addrCity!=null and record.addrCity!='') or (record.addrCity!='' and record.addrCity==0) ">
|
and addr_city = #{record.addrCity}
|
</if>
|
<if test="(record.addrArea!=null and record.addrArea!='') or (record.addrArea!='' and record.addrArea==0) ">
|
and addr_area = #{record.addrArea}
|
</if>
|
<if test="(record.addrDetailaddr!=null and record.addrDetailaddr!='') or (record.addrDetailaddr!='' and record.addrDetailaddr==0) ">
|
and addr_detailaddr = #{record.addrDetailaddr}
|
</if>
|
<if test="(record.addrDefault!=null and record.addrDefault!='') or (record.addrDefault!='' and record.addrDefault==0) ">
|
and addr_default = #{record.addrDefault}
|
</if>
|
</if>
|
|
</sql>
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopReceiveAddress"
|
useGeneratedKeys="true" keyProperty="item.addrId">
|
INSERT INTO shop_receive_address (
|
<include refid="columns"></include>
|
)
|
VALUES (
|
<include refid="propertys"></include>
|
)
|
</insert>
|
|
|
|
<!-- 批量插入 -->
|
<insert id="batchInsert" parameterType="java.util.List">
|
INSERT INTO shop_receive_address (
|
<include refid="columns"></include>
|
)
|
VALUES
|
<foreach collection="list" item="item" index="index" separator=",">(
|
<include refid="propertys"></include>
|
)</foreach>
|
</insert>
|
|
|
|
|
|
<!-- 根据Map更新 部分更新 -->
|
<update id="updateByMap" parameterType="java.util.HashMap" >
|
UPDATE shop_receive_address
|
<set>
|
<if test="_parameter.containsKey('addrUserid')">
|
addr_userid = #{addrUserid},
|
</if>
|
<if test="_parameter.containsKey('addrLiaisonman')">
|
addr_liaisonman = #{addrLiaisonman},
|
</if>
|
<if test="_parameter.containsKey('addrTelephone')">
|
addr_telephone = #{addrTelephone},
|
</if>
|
<if test="_parameter.containsKey('addrProvince')">
|
addr_province = #{addrProvince},
|
</if>
|
<if test="_parameter.containsKey('addrCity')">
|
addr_city = #{addrCity},
|
</if>
|
<if test="_parameter.containsKey('addrArea')">
|
addr_area = #{addrArea},
|
</if>
|
<if test="_parameter.containsKey('addrDetailaddr')">
|
addr_detailaddr = #{addrDetailaddr},
|
</if>
|
<if test="_parameter.containsKey('addrDefault')">
|
addr_default = #{addrDefault},
|
</if>
|
<if test="_parameter.containsKey('dormitory')">
|
dormitory = #{dormitory},
|
</if>
|
<if test="_parameter.containsKey('school')">
|
school = #{school},
|
</if>
|
|
|
|
|
</set>
|
WHERE addr_id=#{addrId}
|
</update>
|
|
|
<!-- 根据对象更新 部分更新 -->
|
<update id="updateByModel" parameterType="Integer">
|
UPDATE shop_receive_address
|
<set>
|
<if test="record.addrUserid != null ">
|
addr_userid = #{record.addrUserid},
|
</if>
|
<if test="record.addrLiaisonman != null and record.addrLiaisonman != '' ">
|
addr_liaisonman = #{record.addrLiaisonman},
|
</if>
|
<if test="record.addrTelephone != null and record.addrTelephone != '' ">
|
addr_telephone = #{record.addrTelephone},
|
</if>
|
<if test="record.addrProvince != null and record.addrProvince != '' ">
|
addr_province = #{record.addrProvince},
|
</if>
|
<if test="record.addrCity != null and record.addrCity != '' ">
|
addr_city = #{record.addrCity},
|
</if>
|
<if test="record.addrArea != null and record.addrArea != '' ">
|
addr_area = #{record.addrArea},
|
</if>
|
<if test="record.addrDetailaddr != null and record.addrDetailaddr != '' ">
|
addr_detailaddr = #{record.addrDetailaddr},
|
</if>
|
<if test="record.addrDefault != null ">
|
addr_default = #{record.addrDefault},
|
</if>
|
<if test="record.addrRegion != null ">
|
addr_region = #{record.addrRegion},
|
</if>
|
<if test="record.addrLongitude != null ">
|
addr_longitude = #{record.addrLongitude},
|
</if>
|
<if test="record.addrLatitude != null ">
|
addr_latitude = #{record.addrLatitude},
|
</if>
|
<if test="record.dormitory != null ">
|
dormitory = #{record.dormitory},
|
</if>
|
<if test="record.school != null ">
|
school = #{record.school},
|
</if>
|
|
|
|
|
</set>
|
WHERE addr_id=#{record.addrId}
|
</update>
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from shop_receive_address where addr_id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除-->
|
<delete id="deleteById" parameterType="Integer">
|
DELETE FROM shop_receive_address
|
where addr_id=#{addrId}
|
</delete>
|
|
<!-- 根据对象删除-->
|
<delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopReceiveAddress">
|
DELETE FROM shop_receive_address
|
<where>
|
<include refid="where_sql" ></include>
|
</where>
|
</delete>
|
|
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="ShopReceiveAddressMap">
|
select
|
<include refid="columns" ></include>
|
from shop_receive_address
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 查询总条数 -->
|
<select id="selectTotalRecord" parameterType="long" resultType="java.lang.Integer">
|
select count(*)
|
from shop_receive_address
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</select>
|
|
<!-- 根据id查询-->
|
<select id="selectById" resultMap="ShopReceiveAddressMap">
|
select
|
<include refid="columns" ></include>
|
from shop_receive_address
|
where addr_id=#{addrId}
|
</select>
|
|
|
<select id="selectDefaultAddress" resultMap="ShopReceiveAddressMap">
|
select * from shop_receive_address where addr_default=1 and addr_userid = #{openId}
|
|
</select>
|
<!-- 根据id 锁表查询-->
|
<select id="selectForUpdate" resultMap="ShopReceiveAddressMap">
|
select
|
<include refid="columns" ></include>
|
from shop_receive_address
|
where addr_id=#{addr_id}
|
for update
|
</select>
|
|
|
|
<!-- 根据对象查询-->
|
<select id="selectByModel" resultMap="ShopReceiveAddressMap">
|
select
|
<include refid="columns" ></include>
|
from shop_receive_address
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
order by addr_default asc,create_time desc
|
<if test="record.offset >=0 and record.limit >0">
|
limit
|
#{record.offset},#{record.limit}
|
</if>
|
</select>
|
</mapper>
|