重构接口,加入"项目"模块
This commit is contained in:
parent
b6d1574603
commit
00ad1f87f4
BIN
libs/redbbs.jar
Normal file
BIN
libs/redbbs.jar
Normal file
Binary file not shown.
@ -56,11 +56,14 @@
|
|||||||
<a href="/">社区</a>
|
<a href="/">社区</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="layui-nav-item">
|
<li class="layui-nav-item">
|
||||||
<a href="http://redkale.org/" target="_blank">Redkale框架</a>
|
<a href="/project">项目</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="layui-nav-item">
|
<li class="layui-nav-item">
|
||||||
<a href="http://redkale.org/articles.html" target="_blank">技术文章</a>
|
<a href="http://redkale.org/" target="_blank">Redkale框架</a>
|
||||||
</li>
|
</li>
|
||||||
|
<!--<li class="layui-nav-item">
|
||||||
|
<a href="http://redkale.org/articles.html" target="_blank">技术文章</a>
|
||||||
|
</li>-->
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul class="layui-nav fly-nav-user">
|
<ul class="layui-nav fly-nav-user">
|
||||||
@ -109,7 +112,10 @@
|
|||||||
#@main?()
|
#@main?()
|
||||||
|
|
||||||
<div class="fly-footer">
|
<div class="fly-footer">
|
||||||
<p><a href="http://b.1216.top/" target="_blank">Redbbs</a> 2017 © <a href="http://1216.top/" target="_blank">http://1216.top</a></p>
|
<p>
|
||||||
|
<a href="http://1216.top" target="_blank">Redbbs 2017 © http://1216.top</a>
|
||||||
|
<a href='https://gitee.com/tc608/redbbs' target="_blank"><img src='https://gitee.com/tc608/redbbs/badge/star.svg?theme=white' alt='star'/></a>
|
||||||
|
</p>
|
||||||
#define x()
|
#define x()
|
||||||
<p>
|
<p>
|
||||||
<a href="http://fly.layui.com/jie/3147/" target="_blank">付费计划</a>
|
<a href="http://fly.layui.com/jie/3147/" target="_blank">付费计划</a>
|
||||||
|
@ -44,8 +44,8 @@
|
|||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<select lay-verify="required" name="status">
|
<select lay-verify="required" name="status">
|
||||||
<!--[内容栏目]10求助,20分享,30建议,40公告,50动态-->
|
<!--[内容栏目]10求助,20分享,30建议,40公告,50动态-->
|
||||||
<option value="1" #if(bean.status?? == 1) selected #end>公开</option>
|
<option value="10" #if(bean.status?? == 10) selected #end>公开</option>
|
||||||
<option value="3" #if(bean.status?? == 3) selected #end>私密(自己和管理能查看)</option>
|
<option value="30" #if(bean.status?? == 30) selected #end>私密(自己和管理能查看)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
258
root/project/index.html
Normal file
258
root/project/index.html
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
<!--项目首页-->
|
||||||
|
<!--- Created by JUECHENG at 2018/4/5 20:55. --->
|
||||||
|
#set(title=bean.title)
|
||||||
|
#set(keywords=bean.title)
|
||||||
|
#set(description=bean.title)
|
||||||
|
|
||||||
|
#@layout()
|
||||||
|
#define css()
|
||||||
|
<style>
|
||||||
|
.fly-panel{margin-right: 15px}
|
||||||
|
</style>
|
||||||
|
#end
|
||||||
|
|
||||||
|
#define main()
|
||||||
|
<div class="layui-container">
|
||||||
|
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md8" style="padding-top: 20px;">
|
||||||
|
<!--内容-->
|
||||||
|
<div class="fly-panel detail-box">
|
||||||
|
<h1>#(bean.title)</h1>
|
||||||
|
<hr>
|
||||||
|
<div class="detail-body photos">
|
||||||
|
#(bean.content??)
|
||||||
|
|
||||||
|
#if(bean.site?? || bean.git??)
|
||||||
|
<blockquote class="layui-elem-quote layui-quote-nm">
|
||||||
|
#if(bean.site??)
|
||||||
|
|
||||||
|
#end
|
||||||
|
#if(bean.git??)
|
||||||
|
|
||||||
|
#end
|
||||||
|
</blockquote>
|
||||||
|
#end
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--评论-->
|
||||||
|
<div class="fly-panel detail-box" id="flyReply">
|
||||||
|
<fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
|
||||||
|
<legend>回帖</legend>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<ul class="jieda" id="jieda">
|
||||||
|
#for(x : comments.rows??)
|
||||||
|
<li data-id="#(x.commentid)" class="jieda-daan">
|
||||||
|
<a name="item-1111111111"></a>
|
||||||
|
<div class="detail-about detail-about-reply">
|
||||||
|
<a class="fly-avatar" href="/user/#(x.userid)">
|
||||||
|
<img src="#(x.avatar)" alt="#(x.nickname)">
|
||||||
|
</a>
|
||||||
|
<div class="fly-detail-user">
|
||||||
|
<a href="" class="fly-link">
|
||||||
|
<cite>#(x.nickname)</cite>
|
||||||
|
<!--<i class="iconfont icon-renzheng" title="认证信息:XXX"></i>
|
||||||
|
<i class="layui-badge fly-badge-vip">VIP3</i>-->
|
||||||
|
</a>
|
||||||
|
#if(x.userid == bean.userid??)
|
||||||
|
<span>(楼主)</span>
|
||||||
|
#end
|
||||||
|
<!--
|
||||||
|
<span style="color:#5FB878">(管理员)</span>
|
||||||
|
<span style="color:#FF9E3F">(社区之光)</span>
|
||||||
|
<span style="color:#999">(该号已被封)</span>
|
||||||
|
-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="detail-hits"><span>#(x.createtime??)</span></div>
|
||||||
|
#if(1>2)
|
||||||
|
<i class="iconfont icon-caina" title="最佳答案"></i>
|
||||||
|
#end
|
||||||
|
</div>
|
||||||
|
<div class="detail-body jieda-body photos">
|
||||||
|
#(x.content)
|
||||||
|
</div>
|
||||||
|
<div class="jieda-reply">
|
||||||
|
#if(x.hadsupport == 1)
|
||||||
|
<span class="jieda-zan zanok" type="zan"><i class="iconfont icon-zan"></i><em>#(x.supportnum)</em></span>
|
||||||
|
#else
|
||||||
|
<span class="jieda-zan" type="zan"><i class="iconfont icon-zan"></i><em>#(x.supportnum)</em></span>
|
||||||
|
#end
|
||||||
|
<span type="reply"><i class="iconfont icon-svgmoban53"></i>回复</span>
|
||||||
|
<div class="jieda-admin">
|
||||||
|
#if(x.userid == mine.userid?? && false)
|
||||||
|
<span type="edit">编辑</span>
|
||||||
|
<span type="del">删除</span>
|
||||||
|
#end
|
||||||
|
#if(bean.userid == mine.userid??)
|
||||||
|
<span class="jieda-accept" type="accept">采纳</span>
|
||||||
|
#end
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
#else
|
||||||
|
<li class="fly-none">消灭零回复</li>
|
||||||
|
#end
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="layui-form layui-form-pane">
|
||||||
|
<form action="/jie/reply/" method="post">
|
||||||
|
<div class="layui-form-item layui-form-text">
|
||||||
|
<a name="comment"></a>
|
||||||
|
<!--<div class="layui-input-block">
|
||||||
|
<textarea id="mytextarea">Hello, World!</textarea>
|
||||||
|
</div>-->
|
||||||
|
<div id="editor"></div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<input type="hidden" name="contentid" value="#(bean.contentid??)">
|
||||||
|
<input type="hidden" name="pid" value="0">
|
||||||
|
<button class="layui-btn" lay-filter="jie-reply" lay-submit>提交回复</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel detail-box">
|
||||||
|
<div class="detail-about">
|
||||||
|
<a class="fly-avatar" href="/user/#(bean.userid)">
|
||||||
|
<img src="#(bean.avatar)" alt="#(bean.nickname)">
|
||||||
|
</a>
|
||||||
|
<div class="fly-detail-user">
|
||||||
|
<a href="/user/#(bean.userid)" class="fly-link">
|
||||||
|
<cite>#(bean.nickname)</cite>
|
||||||
|
<!--
|
||||||
|
<i class="iconfont icon-renzheng" title="认证信息:{{ rows.user.approve }}"></i>
|
||||||
|
<i class="layui-badge fly-badge-vip">VIP3</i>
|
||||||
|
-->
|
||||||
|
</a>
|
||||||
|
<span>#(bean.createtime??)</span>
|
||||||
|
</div>
|
||||||
|
<div class="detail-hits" id="LAY_jieAdmin" data-id="123">
|
||||||
|
态度决定高度!
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src='https://gitee.com/tc608/redbbs/widget_preview'></script>
|
||||||
|
<style>
|
||||||
|
.pro_name a{color: #4183c4;}
|
||||||
|
.osc_git_title{background-color: #fff;}
|
||||||
|
.osc_git_box{background-color: #fff;}
|
||||||
|
.osc_git_box{border-color: #E3E9ED;}
|
||||||
|
.osc_git_info{color: #666;}
|
||||||
|
.osc_git_main a{color: #9B9B9B;}
|
||||||
|
</style>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-md4">
|
||||||
|
<div class="fly-panel" style="padding: 10px">
|
||||||
|
<h2>这里是一个标题这里是一个标题这里是一个标题</h2>
|
||||||
|
<div>
|
||||||
|
这里是内容摘要,这里是内容摘要,这里是内容摘要,这里是内容摘要,
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
#end
|
||||||
|
|
||||||
|
#define js()
|
||||||
|
<script src="//unpkg.com/wangeditor/release/wangEditor.min.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.cache.page = 'jie';
|
||||||
|
layui.cache.user = {
|
||||||
|
username: '游客'
|
||||||
|
,uid: -1
|
||||||
|
,avatar: '../../res/images/avatar/00.jpg'
|
||||||
|
,experience: 83
|
||||||
|
,sex: '男'
|
||||||
|
};
|
||||||
|
layui.config({
|
||||||
|
version: false
|
||||||
|
,base: '../../res/mods/'
|
||||||
|
}).extend({
|
||||||
|
fly: 'index'
|
||||||
|
}).use(['fly', 'jie'], function(){
|
||||||
|
var $ = layui.jquery, fly = layui.fly;
|
||||||
|
var jie = layui.jie;
|
||||||
|
//如果你是采用模版自带的编辑器,你需要开启以下语句来解析。
|
||||||
|
/*$('.detail-body').each(function(){
|
||||||
|
var othis = $(this), html = othis.html();
|
||||||
|
othis.html(fly.content(html));
|
||||||
|
});*/
|
||||||
|
|
||||||
|
jie.createEditer("comment");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
#end
|
@ -1,19 +1,15 @@
|
|||||||
package com.lxyer.bbs.base;
|
package com.lxyer.bbs.base;
|
||||||
|
|
||||||
import com.lxyer.bbs.base.user.UserRecord;
|
import com.lxyer.bbs.base.iface.UI;
|
||||||
import com.lxyer.bbs.base.user.UserInfo;
|
import com.lxyer.bbs.base.user.UserInfo;
|
||||||
|
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;
|
||||||
import org.redkale.source.DataSource;
|
import org.redkale.source.DataSource;
|
||||||
import org.redkale.source.FilterExpress;
|
|
||||||
import org.redkale.source.FilterNode;
|
|
||||||
import org.redkale.util.Sheet;
|
|
||||||
import org.redkalex.cache.RedisCacheSource;
|
import org.redkalex.cache.RedisCacheSource;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Lxy at 2017/10/3 13:50.
|
* Created by Lxy at 2017/10/3 13:50.
|
||||||
@ -36,8 +32,12 @@ public class BaseService<F extends UF,I extends UI> implements Service {
|
|||||||
|
|
||||||
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
||||||
|
|
||||||
|
@RestMapping(ignore = true)
|
||||||
|
public DataSource getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
protected Sheet<I> createInfo(Sheet<F> fSheet){
|
/*protected Sheet<I> createInfo(Sheet<F> fSheet){
|
||||||
Sheet<I> sheet = new Sheet<>();
|
Sheet<I> sheet = new Sheet<>();
|
||||||
|
|
||||||
if (fSheet == null || fSheet.getTotal() < 1){
|
if (fSheet == null || fSheet.getTotal() < 1){
|
||||||
@ -53,7 +53,7 @@ public class BaseService<F extends UF,I extends UI> implements Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return sheet;
|
return sheet;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量设置用户信息
|
* 批量设置用户信息
|
||||||
@ -61,7 +61,7 @@ public class BaseService<F extends UF,I extends UI> implements Service {
|
|||||||
* @param <I>
|
* @param <I>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected <I extends UI> Sheet<I> setIUser(Sheet<I> ufSheet){
|
/*protected <I extends UI> Sheet<I> setIUser(Sheet<I> ufSheet){
|
||||||
int[] userIds = ufSheet.stream().mapToInt(I::getUserid).toArray();
|
int[] userIds = ufSheet.stream().mapToInt(I::getUserid).toArray();
|
||||||
|
|
||||||
List<UserRecord> users = source.queryList(UserRecord.class, FilterNode.create("userId", FilterExpress.IN, userIds));
|
List<UserRecord> users = source.queryList(UserRecord.class, FilterNode.create("userId", FilterExpress.IN, userIds));
|
||||||
@ -70,16 +70,23 @@ public class BaseService<F extends UF,I extends UI> implements Service {
|
|||||||
x.setUser(user);
|
x.setUser(user);
|
||||||
});
|
});
|
||||||
return ufSheet;
|
return ufSheet;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将含有用户外键的实体,转为info,并加入用户信息
|
* 将含有用户外键的实体,转为info,并加入用户信息
|
||||||
* @param uf
|
* @param uf
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected I setIUser(I uf){
|
/*protected I setIUser(I uf){
|
||||||
UserRecord user = source.find(UserRecord.class, uf.getUserid());
|
UserRecord user = source.find(UserRecord.class, uf.getUserid());
|
||||||
|
|
||||||
return (I) uf.setUser(user);
|
return (I) uf.setUser(user);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@RestMapping(ignore = true)
|
||||||
|
public int currentUserId(String sessionid){
|
||||||
|
if (sessionid == null) return 0;
|
||||||
|
Object userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||||
|
return userid == null ? 0 : (Integer)userid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.lxyer.bbs.base;
|
package com.lxyer.bbs.base;
|
||||||
|
|
||||||
|
import com.lxyer.bbs.base.iface.UI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* user foreign key (userId)
|
* user foreign key (userId)
|
||||||
* Created by liangxianyou at 2018/6/9 14:50.
|
* Created by liangxianyou at 2018/6/9 14:50.
|
||||||
|
9
src/com/lxyer/bbs/base/iface/C.java
Normal file
9
src/com/lxyer/bbs/base/iface/C.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package com.lxyer.bbs.base.iface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建信息
|
||||||
|
* Created by liangxianyou at 2018/6/16 17:43.
|
||||||
|
*/
|
||||||
|
public interface C<I extends CI> {
|
||||||
|
I createInfo();
|
||||||
|
}
|
7
src/com/lxyer/bbs/base/iface/CI.java
Normal file
7
src/com/lxyer/bbs/base/iface/CI.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.lxyer.bbs.base.iface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by liangxianyou at 2018/6/16 18:39.
|
||||||
|
*/
|
||||||
|
public interface CI<I extends CI> {
|
||||||
|
}
|
32
src/com/lxyer/bbs/base/iface/CService.java
Normal file
32
src/com/lxyer/bbs/base/iface/CService.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.lxyer.bbs.base.iface;
|
||||||
|
|
||||||
|
import org.redkale.net.http.RestMapping;
|
||||||
|
import org.redkale.util.Sheet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by liangxianyou at 2018/6/16 17:56.
|
||||||
|
*/
|
||||||
|
public interface CService<I extends UI> {
|
||||||
|
|
||||||
|
@RestMapping(ignore = true)
|
||||||
|
default <A extends C> Sheet<I> createInfo(Sheet<A> fSheet){
|
||||||
|
Sheet<I> sheet = new Sheet<>();
|
||||||
|
|
||||||
|
if (fSheet == null || fSheet.getTotal() < 1){
|
||||||
|
sheet.setTotal(0);
|
||||||
|
sheet.setRows(new ArrayList<>());
|
||||||
|
}else {
|
||||||
|
int total = (int)fSheet.getTotal();
|
||||||
|
List<I> rows = new ArrayList<>(total);
|
||||||
|
fSheet.forEach(x->rows.add((I)x.createInfo()));
|
||||||
|
|
||||||
|
sheet.setTotal(total);
|
||||||
|
sheet.setRows(rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.lxyer.bbs.base;
|
package com.lxyer.bbs.base.iface;
|
||||||
|
|
||||||
import com.lxyer.bbs.base.user.UserRecord;
|
import com.lxyer.bbs.base.user.UserRecord;
|
||||||
|
|
38
src/com/lxyer/bbs/base/iface/UIService.java
Normal file
38
src/com/lxyer/bbs/base/iface/UIService.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package com.lxyer.bbs.base.iface;
|
||||||
|
|
||||||
|
import com.lxyer.bbs.base.user.UserRecord;
|
||||||
|
import org.redkale.net.http.RestMapping;
|
||||||
|
import org.redkale.source.DataSource;
|
||||||
|
import org.redkale.source.FilterExpress;
|
||||||
|
import org.redkale.source.FilterNode;
|
||||||
|
import org.redkale.util.Sheet;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by liangxianyou at 2018/6/16 18:25.
|
||||||
|
*/
|
||||||
|
public interface UIService<I extends UI> extends CService<I> {
|
||||||
|
|
||||||
|
DataSource getSource();
|
||||||
|
|
||||||
|
@RestMapping(ignore = true)
|
||||||
|
default Sheet<I> setIUser(Sheet<I> sheet){
|
||||||
|
int[] userids = sheet.stream().mapToInt(I::getUserid).toArray();
|
||||||
|
|
||||||
|
List<UserRecord> users = getSource().queryList(UserRecord.class, FilterNode.create("userid", FilterExpress.IN, userids));
|
||||||
|
sheet.forEach(x->{
|
||||||
|
UserRecord user = users.stream().filter(u -> u.getUserid() == x.getUserid()).findAny().orElse(null);
|
||||||
|
x.setUser(user);
|
||||||
|
});
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RestMapping(ignore = true)
|
||||||
|
default I setIUser(I i){
|
||||||
|
UserRecord user = getSource().find(UserRecord.class, i.getUserid());
|
||||||
|
|
||||||
|
return (I) i.setUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -52,12 +52,6 @@ public class UserService extends BaseService {
|
|||||||
sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||||
return userid == null ? null : findUserInfo((Integer) userid);
|
return userid == null ? null : findUserInfo((Integer) userid);
|
||||||
}
|
}
|
||||||
@RestMapping(name = "userid")
|
|
||||||
public int currentUserId(String sessionid){
|
|
||||||
if (sessionid == null) return 0;
|
|
||||||
Object userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
|
||||||
return userid == null ? 0 : (Integer)userid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RestMapping(name = "info", comment = "用户信息")
|
@RestMapping(name = "info", comment = "用户信息")
|
||||||
public UserInfo findUserInfo(int userid) {
|
public UserInfo findUserInfo(int userid) {
|
||||||
|
@ -3,6 +3,8 @@ package com.lxyer.bbs.comment;
|
|||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
import com.lxyer.bbs.base.UF;
|
import com.lxyer.bbs.base.UF;
|
||||||
|
import com.lxyer.bbs.base.iface.C;
|
||||||
|
import com.lxyer.bbs.base.iface.UI;
|
||||||
import com.lxyer.bbs.base.kit.LxyKit;
|
import com.lxyer.bbs.base.kit.LxyKit;
|
||||||
import org.redkale.convert.json.*;
|
import org.redkale.convert.json.*;
|
||||||
|
|
||||||
@ -14,7 +16,7 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
@Cacheable(interval = 5*60)
|
@Cacheable(interval = 5*60)
|
||||||
@Table(catalog = "redbbs", name = "sys_comment", comment = "[评论表]")
|
@Table(catalog = "redbbs", name = "sys_comment", comment = "[评论表]")
|
||||||
public class Comment implements Serializable, UF {
|
public class Comment implements Serializable, C<CommentInfo> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.lxyer.bbs.comment;
|
package com.lxyer.bbs.comment;
|
||||||
|
|
||||||
import com.lxyer.bbs.base.UI;
|
import com.lxyer.bbs.base.iface.CI;
|
||||||
|
import com.lxyer.bbs.base.iface.UI;
|
||||||
import com.lxyer.bbs.base.user.UserRecord;
|
import com.lxyer.bbs.base.user.UserRecord;
|
||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ import java.io.Serializable;
|
|||||||
*
|
*
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
public class CommentInfo implements UI<CommentInfo>,Serializable {
|
public class CommentInfo implements UI<CommentInfo>,Serializable, CI<CommentInfo> {
|
||||||
|
|
||||||
@Column(comment = "[评论id]")
|
@Column(comment = "[评论id]")
|
||||||
private int commentid;
|
private int commentid;
|
||||||
|
@ -2,6 +2,8 @@ package com.lxyer.bbs.comment;
|
|||||||
|
|
||||||
import com.lxyer.bbs.base.BaseService;
|
import com.lxyer.bbs.base.BaseService;
|
||||||
import com.lxyer.bbs.base.entity.ActLog;
|
import com.lxyer.bbs.base.entity.ActLog;
|
||||||
|
import com.lxyer.bbs.base.iface.UI;
|
||||||
|
import com.lxyer.bbs.base.iface.UIService;
|
||||||
import com.lxyer.bbs.base.kit.LxyKit;
|
import com.lxyer.bbs.base.kit.LxyKit;
|
||||||
import com.lxyer.bbs.base.kit.RetCodes;
|
import com.lxyer.bbs.base.kit.RetCodes;
|
||||||
import com.lxyer.bbs.base.user.UserService;
|
import com.lxyer.bbs.base.user.UserService;
|
||||||
@ -27,10 +29,10 @@ import static com.lxyer.bbs.base.kit.RetCodes.RET_COMMENT_PARA_ILLEGAL;
|
|||||||
* Created by Lxy at 2017/11/29 10:00.
|
* Created by Lxy at 2017/11/29 10:00.
|
||||||
*/
|
*/
|
||||||
@RestService(automapping = true, comment = "评论服务")
|
@RestService(automapping = true, comment = "评论服务")
|
||||||
public class CommentService extends BaseService<Comment, CommentInfo> {
|
public class CommentService extends BaseService implements UIService<CommentInfo> {
|
||||||
|
|
||||||
@Resource
|
/*@Resource
|
||||||
private UserService userService;
|
private UserService userService;*/
|
||||||
|
|
||||||
@RestMapping(name = "save", comment = "评论保存")
|
@RestMapping(name = "save", comment = "评论保存")
|
||||||
public RetResult commentSave(@RestSessionid String sessionid, @RestParam(name = "bean") Comment comment){
|
public RetResult commentSave(@RestSessionid String sessionid, @RestParam(name = "bean") Comment comment){
|
||||||
@ -46,7 +48,7 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
|||||||
return RetCodes.retResult(RET_COMMENT_CONTENT_ILLEGAL, "评论内容无效");
|
return RetCodes.retResult(RET_COMMENT_CONTENT_ILLEGAL, "评论内容无效");
|
||||||
|
|
||||||
if (comment.getCommentid() < 1) {
|
if (comment.getCommentid() < 1) {
|
||||||
int userid = userService.currentUserId(sessionid);
|
int userid = currentUserId(sessionid);
|
||||||
comment.setUserid(userid);
|
comment.setUserid(userid);
|
||||||
comment.setCreatetime(System.currentTimeMillis());
|
comment.setCreatetime(System.currentTimeMillis());
|
||||||
//todo:@用户处理
|
//todo:@用户处理
|
||||||
@ -63,7 +65,7 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
|||||||
|
|
||||||
@RestMapping(name = "query", auth = false,comment = "查询评论")
|
@RestMapping(name = "query", auth = false,comment = "查询评论")
|
||||||
public Sheet<CommentInfo> commentQuery(@RestSessionid String sessionid , int contentId, Flipper flipper){
|
public Sheet<CommentInfo> commentQuery(@RestSessionid String sessionid , int contentId, Flipper flipper){
|
||||||
int userid = userService.currentUserId(sessionid);
|
int userid = currentUserId(sessionid);
|
||||||
|
|
||||||
flipper.setSort("supportnum DESC,commentid ASC");
|
flipper.setSort("supportnum DESC,commentid ASC");
|
||||||
Sheet<Comment> comments = source.querySheet(Comment.class, flipper, FilterNode.create("contentid", contentId));
|
Sheet<Comment> comments = source.querySheet(Comment.class, flipper, FilterNode.create("contentid", contentId));
|
||||||
@ -89,42 +91,35 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
|||||||
Sheet<Comment> comments = source.querySheet(Comment.class, new Flipper().sort("createtime DESC"), FilterNode.create("userid", userid));
|
Sheet<Comment> comments = source.querySheet(Comment.class, new Flipper().sort("createtime DESC"), FilterNode.create("userid", userid));
|
||||||
|
|
||||||
int[] contentIds = comments.stream().mapToInt(x -> x.getCommentid()).toArray();
|
int[] contentIds = comments.stream().mapToInt(x -> x.getCommentid()).toArray();
|
||||||
|
|
||||||
List<Content> contents = source.queryList(Content.class, SelectColumn.createIncludes("contentid","title"), FilterNode.create("contentid", FilterExpress.IN, contentIds));
|
List<Content> contents = source.queryList(Content.class, SelectColumn.createIncludes("contentid","title"), FilterNode.create("contentid", FilterExpress.IN, contentIds));
|
||||||
|
|
||||||
Sheet<CommentInfo> infos = new Sheet<>();
|
Sheet<CommentInfo> infos = createInfo(comments);
|
||||||
List<CommentInfo> list = new ArrayList<>();
|
infos.forEach(x->{
|
||||||
|
|
||||||
comments.forEach(x->{
|
|
||||||
CommentInfo info = x.createInfo();
|
|
||||||
Content content = contents.stream().filter(k -> k.getContentid() == x.getContentid()).findFirst().orElse(new Content());
|
Content content = contents.stream().filter(k -> k.getContentid() == x.getContentid()).findFirst().orElse(new Content());
|
||||||
info.setTitle(content.getTitle());
|
x.setTitle(content.getTitle());
|
||||||
list.add(info);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
infos.setRows(list);
|
|
||||||
infos.setTotal(comments.getTotal());
|
|
||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "support", comment = "评论点赞")
|
@RestMapping(name = "support", comment = "评论点赞")
|
||||||
public RetResult support(@RestSessionid String sessionid, int commentid, int ok){
|
public RetResult support(@RestSessionid String sessionid, int commentid, int ok){
|
||||||
int userid = userService.currentUserId(sessionid);
|
int userid = currentUserId(sessionid);
|
||||||
|
|
||||||
ActLog actLog = source.find(ActLog.class, FilterNode.create("userid", userid).and("tid", commentid).and("cate", 10));
|
source.findAsync(ActLog.class, FilterNode.create("userid", userid).and("tid", commentid).and("cate", 10)).thenAccept(actLog -> {
|
||||||
if (actLog == null && ok == 1){
|
if (actLog == null && ok == 1){
|
||||||
actLog = new ActLog(10, commentid, userid);
|
actLog = new ActLog(10, commentid, userid);
|
||||||
actLog.setCreatetime(System.currentTimeMillis());
|
actLog.setCreatetime(System.currentTimeMillis());
|
||||||
source.insert(actLog);
|
source.insert(actLog);
|
||||||
}else if (actLog != null && actLog.getStatus() != ok){
|
}else if (actLog != null && actLog.getStatus() != ok){
|
||||||
actLog.setStatus((short) -10);
|
actLog.setStatus((short) -10);
|
||||||
source.update(actLog);
|
source.update(actLog);
|
||||||
}else {
|
}/*else {
|
||||||
return RetCodes.retResult(-1, ok == 1 ? "已赞" : "已取消赞");
|
return RetCodes.retResult(-1, ok == 1 ? "已赞" : "已取消赞");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
int count = source.getNumberResult(ActLog.class, FilterFunc.COUNT, 0, "logid", FilterNode.create("tid", commentid).and("status", 10)).intValue();
|
int count = source.getNumberResult(ActLog.class, FilterFunc.COUNT, 0, "logid", FilterNode.create("tid", commentid).and("status", 10)).intValue();
|
||||||
source.updateColumn(Comment.class, commentid,"supportnum", count);
|
source.updateColumn(Comment.class, commentid,"supportnum", count);
|
||||||
|
});
|
||||||
|
|
||||||
return RetResult.success();
|
return RetResult.success();
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package com.lxyer.bbs.content;
|
package com.lxyer.bbs.content;
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
|
|
||||||
import com.jfinal.kit.Kv;
|
import com.jfinal.kit.Kv;
|
||||||
import com.lxyer.bbs.base.UF;
|
import com.lxyer.bbs.base.iface.C;
|
||||||
import com.lxyer.bbs.base.kit.LxyKit;
|
import com.lxyer.bbs.base.kit.LxyKit;
|
||||||
import org.redkale.convert.json.*;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,7 +14,7 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
@Cacheable(interval = 5*60)
|
@Cacheable(interval = 5*60)
|
||||||
@Table(catalog = "redbbs", name = "sys_content", comment = "[内容表]")
|
@Table(catalog = "redbbs", name = "sys_content", comment = "[内容表]")
|
||||||
public class Content implements Serializable, UF<ContentInfo> {
|
public class Content implements Serializable, C<ContentInfo> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.lxyer.bbs.content;
|
package com.lxyer.bbs.content;
|
||||||
|
|
||||||
import com.lxyer.bbs.base.UI;
|
import com.lxyer.bbs.base.iface.CI;
|
||||||
|
import com.lxyer.bbs.base.iface.UI;
|
||||||
import com.lxyer.bbs.base.user.UserRecord;
|
import com.lxyer.bbs.base.user.UserRecord;
|
||||||
import org.redkale.convert.ConvertColumn;
|
import org.redkale.convert.ConvertColumn;
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* Created by Lxy at 2017/11/26 20:52.
|
* Created by Lxy at 2017/11/26 20:52.
|
||||||
*/
|
*/
|
||||||
public class ContentInfo implements UI<ContentInfo>,Serializable {
|
public class ContentInfo implements UI<ContentInfo>,Serializable, CI {
|
||||||
|
|
||||||
private int contentid;
|
private int contentid;
|
||||||
private int userid;
|
private int userid;
|
||||||
|
@ -3,6 +3,7 @@ package com.lxyer.bbs.content;
|
|||||||
import com.jfinal.kit.Kv;
|
import com.jfinal.kit.Kv;
|
||||||
import com.lxyer.bbs.base.BaseService;
|
import com.lxyer.bbs.base.BaseService;
|
||||||
import com.lxyer.bbs.base.entity.ActLog;
|
import com.lxyer.bbs.base.entity.ActLog;
|
||||||
|
import com.lxyer.bbs.base.iface.UIService;
|
||||||
import com.lxyer.bbs.base.kit.RetCodes;
|
import com.lxyer.bbs.base.kit.RetCodes;
|
||||||
import com.lxyer.bbs.base.user.UserInfo;
|
import com.lxyer.bbs.base.user.UserInfo;
|
||||||
import com.lxyer.bbs.base.user.UserService;
|
import com.lxyer.bbs.base.user.UserService;
|
||||||
@ -18,7 +19,7 @@ import javax.annotation.Resource;
|
|||||||
* Created by Lxy at 2017/11/26 9:33.
|
* Created by Lxy at 2017/11/26 9:33.
|
||||||
*/
|
*/
|
||||||
@RestService(automapping = true, comment = "内容管理")
|
@RestService(automapping = true, comment = "内容管理")
|
||||||
public class ContentService extends BaseService<Content,ContentInfo>{
|
public class ContentService extends BaseService implements UIService<ContentInfo> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected UserService userService;
|
protected UserService userService;
|
||||||
@ -32,6 +33,7 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
|||||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode){
|
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode){
|
||||||
Sheet<Content> contents = source.querySheet(Content.class, flipper, filterNode);
|
Sheet<Content> contents = source.querySheet(Content.class, flipper, filterNode);
|
||||||
|
|
||||||
|
createInfo(contents);
|
||||||
Sheet<ContentInfo> infos = createInfo(contents);
|
Sheet<ContentInfo> infos = createInfo(contents);
|
||||||
setIUser(infos);
|
setIUser(infos);
|
||||||
|
|
||||||
@ -134,7 +136,7 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
|||||||
|
|
||||||
@RestMapping(name = "collectquery", comment = "收藏列表")
|
@RestMapping(name = "collectquery", comment = "收藏列表")
|
||||||
public Sheet<ContentInfo> collectQuery(@RestSessionid String sessionid){
|
public Sheet<ContentInfo> collectQuery(@RestSessionid String sessionid){
|
||||||
int userid = userService.currentUserId(sessionid);
|
int userid = currentUserId(sessionid);
|
||||||
|
|
||||||
Flipper flipper = new Flipper().sort("createtime DESC");
|
Flipper flipper = new Flipper().sort("createtime DESC");
|
||||||
FilterNode filterNode = FilterNode.create("cate", 20).and("status", 10).and("userid", userid);
|
FilterNode filterNode = FilterNode.create("cate", 20).and("status", 10).and("userid", userid);
|
||||||
|
@ -69,7 +69,7 @@ public class ContentServlet extends BaseServlet {
|
|||||||
@Override
|
@Override
|
||||||
public String get() {
|
public String get() {
|
||||||
UserRecord user = request.currentUser();
|
UserRecord user = request.currentUser();
|
||||||
if (user == null || user.getUserid() > 10_0003)
|
if (user == null || user.getRoleid() != 0)
|
||||||
contentService.incrViewNum(contentid);
|
contentService.incrViewNum(contentid);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.lxyer.bbs.servlet;
|
|||||||
import com.jfinal.kit.Kv;
|
import com.jfinal.kit.Kv;
|
||||||
import com.lxyer.bbs.base.BaseServlet;
|
import com.lxyer.bbs.base.BaseServlet;
|
||||||
import com.lxyer.bbs.base.user.UserInfo;
|
import com.lxyer.bbs.base.user.UserInfo;
|
||||||
|
import com.lxyer.bbs.comment.CommentInfo;
|
||||||
import com.lxyer.bbs.content.ContentInfo;
|
import com.lxyer.bbs.content.ContentInfo;
|
||||||
import org.redkale.net.http.HttpMapping;
|
import org.redkale.net.http.HttpMapping;
|
||||||
import org.redkale.net.http.HttpRequest;
|
import org.redkale.net.http.HttpRequest;
|
||||||
@ -12,7 +13,6 @@ import org.redkale.source.FilterNode;
|
|||||||
import org.redkale.source.Flipper;
|
import org.redkale.source.Flipper;
|
||||||
import org.redkale.util.Sheet;
|
import org.redkale.util.Sheet;
|
||||||
|
|
||||||
import static org.redkale.source.FilterExpress.GREATERTHAN;
|
|
||||||
import static org.redkale.source.FilterExpress.GREATERTHANOREQUALTO;
|
import static org.redkale.source.FilterExpress.GREATERTHANOREQUALTO;
|
||||||
import static org.redkale.source.FilterExpress.NOTEQUAL;
|
import static org.redkale.source.FilterExpress.NOTEQUAL;
|
||||||
|
|
||||||
@ -20,14 +20,14 @@ import static org.redkale.source.FilterExpress.NOTEQUAL;
|
|||||||
/**
|
/**
|
||||||
* Created by Lxy at 2017/11/25 12:31.
|
* Created by Lxy at 2017/11/25 12:31.
|
||||||
*/
|
*/
|
||||||
@WebServlet({"/"
|
@WebServlet({"/","/project"
|
||||||
/* ,"/article","/article/*" */
|
/* ,"/article","/article/*" */
|
||||||
})
|
})
|
||||||
public class IndexServlet extends BaseServlet {
|
public class IndexServlet extends BaseServlet {
|
||||||
|
|
||||||
@HttpMapping(url = "/", auth = false, comment = "社区首页")
|
@HttpMapping(url = "/", auth = false, comment = "社区首页")
|
||||||
public void abc(HttpRequest request, HttpResponse response){
|
public void abc(HttpRequest request, HttpResponse response){
|
||||||
Flipper flipper = new Flipper().limit(30).sort("top DESC,createtime DESC");
|
Flipper flipper = new Flipper().limit(15).sort("top DESC,createtime DESC");
|
||||||
//置顶贴
|
//置顶贴
|
||||||
FilterNode topNode = FilterNode.create("status", NOTEQUAL, -10).and("top", GREATERTHANOREQUALTO, 20);
|
FilterNode topNode = FilterNode.create("status", NOTEQUAL, -10).and("top", GREATERTHANOREQUALTO, 20);
|
||||||
Sheet<ContentInfo> top = contentService.contentQuery(flipper, setPrivate(topNode));
|
Sheet<ContentInfo> top = contentService.contentQuery(flipper, setPrivate(topNode));
|
||||||
@ -66,4 +66,16 @@ public class IndexServlet extends BaseServlet {
|
|||||||
|
|
||||||
finish("/article/index.html");
|
finish("/article/index.html");
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
//====================================项目相关====================================
|
||||||
|
@HttpMapping(url = "/project", auth = false, comment = "项目首页")
|
||||||
|
public void project(HttpRequest request, HttpResponse response){
|
||||||
|
int contentid = 22;
|
||||||
|
ContentInfo content = contentService.contentInfo(sessionid, contentid);
|
||||||
|
Sheet<CommentInfo> comments = commentService.commentQuery(request.getSessionid(false) ,contentid, new Flipper().limit(30));
|
||||||
|
|
||||||
|
Kv kv = Kv.by("bean", content).set("comments", comments);
|
||||||
|
finish("project/index.html", kv);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user