.
This commit is contained in:
parent
bd59b4f24c
commit
b5506e07e7
@ -1 +1,18 @@
|
|||||||
|
# 是否开发模式
|
||||||
|
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
|
||||||
|
arango.database=redbbs
|
||||||
|
arango.user=root
|
||||||
|
arango.password=abc123
|
||||||
|
|
||||||
|
----------- file conf ----------
|
||||||
|
file.upload_dir=D:/wk/_own/redbbs/root/file_pub/
|
||||||
|
file.view_path=http://127.0.0.1/file_pub/
|
||||||
|
BIN
lib/arangodb-java-driver-5.0.4.jar
Normal file
BIN
lib/arangodb-java-driver-5.0.4.jar
Normal file
Binary file not shown.
BIN
lib/enjoy-3.6.jar
Normal file
BIN
lib/enjoy-3.6.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/redkale-plugins-1.9.9.jar
Normal file
BIN
lib/redkale-plugins-1.9.9.jar
Normal file
Binary file not shown.
16
pom.xml
16
pom.xml
@ -7,6 +7,7 @@
|
|||||||
<groupId>com.lxyer</groupId>
|
<groupId>com.lxyer</groupId>
|
||||||
<artifactId>redbbs</artifactId>
|
<artifactId>redbbs</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>war</packaging>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -26,12 +27,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.redkale</groupId>
|
<groupId>org.redkale</groupId>
|
||||||
<artifactId>redkale</artifactId>
|
<artifactId>redkale</artifactId>
|
||||||
<version>1.9.8</version>
|
<version>1.9.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.redkalex</groupId>
|
<groupId>org.redkalex</groupId>
|
||||||
<artifactId>redkale-plugins</artifactId>
|
<artifactId>redkale-plugins</artifactId>
|
||||||
<version>1.9.8</version>
|
<version>1.9.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -42,21 +43,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jfinal</groupId>
|
<groupId>com.jfinal</groupId>
|
||||||
<artifactId>enjoy</artifactId>
|
<artifactId>enjoy</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.6</version>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- mongodb支持 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mongodb</groupId>
|
|
||||||
<artifactId>mongo-java-driver</artifactId>
|
|
||||||
<version>3.9.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- arangodb支持 -->
|
<!-- arangodb支持 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.arangodb</groupId>
|
<groupId>com.arangodb</groupId>
|
||||||
<artifactId>arangodb-java-driver</artifactId>
|
<artifactId>arangodb-java-driver</artifactId>
|
||||||
<version>5.0.1</version>
|
<version>5.0.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--maven 打包不需要-->
|
<!--maven 打包不需要-->
|
||||||
|
@ -17,7 +17,7 @@ import java.util.function.Function;
|
|||||||
/**
|
/**
|
||||||
* @author: liangxianyou at 2018/11/18 9:02.
|
* @author: liangxianyou at 2018/11/18 9:02.
|
||||||
*/
|
*/
|
||||||
@RestService(automapping = false, comment = "Arango服务")
|
@RestService(automapping = true, comment = "Arango服务")
|
||||||
public class ArangoService extends BaseService {
|
public class ArangoService extends BaseService {
|
||||||
|
|
||||||
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
||||||
@ -43,7 +43,6 @@ public class ArangoService extends BaseService {
|
|||||||
protected static ArangoDatabase dbDev;
|
protected static ArangoDatabase dbDev;
|
||||||
protected static ArangoCollection colVisLog;
|
protected static ArangoCollection colVisLog;
|
||||||
|
|
||||||
/* todo:启用本service 打开注释
|
|
||||||
@Override
|
@Override
|
||||||
public void init(AnyValue config) {
|
public void init(AnyValue config) {
|
||||||
System.out.println("isDev :" + isDev);
|
System.out.println("isDev :" + isDev);
|
||||||
@ -58,7 +57,7 @@ public class ArangoService extends BaseService {
|
|||||||
if (!colVisLog.exists()) {
|
if (!colVisLog.exists()) {
|
||||||
colVisLog.create();
|
colVisLog.create();
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
@RestMapping(auth = false)
|
@RestMapping(auth = false)
|
||||||
public List<Map> hi() {
|
public List<Map> hi() {
|
||||||
@ -77,7 +76,7 @@ public class ArangoService extends BaseService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static long findInt(String aql) {
|
public static long findInt(String aql) {
|
||||||
return dbDev.query(aql, long.class).first();
|
return dbDev.query(aql, long.class).first();
|
||||||
}
|
}
|
||||||
public static long findInt(String aql, Map para) {
|
public static long findInt(String aql, Map para) {
|
||||||
@ -91,6 +90,6 @@ public class ArangoService extends BaseService {
|
|||||||
public static <T> List<T> find(String aql, Map para, Class<T> clazz) {
|
public static <T> List<T> find(String aql, Map para, Class<T> clazz) {
|
||||||
|
|
||||||
return dbDev.query(aql, para, clazz).asListRemaining();
|
return dbDev.query(aql, para, clazz).asListRemaining();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.lxyer.bbs.base;
|
package com.lxyer.bbs.base;
|
||||||
|
|
||||||
|
import com.arangodb.Predicate;
|
||||||
import org.redkale.net.http.RestMapping;
|
import org.redkale.net.http.RestMapping;
|
||||||
import org.redkale.service.Service;
|
import org.redkale.service.Service;
|
||||||
import org.redkale.source.CacheSource;
|
import org.redkale.source.CacheSource;
|
||||||
@ -7,6 +8,9 @@ import org.redkale.source.DataSource;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
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.
|
* Created by Lxy at 2017/10/3 13:50.
|
||||||
@ -34,6 +38,20 @@ public class BaseService implements Service {
|
|||||||
|
|
||||||
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
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)
|
@RestMapping(ignore = true)
|
||||||
public DataSource getSource() {
|
public DataSource getSource() {
|
||||||
return source;
|
return source;
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
package com.lxyer.bbs.base;
|
|
||||||
|
|
||||||
import com.mongodb.MongoClient;
|
|
||||||
import com.mongodb.client.MongoCollection;
|
|
||||||
import com.mongodb.client.MongoDatabase;
|
|
||||||
import org.bson.Document;
|
|
||||||
import org.redkale.net.http.RestService;
|
|
||||||
import org.redkale.util.AnyValue;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@RestService(comment = "Mongo服务")
|
|
||||||
public class MongoService extends BaseService {
|
|
||||||
|
|
||||||
@Resource(name = "property.mongo.host")
|
|
||||||
private String mongoHost;
|
|
||||||
@Resource(name = "property.mongo.database")
|
|
||||||
private String databaseName;
|
|
||||||
@Resource(name = "property.mongo.port")
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
//日志存放doc名称
|
|
||||||
private static final String VIS_LOG = "vis_log";
|
|
||||||
|
|
||||||
private static MongoClient mongoClient;
|
|
||||||
private static MongoDatabase database;
|
|
||||||
private static MongoCollection<Document> visLog;
|
|
||||||
|
|
||||||
/* todo:启用本service 打开注释
|
|
||||||
@Override
|
|
||||||
public void init(AnyValue config) {
|
|
||||||
mongoClient = new MongoClient(mongoHost, port);
|
|
||||||
database = mongoClient.getDatabase(isDev ? databaseName + "_dev": databaseName);
|
|
||||||
visLog = database.getCollection(VIS_LOG);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//todo: 编写mongo操作逻辑 待完成
|
|
||||||
|
|
||||||
}
|
|
@ -15,6 +15,7 @@ import org.redkale.source.FilterNode;
|
|||||||
import org.redkale.source.Flipper;
|
import org.redkale.source.Flipper;
|
||||||
import org.redkale.util.Comment;
|
import org.redkale.util.Comment;
|
||||||
import org.redkale.util.Sheet;
|
import org.redkale.util.Sheet;
|
||||||
|
import org.redkale.util.Utility;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -57,8 +58,7 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
|
|
||||||
//记录访问日志,如果是访问的文章详情:对文章访问数量更新
|
//记录访问日志,如果是访问的文章详情:对文章访问数量更新
|
||||||
if (task instanceof VisLog) {
|
if (task instanceof VisLog) {
|
||||||
System.out.println(task);
|
//System.out.println(task);
|
||||||
/* todo: 需要记录 访问日志,此处添加记录日志逻辑
|
|
||||||
ArangoService.save(task).thenAcceptAsync((_task) -> {
|
ArangoService.save(task).thenAcceptAsync((_task) -> {
|
||||||
VisLog visLog = (VisLog) _task;
|
VisLog visLog = (VisLog) _task;
|
||||||
//[访问量]
|
//[访问量]
|
||||||
@ -67,7 +67,6 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
updateViewNum(visLog);
|
updateViewNum(visLog);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -84,7 +83,7 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
" collect WITH COUNT INTO total\n" +
|
" collect WITH COUNT INTO total\n" +
|
||||||
" return total", visLog.getUri(), visLog.getIp(), visLog.getUserid());
|
" return total", visLog.getUri(), visLog.getIp(), visLog.getUserid());
|
||||||
|
|
||||||
long total = 2;//ArangoService.findInt(aql);
|
long total = ArangoService.findInt(aql);
|
||||||
|
|
||||||
if (total <= 1) {
|
if (total <= 1) {
|
||||||
String uri = visLog.getUri();
|
String uri = visLog.getUri();
|
||||||
@ -97,16 +96,14 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
public Sheet<ContentInfo> hotView(String sessionid){
|
public Sheet<ContentInfo> hotView(String sessionid){
|
||||||
int limit = 8;
|
int limit = 8;
|
||||||
String cacheKey = "hotView";
|
String cacheKey = "hotView";
|
||||||
Object ids = null;//cacheSource.get(cacheKey);
|
Object ids = cacheSource.get(cacheKey);
|
||||||
if (ids == null){
|
if (isEmpty.test(ids)){
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.DAY_OF_MONTH, -7);
|
cal.set(Calendar.DAY_OF_MONTH, -7);
|
||||||
|
|
||||||
Map para = new HashMap();
|
Map para = new HashMap();
|
||||||
para.put("time", cal.getTimeInMillis());
|
para.put("time", cal.getTimeInMillis());
|
||||||
//查询一周某热帖记录
|
//查询一周某热帖记录
|
||||||
List<Count> hotArticle = new ArrayList<>();
|
|
||||||
/* TODO: 依赖日志记录,需记录日志后可使用
|
|
||||||
List<Count> hotArticle = ArangoService.find(
|
List<Count> hotArticle = ArangoService.find(
|
||||||
"for d in vis_log_dev\n" +
|
"for d in vis_log_dev\n" +
|
||||||
" filter d.uri =~ '^/jie/detail/[0-9]+$' and d.userid != 100001 and d.time > @time\n" +
|
" filter d.uri =~ '^/jie/detail/[0-9]+$' and d.userid != 100001 and d.time > @time\n" +
|
||||||
@ -115,7 +112,7 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
" limit 10\n" +
|
" limit 10\n" +
|
||||||
" return {name: uri,total:total}",
|
" return {name: uri,total:total}",
|
||||||
Utility.ofMap("time", cal.getTimeInMillis()),
|
Utility.ofMap("time", cal.getTimeInMillis()),
|
||||||
Count.class);*/
|
Count.class);
|
||||||
|
|
||||||
Function<List<Count>, List<Integer>> deal = (counts) -> {
|
Function<List<Count>, List<Integer>> deal = (counts) -> {
|
||||||
List<Integer> _ids = new ArrayList<>();
|
List<Integer> _ids = new ArrayList<>();
|
||||||
|
@ -62,7 +62,7 @@ public class ContentServlet extends BaseServlet {
|
|||||||
/*Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
/*Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
||||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", sessionid);*/
|
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", sessionid);*/
|
||||||
|
|
||||||
Sheet<ContentInfo> hotView = Sheet.empty();//logQueue.hotView(sessionid); TODO: 依赖日志记录,需记录日志后可使用
|
Sheet<ContentInfo> hotView = logQueue.hotView(sessionid);
|
||||||
|
|
||||||
Kv kv = Kv.by("bean", content).set("comments", comments).set("hotView", hotView)/*.set("hotReply", hotReply)*/;
|
Kv kv = Kv.by("bean", content).set("comments", comments).set("hotView", hotView)/*.set("hotReply", hotReply)*/;
|
||||||
response.finish(HttpScope.refer("/jie/detail.html").attr(kv));
|
response.finish(HttpScope.refer("/jie/detail.html").attr(kv));
|
||||||
@ -87,7 +87,7 @@ public class ContentServlet extends BaseServlet {
|
|||||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, setPrivate(request, setPrivate(request, filterNode)));
|
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, setPrivate(request, setPrivate(request, filterNode)));
|
||||||
|
|
||||||
//热帖
|
//热帖
|
||||||
Sheet<ContentInfo> hotView = Sheet.empty();//logQueue.hotView(sessionid); TODO: 依赖日志记录,需记录日志后可使用
|
Sheet<ContentInfo> hotView = logQueue.hotView(sessionid);
|
||||||
|
|
||||||
Kv kv = Kv.by("contents", contents).set("hotView", hotView)
|
Kv kv = Kv.by("contents", contents).set("hotView", hotView)
|
||||||
.set("solved", solved).set("wonderful", wonderful)
|
.set("solved", solved).set("wonderful", wonderful)
|
||||||
|
@ -42,7 +42,7 @@ public class IndexServlet extends BaseServlet {
|
|||||||
/*Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
/*Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
||||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", sessionid);*/
|
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", sessionid);*/
|
||||||
|
|
||||||
Sheet<ContentInfo> hotView = Sheet.empty();//logQueue.hotView(sessionid); TODO: 依赖日志记录,需记录日志后可使用
|
Sheet<ContentInfo> hotView = logQueue.hotView(sessionid);
|
||||||
|
|
||||||
//最新加入
|
//最新加入
|
||||||
Sheet<UserInfo> lastReg = userService.lastReg();
|
Sheet<UserInfo> lastReg = userService.lastReg();
|
||||||
|
Loading…
Reference in New Issue
Block a user