加了一些注释,代码上的调整,方便阅读代码者,也方便维护升级

深更半夜,没睡着起来搞事情
This commit is contained in:
lxyer 2018-08-01 03:26:05 +08:00
parent cf2b3dd574
commit 42dc965c9a
17 changed files with 76 additions and 86 deletions

View File

@ -1,24 +1,5 @@
# 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论坛系统;
简单易使用、可扩展、高性能;
@ -54,7 +35,7 @@
### 使用到的相关技术和相关人员
redkale -- 后端主要框架
enjoy -- 数据渲染
enjoy -- 数据渲染 查看jfinal使用文档
layui -- 前端界面

View File

@ -22,7 +22,7 @@
var createhtml = function (jsoncontent) {
var classmap = jsoncontent.types;
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">');
for (var i = 0; i < jsoncontent.servers.length; i++) {
var servlets = jsoncontent.servers[i].servlets;

22
doc/update_log.md Normal file
View 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、部分字段值重新定义

Binary file not shown.

Binary file not shown.

View File

@ -40,7 +40,12 @@
<!--<dependency>
<groupId>org.mongodb</groupId>
<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>-->
</dependencies>

View File

@ -1 +0,0 @@
#功能模块

View File

@ -17,6 +17,8 @@ import com.mongodb.client.model.Accumulators;
import com.mongodb.client.model.Aggregates;
import org.bson.Document;
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.FilterExpress;
import org.redkale.source.FilterNode;
@ -35,6 +37,7 @@ import static java.util.Arrays.asList;
/**
* 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 {
@Resource
@ -73,6 +76,7 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
}
@Override
@RestMapping(ignore = true, comment = "独立线程,用户访问行为记录到数据库")
public void run() {
try {
while (true){
@ -94,10 +98,7 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
}
}
/**
* 帖子阅读数处理
* @param logData
*/
@RestMapping(ignore = true, comment = "帖子阅读数处理")
private void updateViewNumAsync(Map logData) {
CompletableFuture.runAsync(()->{
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){
int limit = 8;
String cacheKey = "hotView";
@ -168,8 +170,8 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
/**
* TODO:帖子访客记录 --待完成
* @return
*/
@RestMapping(ignore = true, comment = "帖子访客记录")
public Sheet<Map> readRecordAsync(Flipper flipper ,int contentid){
Bson filter = eq("uri", "/jie/detail/"+ contentid);

View File

@ -5,6 +5,8 @@ import org.redkale.net.http.RestService;
import java.text.SimpleDateFormat;
/**
* enjoy模板引擎使用共享方法类
* 更多关于enjoy的共享方法请查阅jfinal使用文档
* Created by Lxy at 2017/11/26 17:19.
*/
@RestService
@ -17,25 +19,4 @@ public class EJ {
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"));*/
}
}

View File

@ -67,16 +67,4 @@ public final class LxyKit {
}
return ts;
}
public static void main(String[] args) {
Pattern p = Pattern.compile("@*&nbsp;");
Matcher matcher = p.matcher("@nick&nbsp;[污]&nbsp;");
int count = 0;
while (matcher.find()) {
count++;
}
}
}

View File

@ -80,6 +80,7 @@ public class CommentService extends BaseService implements UIService<CommentInfo
return infos;
}
@RestMapping(ignore = true, comment = "查询用户评论数据")
public Sheet<CommentInfo> queryByUserid(int 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;
}
@RestMapping(name = "support", comment = "评论点赞")
@RestMapping(name = "support", comment = "点赞")
public RetResult support(@RestSessionid String sessionid, int commentid, int ok){
int userid = currentUserid(sessionid);
@ -117,7 +118,11 @@ public class CommentService extends BaseService implements UIService<CommentInfo
return RetResult.success();
}
@RestMapping(name = "rankuser", auth = false, comment = "评论榜")
/**
* todo:用户评论榜 待完成
* @return
*/
@RestMapping(ignore = true, name = "rankuser", auth = false, comment = "用户评论榜")
public Map<String, Number> commentRank(){
Flipper flipper = new Flipper().limit(8);
source.querySheet(Comment.class, flipper, FilterNode.create("userid", FilterExpress.IN));

View File

@ -10,6 +10,7 @@ import com.lxyer.bbs.base.user.UserService;
import org.redkale.net.http.*;
import org.redkale.service.RetResult;
import org.redkale.source.*;
import org.redkale.util.Comment;
import org.redkale.util.SelectColumn;
import org.redkale.util.Sheet;
@ -18,18 +19,13 @@ import javax.annotation.Resource;
/**
* 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> {
@Resource
protected UserService userService;
/**
*
* @param flipper
* @param filterNode
* @return
*/
@RestMapping(ignore = true, comment = "根据条件查询帖子数据")
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode 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){
//数据校验
if (content.getTitle().isEmpty() || content.getTitle().length() > 64){
@ -91,7 +87,7 @@ public class ContentService extends BaseService implements UIService<ContentInfo
return RetResult.success();
}
@RestMapping(name = "info", auth = false, comment = "内容详情")
@RestMapping(name = "info", auth = false, comment = "帖子详情")
public ContentInfo contentInfo(@RestSessionid String sessionid, int contentid){
int userId = userService.currentUserid(sessionid);
@ -108,7 +104,7 @@ public class ContentService extends BaseService implements UIService<ContentInfo
return contentInfo;
}
@RestMapping(name = "collect", comment = "内容收藏")
@RestMapping(name = "collect", comment = "帖子收藏")
public RetResult collect(@RestSessionid String sessionid, int contentid, int ok){
int userid = userService.currentUserid(sessionid);//不会为空
@ -144,9 +140,23 @@ public class ContentService extends BaseService implements UIService<ContentInfo
return infos;
}
@RestMapping(name = "set", comment = "内容操作")
public RetResult contentSet(int id, String field, short v){
@RestMapping(name = "set", comment = "便捷的修改内容")
public RetResult contentSet(@RestSessionid String sessionid,
@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();
}

View File

@ -15,8 +15,7 @@ import static org.redkale.source.FilterExpress.NOTEQUAL;
* 帖子相关
* Created by liangxianyou at 2018/6/4 13:15.
*/
@WebServlet({"/jie" ,"/jie/*"
,"/column","/column/*"})
@WebServlet(value = {"/jie" ,"/jie/*","/column","/column/*"}, comment = "文章帖子入口")
public class ContentServlet extends BaseServlet {
@HttpMapping(url = "/jie", auth = false, comment = "问答列表")
public void jie(HttpRequest request, HttpResponse response){

View File

@ -14,7 +14,7 @@ import java.util.Map;
* 文件相关
* Created by liangxianyou at 2018/6/4 13:17.
*/
@WebServlet({"/upload","/upload/*"})
@WebServlet(value = {"/upload","/upload/*"}, comment = "文件管理入口")
public class FileServlet extends BaseServlet {
private static final String dir = "/var/www/upload/redbbs/";

View File

@ -17,9 +17,7 @@ import static org.redkale.source.FilterExpress.NOTEQUAL;
/**
* Created by Lxy at 2017/11/25 12:31.
*/
@WebServlet({"/","/project"
/* ,"/article","/article/*" */
})
@WebServlet(value = {"/","/project" /* ,"/article","/article/*" */}, comment = "首页一级菜单入口")
public class IndexServlet extends BaseServlet {
@HttpMapping(url = "/", auth = false, comment = "社区首页")

View File

@ -17,7 +17,7 @@ import org.redkale.util.Sheet;
* 用户相关的servlet
* Created by liangxianyou at 2018/6/4 13:12.
*/
@WebServlet({"/user", "/user/*"})
@WebServlet(value = {"/user", "/user/*"}, comment = "用户请求入口")
public class UserServlet extends BaseServlet {