1、栏目页用户昵称点击跳转失败,栏目下帖子a标签中加入title属性
2、修改本周热贴,查询一周内访问量最多的帖子
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
2018-07-01更新
|
2018-07-01更新
|
||||||
1、优化帖子阅读计数,让帖子阅读数更准确
|
1、优化帖子阅读计数,让帖子阅读数更准确
|
||||||
2、更新最新redkale-plugins.jar,加入redis验权
|
2、更新最新redkale-plugins.jar,加入redis验权
|
||||||
|
3、栏目页用户昵称点击跳转失败,栏目下帖子a标签中加入title属性
|
||||||
|
4、修改本周热贴,查询一周内访问量最多的帖子
|
||||||
|
|
||||||
2018-06-30更新
|
2018-06-30更新
|
||||||
1、修改servlet层中BaseServlet中共享request的重大bug
|
1、修改servlet层中BaseServlet中共享request的重大bug
|
||||||
|
Binary file not shown.
BIN
lib/mongo-java-driver-3.8.0.jar
Normal file
BIN
lib/mongo-java-driver-3.8.0.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
libs/redbbs.jar
BIN
libs/redbbs.jar
Binary file not shown.
@@ -135,7 +135,7 @@
|
|||||||
<div class="fly-panel fly-column">
|
<div class="fly-panel fly-column">
|
||||||
<div class="layui-container">
|
<div class="layui-container">
|
||||||
<ul class="layui-clear">
|
<ul class="layui-clear">
|
||||||
<li class="layui-hide-xs #@columned('')"><a href="/">全部</a></li>
|
<li class="layui-hide-xs #@columned('')"><a href="/column/">全部</a></li>
|
||||||
<li class="#@columned('qz')"><a href="/column/qz">求助</a></li>
|
<li class="#@columned('qz')"><a href="/column/qz">求助</a></li>
|
||||||
<li class="#@columned('fx')"><a href="/column/fx">分享<!--<span class="layui-badge-dot"></span>--></a></li>
|
<li class="#@columned('fx')"><a href="/column/fx">分享<!--<span class="layui-badge-dot"></span>--></a></li>
|
||||||
<!--
|
<!--
|
||||||
|
@@ -192,16 +192,16 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--热议-->
|
<!--热帖-->
|
||||||
<dl class="fly-panel fly-list-one">
|
<dl class="fly-panel fly-list-one">
|
||||||
<dt class="fly-panel-title">本周热议</dt>
|
<dt class="fly-panel-title">本周热帖</dt>
|
||||||
#for(x : hotReply.rows)
|
#for(x : hotView.rows??)
|
||||||
<dd>
|
<dd>
|
||||||
<a href="/jie/detail/#(x.contentid)">#(x.title)</a>
|
<a href="/jie/detail/#(x.contentid)">#(x.title)</a>
|
||||||
<span><i class="iconfont icon-pinglun1"></i> #(x.replynum)</span>
|
<span><i class="iconfont icon-pinglun1"></i> #(x.viewnum)</span>
|
||||||
</dd>
|
</dd>
|
||||||
#else
|
#else
|
||||||
<div class="fly-none">没有相关数据</div>
|
<div class="fly-none">没有相关数据</div>
|
||||||
#end
|
#end
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
@@ -96,7 +96,7 @@
|
|||||||
<!--评论-->
|
<!--评论-->
|
||||||
<div class="fly-panel detail-box" id="flyReply">
|
<div class="fly-panel detail-box" id="flyReply">
|
||||||
<fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
|
<fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
|
||||||
<legend>回帖</legend>
|
<legend>还有不明白?追问</legend>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<ul class="jieda" id="jieda">
|
<ul class="jieda" id="jieda">
|
||||||
@@ -173,13 +173,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-col-md4">
|
<div class="layui-col-md4">
|
||||||
<!--热议-->
|
<!--热帖-->
|
||||||
<dl class="fly-panel fly-list-one">
|
<dl class="fly-panel fly-list-one">
|
||||||
<dt class="fly-panel-title">本周热议</dt>
|
<dt class="fly-panel-title">本周热帖</dt>
|
||||||
#for(x : hotReply.rows)
|
#for(x : hotView.rows??)
|
||||||
<dd>
|
<dd>
|
||||||
<a href="/jie/detail/#(x.contentid)">#(x.title)</a>
|
<a href="/jie/detail/#(x.contentid)">#(x.title)</a>
|
||||||
<span><i class="iconfont icon-pinglun1"></i> #(x.replynum)</span>
|
<span><i class="iconfont icon-pinglun1"></i> #(x.viewnum)</span>
|
||||||
</dd>
|
</dd>
|
||||||
#else
|
#else
|
||||||
<div class="fly-none">没有相关数据</div>
|
<div class="fly-none">没有相关数据</div>
|
||||||
|
@@ -42,10 +42,10 @@
|
|||||||
#else
|
#else
|
||||||
<a class="layui-badge">#(x.typename)</a>
|
<a class="layui-badge">#(x.typename)</a>
|
||||||
#end
|
#end
|
||||||
<a href="/jie/detail/#(x.contentid)">#(x.title)</a>
|
<a href="/jie/detail/#(x.contentid)" title="#(x.title)">#(x.title)</a>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="fly-list-info">
|
<div class="fly-list-info">
|
||||||
<a href="user/#(x.userid)" link>
|
<a href="/user/#(x.userid)" link>
|
||||||
<cite>#(x.nickname)</cite>
|
<cite>#(x.nickname)</cite>
|
||||||
<!--
|
<!--
|
||||||
<i class="iconfont icon-renzheng" title="认证信息:XXX"></i>
|
<i class="iconfont icon-renzheng" title="认证信息:XXX"></i>
|
||||||
@@ -84,11 +84,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="layui-col-md4">
|
<div class="layui-col-md4">
|
||||||
<dl class="fly-panel fly-list-one">
|
<dl class="fly-panel fly-list-one">
|
||||||
<dt class="fly-panel-title">本周热议</dt>
|
<dt class="fly-panel-title">本周热帖</dt>
|
||||||
#for(x : hotReply.rows??)
|
#for(x : hotView.rows??)
|
||||||
<dd>
|
<dd>
|
||||||
<a href="/jie/detail/#(x.contentid)">#(x.title)</a>
|
<a href="/jie/detail/#(x.contentid)">#(x.title)</a>
|
||||||
<span><i class="iconfont icon-pinglun1"></i> #(x.replynum)</span>
|
<span><i class="iconfont icon-pinglun1"></i> #(x.viewnum)</span>
|
||||||
</dd>
|
</dd>
|
||||||
#else
|
#else
|
||||||
<div class="fly-none">没有相关数据</div>
|
<div class="fly-none">没有相关数据</div>
|
||||||
|
@@ -26,6 +26,9 @@ public class BaseService implements Service {
|
|||||||
@Resource(name = "redis")
|
@Resource(name = "redis")
|
||||||
protected RedisCacheSource<Integer> sessions;
|
protected RedisCacheSource<Integer> sessions;
|
||||||
|
|
||||||
|
@Resource(name = "cacheSource")
|
||||||
|
protected CacheSource cacheSource;
|
||||||
|
|
||||||
@Resource(name = "userInfos")
|
@Resource(name = "userInfos")
|
||||||
protected CacheSource<UserInfo> userInfos;
|
protected CacheSource<UserInfo> userInfos;
|
||||||
|
|
||||||
@@ -39,7 +42,12 @@ public class BaseService implements Service {
|
|||||||
@RestMapping(ignore = true)
|
@RestMapping(ignore = true)
|
||||||
public int currentUserId(String sessionid){
|
public int currentUserId(String sessionid){
|
||||||
if (sessionid == null) return 0;
|
if (sessionid == null) return 0;
|
||||||
Object userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
Object userid = null;
|
||||||
|
try {
|
||||||
|
userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return userid == null ? 0 : (Integer)userid;
|
return userid == null ? 0 : (Integer)userid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +1,36 @@
|
|||||||
package com.lxyer.bbs.base;
|
package com.lxyer.bbs.base;
|
||||||
|
|
||||||
|
import com.lxyer.bbs.base.user.UserInfo;
|
||||||
|
import com.lxyer.bbs.base.user.UserService;
|
||||||
import com.lxyer.bbs.content.Content;
|
import com.lxyer.bbs.content.Content;
|
||||||
|
import com.lxyer.bbs.content.ContentInfo;
|
||||||
import com.lxyer.bbs.content.ContentService;
|
import com.lxyer.bbs.content.ContentService;
|
||||||
|
import com.mongodb.Block;
|
||||||
import com.mongodb.MongoClient;
|
import com.mongodb.MongoClient;
|
||||||
|
import com.mongodb.client.AggregateIterable;
|
||||||
import com.mongodb.client.MongoCollection;
|
import com.mongodb.client.MongoCollection;
|
||||||
import com.mongodb.client.MongoDatabase;
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import com.mongodb.client.model.Accumulators;
|
||||||
|
import com.mongodb.client.model.Aggregates;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
import org.redkale.source.ColumnValue;
|
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.AnyValue;
|
||||||
|
import org.redkale.util.Sheet;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
import static com.mongodb.client.model.Filters.*;
|
import static com.mongodb.client.model.Filters.*;
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by liangxianyou at 2018/6/20 22:54.
|
* Created by liangxianyou at 2018/6/20 22:54.
|
||||||
@@ -24,6 +39,8 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
|
@Resource
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
@Resource(name = "property.mongo.host")
|
@Resource(name = "property.mongo.host")
|
||||||
private String mongoHost;
|
private String mongoHost;
|
||||||
@@ -99,4 +116,54 @@ public class TaskQueue<T extends Object> extends BaseService implements Runnable
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Sheet<ContentInfo> hotView(String sessionid){
|
||||||
|
int limit = 8;
|
||||||
|
String cacheKey = "hotView";
|
||||||
|
Object ids = cacheSource.get(cacheKey);
|
||||||
|
if (ids == null){
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.set(Calendar.DAY_OF_MONTH, -7);
|
||||||
|
|
||||||
|
//查询一周某热帖记录
|
||||||
|
Bson filter = and(ne("userid", 100001)
|
||||||
|
,regex("uri", "/jie/detail/*")
|
||||||
|
,ne("ip", "")
|
||||||
|
,gt("time", cal.getTimeInMillis())
|
||||||
|
);
|
||||||
|
List<Bson> list = asList(
|
||||||
|
Aggregates.match(filter)
|
||||||
|
,Aggregates.group("$uri", Accumulators.sum("count", 1))
|
||||||
|
,Aggregates.sort(new Document("count", -1))
|
||||||
|
,Aggregates.limit(8)
|
||||||
|
);
|
||||||
|
AggregateIterable<Document> documents = visLog.aggregate(list, Document.class);
|
||||||
|
|
||||||
|
List<Integer> _ids = new ArrayList<>(limit);
|
||||||
|
documents.forEach((Block<? super Document>) x->{
|
||||||
|
String uri = x.getString("_id");
|
||||||
|
_ids.add(Integer.parseInt(uri.replace("/jie/detail/", "")));
|
||||||
|
});
|
||||||
|
|
||||||
|
cacheSource.set(30 * 60, cacheKey, ids = _ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] contentids = new int[limit];
|
||||||
|
for (int i = 0; i < ((List<Integer>) ids).size(); i++) {
|
||||||
|
contentids[i] = ((List<Integer>) ids).get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Flipper flipper = new Flipper().limit(limit);
|
||||||
|
FilterNode node = FilterNode.create("contentid", FilterExpress.IN, contentids);
|
||||||
|
|
||||||
|
//权限过滤
|
||||||
|
UserInfo userInfo = userService.current(sessionid);
|
||||||
|
if (userInfo == null){
|
||||||
|
node.and("status", FilterExpress.NOTEQUAL, 30);
|
||||||
|
}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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -50,8 +50,13 @@ public class UserService extends BaseService {
|
|||||||
public UserInfo current(String sessionid){
|
public UserInfo current(String sessionid){
|
||||||
if (sessionid == null) return null;
|
if (sessionid == null) return null;
|
||||||
|
|
||||||
Object userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
Object userid = null;
|
||||||
sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
try {
|
||||||
|
userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||||
|
sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return userid == null ? null : findUserInfo((Integer) userid);
|
return userid == null ? null : findUserInfo((Integer) userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,10 +60,12 @@ public class ContentServlet extends BaseServlet {
|
|||||||
//Sheet<ContentInfo> hotView = contentService.contentQuery(flipper2, "");
|
//Sheet<ContentInfo> hotView = contentService.contentQuery(flipper2, "");
|
||||||
|
|
||||||
//热议
|
//热议
|
||||||
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);*/
|
||||||
|
|
||||||
Kv kv = Kv.by("bean", content).set("comments", comments)/*.set("hotView", hotView)*/.set("hotReply", hotReply);
|
Sheet<ContentInfo> hotView = logQueue.hotView(sessionid);
|
||||||
|
|
||||||
|
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,11 +89,12 @@ public class ContentServlet extends BaseServlet {
|
|||||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, setPrivate(request,filterNode));
|
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, setPrivate(request,filterNode));
|
||||||
|
|
||||||
//热议
|
//热议
|
||||||
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 = logQueue.hotView(sessionid);
|
||||||
|
|
||||||
Kv kv = Kv.by("contents", contents).set("hotReply", hotReply)
|
Kv kv = Kv.by("contents", contents).set("hotView", hotView)
|
||||||
.set("solved", solved).set("wonderful", wonderful)
|
.set("solved", solved).set("wonderful", wonderful)
|
||||||
.set("column", para).set("curr", curr);
|
.set("column", para).set("curr", curr);
|
||||||
response.finish(HttpScope.refer("/jie/index.html").attr(kv));
|
response.finish(HttpScope.refer("/jie/index.html").attr(kv));
|
||||||
|
@@ -41,8 +41,10 @@ public class IndexServlet extends BaseServlet {
|
|||||||
Sheet<ContentInfo> hotView = contentService.contentQuery(flipper2, "");*/
|
Sheet<ContentInfo> hotView = contentService.contentQuery(flipper2, "");*/
|
||||||
|
|
||||||
//热议
|
//热议
|
||||||
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 = logQueue.hotView(sessionid);
|
||||||
|
|
||||||
//最新加入
|
//最新加入
|
||||||
Sheet<UserInfo> lastReg = userService.lastReg();
|
Sheet<UserInfo> lastReg = userService.lastReg();
|
||||||
@@ -50,7 +52,7 @@ public class IndexServlet extends BaseServlet {
|
|||||||
//用户统计
|
//用户统计
|
||||||
Number userCount = userService.userCount();
|
Number userCount = userService.userCount();
|
||||||
|
|
||||||
Kv kv = Kv.by("top", top).set("contents", contents).set("hotReply", hotReply).set("lastReg", lastReg).set("userCount", userCount);
|
Kv kv = Kv.by("top", top).set("contents", contents).set("hotView", hotView).set("lastReg", lastReg).set("userCount", userCount);
|
||||||
response.finish(HttpScope.refer("index.html").attr(kv));
|
response.finish(HttpScope.refer("index.html").attr(kv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user