修改消息提示,必要的异常判断

This commit is contained in:
暮光:城中城
2020-10-27 22:51:32 +08:00
parent cec0e2d5c8
commit 3048d203ff
5 changed files with 17 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ public enum UserMsgType {
// 6=wiki文档评论 7=wiki文档删除评论 8=wiki文档上传附件 9=wiki文档修改了父级 10=wiki文档点赞 11=wiki文档附件删除
SIMPLE(1), WIKI_PAGE_CREATE(2), WIKI_PAGE_DELETE(3), WIKI_PAGE_UPDATE(4), WIKI_PAGE_AUTH(5),
WIKI_PAGE_COMMENT(6), WIKI_PAGE_COMMENT_DEL(7), WIKI_PAGE_UPLOAD(8), WIKI_PAGE_PARENT(9), WIKI_PAGE_ZAN(10), WIKI_PAGE_FILE_DEL(11),
WIKI_PAGE_ZAN_CANCEL(12),
;
UserMsgType(int type) {

View File

@@ -82,6 +82,8 @@ public class UserMessageServiceImpl extends ServiceImpl<UserMessageMapper, UserM
userMessage.setMsgContent(String.format("您赞同了‘%s", userMessage.getDataDesc()));
} else if (Objects.equals(UserMsgType.WIKI_PAGE_FILE_DEL.getType(), userMessage.getMsgType())) {
userMessage.setMsgContent(String.format("您删除了‘%s文档的一个附件", userMessage.getDataDesc()));
} else if (Objects.equals(UserMsgType.WIKI_PAGE_ZAN_CANCEL.getType(), userMessage.getMsgType())) {
userMessage.setMsgContent(String.format("您取消了对‘%s文档的赞同", userMessage.getDataDesc()));
}
}
@@ -109,6 +111,8 @@ public class UserMessageServiceImpl extends ServiceImpl<UserMessageMapper, UserM
userMessage.setMsgContent(String.format("您的‘%s文档收到了%s的赞同", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
} else if (Objects.equals(UserMsgType.WIKI_PAGE_FILE_DEL.getType(), userMessage.getMsgType())) {
userMessage.setMsgContent(String.format("您的‘%s文档被%s删除了一个附件", userMessage.getDataDesc(), userMessage.getOperatorUserName()));
} else if (Objects.equals(UserMsgType.WIKI_PAGE_ZAN_CANCEL.getType(), userMessage.getMsgType())) {
userMessage.setMsgContent(String.format("%s取消了对文档%s的赞同", userMessage.getOperatorUserName(), userMessage.getDataDesc()));
}
}
}

View File

@@ -50,7 +50,7 @@ public class WikiPageZanServiceImpl extends ServiceImpl<WikiPageZanMapper, WikiP
wikiPageZan.setCreateUserName(currentUser.getUsername());
this.save(wikiPageZan);
}
int numAdd = wikiPageZan.getYn() == 1 ? 1 : -1;
int numAdd = Objects.equals(wikiPageZan.getYn(), 1) ? 1 : -1;
wikiPageMapper.updateZanNum(wikiPageZan.getPageId(), numAdd);
}
}

View File

@@ -196,6 +196,7 @@ public class WikiPageController {
WikiPage wikiPage = new WikiPage();
wikiPage.setId(pageId);
wikiPage.setDelFlag(1);
wikiPage.setName(wikiPageSel.getName());
wikiPage.setUpdateTime(new Date());
wikiPage.setUpdateUserId(currentUser.getUserId());
wikiPage.setUpdateUserName(currentUser.getUsername());
@@ -254,6 +255,12 @@ public class WikiPageController {
if (SpaceType.isOthersPersonal(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
return DocResponseJson.warn("您没有权限新增该空间的文章!");
}
if (wikiPage.getParentId() != null && wikiPage.getParentId() > 0) {
WikiPage wikiPageParent = wikiPageService.getById(wikiPage.getParentId());
if (Objects.equals(wikiPage.getSpaceId(), wikiPageParent.getSpaceId())) {
return DocResponseJson.warn("当前空间和父页面的空间不一致,请重新选择父页面!");
}
}
Integer lastSeq = wikiPageMapper.getLastSeq(wikiPage.getParentId());
lastSeq = Optional.ofNullable(lastSeq).orElse(0);
wikiPage.setSeqNo(lastSeq + 1);

View File

@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
/**
* 文档控制器
@@ -86,6 +87,9 @@ public class WikiPageZanController {
wikiPageZanService.zanPage(wikiPageZan);
// 给相关人发送消息
UserMessage userMessage = userMessageService.createUserMessage(currentUser, wikiPageSel.getId(), wikiPageSel.getName(), UserMsgSysType.WIKI, UserMsgType.WIKI_PAGE_ZAN);
if (!Objects.equals(wikiPageZan.getYn(), 1)) {
userMessage.setMsgType(UserMsgType.WIKI_PAGE_ZAN_CANCEL.getType());
}
userMessage.setAffectUserId(wikiPageSel.getCreateUserId());
userMessage.setAffectUserName(wikiPageSel.getCreateUserName());
userMessageService.addWikiMessage(userMessage);