2022-03-22 14:46:05 +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.CustomerMapper">
|
|
|
|
|
|
2022-05-02 14:48:15 +08:00
|
|
|
<resultMap id="CustomerResult" type="com.ghy.customer.domain.Customer">
|
2022-03-22 15:30:40 +08:00
|
|
|
<result property="customerId" column="customer_id" />
|
|
|
|
|
<result property="name" column="name" />
|
|
|
|
|
<result property="account" column="account" />
|
|
|
|
|
<result property="phone" column="phone" />
|
|
|
|
|
<result property="openId" column="open_id" />
|
2022-05-02 16:31:54 +08:00
|
|
|
<result property="password" column="password" />
|
2022-03-22 15:30:40 +08:00
|
|
|
<result property="status" column="status" />
|
2022-07-20 16:03:44 +08:00
|
|
|
<result property="placeStatus" column="place_status" />
|
2022-03-22 15:30:40 +08:00
|
|
|
<result property="customerLogoUrl" column="customer_logo_url" />
|
2022-05-11 17:35:13 +08:00
|
|
|
<result property="customerPlace" column="customer_place" />
|
|
|
|
|
<result property="parentCustomerPlace" column="parent_customer_place" />
|
2022-03-22 14:46:05 +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>
|
|
|
|
|
|
2022-03-22 15:30:40 +08:00
|
|
|
<sql id="selectCustomer">
|
2022-07-20 16:03:44 +08:00
|
|
|
SELECT customer_id, name, account, phone, open_id, password, status, place_status,
|
2022-05-11 17:35:13 +08:00
|
|
|
customer_logo_url, customer_place, parent_customer_place, create_by, create_time, remark
|
2022-03-22 15:30:40 +08:00
|
|
|
FROM customer
|
2022-03-22 14:46:05 +08:00
|
|
|
</sql>
|
2022-05-19 18:53:19 +08:00
|
|
|
|
2022-08-16 23:00:46 +08:00
|
|
|
<sql id="selectCount">
|
|
|
|
|
SELECT COUNT(*)
|
|
|
|
|
FROM customer
|
|
|
|
|
</sql>
|
|
|
|
|
|
2022-05-02 14:48:15 +08:00
|
|
|
<select id="getCustomerList" resultMap="CustomerResult">
|
|
|
|
|
<include refid="selectCustomer" />
|
2022-05-19 16:21:25 +08:00
|
|
|
<where>
|
2022-11-13 23:21:26 +08:00
|
|
|
<if test="customerId != null">
|
|
|
|
|
AND customer_id = #{customerId}
|
|
|
|
|
</if>
|
2022-05-19 16:21:25 +08:00
|
|
|
<if test="openId != null and openId != ''">
|
|
|
|
|
AND open_id = #{openId}
|
|
|
|
|
</if>
|
2022-08-12 22:24:19 +08:00
|
|
|
<if test="customerPlace != null and customerPlace != ''">
|
|
|
|
|
AND customer_place = #{customerPlace}
|
|
|
|
|
</if>
|
2022-11-21 00:57:57 +08:00
|
|
|
<if test="placeStatus != null">
|
|
|
|
|
AND place_status = #{placeStatus}
|
|
|
|
|
</if>
|
2024-12-09 00:37:48 +08:00
|
|
|
<if test="phone != null and phone != ''">
|
|
|
|
|
AND phone like concat('%', #{phone}, '%')
|
|
|
|
|
</if>
|
2022-05-19 16:21:25 +08:00
|
|
|
</where>
|
2022-12-12 01:21:33 +08:00
|
|
|
order by update_time desc
|
2022-05-02 14:48:15 +08:00
|
|
|
</select>
|
2022-03-22 14:46:05 +08:00
|
|
|
|
2022-08-16 23:00:46 +08:00
|
|
|
<select id="countCustomer" resultType="long">
|
|
|
|
|
<include refid="selectCount" />
|
|
|
|
|
<where>
|
|
|
|
|
<if test="openId != null and openId != ''">
|
|
|
|
|
AND open_id = #{openId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="customerPlace != null and customerPlace != ''">
|
|
|
|
|
AND customer_place = #{customerPlace}
|
|
|
|
|
</if>
|
2022-11-16 01:58:58 +08:00
|
|
|
<if test="customerPlaces != null and customerPlaces.size > 0">
|
|
|
|
|
AND customer_place in
|
|
|
|
|
<foreach item="customerPlace" collection="customerPlaces" open="(" separator="," close=")">
|
|
|
|
|
#{customerPlace}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
2022-08-16 23:00:46 +08:00
|
|
|
<if test="updateTimeStart != null">
|
2022-11-16 01:58:58 +08:00
|
|
|
AND update_time >= #{updateTimeStart}
|
2022-08-16 23:00:46 +08:00
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-03-22 15:30:40 +08:00
|
|
|
<delete id="deleteByIds">
|
|
|
|
|
DELETE FROM customer WHERE customer_id IN
|
|
|
|
|
<foreach collection="array" item="customerIds" open="(" separator="," close=")">
|
|
|
|
|
#{customerIds}
|
2022-03-22 14:46:05 +08:00
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
2022-03-22 15:30:40 +08:00
|
|
|
<delete id="deleteByCustomerId" parameterType="Long">
|
|
|
|
|
DELETE FROM customer WHERE customer_id = #{customerId}
|
2022-03-22 14:46:05 +08:00
|
|
|
</delete>
|
|
|
|
|
|
2022-05-30 15:40:57 +08:00
|
|
|
<select id="selectByCustomerId" resultMap="CustomerResult">
|
2022-03-22 15:30:40 +08:00
|
|
|
<include refid="selectCustomer"/>
|
2022-03-22 14:46:05 +08:00
|
|
|
<where>
|
2022-03-22 15:30:40 +08:00
|
|
|
<if test="customerId != null and customerId != 0">
|
2022-05-02 16:31:54 +08:00
|
|
|
AND customer_id = #{customerId}
|
2022-03-22 14:46:05 +08:00
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-03-22 15:30:40 +08:00
|
|
|
<insert id="insertCustomer" parameterType="com.ghy.customer.domain.Customer" useGeneratedKeys="true" keyProperty="customerId">
|
|
|
|
|
insert into customer(
|
|
|
|
|
<if test="customerId != null and customerId != 0">customer_id,</if>
|
|
|
|
|
<if test="name != null and name != ''">name,</if>
|
|
|
|
|
<if test="account != null and account != ''">account,</if>
|
|
|
|
|
<if test="phone != null and phone != ''">phone,</if>
|
|
|
|
|
<if test="customerLogoUrl != null and customerLogoUrl != ''">customer_logo_url,</if>
|
|
|
|
|
<if test="openId != null and openId != ''">open_id,</if>
|
|
|
|
|
<if test="status != null and status != ''">status,</if>
|
|
|
|
|
<if test="remark != null and remark != ''">remark,</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
|
|
|
create_time
|
|
|
|
|
)values(
|
2022-05-19 18:53:19 +08:00
|
|
|
<if test="customerId != null and customerId != 0">#{customerId},</if>
|
|
|
|
|
<if test="name != null and name != ''">#{name},</if>
|
|
|
|
|
<if test="account != null and account != ''">#{account},</if>
|
|
|
|
|
<if test="phone != null and phone != ''">#{phone},</if>
|
|
|
|
|
<if test="customerLogoUrl != null and customerLogoUrl != ''">#{customerLogoUrl},</if>
|
|
|
|
|
<if test="openId != null and openId != ''">#{openId},</if>
|
|
|
|
|
<if test="status != null and status != ''">#{status},</if>
|
|
|
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
2022-03-22 15:30:40 +08:00
|
|
|
sysdate()
|
|
|
|
|
)
|
2022-03-22 14:46:05 +08:00
|
|
|
</insert>
|
|
|
|
|
|
2022-03-22 15:30:40 +08:00
|
|
|
<update id="updateCustomer" parameterType="com.ghy.customer.domain.Customer">
|
2022-05-24 13:50:09 +08:00
|
|
|
update customer
|
2022-03-22 15:30:40 +08:00
|
|
|
<set>
|
2022-05-19 18:53:19 +08:00
|
|
|
<if test="name != null and name != ''">name = #{name},</if>
|
|
|
|
|
<if test="account != null and account != ''">account = #{account},</if>
|
|
|
|
|
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
|
|
|
|
<if test="customerLogoUrl != null and customerLogoUrl != ''">customer_logo_url = #{customerLogoUrl},</if>
|
2022-03-22 15:30:40 +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>
|
2022-07-13 23:56:31 +08:00
|
|
|
<if test="customerPlace != null">customer_place = #{customerPlace},</if>
|
|
|
|
|
<if test="parentCustomerPlace != null">parent_customer_place = #{parentCustomerPlace},</if>
|
2022-07-20 16:03:44 +08:00
|
|
|
<if test="placeStatus != null">place_status = #{placeStatus},</if>
|
2022-03-22 15:30:40 +08:00
|
|
|
update_time = sysdate()
|
|
|
|
|
</set>
|
|
|
|
|
where customer_id = #{customerId}
|
2022-03-22 14:46:05 +08:00
|
|
|
</update>
|
|
|
|
|
|
2023-02-17 21:11:23 +08:00
|
|
|
<select id="selectByIds" resultMap="CustomerResult">
|
2022-06-01 14:50:58 +08:00
|
|
|
<include refid="selectCustomer" />
|
|
|
|
|
<where>
|
2023-02-17 21:11:23 +08:00
|
|
|
AND customer_id IN
|
|
|
|
|
<foreach item="item" index="customerIds" collection="customerIds" open="(" separator="," close=")">
|
2022-06-01 14:50:58 +08:00
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
2023-05-17 21:31:48 +08:00
|
|
|
<select id="selectByAccount" resultMap="CustomerResult">
|
|
|
|
|
<include refid="selectCustomer" />
|
|
|
|
|
WHERE account = #{account}
|
|
|
|
|
</select>
|
|
|
|
|
|
2022-05-19 18:53:19 +08:00
|
|
|
</mapper>
|