refactor: 通知公告重构完成

This commit is contained in:
ray
2024-09-29 23:01:36 +08:00
77 changed files with 904 additions and 903 deletions

View File

@@ -1,63 +0,0 @@
<?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.youlai.boot.system.mapper.NoticeMapper">
<!-- 获取通知公告分页列表 -->
<select id="getNoticePage" resultType="com.youlai.boot.system.model.bo.NoticeBO">
SELECT
sn.id,
sn.title,
sn.notice_type,
su.nickname AS release_by,
sn.priority,
sn.tar_type,
sn.release_status,
sn.release_time,
sn.recall_time
FROM
sys_notice sn
LEFT JOIN
sys_user su ON su.id = sn.release_by
where
sn.is_deleted = 0
<if test="queryParams.title != null and queryParams.title != ''">
AND sn.title LIKE CONCAT('%',#{queryParams.title},'%')
</if>
<if test="queryParams.releaseStatus != null">
AND sn.release_status = #{queryParams.releaseStatus}
</if>
<if test="queryParams.releaseTime != null">
<if test="queryParams.releaseTime[0] != null and queryParams.releaseTime[0] != ''">
<bind name="startDate" value="queryParams.releaseTime[0].length() == 10 ? queryParams.releaseTime[0] + ' 00:00:00' : queryParams.releaseTime[0]"/>
AND sn.release_time &gt;= #{startDate}
</if>
<if test="queryParams.releaseTime[1] != null and queryParams.releaseTime[1] != ''">
<bind name="endDate" value="queryParams.releaseTime[1].length() == 10 ? queryParams.releaseTime[1] + ' 23:59:59' : queryParams.releaseTime[1]"/>
AND sn.release_time &lt;= #{endDate}
</if>
</if>
ORDER BY
id
DESC
</select>
<select id="getReadNoticeVO" resultType="com.youlai.boot.system.model.vo.NoticeDetailVO">
SELECT
sn.id,
sn.title,
sn.content,
sn.notice_type,
su.nickname AS release_by,
sn.priority,
sn.release_status,
sn.release_time
FROM
sys_notice sn
LEFT JOIN
sys_user su ON su.id = sn.release_by
where
sn.is_deleted = 0
AND sn.id = #{id}
</select>
</mapper>

View File

@@ -1,49 +0,0 @@
<?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.youlai.boot.system.mapper.NoticeStatusMapper">
<select id="listUnreadNotices" resultType="com.youlai.boot.system.model.vo.NoticeStatusVO">
SELECT
sn.id,
sn.title,
sns.read_status
FROM
sys_notice_status sns
LEFT JOIN
sys_notice sn
ON
sn.id = sns.notice_id
WHERE
user_id = #{userId}
AND sns.read_status = 0
ORDER BY
sn.release_time DESC
</select>
<select id="getMyNoticePage" resultType="com.youlai.boot.system.model.vo.NoticeStatusVO">
SELECT
sn.id,
sn.title,
sn.notice_type,
sn.release_by,
sn.priority,
sn.release_time,
sns.read_status
FROM
sys_notice sn
LEFT JOIN
sys_notice_status sns
ON
sn.id = sns.notice_id
<where>
<if test="queryParams.userId != null">
sns.user_id = #{queryParams.userId}
</if>
<if test="queryParams.title != null and queryParams.title != ''">
AND sn.title LIKE CONCAT('%',#{queryParams.title},'%')
</if>
</where>
ORDER BY
sn.release_time DESC
</select>
</mapper>

View File

@@ -44,7 +44,7 @@
INNER JOIN sys_role_menu t2 ON t1.id = t2.menu_id
INNER JOIN sys_role t3 ON t2.role_id = t3.id AND t3.status = 1 AND t3.is_deleted = 0
WHERE
t1.type != '${@com.youlai.boot.common.enums.MenuTypeEnum@BUTTON.getValue()}'
t1.type != '${@com.youlai.boot.system.enums.MenuTypeEnum@BUTTON.getValue()}'
<if test="roles != null and roles.size() > 0">
<!-- ROOT 可查看所有菜单 -->
<if test="!roles.contains('ROOT')">

View File

@@ -0,0 +1,65 @@
<?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.youlai.boot.system.mapper.NoticeMapper">
<!-- 获取通知公告分页列表 -->
<select id="getNoticePage" resultType="com.youlai.boot.system.model.bo.NoticeBO">
SELECT
t1.id,
t1.title,
t1.type,
t2.nickname AS publisherName,
t1.level,
t1.target_type,
t1.publish_status,
t1.publish_time,
t1.revoke_time,
t3.name typeLabel,
t4.name levelLabel,
t1.create_time
FROM
sys_notice t1
LEFT JOIN sys_user t2 ON t2.id = t1.publisher_id
LEFT JOIN sys_dict_item t3 ON t1.type = t3.value AND t3.dict_code = 'notice_type'
LEFT JOIN sys_dict_item t4 ON t1.level = t4.value AND t4.dict_code = 'notice_level'
WHERE
t1.is_deleted = 0
<if test="queryParams.title != null and queryParams.title != ''">
AND t1.title LIKE CONCAT('%',#{queryParams.title},'%')
</if>
<if test="queryParams.publishStatus != null">
AND t1.publish_status = #{queryParams.publishStatus}
</if>
<if test="queryParams.publishTime != null">
<if test="queryParams.publishTime[0] != null and queryParams.publishTime[0] != ''">
<bind name="startDate" value="queryParams.publishTime[0].length() == 10 ? queryParams.publishTime[0] + ' 00:00:00' : queryParams.publishTime[0]"/>
AND t1.publish_time &gt;= #{startDate}
</if>
<if test="queryParams.publishTime[1] != null and queryParams.publishTime[1] != ''">
<bind name="endDate" value="queryParams.publishTime[1].length() == 10 ? queryParams.publishTime[1] + ' 23:59:59' : queryParams.publishTime[1]"/>
AND t1.publish_time &lt;= #{endDate}
</if>
</if>
ORDER BY
t1.create_time DESC
</select>
<!-- 获取通知公告详情 -->
<select id="getNoticeDetail" resultType="com.youlai.boot.system.model.bo.NoticeBO">
SELECT
t1.id,
t1.title,
t1.content,
t1.type,
t2.nickname AS publisherName,
t1.level,
t1.publish_status,
t1.publish_time
FROM
sys_notice t1
LEFT JOIN sys_user t2 ON t2.id = t1.publisher_id
WHERE
t1.id = #{id} AND t1.is_deleted = 0
</select>
</mapper>

View File

@@ -33,7 +33,7 @@
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.is_deleted = 0 AND t2.`status` = 1
INNER JOIN sys_menu t3 ON t1.menu_id = t3.id
WHERE
type = '${@com.youlai.boot.common.enums.MenuTypeEnum@BUTTON.getValue()}'
type = '${@com.youlai.boot.system.enums.MenuTypeEnum@BUTTON.getValue()}'
<if test="roleCode!=null and roleCode.trim() neq ''">
AND t2.`code` = #{roleCode}
</if>
@@ -48,7 +48,7 @@
INNER JOIN sys_menu t2 ON t2.id = t1.menu_id
INNER JOIN sys_role t3 ON t3.id = t1.role_id
WHERE
t2.type = '${@com.youlai.boot.common.enums.MenuTypeEnum@BUTTON.getValue()}'
t2.type = '${@com.youlai.boot.system.enums.MenuTypeEnum@BUTTON.getValue()}'
AND t2.perm IS NOT NULL
AND t3.CODE IN
<foreach collection="roles" item="role" separator="," open="(" close=")">

View File

@@ -0,0 +1,43 @@
<?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.youlai.boot.system.mapper.UserNoticeMapper">
<!-- 获取用户未读通知列表 -->
<select id="listUnreadNotices" resultType="com.youlai.boot.system.model.vo.UserUnreadNoticeVO">
SELECT
t2.id,
t2.title
FROM
sys_user_notice t1
INNER JOIN sys_notice t2 ON t2.id = t1.notice_id AND t2.publish_status = 1 AND t2.is_deleted = 0
WHERE
t1.user_id = #{userId} AND t1.is_read = 0 AND t1.is_deleted = 0
ORDER BY
t2.publish_time DESC
</select>
<!-- 获取我的通知分页列表 -->
<select id="getMyNoticePage" resultType="com.youlai.boot.system.model.vo.UserNoticePageVO">
SELECT
t2.id,
t2.title,
t4.name typeLabel,
t3.nickname publisherName,
t5.name levelLabel,
t2.publish_time,
t1.is_read
FROM
sys_user_notice t1
INNER JOIN sys_notice ON t2.notice_id = t1.id AND t2.publish_status = 1
LEFT JOIN sys_user t3 ON t2.publisher_id = t3.id
LEFT JOIN sys_dict_item t4 ON t2.type = t4.value AND t4.dict_code = 'notice_type'
LEFT JOIN sys_dict_item t5 ON t2.level = t5.value AND t5.dict_code = 'notice_level'
WHERE
t1.user_id = #{queryParams.userId}
<if test="queryParams.title != null and queryParams.title != ''">
AND t2.title LIKE CONCAT('%',#{queryParams.title},'%')
</if>
ORDER BY
t2.release_time DESC
</select>
</mapper>