From 8d6fa0b244b9a6a110681d777a067c6fc04e25ba Mon Sep 17 00:00:00 2001 From: zhuangtianxiang <2913129173@qq.com> Date: Tue, 3 Dec 2024 14:31:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B6=88=E6=81=AF=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=B8=8E=E9=83=A8=E9=97=A8=E6=A8=A1=E5=9D=97):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E6=B6=88=E6=81=AF=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?bug=E5=B9=B6=E4=BB=8E=E6=96=B0=E5=BB=BA=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=B8=AD=E7=8B=AC=E7=AB=8B=E5=87=BA=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=99=84=E4=BB=B6=E6=8E=A5=E5=8F=A3=EF=BC=8C=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=A8=A1=E5=9D=97=E6=96=B0=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E6=A0=91=E8=BF=94=E5=9B=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edu/gateway/framework/DeptTreeUtil.java | 3 + .../controller/UserMessageController.java | 3 - .../notice/repo/UserMessageRepository.java | 1 + .../service/impl/UserMessageServiceImpl.java | 9 +- .../modules/notice/vo/UserMessageVo.java | 7 +- src/main/resources/db/gateway.sql | 61 +++--- .../noticeMappers/UserMessageMapper.xml | 32 ++-- .../gateway/service/BulletinServiceTest.java | 178 +++++++++--------- 8 files changed, 144 insertions(+), 150 deletions(-) diff --git a/src/main/java/com/zsc/edu/gateway/framework/DeptTreeUtil.java b/src/main/java/com/zsc/edu/gateway/framework/DeptTreeUtil.java index 3c75c53..544aaef 100644 --- a/src/main/java/com/zsc/edu/gateway/framework/DeptTreeUtil.java +++ b/src/main/java/com/zsc/edu/gateway/framework/DeptTreeUtil.java @@ -12,6 +12,9 @@ import java.util.function.BiFunction; import java.util.function.Predicate; import java.util.stream.Collectors; +/** + * @author zhuang + */ @Component public class DeptTreeUtil { diff --git a/src/main/java/com/zsc/edu/gateway/modules/notice/controller/UserMessageController.java b/src/main/java/com/zsc/edu/gateway/modules/notice/controller/UserMessageController.java index 0d6e2d4..259eddf 100644 --- a/src/main/java/com/zsc/edu/gateway/modules/notice/controller/UserMessageController.java +++ b/src/main/java/com/zsc/edu/gateway/modules/notice/controller/UserMessageController.java @@ -4,19 +4,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zsc.edu.gateway.framework.security.UserDetailsImpl; import com.zsc.edu.gateway.modules.notice.dto.UserMessageDto; -import com.zsc.edu.gateway.modules.notice.entity.MessagePayload; import com.zsc.edu.gateway.modules.notice.entity.MessageSetting; import com.zsc.edu.gateway.modules.notice.query.UserMessageQuery; import com.zsc.edu.gateway.modules.notice.service.UserMessageService; import com.zsc.edu.gateway.modules.notice.vo.UserMessageVo; -import com.zsc.edu.gateway.modules.system.entity.User; import lombok.AllArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Set; /** * 用户消息Controller diff --git a/src/main/java/com/zsc/edu/gateway/modules/notice/repo/UserMessageRepository.java b/src/main/java/com/zsc/edu/gateway/modules/notice/repo/UserMessageRepository.java index 778cfb9..99f0c08 100644 --- a/src/main/java/com/zsc/edu/gateway/modules/notice/repo/UserMessageRepository.java +++ b/src/main/java/com/zsc/edu/gateway/modules/notice/repo/UserMessageRepository.java @@ -16,6 +16,7 @@ import org.apache.ibatis.annotations.Param; * @author harry_yao */ public interface UserMessageRepository extends BaseMapper { + UserMessageVo selectByMessageIdAndUserId(@Param("messageId") Long messageId, @Param("userId") Long userId); IPage query(Page page, @Param("query") UserMessageQuery query); diff --git a/src/main/java/com/zsc/edu/gateway/modules/notice/service/impl/UserMessageServiceImpl.java b/src/main/java/com/zsc/edu/gateway/modules/notice/service/impl/UserMessageServiceImpl.java index dcd64d0..c60dc1a 100644 --- a/src/main/java/com/zsc/edu/gateway/modules/notice/service/impl/UserMessageServiceImpl.java +++ b/src/main/java/com/zsc/edu/gateway/modules/notice/service/impl/UserMessageServiceImpl.java @@ -44,7 +44,6 @@ public class UserMessageServiceImpl extends ServiceImpl attachments; + public List attachments; } diff --git a/src/main/resources/db/gateway.sql b/src/main/resources/db/gateway.sql index 976d0ca..acc146b 100644 --- a/src/main/resources/db/gateway.sql +++ b/src/main/resources/db/gateway.sql @@ -291,24 +291,31 @@ comment on column sys_user.enabled_status is '状态'; alter table sys_user owner to postgres; -create table sys_user_message +CREATE TABLE sys_user_message ( - id bigint not null - constraint sys_user_message_pk - primary key, - user_id bigint not null, - message_id bigint not null, - is_read boolean not null, + id bigserial NOT NULL + CONSTRAINT sys_user_message_pk + PRIMARY KEY, + user_id bigint NOT NULL, + message_id bigint NOT NULL, + is_read boolean NOT NULL, read_time timestamp ); -comment on table sys_user_message is '用户消息'; -comment on column sys_user_message.id is '主键'; -comment on column sys_user_message.user_id is '用户'; -comment on column sys_user_message.message_id is '消息'; -comment on column sys_user_message.is_read is '是否已读'; -comment on column sys_user_message.read_time is '阅读时间'; -alter table sys_user_message - owner to postgres; + +COMMENT ON TABLE sys_user_message IS '用户消息'; +COMMENT ON COLUMN sys_user_message.id IS '主键'; +COMMENT ON COLUMN sys_user_message.user_id IS '用户'; +COMMENT ON COLUMN sys_user_message.message_id IS '消息'; +COMMENT ON COLUMN sys_user_message.is_read IS '是否已读'; +COMMENT ON COLUMN sys_user_message.read_time IS '阅读时间'; + +ALTER TABLE sys_user_message + OWNER TO postgres; + +-- 确保序列从1开始 +SELECT setval('sys_user_message_id_seq', 1, false); + + create table sys_users_roles ( @@ -457,20 +464,12 @@ VALUES (1, TRUE, FALSE), (10, FALSE, TRUE); INSERT INTO attachment (id, file_name, mime_type, url, upload_time) -VALUES ('8', 'document1.pdf', 'application/pdf', 'http://example.com/files/document1.pdf', - CURRENT_TIMESTAMP - INTERVAL '1 day'), - ('9', 'image1.jpg', 'image/jpeg', 'http://example.com/files/image1.jpg', CURRENT_TIMESTAMP - INTERVAL '2 days'), - ('10', 'presentation.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'http://example.com/files/presentation.pptx', CURRENT_TIMESTAMP - INTERVAL '3 days'), - ('11', 'spreadsheet.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'http://example.com/files/spreadsheet.xlsx', CURRENT_TIMESTAMP - INTERVAL '4 days'), - ('12', 'audio1.mp3', 'audio/mpeg', 'http://example.com/files/audio1.mp3', CURRENT_TIMESTAMP - INTERVAL '5 days'), - ('13', 'video1.mp4', 'video/mp4', 'http://example.com/files/video1.mp4', CURRENT_TIMESTAMP - INTERVAL '6 days'), - ('14', 'archive.zip', 'application/zip', 'http://example.com/files/archive.zip', - CURRENT_TIMESTAMP - INTERVAL '7 days'), - ('15', 'textfile.txt', 'text/plain', 'http://example.com/files/textfile.txt', - CURRENT_TIMESTAMP - INTERVAL '8 days'), - ('16', 'image2.png', 'image/png', 'http://example.com/files/image2.png', CURRENT_TIMESTAMP - INTERVAL '9 days'), - ('17', 'document2.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'http://example.com/files/document2.docx', CURRENT_TIMESTAMP - INTERVAL '10 days'); +VALUES ('1', 'document1.pdf', 'application/pdf', 'http://example.com/files/document1.pdf', CURRENT_TIMESTAMP), + ('2', 'image1.jpg', 'image/jpeg', 'http://example.com/files/image1.jpg', CURRENT_TIMESTAMP - INTERVAL '1 day'), + ('3', 'presentation.pptx', 'application/pptx', 'http://example.com/files/presentation.pptx', + CURRENT_TIMESTAMP - INTERVAL '2 days'), + ('4', 'spreadsheet.xlsx', 'application/xlsx', 'http://example.com/files/spreadsheet.xlsx', + CURRENT_TIMESTAMP - INTERVAL '3 days'), + ('5', 'audio.mp3', 'audio/mpeg', 'http://example.com/files/audio.mp3', CURRENT_TIMESTAMP - INTERVAL '4 days'); + diff --git a/src/main/resources/mappers/noticeMappers/UserMessageMapper.xml b/src/main/resources/mappers/noticeMappers/UserMessageMapper.xml index 64c3234..de3e432 100644 --- a/src/main/resources/mappers/noticeMappers/UserMessageMapper.xml +++ b/src/main/resources/mappers/noticeMappers/UserMessageMapper.xml @@ -11,7 +11,6 @@ - @@ -24,25 +23,19 @@ - - + - -