Bonus-Cloud-Material-Mall/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/reply/ReplyMapper.xml

51 lines
1.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.reply.mapper.ReplyMapper">
<insert id="add" useGeneratedKeys="true" keyProperty="id">
insert into bm_reply(reply_title, reply_content, creater, creater_time)
values(#{replyTitle}, #{replyContent}, #{creater}, now())
</insert>
<update id="edit">
update bm_reply
<set>
<if test="replyTitle != null and replyTitle != ''">
reply_title = #{replyTitle},
</if>
<if test="replyContent != null and replyContent != ''">
reply_content = #{replyContent},
</if>
<if test="updater != null">
updater = #{updater},
</if>
updater_time = now()
</set>
where id = #{id}
</update>
<select id="list" resultType="com.bonus.material.reply.entity.BmReply">
select
br.id,
br.reply_title,
br.reply_content,
br.creater,
su.nick_name,
br.creater_time,
br.updater,
br.updater_time
from bm_reply br
left join sys_user su on su.user_id = br.creater
<where>
<if test="replyTitle != null and replyTitle != ''">
and br.replyTitle like concat('%',#{replyTitle},'%')
</if>
<if test="nickName != null and nickName != ''">
and su.nick_name like concat('%',#{nickName},'%')
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND br.creater_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
</if>
</where>
</select>
</mapper>