.
This commit is contained in:
parent
c3f5a5f5be
commit
976c62197a
@ -18,7 +18,7 @@
|
|||||||
<img src="#(x.avatar)" alt="#(x.nickname)">
|
<img src="#(x.avatar)" alt="#(x.nickname)">
|
||||||
</a>
|
</a>
|
||||||
<h2>
|
<h2>
|
||||||
<a class="layui-badge">动态</a>
|
<a class="layui-badge">#(x.typeName)</a>
|
||||||
<a href="/jie/detail/#(x.contentId)">#(x.title)</a>
|
<a href="/jie/detail/#(x.contentId)">#(x.title)</a>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="fly-list-info">
|
<div class="fly-list-info">
|
||||||
@ -162,7 +162,7 @@
|
|||||||
<!--最新加入-->
|
<!--最新加入-->
|
||||||
<div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
|
<div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
|
||||||
<h3 class="fly-panel-title">
|
<h3 class="fly-panel-title">
|
||||||
总用户:<span id="user_count">0</span>人
|
总用户:#(userCount??"0") 人
|
||||||
</h3>
|
</h3>
|
||||||
<dl>
|
<dl>
|
||||||
<!--<i class="layui-icon fly-loading"></i>-->
|
<!--<i class="layui-icon fly-loading"></i>-->
|
||||||
@ -200,18 +200,13 @@
|
|||||||
</div>
|
</div>
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#define link()
|
|
||||||
<div class="fly-panel fly-link">
|
<div class="fly-panel fly-link">
|
||||||
<h3 class="fly-panel-title">友情链接</h3>
|
<h3 class="fly-panel-title">友情链接</h3>
|
||||||
<dl class="fly-panel-main">
|
<dl class="fly-panel-main">
|
||||||
|
<dd><a href="http://redkale.org/" target="_blank">Redkale</a><dd>
|
||||||
<dd><a href="http://www.layui.com/" target="_blank">layui</a><dd>
|
<dd><a href="http://www.layui.com/" target="_blank">layui</a><dd>
|
||||||
<dd><a href="http://layim.layui.com/" target="_blank">WebIM</a><dd>
|
|
||||||
<dd><a href="http://layer.layui.com/" target="_blank">layer</a><dd>
|
|
||||||
<dd><a href="http://www.layui.com/laydate/" target="_blank">layDate</a><dd>
|
|
||||||
<dd><a href="mailto:xianxin@layui-inc.com?subject=%E7%94%B3%E8%AF%B7Fly%E7%A4%BE%E5%8C%BA%E5%8F%8B%E9%93%BE" class="fly-link">申请友链</a><dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
#end
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -235,7 +230,7 @@
|
|||||||
fly: 'index'
|
fly: 'index'
|
||||||
}).use('fly',function () {
|
}).use('fly',function () {
|
||||||
var fly = layui.fly;
|
var fly = layui.fly;
|
||||||
fly.userstat();
|
//fly.userstat();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
#end
|
#end
|
@ -13,7 +13,7 @@
|
|||||||
<h1>#(bean.title)</h1>
|
<h1>#(bean.title)</h1>
|
||||||
<div class="fly-detail-info">
|
<div class="fly-detail-info">
|
||||||
<!-- <span class="layui-badge">审核中</span> -->
|
<!-- <span class="layui-badge">审核中</span> -->
|
||||||
<span class="layui-badge layui-bg-green fly-detail-column">动态</span>
|
<span class="layui-badge layui-bg-green fly-detail-column">#(bean.typeName)</span>
|
||||||
|
|
||||||
<span class="layui-badge" style="background-color: #999;">未结</span>
|
<span class="layui-badge" style="background-color: #999;">未结</span>
|
||||||
<!-- <span class="layui-badge" style="background-color: #5FB878;">已结</span> -->
|
<!-- <span class="layui-badge" style="background-color: #5FB878;">已结</span> -->
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.lxyer.bbs.base;
|
package com.lxyer.bbs.base;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Lxy at 2017/11/29 15:17.
|
* Created by Lxy at 2017/11/29 15:17.
|
||||||
@ -30,4 +32,39 @@ public final class LxyKit {
|
|||||||
return new SimpleDateFormat("yyyy-MM-dd").format(time);
|
return new SimpleDateFormat("yyyy-MM-dd").format(time);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String delHTMLTag(String htmlStr){
|
||||||
|
String regEx_script="<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式
|
||||||
|
String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式
|
||||||
|
String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式
|
||||||
|
|
||||||
|
Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher m_script=p_script.matcher(htmlStr);
|
||||||
|
htmlStr=m_script.replaceAll(""); //过滤script标签
|
||||||
|
|
||||||
|
Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher m_style=p_style.matcher(htmlStr);
|
||||||
|
htmlStr=m_style.replaceAll(""); //过滤style标签
|
||||||
|
|
||||||
|
Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher m_html=p_html.matcher(htmlStr);
|
||||||
|
htmlStr=m_html.replaceAll(""); //过滤html标签
|
||||||
|
|
||||||
|
return htmlStr.trim(); //返回文本字符串
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Pattern p = Pattern.compile("@* ");
|
||||||
|
|
||||||
|
Matcher matcher = p.matcher("@nick [污] ");
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
while (matcher.find()) {
|
||||||
|
count++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,12 @@ public abstract class RetCodes {
|
|||||||
@RetLabel("邮箱无效")
|
@RetLabel("邮箱无效")
|
||||||
public static final int RET_USER_EMAIL_ILLEGAL = 3002_0009;
|
public static final int RET_USER_EMAIL_ILLEGAL = 3002_0009;
|
||||||
|
|
||||||
|
@RetLabel("昵称无效")
|
||||||
|
public static final int RET_USER_NICKNAME_ILLEGAL = 3002_0010;
|
||||||
|
|
||||||
|
@RetLabel("昵称已存在")
|
||||||
|
public static final int RET_USER_NICKNAME_EXISTS = 3002_0011;
|
||||||
|
|
||||||
//------------------------------------- 内容模块 -----------------------------------------
|
//------------------------------------- 内容模块 -----------------------------------------
|
||||||
|
|
||||||
//------------------------------------- 评论模块 -----------------------------------------
|
//------------------------------------- 评论模块 -----------------------------------------
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.lxyer.bbs.base.user;
|
package com.lxyer.bbs.base.user;
|
||||||
|
|
||||||
import com.jfinal.kit.Kv;
|
|
||||||
import com.lxyer.bbs.base.BaseService;
|
import com.lxyer.bbs.base.BaseService;
|
||||||
import com.lxyer.bbs.base.LxyKit;
|
import com.lxyer.bbs.base.LxyKit;
|
||||||
import com.lxyer.bbs.base.RetCodes;
|
import com.lxyer.bbs.base.RetCodes;
|
||||||
@ -16,7 +15,6 @@ import org.redkalex.cache.RedisCacheSource;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@ -62,6 +60,7 @@ public class UserService extends BaseService {
|
|||||||
}
|
}
|
||||||
@RestMapping(name = "userid")
|
@RestMapping(name = "userid")
|
||||||
public int currentUserId(String sessionid){
|
public int currentUserId(String sessionid){
|
||||||
|
if (sessionid == null) return 0;
|
||||||
Integer userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
Integer userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||||
return userid == null ? 0 : userid;
|
return userid == null ? 0 : userid;
|
||||||
}
|
}
|
||||||
@ -125,6 +124,16 @@ public class UserService extends BaseService {
|
|||||||
|
|
||||||
@RestMapping(name = "update", comment = "用户信息修改")
|
@RestMapping(name = "update", comment = "用户信息修改")
|
||||||
public RetResult userUpdate(@RestSessionid String sessionid, @RestParam(name = "bean") User user, String[] columns){
|
public RetResult userUpdate(@RestSessionid String sessionid, @RestParam(name = "bean") User user, String[] columns){
|
||||||
|
String nickname = user.getNickname();
|
||||||
|
if (nickname == null && nickname.isEmpty())
|
||||||
|
return RetCodes.retResult(RET_USER_NICKNAME_ILLEGAL, "昵称无效");
|
||||||
|
|
||||||
|
nickname = nickname.replace(" ", "");
|
||||||
|
User _user = source.find(User.class, FilterNode.create("nickname", nickname));
|
||||||
|
if (_user != null && _user.getUserId() != currentUserId(sessionid))
|
||||||
|
return RetCodes.retResult(RET_USER_NICKNAME_EXISTS, "昵称已存在");
|
||||||
|
|
||||||
|
user.setNickname(nickname);//去除昵称中的空格
|
||||||
source.updateColumn(user
|
source.updateColumn(user
|
||||||
,FilterNode.create("userId", currentUserId(sessionid))
|
,FilterNode.create("userId", currentUserId(sessionid))
|
||||||
,SelectColumn.createIncludes(columns)
|
,SelectColumn.createIncludes(columns)
|
||||||
@ -154,11 +163,16 @@ public class UserService extends BaseService {
|
|||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "stat", auth = false, comment = "用户数据统计")
|
/*@RestMapping(name = "stat", auth = false, comment = "用户数据统计")
|
||||||
public Map userStat(){
|
public Map userStat(){
|
||||||
|
|
||||||
Number count = source.getNumberResult(User.class, FilterFunc.COUNT, "userId", FilterNode.create("status", FilterExpress.NOTEQUAL, -1));
|
Number count = source.getNumberResult(User.class, FilterFunc.COUNT, "userId", FilterNode.create("status", FilterExpress.NOTEQUAL, -1));
|
||||||
|
|
||||||
return Kv.by("count", count);
|
return Kv.by("count", count);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@RestMapping(name = "usercount", auth = false, comment = "用户数据统计")
|
||||||
|
public Number userCount() {
|
||||||
|
return source.getNumberResult(User.class, FilterFunc.COUNT, "userId", FilterNode.create("status", FilterExpress.NOTEQUAL, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,10 @@ public class IndexServlet extends BaseServlet {
|
|||||||
//最新加入
|
//最新加入
|
||||||
Sheet<UserInfo> lastReg = userService.lastReg();
|
Sheet<UserInfo> lastReg = userService.lastReg();
|
||||||
|
|
||||||
Kv kv = Kv.by("top", top).set("contents", contents).set("hotReply", hotReply).set("lastReg", lastReg);
|
//用户统计
|
||||||
|
Number userCount = userService.userCount();
|
||||||
|
|
||||||
|
Kv kv = Kv.by("top", top).set("contents", contents).set("hotReply", hotReply).set("lastReg", lastReg).set("userCount", userCount);
|
||||||
finish("index.html", kv);
|
finish("index.html", kv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user