|
@@ -301,27 +301,29 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void backMsg(UpdateNoticeInfo info) {
|
|
|
- // 校验通知状态,只能撤回已经发送的消息
|
|
|
- NoticeEntity originalNotice = GlobalHelper.getEntity(noticeRepo, info.getId(),
|
|
|
- NoticeEntity.class);
|
|
|
- if (originalNotice == null) {
|
|
|
- throw new StatusException("501006", "找不到通知id为:" + info.getId() + "的数据");
|
|
|
- }
|
|
|
- if (originalNotice.getNoticeStatus() != NoticeStatus.PUBLISHED) {
|
|
|
- throw new StatusException("501008", "只能撤回已经发送的消息");
|
|
|
+ public void sendMsg(NoticeStatus status, Long id) {
|
|
|
+ Optional<NoticeEntity> optional = noticeRepo.findById(id);
|
|
|
+ if(optional.isPresent()){
|
|
|
+ NoticeEntity entity = optional.get();
|
|
|
+ entity.setNoticeStatus(status);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ //根据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", "只能发送未发布的消息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ noticeRepo.save(entity);
|
|
|
+ } else {
|
|
|
+ throw new StatusException("501006", "找不到通知id为:" + id + "的数据");
|
|
|
}
|
|
|
-
|
|
|
- // 更新通知表
|
|
|
- originalNotice.setTitle(info.getTitle());
|
|
|
- originalNotice.setPublisher(info.getPublisher());
|
|
|
- originalNotice.setNoticeStatus(NoticeStatus.DRAFT);
|
|
|
- originalNotice.setContent(info.getContent());
|
|
|
- originalNotice.setUpdateTime(new Date());
|
|
|
- noticeRepo.save(originalNotice);
|
|
|
-
|
|
|
- //根据noticeId删除用户通知记录
|
|
|
- userNoticeRepo.deleteByNoticeId(info.getId());
|
|
|
}
|
|
|
|
|
|
/**
|