Files
chaozhanggui/pluss-dao-bundle/target/classes/mapper/Notice-sqlmap.xml
2023-01-28 15:57:27 +08:00

271 lines
9.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="cn.pluss.platform.mapper.NoticeMapper">
<insert id="saveNotice" parameterType="cn.pluss.platform.entity.Notice">
insert into tb_pluss_notice(userId, userName, typeFirst, typeSecond, conrtent, createDt, noticeCode,
orderNumber, isDeal, isApply)
VALUES (#{userId}, #{userName}, #{typeFirst}, #{typeSecond}, #{conrtent}, NOW(), #{noticeCode}, #{orderNumber},
#{isDeal}, #{isApply})
</insert>
<insert id="saveNoticeBatch">
insert into
tb_pluss_notice(userId,userName,typeFirst,typeSecond,conrtent,createDt,noticeCode,`desc`,title,url,uniqueKey)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.userId},#{item.userName},#{item.typeFirst},#{item.typeSecond},#{item.conrtent},#{item.createDt},#{item.noticeCode},#{item.desc},#{item.title},#{item.url},#{item.uniqueKey})
</foreach>
</insert>
<select id="queryNotice" parameterType="cn.pluss.platform.entity.Notice"
resultType="cn.pluss.platform.entity.Notice">
SELECT * from tb_pluss_notice
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="userId!= null">
and userId = #{userId}
</if>
<if test="userName!= null">
and userName = #{userName}
</if>
<if test="typeFirst!= null">
and typeFirst = #{typeFirst}
</if>
<if test="typeSecond!= null">
and typeSecond = #{typeSecond}
</if>
<if test="conrtent!= null">
and conrtent = #{conrtent}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="noticeCode!= null">
and noticeCode = #{noticeCode}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="isDeal!= null">
and isDeal = #{isDeal}
</if>
<if test="isApply!= null">
and isApply = #{isApply}
</if>
</where>
</select>
<select id="queryNoticeList" parameterType="cn.pluss.platform.entity.Notice"
resultType="cn.pluss.platform.entity.Notice">
SELECT * from tb_pluss_notice
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="userId!= null">
and userId = #{userId}
</if>
<if test="userName!= null">
and userName = #{userName}
</if>
<if test="typeFirst!= null">
and typeFirst = #{typeFirst}
</if>
<if test="typeSecond!= null">
and typeSecond = #{typeSecond}
</if>
<if test="conrtent!= null">
and conrtent = #{conrtent}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="noticeCode!= null">
and noticeCode = #{noticeCode}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="isDeal!= null">
and isDeal = #{isDeal}
</if>
<if test="isApply!= null">
and isApply = #{isApply}
</if>
</where>
</select>
<update id="updateNotice" parameterType="cn.pluss.platform.entity.Notice">
update tb_pluss_notice
<set>
<if test="userId!= null">
userId = #{userId},
</if>
<if test="userName!= null">
userName = #{userName},
</if>
<if test="typeFirst!= null">
typeFirst = #{typeFirst},
</if>
<if test="typeSecond!= null">
typeSecond = #{typeSecond},
</if>
<if test="conrtent!= null">
conrtent = #{conrtent},
</if>
<if test="createDt!= null">
createDt = #{createDt},
</if>
<if test="noticeCode!= null">
noticeCode = #{noticeCode},
</if>
<if test="orderNumber!= null">
orderNumber = #{orderNumber},
</if>
<if test="isDeal!= null">
isDeal = #{isDeal},
</if>
<if test="isApply!= null">
isApply = #{isApply}
</if>
</set>
where id=#{id}
</update>
<delete id="deleteNotice" parameterType="cn.pluss.platform.entity.Notice">
DELETE
FROM tb_pluss_notice
where id = #{id}
</delete>
<select id="queryNoticeId" resultType="int">
SELECT n.id FROM tb_pluss_notice n
<where>
<if test="id!= null">
and n.id = #{id}
</if>
<if test="userId!= null">
and n.userId IN ('-1', #{userId})
</if>
<if test="userName!= null">
and userName like CONCAT("%",#{userName},"%")
</if>
<if test="typeFirst!= null">
and typeFirst = #{typeFirst}
</if>
<if test="typeSecond!= null">
and typeSecond = #{typeSecond}
</if>
<if test="conrtent!= null">
and conrtent = #{conrtent}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="noticeCode!= null">
and noticeCode = #{noticeCode}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="isDeal!= null">
and isDeal = #{isDeal}
</if>
<if test="isApply!= null">
and isApply = #{isApply}
</if>
</where>
order by n.id desc limit #{pageSize} offset #{offset}
</select>
<select id="queryNoticePage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.Notice">
SELECT
n.id, n.userId, n.userName, n.typeFirst, n.typeSecond, n.title, n.`desc`,
n.url, n.conrtent, n.createDt, n.noticeCode,
n.orderNumber, n.isDeal, n.isApply, n.uniqueKey,
IF ( nrr.id IS NULL, 0, 1 ) readStatus
FROM
tb_pluss_notice n
LEFT JOIN tb_pluss_notice_read_record nrr ON n.id = nrr.noticeId
AND nrr.userId = n.userId
<where>
<if test="id!= null">
and n.id = #{id}
</if>
<if test="userId!= null">
and n.userId IN ('-1', #{userId})
</if>
<if test="userName!= null">
and userName like CONCAT("%",#{userName},"%")
</if>
<if test="typeFirst!= null">
and typeFirst = #{typeFirst}
</if>
<if test="typeSecond!= null">
and typeSecond = #{typeSecond}
</if>
<if test="conrtent!= null">
and conrtent = #{conrtent}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="noticeCode!= null">
and noticeCode = #{noticeCode}
</if>
<if test="orderNumber!= null">
and orderNumber = #{orderNumber}
</if>
<if test="isDeal!= null">
and isDeal = #{isDeal}
</if>
<if test="isApply!= null">
and isApply = #{isApply}
</if>
</where>
order by n.id desc limit #{pageSize} offset #{offset}
</select>
<select id="queryNoticePageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) from tb_pluss_notice
<where>
<if test="id!= null">
and id = #{id}
</if>
<if test="userId!= null">
and userId = #{userId}
</if>
<if test="userName!= null">
and userName like CONCAT("%",#{userName},"%")
</if>
<if test="typeFirst!= null">
and typeFirst = #{typeFirst}
</if>
<if test="typeSecond!= null">
and typeSecond = #{typeSecond}
</if>
<if test="conrtent!= null">
and conrtent = #{conrtent}
</if>
<if test="createDt!= null">
and createDt = #{createDt}
</if>
<if test="noticeCode!= null">
and noticeCode = #{noticeCode}
</if>
<if test="isDeal!= null">
and isDeal = #{isDeal}
</if>
<if test="isApply!= null">
and isApply = #{isApply}
</if>
</where>
</select>
</mapper>