smart-admin/smart-admin-api/sa-admin/src/main/resources/mapper/business/notice/NoticeMapper.xml
2023-02-16 20:11:43 +08:00

69 lines
3.1 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="net.lab1024.sa.admin.module.business.notice.NoticeDao">
<update id="updateWatchAmount">
UPDATE t_notice
SET watch_amount = watch_amount + 1
WHERE notice_id = #{noticeId}
</update>
<update id="batchDeleteNotice">
UPDATE t_notice
SET deleted_flag = #{deletedFlag}
WHERE notice_id IN
<foreach collection="noticeIdList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</update>
<update id="updateNotice">
UPDATE t_notice
SET notice_type = #{noticeType},
notice_belong_type = #{noticeBelongType},
notice_title = #{noticeTitle},
notice_content = #{noticeContent},
link_address = #{linkAddress},
cover_file_key = #{coverFileKey},
accessory_file_keys = #{accessoryFileKeys},
top_flag = #{topFlag},
publish_time = #{publishTime},
disabled_flag = #{disabledFlag}
WHERE notice_id = #{noticeId}
</update>
<select id="queryPage" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeVO">
SELECT t_notice.*,
t_employee.actual_name AS createUserName
FROM t_notice
LEFT JOIN t_employee ON t_notice.create_user_id = t_employee.employee_id
<where>
t_notice.deleted_flag = #{queryForm.deletedFlag}
<if test="queryForm.keywords != null and queryForm.keywords != ''">
AND (INSTR(t_notice.notice_title,#{queryForm.keywords}) OR INSTR(t_employee.actual_name,#{queryForm.keywords}))
</if>
<if test="queryForm.noticeType != null">
AND t_notice.notice_type = #{queryForm.noticeType}
</if>
<if test="queryForm.noticeBelongType != null">
AND t_notice.notice_belong_type = #{queryForm.noticeBelongType}
</if>
<if test="queryForm.startTime != null">
AND DATE_FORMAT(t_notice.publish_time, '%Y-%m-%d') &gt;= #{queryForm.startTime}
</if>
<if test="queryForm.endTime != null">
AND DATE_FORMAT(t_notice.publish_time, '%Y-%m-%d') &lt;= #{queryForm.endTime}
</if>
<if test="queryForm.disabledFlag != null">
AND t_notice.disabled_flag = #{queryForm.disabledFlag}
</if>
</where>
<if test="queryForm.sortItemList == null or queryForm.sortItemList.size == 0">
ORDER BY t_notice.top_flag DESC,t_notice.publish_time DESC
</if>
</select>
<select id="getDetail" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeVO">
SELECT tn.*,
e.actual_name AS createUserName
FROM t_notice tn
LEFT JOIN t_employee e ON tn.create_user_id = e.employee_id
WHERE tn.notice_id = #{noticeId}
AND tn.deleted_flag = #{deletedFlag}
</select>
</mapper>