加了一些注释,代码上的调整,方便阅读代码者,也方便维护升级
深更半夜,没睡着起来搞事情
This commit is contained in:
parent
cf2b3dd574
commit
42dc965c9a
27
README.md
27
README.md
@ -1,28 +1,9 @@
|
|||||||
# redbbs
|
# redbbs
|
||||||
|
|
||||||
2018-07-01更新
|
|
||||||
1、优化帖子阅读计数,让帖子阅读数更准确
|
|
||||||
2、更新最新redkale-plugins.jar,加入redis验权
|
|
||||||
3、栏目页用户昵称点击跳转失败,栏目下帖子a标签中加入title属性
|
|
||||||
4、修改本周热贴,查询一周内访问量最多的帖子
|
|
||||||
|
|
||||||
2018-06-30更新
|
|
||||||
1、修改servlet层中BaseServlet中共享request的重大bug
|
|
||||||
2、将servlet中页面统一使用HttpScope进行渲染
|
|
||||||
3、优化帖子阅读计数,让帖子阅读数更准确
|
|
||||||
4、更新最新redkale-plugins.jar,加入redis验权
|
|
||||||
|
|
||||||
2018-06-17更新
|
|
||||||
社区升级
|
|
||||||
1、表字段统一小写,
|
|
||||||
2、表模块划分
|
|
||||||
3、表状态等字段统一smallint
|
|
||||||
4、部分字段值重新定义
|
|
||||||
|
|
||||||
### 项目介绍
|
### 项目介绍
|
||||||
redbbs是基于redkale实现java bbs论坛系统;
|
redbbs是基于redkale实现java bbs论坛系统;
|
||||||
简单易使用、可扩展、高性能;
|
简单易使用、可扩展、高性能;
|
||||||
修改配置文件,运行启动脚本便可快速实现论坛系统的搭建;
|
修改配置文件,运行启动脚本便可快速实现论坛系统的搭建;
|
||||||
|
|
||||||
### 实现功能
|
### 实现功能
|
||||||
##### 用户模块
|
##### 用户模块
|
||||||
@ -54,7 +35,7 @@
|
|||||||
|
|
||||||
### 使用到的相关技术和相关人员
|
### 使用到的相关技术和相关人员
|
||||||
redkale -- 后端主要框架
|
redkale -- 后端主要框架
|
||||||
enjoy -- 数据渲染
|
enjoy -- 数据渲染 查看jfinal使用文档
|
||||||
layui -- 前端界面
|
layui -- 前端界面
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
var createhtml = function (jsoncontent) {
|
var createhtml = function (jsoncontent) {
|
||||||
var classmap = jsoncontent.types;
|
var classmap = jsoncontent.types;
|
||||||
var html = [];
|
var html = [];
|
||||||
html.push('<div style="width:' + Math.floor(window.screen.width * 0.9) + 'px;margin:0 auto;text-align: center;">');
|
html.push('<div style="width:' + Math.floor(window.screen.width * 0.7) + 'px;margin:0 auto;text-align: center;">');
|
||||||
html.push('<br/><br/><table class="table" align="center">');
|
html.push('<br/><br/><table class="table" align="center">');
|
||||||
for (var i = 0; i < jsoncontent.servers.length; i++) {
|
for (var i = 0; i < jsoncontent.servers.length; i++) {
|
||||||
var servlets = jsoncontent.servers[i].servlets;
|
var servlets = jsoncontent.servers[i].servlets;
|
||||||
|
22
doc/update_log.md
Normal file
22
doc/update_log.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#更新日志
|
||||||
|
2018-07-21更新
|
||||||
|
1、登录的用户,访问首页进入自己的工作台
|
||||||
|
|
||||||
|
2018-07-01更新
|
||||||
|
1、优化帖子阅读计数,让帖子阅读数更准确
|
||||||
|
2、更新最新redkale-plugins.jar,加入redis验权
|
||||||
|
3、栏目页用户昵称点击跳转失败,栏目下帖子a标签中加入title属性
|
||||||
|
4、修改本周热贴,查询一周内访问量最多的帖子
|
||||||
|
|
||||||
|
2018-06-30更新
|
||||||
|
1、修改servlet层中BaseServlet中共享request的重大bug
|
||||||
|
2、将servlet中页面统一使用HttpScope进行渲染
|
||||||
|
3、优化帖子阅读计数,让帖子阅读数更准确
|
||||||
|
4、更新最新redkale-plugins.jar,加入redis验权
|
||||||
|
|
||||||
|
2018-06-17更新
|
||||||
|
社区升级
|
||||||
|
1、表字段统一小写,
|
||||||
|
2、表模块划分
|
||||||
|
3、表状态等字段统一smallint
|
||||||
|
4、部分字段值重新定义
|
BIN
lib/redkale.jar
BIN
lib/redkale.jar
Binary file not shown.
BIN
libs/redbbs.jar
BIN
libs/redbbs.jar
Binary file not shown.
7
pom.xml
7
pom.xml
@ -40,7 +40,12 @@
|
|||||||
<!--<dependency>
|
<!--<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongodb-driver</artifactId>
|
<artifactId>mongodb-driver</artifactId>
|
||||||
<version>3.7.1</version>
|
<version>3.8.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongo-java-driver</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
</dependency>-->
|
</dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -1 +0,0 @@
|
|||||||
#功能模块
|
|
@ -17,6 +17,8 @@ import com.mongodb.client.model.Accumulators;
|
|||||||
import com.mongodb.client.model.Aggregates;
|
import com.mongodb.client.model.Aggregates;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
|
import org.redkale.net.http.RestMapping;
|
||||||
|
import org.redkale.net.http.RestService;
|
||||||
import org.redkale.source.ColumnValue;
|
import org.redkale.source.ColumnValue;
|
||||||
import org.redkale.source.FilterExpress;
|
import org.redkale.source.FilterExpress;
|
||||||
import org.redkale.source.FilterNode;
|
import org.redkale.source.FilterNode;
|
||||||
@ -35,6 +37,7 @@ import static java.util.Arrays.asList;
|
|||||||
/**
|
/**
|
||||||
* Created by liangxianyou at 2018/6/20 22:54.
|
* Created by liangxianyou at 2018/6/20 22:54.
|
||||||
*/
|
*/
|
||||||
|
@RestService(name = "xxx",automapping = true, comment = "日志记录")
|
||||||
public class TaskQueue<T extends Object> extends BaseService implements Runnable {
|
public class TaskQueue<T extends Object> extends BaseService implements Runnable {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -73,6 +76,7 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@RestMapping(ignore = true, comment = "独立线程,用户访问行为记录到数据库")
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
while (true){
|
while (true){
|
||||||
@ -94,10 +98,7 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@RestMapping(ignore = true, comment = "帖子阅读数处理")
|
||||||
* 帖子阅读数处理
|
|
||||||
* @param logData
|
|
||||||
*/
|
|
||||||
private void updateViewNumAsync(Map logData) {
|
private void updateViewNumAsync(Map logData) {
|
||||||
CompletableFuture.runAsync(()->{
|
CompletableFuture.runAsync(()->{
|
||||||
Bson filter = and(
|
Bson filter = and(
|
||||||
@ -117,6 +118,7 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RestMapping(ignore = true, comment = "访问热帖数据")
|
||||||
public Sheet<ContentInfo> hotView(String sessionid){
|
public Sheet<ContentInfo> hotView(String sessionid){
|
||||||
int limit = 8;
|
int limit = 8;
|
||||||
String cacheKey = "hotView";
|
String cacheKey = "hotView";
|
||||||
@ -168,8 +170,8 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO:帖子访客记录 --待完成
|
* TODO:帖子访客记录 --待完成
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
@RestMapping(ignore = true, comment = "帖子访客记录")
|
||||||
public Sheet<Map> readRecordAsync(Flipper flipper ,int contentid){
|
public Sheet<Map> readRecordAsync(Flipper flipper ,int contentid){
|
||||||
Bson filter = eq("uri", "/jie/detail/"+ contentid);
|
Bson filter = eq("uri", "/jie/detail/"+ contentid);
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import org.redkale.net.http.RestService;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* enjoy模板引擎使用共享方法类,
|
||||||
|
* 更多关于enjoy的共享方法请查阅jfinal使用文档
|
||||||
* Created by Lxy at 2017/11/26 17:19.
|
* Created by Lxy at 2017/11/26 17:19.
|
||||||
*/
|
*/
|
||||||
@RestService
|
@RestService
|
||||||
@ -17,25 +19,4 @@ public class EJ {
|
|||||||
return new SimpleDateFormat(pattern).format(time);
|
return new SimpleDateFormat(pattern).format(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
/*EJ ej = new EJ();
|
|
||||||
|
|
||||||
System.out.println(ej.date(1511682960591L));*/
|
|
||||||
/*List<Kv> list = asList(
|
|
||||||
Kv.by("k", 1).set("a", "1+1=?").set("q", 2)
|
|
||||||
, Kv.by("k", 2).set("a", "1*1=?").set("q", 1)
|
|
||||||
, Kv.by("k", 3).set("a", "3+2-5=?").set("q", 0)
|
|
||||||
, Kv.by("k", 4).set("a", "Math.abs(-3)=?").set("q", 3)
|
|
||||||
);
|
|
||||||
|
|
||||||
int k = 3;
|
|
||||||
Kv kv = list.stream().filter(x -> x.getInt("k") == k).findFirst().orElse(Kv.create());
|
|
||||||
|
|
||||||
System.out.println(System.currentTimeMillis());
|
|
||||||
System.out.println(kv.toString());
|
|
||||||
System.out.println(kv.getStr("q").equals("0"));*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,16 +67,4 @@ public final class LxyKit {
|
|||||||
}
|
}
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Pattern p = Pattern.compile("@* ");
|
|
||||||
|
|
||||||
Matcher matcher = p.matcher("@nick [污] ");
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
while (matcher.find()) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ public class CommentService extends BaseService implements UIService<CommentInfo
|
|||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RestMapping(ignore = true, comment = "查询用户评论数据")
|
||||||
public Sheet<CommentInfo> queryByUserid(int userid){
|
public Sheet<CommentInfo> queryByUserid(int userid){
|
||||||
Sheet<Comment> comments = source.querySheet(Comment.class, new Flipper().sort("createtime DESC"), FilterNode.create("userid", userid));
|
Sheet<Comment> comments = source.querySheet(Comment.class, new Flipper().sort("createtime DESC"), FilterNode.create("userid", userid));
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ public class CommentService extends BaseService implements UIService<CommentInfo
|
|||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "support", comment = "评论点赞")
|
@RestMapping(name = "support", comment = "点赞")
|
||||||
public RetResult support(@RestSessionid String sessionid, int commentid, int ok){
|
public RetResult support(@RestSessionid String sessionid, int commentid, int ok){
|
||||||
int userid = currentUserid(sessionid);
|
int userid = currentUserid(sessionid);
|
||||||
|
|
||||||
@ -117,7 +118,11 @@ public class CommentService extends BaseService implements UIService<CommentInfo
|
|||||||
return RetResult.success();
|
return RetResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "rankuser", auth = false, comment = "评论榜")
|
/**
|
||||||
|
* todo:用户评论榜 待完成
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RestMapping(ignore = true, name = "rankuser", auth = false, comment = "用户评论榜")
|
||||||
public Map<String, Number> commentRank(){
|
public Map<String, Number> commentRank(){
|
||||||
Flipper flipper = new Flipper().limit(8);
|
Flipper flipper = new Flipper().limit(8);
|
||||||
source.querySheet(Comment.class, flipper, FilterNode.create("userid", FilterExpress.IN));
|
source.querySheet(Comment.class, flipper, FilterNode.create("userid", FilterExpress.IN));
|
||||||
|
@ -10,6 +10,7 @@ import com.lxyer.bbs.base.user.UserService;
|
|||||||
import org.redkale.net.http.*;
|
import org.redkale.net.http.*;
|
||||||
import org.redkale.service.RetResult;
|
import org.redkale.service.RetResult;
|
||||||
import org.redkale.source.*;
|
import org.redkale.source.*;
|
||||||
|
import org.redkale.util.Comment;
|
||||||
import org.redkale.util.SelectColumn;
|
import org.redkale.util.SelectColumn;
|
||||||
import org.redkale.util.Sheet;
|
import org.redkale.util.Sheet;
|
||||||
|
|
||||||
@ -18,18 +19,13 @@ import javax.annotation.Resource;
|
|||||||
/**
|
/**
|
||||||
* Created by Lxy at 2017/11/26 9:33.
|
* Created by Lxy at 2017/11/26 9:33.
|
||||||
*/
|
*/
|
||||||
@RestService(automapping = true, comment = "内容管理")
|
@RestService(automapping = true, comment = "文章帖子服务")
|
||||||
public class ContentService extends BaseService implements UIService<ContentInfo> {
|
public class ContentService extends BaseService implements UIService<ContentInfo> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected UserService userService;
|
protected UserService userService;
|
||||||
|
|
||||||
/**
|
@RestMapping(ignore = true, comment = "根据条件查询帖子数据")
|
||||||
*
|
|
||||||
* @param flipper
|
|
||||||
* @param filterNode
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode){
|
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode){
|
||||||
Sheet<Content> contents = source.querySheet(Content.class, flipper, filterNode);
|
Sheet<Content> contents = source.querySheet(Content.class, flipper, filterNode);
|
||||||
|
|
||||||
@ -64,7 +60,7 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RestMapping(name = "save", comment = "内容保存")
|
@RestMapping(name = "save", comment = "帖子保存")
|
||||||
public RetResult contentSave(@RestParam(name = "bean")Content content, @RestSessionid String sessionid){
|
public RetResult contentSave(@RestParam(name = "bean")Content content, @RestSessionid String sessionid){
|
||||||
//数据校验
|
//数据校验
|
||||||
if (content.getTitle().isEmpty() || content.getTitle().length() > 64){
|
if (content.getTitle().isEmpty() || content.getTitle().length() > 64){
|
||||||
@ -91,7 +87,7 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
|||||||
return RetResult.success();
|
return RetResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "info", auth = false, comment = "内容详情")
|
@RestMapping(name = "info", auth = false, comment = "帖子详情")
|
||||||
public ContentInfo contentInfo(@RestSessionid String sessionid, int contentid){
|
public ContentInfo contentInfo(@RestSessionid String sessionid, int contentid){
|
||||||
int userId = userService.currentUserid(sessionid);
|
int userId = userService.currentUserid(sessionid);
|
||||||
|
|
||||||
@ -108,7 +104,7 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
|||||||
return contentInfo;
|
return contentInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "collect", comment = "内容收藏")
|
@RestMapping(name = "collect", comment = "帖子收藏")
|
||||||
public RetResult collect(@RestSessionid String sessionid, int contentid, int ok){
|
public RetResult collect(@RestSessionid String sessionid, int contentid, int ok){
|
||||||
int userid = userService.currentUserid(sessionid);//不会为空
|
int userid = userService.currentUserid(sessionid);//不会为空
|
||||||
|
|
||||||
@ -144,9 +140,23 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
|||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "set", comment = "内容操作")
|
@RestMapping(name = "set", comment = "便捷的修改内容")
|
||||||
public RetResult contentSet(int id, String field, short v){
|
public RetResult contentSet(@RestSessionid String sessionid,
|
||||||
source.updateColumn(Content.class, id, field, v);
|
@Comment("帖子id") int id,
|
||||||
|
@Comment("status|top|wonderful") String field,
|
||||||
|
@Comment("目标修改值")short v){
|
||||||
|
//只有管理员可访问
|
||||||
|
int userid = currentUserid(sessionid);
|
||||||
|
//身份验证 后修改内容
|
||||||
|
source.findAsync(Content.class, id).thenAccept(content -> {
|
||||||
|
if (content.getUserid() == userid && userService.isAdmin(userid)){//管理员可以做更多
|
||||||
|
//field: status|top|wonderful
|
||||||
|
// update content set {field}={v} where id={id}
|
||||||
|
source.updateColumn(Content.class, id, field, v);
|
||||||
|
}else if (content.getUserid() == userid && ("status".equals(field))){//非管理员只能修改状态
|
||||||
|
source.updateColumn(Content.class, id, field, v);
|
||||||
|
}
|
||||||
|
});
|
||||||
return RetResult.success();
|
return RetResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@ import static org.redkale.source.FilterExpress.NOTEQUAL;
|
|||||||
* 帖子相关
|
* 帖子相关
|
||||||
* Created by liangxianyou at 2018/6/4 13:15.
|
* Created by liangxianyou at 2018/6/4 13:15.
|
||||||
*/
|
*/
|
||||||
@WebServlet({"/jie" ,"/jie/*"
|
@WebServlet(value = {"/jie" ,"/jie/*","/column","/column/*"}, comment = "文章帖子入口")
|
||||||
,"/column","/column/*"})
|
|
||||||
public class ContentServlet extends BaseServlet {
|
public class ContentServlet extends BaseServlet {
|
||||||
@HttpMapping(url = "/jie", auth = false, comment = "问答列表")
|
@HttpMapping(url = "/jie", auth = false, comment = "问答列表")
|
||||||
public void jie(HttpRequest request, HttpResponse response){
|
public void jie(HttpRequest request, HttpResponse response){
|
||||||
|
@ -14,7 +14,7 @@ import java.util.Map;
|
|||||||
* 文件相关
|
* 文件相关
|
||||||
* Created by liangxianyou at 2018/6/4 13:17.
|
* Created by liangxianyou at 2018/6/4 13:17.
|
||||||
*/
|
*/
|
||||||
@WebServlet({"/upload","/upload/*"})
|
@WebServlet(value = {"/upload","/upload/*"}, comment = "文件管理入口")
|
||||||
public class FileServlet extends BaseServlet {
|
public class FileServlet extends BaseServlet {
|
||||||
|
|
||||||
private static final String dir = "/var/www/upload/redbbs/";
|
private static final String dir = "/var/www/upload/redbbs/";
|
||||||
|
@ -17,9 +17,7 @@ import static org.redkale.source.FilterExpress.NOTEQUAL;
|
|||||||
/**
|
/**
|
||||||
* Created by Lxy at 2017/11/25 12:31.
|
* Created by Lxy at 2017/11/25 12:31.
|
||||||
*/
|
*/
|
||||||
@WebServlet({"/","/project"
|
@WebServlet(value = {"/","/project" /* ,"/article","/article/*" */}, comment = "首页一级菜单入口")
|
||||||
/* ,"/article","/article/*" */
|
|
||||||
})
|
|
||||||
public class IndexServlet extends BaseServlet {
|
public class IndexServlet extends BaseServlet {
|
||||||
|
|
||||||
@HttpMapping(url = "/", auth = false, comment = "社区首页")
|
@HttpMapping(url = "/", auth = false, comment = "社区首页")
|
||||||
|
@ -17,7 +17,7 @@ import org.redkale.util.Sheet;
|
|||||||
* 用户相关的servlet
|
* 用户相关的servlet
|
||||||
* Created by liangxianyou at 2018/6/4 13:12.
|
* Created by liangxianyou at 2018/6/4 13:12.
|
||||||
*/
|
*/
|
||||||
@WebServlet({"/user", "/user/*"})
|
@WebServlet(value = {"/user", "/user/*"}, comment = "用户请求入口")
|
||||||
public class UserServlet extends BaseServlet {
|
public class UserServlet extends BaseServlet {
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user