加了一些注释,代码上的调整,方便阅读代码者,也方便维护升级
深更半夜,没睡着起来搞事情
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -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"));*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -67,16 +67,4 @@ public final class LxyKit {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@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));
|
||||
|
@@ -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){
|
||||
source.updateColumn(Content.class, id, field, 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();
|
||||
}
|
||||
|
||||
|
@@ -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){
|
||||
|
@@ -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/";
|
||||
|
@@ -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 = "社区首页")
|
||||
|
@@ -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 {
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user