diff --git a/conf/application.xml b/conf/application.xml
index edfcec2..9e170ab 100644
--- a/conf/application.xml
+++ b/conf/application.xml
@@ -5,22 +5,17 @@
-
-
+
-
+
+ -->
-
+
-
-
-
@@ -30,10 +25,7 @@
-
-
-
-
+
@@ -42,32 +34,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/conf.txt b/conf/conf.txt
index 1d270c7..3362e7f 100644
--- a/conf/conf.txt
+++ b/conf/conf.txt
@@ -1,11 +1,6 @@
# 是否开发模式
isDev=true
------------ mongo conf ----------
-mongo.host=127.0.0.1
-mongo.port=27017
-mongo.database=redbbs
-
----------- arango conf ----------
arango.host=120.24.230.60
arango.port=8529
diff --git a/lib/redkale-plugins.jar b/lib/redkale-plugins.jar
deleted file mode 100644
index 214224d..0000000
Binary files a/lib/redkale-plugins.jar and /dev/null differ
diff --git a/lib/redkale.jar b/lib/redkale.jar
deleted file mode 100644
index a720365..0000000
Binary files a/lib/redkale.jar and /dev/null differ
diff --git a/pom.xml b/pom.xml
index 48a5c71..7a80363 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,6 +8,7 @@
redbbs
1.0-SNAPSHOT
+ redbbs
src
@@ -22,40 +23,34 @@
+
org.redkale
redkale
- 1.9.8
+ 1.9.9
org.redkalex
redkale-plugins
- 1.9.8
+ 1.9.9
mysql
mysql-connector-java
- 6.0.6
+ 5.1.34
com.jfinal
enjoy
- 3.5
-
-
-
-
- org.mongodb
- mongo-java-driver
- 3.9.0
+ 3.6
com.arangodb
arangodb-java-driver
- 5.0.1
+ 5.0.4
com.lxyer
diff --git a/src/com/lxyer/bbs/base/ArangoKit.java b/src/com/lxyer/bbs/base/ArangoKit.java
index cc6dad5..835b82f 100644
--- a/src/com/lxyer/bbs/base/ArangoKit.java
+++ b/src/com/lxyer/bbs/base/ArangoKit.java
@@ -20,7 +20,7 @@ public class ArangoKit {
protected static Function chDev = (s) -> s + (winos ? "_dev" : "");
//Arango
- protected static ArangoDB arangoDb = new ArangoDB.Builder().host("120.24.230.60", 8529).user("root").password("root").build();
+ protected static ArangoDB arangoDb = new ArangoDB.Builder().host("120.24.230.60", 8529).user("root").password("abc123").build();
protected static ArangoDatabase dbDev = arangoDb.db(chDev.apply("redbbs"));
protected static ArangoCollection colVisLog = dbDev.collection(chDev.apply("vis_log"));
diff --git a/src/com/lxyer/bbs/base/BaseService.java b/src/com/lxyer/bbs/base/BaseService.java
index c54f87c..d57a591 100644
--- a/src/com/lxyer/bbs/base/BaseService.java
+++ b/src/com/lxyer/bbs/base/BaseService.java
@@ -1,5 +1,6 @@
package com.lxyer.bbs.base;
+import com.arangodb.Predicate;
import org.redkale.net.http.RestMapping;
import org.redkale.service.Service;
import org.redkale.source.CacheSource;
@@ -7,6 +8,9 @@ import org.redkale.source.DataSource;
import javax.annotation.Resource;
import java.io.File;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
/**
* Created by Lxy at 2017/10/3 13:50.
@@ -15,20 +19,39 @@ public class BaseService implements Service {
protected final int sessionExpireSeconds = 7 * 24 * 60 * 60;
+ @Resource(name = "property.isDev")
+ public boolean isDev = true;
+
@Resource(name = "SERVER_ROOT")
protected File webroot;
@Resource(name = "art123")
protected DataSource source;
- @Resource(name = "redis")
- protected CacheSource sessions;
+ /* 使用redis 代码中配置此处即可
+ @Resource(name = "redis")*/
+ @Resource(name = "cacheSource")
+ protected CacheSource sessions;
@Resource(name = "cacheSource")
protected CacheSource cacheSource;
protected static final boolean winos = System.getProperty("os.name").contains("Window");
+ public static Predicate isEmpty = (x) -> {
+ if (x == null)
+ return true;
+ if (x instanceof List)
+ return ((List) x).isEmpty();
+ if (x instanceof String)
+ return ((String) x).isEmpty();
+ if (x instanceof Map)
+ return ((Map) x).isEmpty();
+ if (x instanceof Collection)
+ return ((Collection) x).isEmpty();
+ return false;
+ };
+
@RestMapping(ignore = true)
public DataSource getSource() {
return source;
diff --git a/src/com/lxyer/bbs/base/BaseServlet.java b/src/com/lxyer/bbs/base/BaseServlet.java
index b800116..ae75a8f 100644
--- a/src/com/lxyer/bbs/base/BaseServlet.java
+++ b/src/com/lxyer/bbs/base/BaseServlet.java
@@ -88,6 +88,7 @@ public class BaseServlet extends HttpServlet {
visLog.setIp(request.getRemoteAddr());
visLog.setUri(request.getRequestURI());
visLog.setHeaders(headers);
+ visLog.setUserid(userid);
visLog.setPara(para);
visLog.setTime(System.currentTimeMillis());
visLog.setFtime(String.format("%1$tY%1$tm%1$td%1$tH%1$tM%1$tS", visLog.getTime()));
diff --git a/src/com/lxyer/bbs/base/TaskQueue.java b/src/com/lxyer/bbs/base/TaskQueue.java
index cb891db..bc8a790 100644
--- a/src/com/lxyer/bbs/base/TaskQueue.java
+++ b/src/com/lxyer/bbs/base/TaskQueue.java
@@ -2,37 +2,26 @@ package com.lxyer.bbs.base;
import com.lxyer.bbs.base.entity.Count;
import com.lxyer.bbs.base.entity.VisLog;
-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;
import com.lxyer.bbs.content.ContentService;
-import com.mongodb.MongoClient;
-import com.mongodb.client.FindIterable;
-import com.mongodb.client.MongoCollection;
-import com.mongodb.client.MongoDatabase;
-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;
import org.redkale.source.Flipper;
-import org.redkale.util.AnyValue;
import org.redkale.util.Comment;
import org.redkale.util.Sheet;
+import org.redkale.util.Utility;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.function.Consumer;
import java.util.function.Function;
-import static com.mongodb.client.model.Filters.eq;
-
/**
* Created by liangxianyou at 2018/6/20 22:54.
*/
@@ -44,28 +33,12 @@ public class TaskQueue extends BaseService implements Runnable
@Resource
private UserService userService;
- @Resource(name = "property.mongo.host")
- private String mongoHost;
- @Resource(name = "property.mongo.database")
- private String mongoDatabase;
-
protected static LinkedBlockingQueue queue = new LinkedBlockingQueue();
- private static MongoClient mongoClient;
- private static MongoDatabase database;
- private static MongoCollection visLog;
-
public TaskQueue() {
new Thread(this).start();
}
- @Override
- public void init(AnyValue config) {
- mongoClient = new MongoClient(mongoHost, 27017);
- database = mongoClient.getDatabase(winos ? mongoDatabase + "_dev": mongoDatabase);
- visLog = database.getCollection("vis_log");
- }
-
@RestMapping(ignore = true)
public T take() throws InterruptedException {
return (T) queue.take();
@@ -85,7 +58,8 @@ public class TaskQueue extends BaseService implements Runnable
//记录访问日志,如果是访问的文章详情:对文章访问数量更新
if (task instanceof VisLog) {
- ArangoKit.save(task).thenAcceptAsync((_task) -> {
+ //System.out.println(task);
+ ArangoService.save(task).thenAcceptAsync((_task) -> {
VisLog visLog = (VisLog) _task;
//[访问量]
String uri = visLog.getUri();
@@ -109,8 +83,7 @@ public class TaskQueue extends BaseService implements Runnable
" collect WITH COUNT INTO total\n" +
" return total", visLog.getUri(), visLog.getIp(), visLog.getUserid());
- long total = ArangoKit.findInt(aql);
-
+ long total = ArangoService.findInt(aql);
if (total <= 1) {
String uri = visLog.getUri();
@@ -123,22 +96,22 @@ public class TaskQueue extends BaseService implements Runnable
public Sheet hotView(String sessionid){
int limit = 8;
String cacheKey = "hotView";
- Object ids = null;//cacheSource.get(cacheKey);
- if (ids == null){
+ Object ids = cacheSource.get(cacheKey);
+ if (isEmpty.test(ids)){
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, -7);
Map para = new HashMap();
para.put("time", cal.getTimeInMillis());
//查询一周某热帖记录
- List hotArticle = ArangoKit.find(
- "for d in vis_log_dev\n" +
+ List hotArticle = ArangoService.find(
+ "for d in " + (isDev ? "vis_log_dev" : "vis_log") + "\n" +
" filter d.uri =~ '^/jie/detail/[0-9]+$' and d.userid != 100001 and d.time > @time\n" +
" COLLECT uri=d.uri WITH COUNT INTO total\n" +
" sort total desc\n" +
" limit 10\n" +
" return {name: uri,total:total}",
- Map.of("time", cal.getTimeInMillis()),
+ Utility.ofMap("time", cal.getTimeInMillis()),
Count.class);
Function, List> deal = (counts) -> {
@@ -159,13 +132,13 @@ public class TaskQueue extends BaseService implements Runnable
}
Flipper flipper = new Flipper().limit(limit);
- FilterNode node = FilterNode.create("contentid", FilterExpress.IN, contentids);
+ FilterNode node = FilterNode.create("contentid", FilterExpress.IN, contentids).and("status", FilterExpress.NOTEQUAL, -10);
//权限过滤
UserInfo userInfo = userService.current(sessionid);
- if (userInfo == null){
+ if (userInfo == null){ //访客
node.and("status", FilterExpress.NOTEQUAL, 30);
- }else if (!userService.isAdmin(userInfo.getUserid())){
+ }else if (!userService.isAdmin(userInfo.getUserid())){ //非管理员
node.and(FilterNode.create("status", FilterExpress.NOTEQUAL, 30).or(FilterNode.create("status", 30).and("userid", userInfo.getUserid())));
}
return contentService.contentQuery(flipper, node);
@@ -176,7 +149,7 @@ public class TaskQueue extends BaseService implements Runnable
*/
@RestMapping(ignore = true, comment = "帖子访客记录")
public Sheet