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

91 lines
4.4 KiB
XML

<?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">
<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" />
<result property="status" column="status" />
<result property="customerLogoUrl" column="customer_logo_url" />
<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">
SELECT customer_id, name, account, phone, open_id, status,
customer_logo_url, create_by, create_time, remark
FROM customer
</sql>
<select id="getCustomerList" resultMap="CustomerResult">
<include refid="selectCustomer" />
</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">
AND customer = #{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(
<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>
sysdate()
)
</insert>
<update id="updateCustomer" parameterType="com.ghy.customer.domain.Customer">
update costomer
<set>
<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 = ${customer_logo_url},</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>
</mapper>