.
This commit is contained in:
parent
ed7ef7e507
commit
c5b9f856b5
BIN
libs/redbbs.jar
BIN
libs/redbbs.jar
Binary file not shown.
@ -38,6 +38,7 @@ public class EnjoyRender implements HttpRender<HttpScope> {
|
||||
Map attr = scope.getAttributes();
|
||||
if (attr == null) attr = Kv.create();
|
||||
attr.put("mine", mine);
|
||||
attr.put("token", request.getSessionid(false));
|
||||
|
||||
String str = template.renderToString(attr);
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import com.lxyer.bbs.base.kit.LxyKit;
|
||||
import com.lxyer.bbs.base.user.UserInfo;
|
||||
import com.lxyer.bbs.base.user.UserRecord;
|
||||
import com.lxyer.bbs.base.user.UserService;
|
||||
import com.lxyer.bbs.content.Content;
|
||||
import com.lxyer.bbs.content.ContentInfo;
|
||||
@ -8,6 +10,7 @@ import com.lxyer.bbs.content.ContentService;
|
||||
import com.mongodb.Block;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.client.AggregateIterable;
|
||||
import com.mongodb.client.FindIterable;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import com.mongodb.client.model.Accumulators;
|
||||
@ -22,10 +25,7 @@ import org.redkale.util.AnyValue;
|
||||
import org.redkale.util.Sheet;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@ -166,4 +166,40 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
||||
return contentService.contentQuery(flipper, node);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO:帖子访客记录 --待完成
|
||||
* @return
|
||||
*/
|
||||
public Sheet<Map> readRecordAsync(Flipper flipper ,int contentid){
|
||||
Bson filter = eq("uri", "/jie/detail/"+ contentid);
|
||||
|
||||
FindIterable<Document> documents = visLog.find(filter).limit(flipper.getLimit()).skip(flipper.getOffset());
|
||||
long total = visLog.countDocuments(filter);
|
||||
|
||||
List<Map> rows = new ArrayList<>();
|
||||
List<Integer> uids = new ArrayList<>();
|
||||
documents.forEach((Block<? super Document>) x->{
|
||||
Integer userid = x.getInteger("userid");
|
||||
if (userid > 0) uids.add(userid);
|
||||
|
||||
Map row = new HashMap<String, Object>();
|
||||
row.put("userid", userid);
|
||||
row.put("ip", x.getString("ip"));
|
||||
});
|
||||
|
||||
int[] userids = LxyKit.listToArray(uids, new int[uids.size()]);
|
||||
List<UserRecord> records = source.queryList(UserRecord.class, FilterNode.create("userid", FilterExpress.IN, userids));
|
||||
|
||||
rows.forEach(x->{
|
||||
UserRecord record = records.stream().filter(y -> (Integer) x.get("userid") == y.getUserid()).findFirst().orElse(new UserRecord());
|
||||
x.put("nickname", record.getRealname());
|
||||
x.put("avatar", record.getAvatar());
|
||||
});
|
||||
|
||||
Sheet<Map> sheet = new Sheet<>();
|
||||
sheet.setTotal(total);
|
||||
sheet.setRows(rows);
|
||||
|
||||
return sheet;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.lxyer.bbs.base.kit;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -53,6 +54,21 @@ public final class LxyKit {
|
||||
return htmlStr.trim(); //返回文本字符串
|
||||
}
|
||||
|
||||
public static <T> T[] listToArray(List list, T[] ts){
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ts[0] = (T) list.get(i);
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
public static int[] listToArray(List list, int[] ts){
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ts[0] = (int) list.get(i);
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Pattern p = Pattern.compile("@* ");
|
||||
|
||||
@ -61,10 +77,6 @@ public final class LxyKit {
|
||||
int count = 0;
|
||||
while (matcher.find()) {
|
||||
count++;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
||||
UserInfo current = userService.current(sessionid);
|
||||
int currentid = current == null ? 0 : current.getUserid();
|
||||
|
||||
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1);
|
||||
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -10);
|
||||
switch (actived){
|
||||
case "top": filterNode.and("top", FilterExpress.GREATERTHANOREQUALTO, 20);break;
|
||||
case "untop": filterNode.and("top", 10);break;
|
||||
@ -64,13 +64,13 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
||||
}
|
||||
|
||||
|
||||
public Sheet<ContentInfo> queryByBean(Flipper flipper, FilterBean bean){
|
||||
/*public Sheet<ContentInfo> queryByBean(Flipper flipper, FilterBean bean){
|
||||
Sheet<Content> contents = source.querySheet(Content.class, flipper, bean);
|
||||
|
||||
Sheet<ContentInfo> infos = createInfo(contents);
|
||||
|
||||
return infos;
|
||||
}
|
||||
}*/
|
||||
|
||||
@RestMapping(name = "save", auth = true, comment = "内容保存")
|
||||
public RetResult contentSave(@RestParam(name = "bean")Content content, @RestSessionid String sessionid){
|
||||
@ -112,11 +112,6 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
||||
return contentInfo;
|
||||
}
|
||||
|
||||
@RestMapping(name = "upview", comment = "增加文章1个访问量")
|
||||
public void incrViewNum(int contentId){
|
||||
source.updateColumn(Content.class, contentId, ColumnValue.inc("viewnum", 1));
|
||||
}
|
||||
|
||||
@RestMapping(name = "collect", comment = "内容收藏")
|
||||
public RetResult collect(@RestSessionid String sessionid, int contentid, int ok){
|
||||
int userid = userService.currentUserId(sessionid);//不会为空
|
||||
@ -171,10 +166,6 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
||||
FilterNode untopNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -10).and("top", 0);
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, untopNode);
|
||||
|
||||
//热帖
|
||||
/*Flipper flipper2 = new Flipper().limit(8).sort("viewNum DESC");
|
||||
Sheet<ContentInfo> hotView = contentService.contentQuery(flipper2, "");*/
|
||||
|
||||
//热议
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", sessionid);
|
||||
|
@ -82,16 +82,12 @@ public class ContentServlet extends BaseServlet {
|
||||
|
||||
Flipper flipper = new Flipper().offset((curr-1) * 20).limit(20).sort("top DESC,createtime DESC");
|
||||
//帖子列表
|
||||
FilterNode filterNode = FilterNode.create("status", NOTEQUAL, -1).and("type", column.getAs(para));
|
||||
FilterNode filterNode = FilterNode.create("status", NOTEQUAL, -10).and("type", column.getAs(para));
|
||||
if (solved > 0) filterNode.and("solved", 20);
|
||||
if (wonderful > 0) filterNode.and("wonderful", 20);
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, setPrivate(request, setPrivate(request, filterNode)));
|
||||
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, setPrivate(request,filterNode));
|
||||
|
||||
//热议
|
||||
/*Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", sessionid);*/
|
||||
|
||||
//热帖
|
||||
Sheet<ContentInfo> hotView = logQueue.hotView(sessionid);
|
||||
|
||||
Kv kv = Kv.by("contents", contents).set("hotView", hotView)
|
||||
|
Loading…
Reference in New Issue
Block a user