提交 b67cbb4f 编写于 作者: 街头小贩's avatar 街头小贩

修正回复后跳转的连接失败

上级 d3aecb57
......@@ -4,7 +4,6 @@ import com.apobates.forum.core.ImageIOMeta;
import com.apobates.forum.core.entity.BoardTopicCategoryIndex;
import com.apobates.forum.core.entity.Posts;
import com.apobates.forum.core.entity.Topic;
import com.apobates.forum.core.entity.TopicStats;
import com.apobates.forum.core.entity.proxy.PostsReplica;
import com.apobates.forum.core.entity.proxy.TopicReplica;
import com.apobates.forum.core.security.exposure.impl.TopicDetectionStrategy;
......@@ -15,7 +14,6 @@ import com.apobates.forum.core.service.BoardService;
import com.apobates.forum.core.service.BoardTopicCategoryIndexService;
import com.apobates.forum.core.service.PostsService;
import com.apobates.forum.core.service.TopicService;
import com.apobates.forum.core.service.TopicStatsService;
import com.apobates.forum.event.elderly.ActionEventCulpritor;
import com.apobates.forum.event.elderly.ForumActionEnum;
import com.apobates.forum.member.MemberBaseProfile;
......@@ -61,8 +59,6 @@ public class PostsController {
@Autowired
private TopicService topicService;
@Autowired
private TopicStatsService topicStatsService;
@Autowired
private PostsService postsService;
@Autowired
private BoardTopicCategoryIndexService boardTopicCategoryIndexService;
......@@ -146,19 +142,13 @@ public class PostsController {
long topicId = form.getLongTopic();
//
if (boardId > 0 && volumesId >= 0 && topicId > 0) {
boolean data = postsService.create(
volumesId,
boardId,
topicId,
postsContent,
imageIOMeta,
aec)>0;
if (data) {
long postsId = postsService.create(volumesId, boardId, topicId, postsContent, imageIOMeta, aec);
if (postsId>0) {
//----------------------------------
// 回复通知(tc.notify)
//----------------------------------
TopicStats topicStats = topicStatsService.getByTopic(topicId).orElse(new TopicStats(topicId, volumesId, boardId));
return String.format("redirect:/topic/%s.xhtml?p=%d", TopicReplica.generateConnectString(topicId, boardId, volumesId), topicStats.getTopicPageSize(pageSize));
long lastPostsPageNumber = calcPostsPageNumber(postsService.get(postsId), pageSize);
return String.format("redirect:/topic/%s.xhtml?p=%d", TopicReplica.generateConnectString(topicId, boardId, volumesId), lastPostsPageNumber);
}
}
model.addAttribute("form", form);
......@@ -169,7 +159,23 @@ public class PostsController {
model.addAttribute("topic", topic);
return "default/posts/create";
}
//计算指定回复所在页码值
private long calcPostsPageNumber(Optional<Posts> posts, int pageSize){
if(!posts.isPresent()){
return 1L;
}
long currentFloor = posts.get().getFloorNumber();
if (currentFloor <= pageSize) {
return 1;
}
// 整除
long t = currentFloor / pageSize;
// 不整除
if (currentFloor % pageSize != 0) {
t += 1;
}
return t;
}
// 编辑回复,只允许针对Posts.reply(回复的内容/非话题的内容/)的记录
@GetMapping(path = "/edit")
@OnlineDescriptor(action=ForumActionEnum.POSTS_EDIT)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册