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

100 lines
4.8 KiB
XML
Raw Normal View History

<?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">
<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" />
<result property="status" column="status" />
<result property="customerLogoUrl" column="customer_logo_url" />
<result property="customerPlace" column="customer_place" />
<result property="parentCustomerPlace" column="parent_customer_place" />
<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="selectCustomer">
2022-05-02 16:31:54 +08:00
SELECT customer_id, name, account, phone, open_id, password, status,
customer_logo_url, customer_place, parent_customer_place, create_by, create_time, remark
FROM customer
</sql>
2022-05-19 18:53:19 +08:00
2022-05-02 14:48:15 +08:00
<select id="getCustomerList" resultMap="CustomerResult">
<include refid="selectCustomer" />
<where>
<if test="openId != null and openId != ''">
AND open_id = #{openId}
</if>
</where>
2022-05-02 14:48:15 +08:00
</select>
<delete id="deleteByIds">
DELETE FROM customer WHERE customer_id IN
<foreach collection="array" item="customerIds" open="(" separator="," close=")">
#{customerIds}
</foreach>
</delete>
<delete id="deleteByCustomerId" parameterType="Long">
DELETE FROM customer WHERE customer_id = #{customerId}
</delete>
<select id="selectByCustomerId" resultType="com.ghy.customer.domain.Customer">
<include refid="selectCustomer"/>
<where>
<if test="customerId != null and customerId != 0">
2022-05-02 16:31:54 +08:00
AND customer_id = #{customerId}
</if>
</where>
</select>
<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>
sysdate()
)
</insert>
<update id="updateCustomer" parameterType="com.ghy.customer.domain.Customer">
update costomer
<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>
<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_id = #{customerId}
</update>
2022-05-19 18:53:19 +08:00
</mapper>