From 206f601b1f2a2e3cb0bf4f5dead01bec9077d8e9 Mon Sep 17 00:00:00 2001
From: 彭雪彬 <1724387007@qq.com>
Date: Thu, 04 Sep 2025 15:28:52 +0800
Subject: [PATCH] Merge branch 'xin' into pxb
---
oying-system/src/main/resources/mapper/sh/UserAddressMapper.xml | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/oying-system/src/main/resources/mapper/sh/UserAddressMapper.xml b/oying-system/src/main/resources/mapper/sh/UserAddressMapper.xml
index 52be65d..71bfbea 100644
--- a/oying-system/src/main/resources/mapper/sh/UserAddressMapper.xml
+++ b/oying-system/src/main/resources/mapper/sh/UserAddressMapper.xml
@@ -10,11 +10,13 @@
<result column="city" property="city"/>
<result column="district" property="district"/>
<result column="street" property="street"/>
+ <result column="short_address" property="shortAddress"/>
<result column="detail" property="detail"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
<result column="is_default" property="isDefault"/>
<result column="tag" property="tag"/>
+ <result column="distance" property="distance"/>
<result column="create_by" property="createBy"/>
<result column="create_time" property="createTime"/>
<result column="update_by" property="updateBy"/>
@@ -22,19 +24,35 @@
</resultMap>
<sql id="Base_Column_List">
- address_id, user_id, receiver_name, receiver_phone, province, city, district, street, detail, longitude, latitude, is_default, tag, create_by, create_time, update_by, update_time
+ address_id, user_id, receiver_name, receiver_phone, province, city, district, street, short_address, detail, longitude, latitude, is_default, tag, create_by, create_time, update_by, update_time
</sql>
+ <update id="isDefault">
+ update sh_user_address
+ set is_default = false
+ where user_id = #{userId}
+ </update>
<select id="findAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
+ <if test="criteria.longitude != null and criteria.latitude != null and criteria.longitude != '' and criteria.latitude != ''">
+ , ROUND(ST_Distance_Sphere(POINT(#{criteria.longitude}, #{criteria.latitude}), POINT(longitude,
+ latitude)), 2) distance
+ </if>
from sh_user_address
<where>
- <if test="criteria.userId != null">
+ <if test="criteria.userId != null and criteria.userId != ''">
and user_id = #{criteria.userId}
</if>
- <if test="criteria.tag != null">
+ <if test="criteria.tag != null and criteria.tag != ''">
and tag = #{criteria.tag}
+ </if>
+ <if test="criteria.phone != null and criteria.phone != ''">
+ and receiver_phone like concat('%',#{criteria.phone},'%')
+ </if>
+ <if test="criteria.radius != null and criteria.radius != ''">
+ and ST_Distance_Sphere(POINT(#{criteria.longitude}, #{criteria.latitude}), POINT(longitude,
+ latitude)) distance <= #{criteria.radius}
</if>
<if test="criteria.createTime != null and criteria.createTime.size() > 0">
AND create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]}
@@ -42,4 +60,11 @@
</where>
order by address_id desc
</select>
-</mapper>
\ No newline at end of file
+ <select id="getById" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List"/>
+ , ROUND(ST_Distance_Sphere(POINT(#{longitude}, #{latitude}), POINT(longitude, latitude)), 2) distance
+ from sh_user_address
+ where user_id = #{userId} and address_id = #{addressId}
+ </select>
+</mapper>
--
Gitblit v1.9.3