2022-05-13 10:27:08 +08:00
|
|
|
<?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.ghy.customer.mapper.CustomerAddressMapper">
|
|
|
|
|
|
|
|
|
|
<resultMap id="CustomerAddressResult" type="com.ghy.customer.domain.CustomerAddress">
|
|
|
|
|
<result property="customerAddressId" column="customer_address_id" />
|
|
|
|
|
<result property="customerId" column="customer_id" />
|
|
|
|
|
<result property="name" column="name" />
|
|
|
|
|
<result property="phone" column="phone" />
|
|
|
|
|
<result property="provinceId" column="province_id"/>
|
|
|
|
|
<result property="cityId" column="city_id"/>
|
|
|
|
|
<result property="countryId" column="country_id"/>
|
|
|
|
|
<result property="address" column="address"/>
|
|
|
|
|
<result property="status" column="status" />
|
2022-05-17 12:38:27 +08:00
|
|
|
<result property="isDefault" column="is_default" />
|
2022-05-13 10:27:08 +08:00
|
|
|
<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="remark" column="remark" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectCustomerAddress">
|
2022-05-17 00:00:26 +08:00
|
|
|
SELECT customer_address_id, customer_id, name, phone, province_id, city_id, country_id, status,
|
2022-05-17 21:10:10 +08:00
|
|
|
address, create_by, create_time, remark, is_default
|
2022-05-13 10:27:08 +08:00
|
|
|
FROM customer_address
|
|
|
|
|
</sql>
|
2022-05-17 21:10:10 +08:00
|
|
|
|
2022-05-13 10:27:08 +08:00
|
|
|
<select id="getCustomerAddressList" resultMap="CustomerAddressResult">
|
|
|
|
|
<include refid="selectCustomerAddress" />
|
2022-08-25 00:05:50 +08:00
|
|
|
<where>
|
2022-09-20 23:00:35 +08:00
|
|
|
deleted = 0
|
2022-08-25 00:05:50 +08:00
|
|
|
<if test="customerId != null">
|
|
|
|
|
AND customer_id = #{customerId}
|
|
|
|
|
</if>
|
2023-10-21 03:04:05 +08:00
|
|
|
<if test="cityIds != null and cityIds.size > 0">
|
|
|
|
|
AND city_id IN
|
|
|
|
|
<foreach collection="cityIds" item="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="districtIds != null and districtIds.size > 0">
|
|
|
|
|
AND country_id IN
|
|
|
|
|
<foreach collection="districtIds" item="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
2022-08-25 00:05:50 +08:00
|
|
|
</where>
|
2022-05-13 10:27:08 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteByIds">
|
2022-09-20 23:00:35 +08:00
|
|
|
UPDATE customer_address SET deleted = 1 WHERE customer_address_id IN
|
2022-05-13 10:27:08 +08:00
|
|
|
<foreach collection="array" item="customerIds" open="(" separator="," close=")">
|
|
|
|
|
#{customerAddressIds}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteByCustomerAddressId" parameterType="Long">
|
2022-09-20 23:00:35 +08:00
|
|
|
UPDATE customer_address SET deleted = 1 WHERE customer_address_id = #{customerAddressId}
|
2022-05-13 10:27:08 +08:00
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<select id="selectByCustomerId" resultMap="CustomerAddressResult">
|
|
|
|
|
<include refid="selectCustomerAddress"/>
|
|
|
|
|
<where>
|
2022-09-20 23:00:35 +08:00
|
|
|
deleted = 0
|
2022-05-13 10:27:08 +08:00
|
|
|
<if test="customerId != null and customerId != 0">
|
|
|
|
|
AND customer_id = #{customerId}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectByCustomerAddressId" resultMap="CustomerAddressResult">
|
|
|
|
|
<include refid="selectCustomerAddress"/>
|
2023-02-16 23:01:36 +08:00
|
|
|
WHERE customer_address_id = #{customerAddressId}
|
2022-05-13 10:27:08 +08:00
|
|
|
</select>
|
|
|
|
|
|
2023-05-17 21:31:48 +08:00
|
|
|
<select id="selectByCustomerAndAddress" resultMap="CustomerAddressResult">
|
|
|
|
|
<include refid="selectCustomerAddress"/>
|
|
|
|
|
WHERE customer_id = #{customerId}
|
|
|
|
|
AND province_id = #{provinceId}
|
|
|
|
|
AND city_id = #{cityId}
|
|
|
|
|
AND country_id = #{countryId}
|
|
|
|
|
AND address = #{address}
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-05-13 10:27:08 +08:00
|
|
|
<insert id="insertCustomerAddress" parameterType="com.ghy.customer.domain.CustomerAddress" useGeneratedKeys="true" keyProperty="customerAddressId">
|
|
|
|
|
insert into customer_address(
|
|
|
|
|
<if test="customerId != null and customerId != 0">customer_id,</if>
|
|
|
|
|
<if test="name != null and name != ''">name,</if>
|
|
|
|
|
<if test="phone != null and phone != ''">phone,</if>
|
|
|
|
|
<if test="provinceId != null and provinceId != 0">province_id,</if>
|
|
|
|
|
<if test="cityId != null and cityId != 0">city_id,</if>
|
|
|
|
|
<if test="countryId != null and countryId != 0">country_id,</if>
|
|
|
|
|
<if test="status != null and status != ''">status,</if>
|
2022-05-17 12:38:27 +08:00
|
|
|
<if test="address != null and address != ''">address,</if>
|
2022-05-17 21:10:10 +08:00
|
|
|
<if test="isDefault != null">is_default,</if>
|
2022-05-13 10:27:08 +08:00
|
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
|
|
|
<if test="remark != null and remark != ''">remark,</if>
|
2022-09-20 23:00:35 +08:00
|
|
|
deleted,
|
2022-05-13 10:27:08 +08:00
|
|
|
create_time
|
|
|
|
|
)values(
|
2022-05-17 11:28:19 +08:00
|
|
|
<if test="customerId != null and customerId != 0">#{customerId},</if>
|
|
|
|
|
<if test="name != null and name != ''">#{name},</if>
|
|
|
|
|
<if test="phone != null and phone != ''">#{phone},</if>
|
|
|
|
|
<if test="provinceId != null and provinceId != 0">#{provinceId},</if>
|
|
|
|
|
<if test="cityId != null and cityId != 0">#{cityId},</if>
|
|
|
|
|
<if test="countryId != null and countryId != 0">#{countryId},</if>
|
|
|
|
|
<if test="status != null">#{status},</if>
|
2022-05-17 12:38:27 +08:00
|
|
|
<if test="address != null and address != ''">#{address},</if>
|
2022-07-19 09:55:00 +08:00
|
|
|
<if test="isDefault != null">#{isDefault},</if>
|
2022-05-17 11:28:19 +08:00
|
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
|
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
2022-09-20 23:00:35 +08:00
|
|
|
0,
|
2022-05-13 10:27:08 +08:00
|
|
|
sysdate()
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateCustomerAddress" parameterType="com.ghy.customer.domain.CustomerAddress">
|
2022-05-17 21:10:10 +08:00
|
|
|
update customer_address
|
2022-05-13 10:27:08 +08:00
|
|
|
<set>
|
2022-05-17 11:28:19 +08:00
|
|
|
<if test="name != null and name != ''">name = #{name},</if>
|
|
|
|
|
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
|
|
|
|
<if test="provinceId != null and provinceId != 0">province_id = #{provinceId},</if>
|
|
|
|
|
<if test="cityId != null and cityId != 0">city_id = #{cityId},</if>
|
|
|
|
|
<if test="countryId != null and countryId != 0">country_id = #{countryId},</if>
|
2022-05-13 10:27:08 +08:00
|
|
|
<if test="address != null and address != ''">address = #{address},</if>
|
2022-05-17 21:10:10 +08:00
|
|
|
<if test="isDefault != null">is_default = #{isDefault},</if>
|
2022-05-13 10:27:08 +08:00
|
|
|
<if test="status != null and status != ''">status = #{status},</if>
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
|
|
|
update_time = sysdate()
|
|
|
|
|
</set>
|
|
|
|
|
where customer_address_id = #{customerAddressId}
|
|
|
|
|
</update>
|
|
|
|
|
|
2022-05-17 21:10:10 +08:00
|
|
|
</mapper>
|