113 lines
6.0 KiB
XML
113 lines
6.0 KiB
XML
<?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.bonus.canteen.core.user.mapper.UserAddrMapper">
|
|
<resultMap type="com.bonus.canteen.core.user.domain.UserAddr" id="UserAddrResult">
|
|
<result property="userId" column="user_id" />
|
|
<result property="addrId" column="addr_id" />
|
|
<result property="contactName" column="contact_name" />
|
|
<result property="mobile" column="mobile" />
|
|
<result property="areaCode" column="area_code" />
|
|
<result property="detailAddr" column="detail_addr" />
|
|
<result property="addrFullName" column="addr_full_name" />
|
|
<result property="ifDefault" column="if_default" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
</resultMap>
|
|
|
|
<sql id="selectUserAddrVo">
|
|
select user_id, addr_id, contact_name, mobile, area_code, detail_addr, addr_full_name,
|
|
if_default, create_by, create_time, update_by, update_time
|
|
from user_addr
|
|
</sql>
|
|
|
|
<select id="selectUserAddrList" parameterType="com.bonus.canteen.core.user.domain.UserAddr" resultMap="UserAddrResult">
|
|
<include refid="selectUserAddrVo"/>
|
|
<where>
|
|
<if test="userId != null "> and user_id = #{userId}</if>
|
|
<if test="addrId != null "> and addr_id = #{addrId}</if>
|
|
<if test="contactName != null and contactName != ''"> and contact_name like concat('%', #{contactName}, '%')</if>
|
|
<if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if>
|
|
<if test="areaCode != null and areaCode != ''"> and area_code = #{areaCode}</if>
|
|
<if test="detailAddr != null and detailAddr != ''"> and detail_addr = #{detailAddr}</if>
|
|
<if test="addrFullName != null and addrFullName != ''"> and addr_full_name like concat('%', #{addrFullName}, '%')</if>
|
|
<if test="ifDefault != null "> and if_default = #{ifDefault}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectUserAddrById" parameterType="Long" resultMap="UserAddrResult">
|
|
<include refid="selectUserAddrVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertUserAddr" parameterType="com.bonus.canteen.core.user.domain.UserAddr" useGeneratedKeys="true" keyProperty="addrId">
|
|
insert into user_addr
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">user_id,</if>
|
|
<if test="contactName != null and contactName != ''">contact_name,</if>
|
|
<if test="mobile != null and mobile != ''">mobile,</if>
|
|
<if test="areaCode != null and areaCode != ''">area_code,</if>
|
|
<if test="detailAddr != null and detailAddr != ''">detail_addr,</if>
|
|
<if test="addrFullName != null and addrFullName != ''">addr_full_name,</if>
|
|
<if test="ifDefault != null">if_default,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="userId != null">#{userId},</if>
|
|
<if test="contactName != null and contactName != ''">#{contactName},</if>
|
|
<if test="mobile != null and mobile != ''">#{mobile},</if>
|
|
<if test="areaCode != null and areaCode != ''">#{areaCode},</if>
|
|
<if test="detailAddr != null and detailAddr != ''">#{detailAddr},</if>
|
|
<if test="addrFullName != null and addrFullName != ''">#{addrFullName},</if>
|
|
<if test="ifDefault != null">#{ifDefault},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateUserAddr" parameterType="com.bonus.canteen.core.user.domain.UserAddr">
|
|
update user_addr
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="userId != null">user_id = #{userId},</if>
|
|
<if test="contactName != null and contactName != ''">contact_name = #{contactName},</if>
|
|
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
|
|
<if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
|
|
<if test="detailAddr != null and detailAddr != ''">detail_addr = #{detailAddr},</if>
|
|
<if test="addrFullName != null and addrFullName != ''">addr_full_name = #{addrFullName},</if>
|
|
<if test="ifDefault != null">if_default = #{ifDefault},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
</trim>
|
|
where addr_id = #{addrId}
|
|
</update>
|
|
|
|
<update id="updateUserAddrAsNotDefault">
|
|
update user_addr set if_default = #{ifDefault} where user_id = #{userId}
|
|
</update>
|
|
|
|
<update id="updateUserAddrAsDefault">
|
|
update user_addr set if_default = #{ifDefault} where user_id = #{userId} and addr_id = #{addrId}
|
|
</update>
|
|
|
|
<delete id="deleteUserAddrById" parameterType="Long">
|
|
delete from user_addr where addr_id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteUserAddrByIds" parameterType="String">
|
|
delete from user_addr where addr_id in
|
|
<foreach item="addrId" collection="array" open="(" separator="," close=")">
|
|
#{addrId}
|
|
</foreach>
|
|
</delete>
|
|
</mapper>
|