ghy-all/ghy-custom/src/main/resources/mapper/customer/CustomerAddressMapper.xml

107 lines
5.4 KiB
XML
Raw Normal View History

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" />
<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">
SELECT customer_address_id, customer_id, name, phone, provinceId, cityId, countryId, status,
address, create_by, create_time, remark
FROM customer_address
</sql>
<select id="getCustomerAddressList" resultMap="CustomerAddressResult">
<include refid="selectCustomerAddress" />
</select>
<delete id="deleteByIds">
DELETE FROM customer_address WHERE customer_address_id IN
<foreach collection="array" item="customerIds" open="(" separator="," close=")">
#{customerAddressIds}
</foreach>
</delete>
<delete id="deleteByCustomerAddressId" parameterType="Long">
DELETE FROM customer_address WHERE customer_address_id = #{customerAddressId}
</delete>
<select id="selectByCustomerId" resultMap="CustomerAddressResult">
<include refid="selectCustomerAddress"/>
<where>
<if test="customerId != null and customerId != 0">
AND customer_id = #{customerId}
</if>
</where>
</select>
<select id="selectByCustomerAddressId" resultMap="CustomerAddressResult">
<include refid="selectCustomerAddress"/>
<where>
<if test="customerAddressId != null and customerAddressId != 0">
AND customer_address_id = #{customerAddressId}
</if>
</where>
</select>
<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>
<if test="isDefault != null and isDefault != 0">is_default,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<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>
<if test="isDefault != null and isDefault != 0">${isDefault},</if>
<if test="createBy != null and createBy != ''">${createBy},</if>
<if test="remark != null and remark != ''">${remark},</if>
sysdate()
)
</insert>
<update id="updateCustomerAddress" parameterType="com.ghy.customer.domain.CustomerAddress">
update costomer_address
<set>
<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>
<if test="address != null and address != ''">address = #{address},</if>
<if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
<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>
</mapper>