|
swer answer = null;
Project project = null;
switch (eventRule.getType()) {
case ModuleConstants.EVENT_TYPE_RULE_PROJECT_CREATE:
case ModuleConstants.EVENT_TYPE_RULE_PROJECT_DELETE_BY_USER:
case ModuleConstants.EVENT_TYPE_RULE_PROJECT_DELETE_BY_ADMIN:
case ModuleConstants.EVENT_TYPE_RULE_PROJECT_VIEW:
case ModuleConstants.EVENT_TYPE_RULE_PROJECT_COLLECT:
case ModuleConstants.EVENT_TYPE_RULE_PROJECT_REWARD:
if (sourceId > 0) {
source = projectService.findOneById(sourceId);
}
if (targetId > 0) {
target = projectService.findOneById(targetId);
}
project = (Project) target;
if (source != null) {
project = (Project) source;
}
if (project == null) {
return;
}
_description = String.format(
description,
ModuleConstants.PROJECT_TYPE_DESC_MAP.get(
project.getType()).getDesc());
break;
case ModuleConstants.EVENT_TYPE_RULE_POST_CREATE:
case ModuleConstants.EVENT_TYPE_RULE_POST_DELETE_BY_USER:
case ModuleConstants.EVENT_TYPE_RULE_POST_DELETE_BY_ADMIN:
if (sourceId > 0) {
source = postService.findOneById(sourceId);
}
if (targetId > 0) {
target = postService.findOneById(targetId);
}
Post post = (Post) target;
if (source != null) {
post = (Post) source;
}
_description = String.format(description,
ModuleConstants.POST_TYPE_DESC_MAP.get(post.getType()));
break;
// case ModuleConstants.EVENT_TYPE_RULE_GROUP_CREATE://暂时没有这种动态
case ModuleConstants.EVENT_TYPE_RULE_GROUP_JOIN_IN:
case ModuleConstants.EVENT_TYPE_RULE_GROUP_DELETE_BY_USER:
// case
// ModuleConstants.EVENT_TYPE_RULE_GROUP_DELETE_BY_ADMIN://暂时没有这种动态
if (sourceId > 0) {
source = groupService.findOneById(sourceId);
}
if (targetId > 0) {
target = groupService.findOneById(targetId);
}
Group group = (Group) source;
_description = String
.format(description,
ModuleConstants.GROUP_TYPE_DESC_MAP.get(group
.getType()));
break;
case ModuleConstants.EVENT_TYPE_RULE_COMMENT_CREATE:
case ModuleConstants.EVENT_TYPE_RULE_COMMENT_DELETE_BY_USER:
case ModuleConstants.EVENT_TYPE_RULE_COMMENT_DELETE_BY_ADMIN:
target = commentService.findOneById(targetId);
Comment comment = (Comment) target;
int commentType = comment.getType();
if (commentType == ModuleConstants.COMMENT_TYPE_ANSWER) {
source = answerService.findOneById(sourceId);
answer = (Answer) source;
project = (Project) answer.getTarget();
_description = String.format(
description,
ModuleConstants.PROJECT_TYPE_DESC_MAP.get(
project.getType()).getDesc());
} else if (commentType == ModuleConstants.COMMENT_TYPE_PROJECT) {
source = projectService.findOneById(sourceId);
project = (Project) source;
_description = String.format(
description,
ModuleConstants.PROJECT_TYPE_DESC_MAP.get(
project.getType()).getDesc());
} else if (commentType == ModuleConstants.COMMENT_TYPE_POST) {
source = postService.findOneById(sourceId);
post = (Post) source;
_des |