Bonus-Cloud-Material/bonus-modules/bonus-material/src/main/resources/mapper/material/purchase/PurchaseNoticePersonMapper.xml

80 lines
3.8 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.bonus.material.purchase.mapper.PurchaseNoticePersonMapper">
<resultMap type="com.bonus.material.purchase.domain.PurchaseNoticePerson" id="PurchaseNoticePersonResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="telphone" column="telphone" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectPurchaseNoticePersonVo">
select id, user_id, user_name, telphone, create_time, update_time from purchase_notice_person
</sql>
<select id="selectPurchaseNoticePersonList" parameterType="com.bonus.material.purchase.domain.PurchaseNoticePerson" resultMap="PurchaseNoticePersonResult">
<include refid="selectPurchaseNoticePersonVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="telphone != null and telphone != ''"> and telphone = #{telphone}</if>
</where>
</select>
<select id="selectPurchaseNoticePersonById" parameterType="Long" resultMap="PurchaseNoticePersonResult">
<include refid="selectPurchaseNoticePersonVo"/>
where id = #{id}
</select>
<insert id="insertPurchaseNoticePerson" parameterType="com.bonus.material.purchase.domain.PurchaseNoticePerson" useGeneratedKeys="true" keyProperty="id">
insert into purchase_notice_person
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="userName != null">user_name,</if>
<if test="telphone != null">telphone,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="userName != null">#{userName},</if>
<if test="telphone != null">#{telphone},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updatePurchaseNoticePerson" parameterType="com.bonus.material.purchase.domain.PurchaseNoticePerson">
update purchase_notice_person
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null">user_name = #{userName},</if>
<if test="telphone != null">telphone = #{telphone},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deletePurchaseNoticePersonById" parameterType="Long">
delete from purchase_notice_person where id = #{id}
</delete>
<delete id="deletePurchaseNoticePersonByIds" parameterType="String">
delete from purchase_notice_person where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="insertBatchPurchaseNoticePerson">
insert into purchase_notice_person(user_id,user_name,telphone,create_time) values
<foreach collection="list" item="item" separator=",">
(#{item.userId},#{item.userName},#{item.telphone},now())
</foreach>
</insert>
</mapper>