|
@@ -100,6 +100,7 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
info.setPublisher(noticeEntity.getPublisher());
|
|
|
info.setPublishTime(noticeEntity.getPublishTime());
|
|
|
info.setHasRead(un.getHasRead());
|
|
|
+ info.setHasRecalled(un.getHasRecalled());
|
|
|
resultList.add(info);
|
|
|
}
|
|
|
}
|
|
@@ -301,24 +302,38 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void sendMsg(NoticeStatus status, Long id) {
|
|
|
+ public void sendMsg(Long id) {
|
|
|
Optional<NoticeEntity> optional = noticeRepo.findById(id);
|
|
|
if(optional.isPresent()){
|
|
|
NoticeEntity entity = optional.get();
|
|
|
- //根据noticeId删除用户通知记录
|
|
|
- if(NoticeStatus.DRAFT.equals(status)){
|
|
|
- if (entity.getNoticeStatus() != NoticeStatus.PUBLISHED) {
|
|
|
- throw new StatusException("501008", "只能撤回已经发送的消息");
|
|
|
- } else {
|
|
|
- userNoticeRepo.deleteByNoticeId(id);
|
|
|
- }
|
|
|
- } else if (NoticeStatus.TO_BE_PUBLISHED.equals(status)){
|
|
|
- if (entity.getNoticeStatus() != NoticeStatus.DRAFT) {
|
|
|
- throw new StatusException("501008", "只能发送未发布的消息");
|
|
|
- }
|
|
|
+
|
|
|
+ if (entity.getNoticeStatus() != NoticeStatus.DRAFT) {
|
|
|
+ throw new StatusException("501008", "只能发送未发布的消息");
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setNoticeStatus(NoticeStatus.TO_BE_PUBLISHED);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ noticeRepo.save(entity);
|
|
|
+ } else {
|
|
|
+ throw new StatusException("501006", "找不到通知id为:" + id + "的数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void recallMsg(Long id) {
|
|
|
+ Optional<NoticeEntity> optional = noticeRepo.findById(id);
|
|
|
+ if(optional.isPresent()){
|
|
|
+ NoticeEntity entity = optional.get();
|
|
|
+
|
|
|
+ if (entity.getNoticeStatus() != NoticeStatus.PUBLISHED) {
|
|
|
+ throw new StatusException("501008", "只能撤回已经发送的消息");
|
|
|
+ } else {
|
|
|
+ //根据noticeId删除用户通知,改为更新是否已经撤回状态
|
|
|
+ //userNoticeRepo.deleteByNoticeId(id);
|
|
|
+ userNoticeRepo.updateNoticeRecalledStatus(id);
|
|
|
}
|
|
|
|
|
|
- entity.setNoticeStatus(status);
|
|
|
+ entity.setNoticeStatus(NoticeStatus.RECALLED);
|
|
|
entity.setUpdateTime(new Date());
|
|
|
noticeRepo.save(entity);
|
|
|
} else {
|