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

119 lines
5.2 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.CustomerPlaceMapper">
<resultMap type="com.ghy.customer.domain.CustomerPlace" id="CustomerPlaceResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="customerId" column="customer_id" />
<result property="phone" column="phone" />
<result property="city" column="city" />
<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="selectCustomerPlaceVo">
select id, name, customer_id, phone, city, status, create_by, create_time, update_by, update_time, remark from customer_place
</sql>
<select id="getByCustomerIds" resultMap="CustomerPlaceResult">
<include refid="selectCustomerPlaceVo" />
<where>
<if test="ids != null and ids.size > 0">
and customer_id in
<foreach item="item" index="ids" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and remark is null
</where>
</select>
<select id="selectCustomerPlaceList" parameterType="com.ghy.customer.domain.CustomerPlace" resultMap="CustomerPlaceResult">
<include refid="selectCustomerPlaceVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="city != null "> and city = #{city}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
</where>
order by create_time desc
</select>
<select id="selectCustomerPlaceById" parameterType="String" resultMap="CustomerPlaceResult">
<include refid="selectCustomerPlaceVo"/>
where id = #{id}
</select>
<insert id="insertCustomerPlace" parameterType="com.ghy.customer.domain.CustomerPlace" useGeneratedKeys="true" keyProperty="id">
insert into customer_place
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="customerId != null">customer_id,</if>
<if test="phone != null">phone,</if>
<if test="city != null">city,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="type != null">type,</if>
<if test="subType != null">sub_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="customerId != null">#{customerId},</if>
<if test="phone != null">#{phone},</if>
<if test="city != null">#{city},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="type != null">#{type},</if>
<if test="subType != null">#{subType},</if>
</trim>
</insert>
<update id="updateCustomerPlace" parameterType="com.ghy.customer.domain.CustomerPlace">
update customer_place
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="city != null">city = #{city},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCustomerPlaceById" parameterType="String">
delete from customer_place where id = #{id}
</delete>
<delete id="deleteCustomerPlaceByIds" parameterType="String">
delete from customer_place where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="changeStatus">
UPDATE customer_place set status = #{status}
WHERE id in ( #{ids} )
</update>
</mapper>