.
This commit is contained in:
parent
92d3f7a49e
commit
b94ad367d9
36
README.md
36
README.md
@ -1 +1,37 @@
|
||||
# redbbs
|
||||
|
||||
### 要解决的问题:
|
||||
1.发布帖子按照类型保存
|
||||
2.发布帖子按照栏目查询
|
||||
3.这个阶段不需要签到、积分,隐藏不需要的界面
|
||||
|
||||
### 首页
|
||||
综合信息展示
|
||||
|
||||
### 交流
|
||||
公共需要的数据 【最新加入成员】【本周热议】【推荐帖子】
|
||||
|
||||
>全部
|
||||
默认,展示所有的帖子列表,分为置顶/非置顶两个查询
|
||||
需要的数据【置顶贴】【普通帖子列表】
|
||||
|
||||
>求助
|
||||
【求助贴】
|
||||
|
||||
>分享
|
||||
【分享贴】
|
||||
|
||||
>建议
|
||||
【建议贴】
|
||||
|
||||
>公告
|
||||
【公告贴】
|
||||
|
||||
>动态
|
||||
【动态贴】
|
||||
|
||||
>帖子接口
|
||||
【发布】 【详情】【置顶/取消置顶】【加精/取消加精】
|
||||
|
||||
>签到
|
||||
暂时不做
|
@ -69,11 +69,11 @@
|
||||
<div class="layui-container">
|
||||
<ul class="layui-clear">
|
||||
<li class="layui-hide-xs layui-this"><a href="/">首页</a></li>
|
||||
<li><a href="jie/index.html">求助</a></li>
|
||||
<li><a href="jie/index.html">分享<span class="layui-badge-dot"></span></a></li>
|
||||
<li><a href="jie/index.html">建议</a></li>
|
||||
<li><a href="jie/index.html">公告</a></li>
|
||||
<li><a href="jie/index.html">动态</a></li>
|
||||
<li><a href="/column/qz">求助</a></li>
|
||||
<li><a href="/column/fx">分享<span class="layui-badge-dot"></span></a></li>
|
||||
<li><a href="/column/jy">建议</a></li>
|
||||
<li><a href="/column/gg">公告</a></li>
|
||||
<li><a href="/column/dt">动态</a></li>
|
||||
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>
|
||||
|
||||
<!-- 用户登入后显示 -->
|
||||
|
@ -233,7 +233,7 @@ layui.define('fly', function(exports){
|
||||
|
||||
form.on('submit(jie-add)', function(data){
|
||||
var bean = {};
|
||||
["contentId","title", "content", "cate"].forEach(function (value) {
|
||||
["contentId","title", "content", "type"].forEach(function (value) {
|
||||
bean[value] = data.field[value];
|
||||
});
|
||||
console.log(bean);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,6 @@ import com.lxyer.bbs.base.bean.ContentInfo;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -17,7 +17,8 @@ import org.redkale.util.SelectColumn;
|
||||
import org.redkale.util.Sheet;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/11/26 9:33.
|
||||
@ -25,23 +26,16 @@ import java.util.*;
|
||||
@RestService(automapping = true, comment = "内容管理")
|
||||
public class ContentService extends BaseService{
|
||||
|
||||
/*@Resource(name = "contentInfos")
|
||||
protected CacheSource<ContentInfo> infoCache;*/
|
||||
|
||||
@Resource
|
||||
protected UserService userService;
|
||||
|
||||
@RestMapping(name = "query", auth = false, comment = "内容列表")
|
||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, String actived){
|
||||
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1);
|
||||
switch (actived){
|
||||
case "top": filterNode.and("top", 1);break;
|
||||
case "untop": filterNode.and("top", 0);break;
|
||||
case "unsolved": filterNode.and("solved", 0);break;
|
||||
case "solved": filterNode.and("solved", 1);break;
|
||||
case "wonderful": filterNode.and("wonderful", 1);break;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param flipper
|
||||
* @param filterNode
|
||||
* @return
|
||||
*/
|
||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode){
|
||||
Sheet<Content> contents = source.querySheet(Content.class, flipper, filterNode);
|
||||
|
||||
int[] userids = contents.stream().mapToInt(x -> x.getUserId()).distinct().toArray();
|
||||
@ -63,6 +57,19 @@ public class ContentService extends BaseService{
|
||||
return infos;
|
||||
}
|
||||
|
||||
@RestMapping(name = "query", auth = false, comment = "内容列表")
|
||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, String actived){
|
||||
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1);
|
||||
switch (actived){
|
||||
case "top": filterNode.and("top", 1);break;
|
||||
case "untop": filterNode.and("top", 0);break;
|
||||
case "unsolved": filterNode.and("solved", 0);break;
|
||||
case "solved": filterNode.and("solved", 1);break;
|
||||
case "wonderful": filterNode.and("wonderful", 1);break;
|
||||
}
|
||||
return contentQuery(flipper, filterNode);
|
||||
}
|
||||
|
||||
|
||||
public Sheet<ContentInfo> queryByBean(Flipper flipper, FilterBean bean){
|
||||
Sheet<Content> contents = source.querySheet(Content.class, flipper, bean);
|
||||
@ -92,7 +99,7 @@ public class ContentService extends BaseService{
|
||||
|
||||
source.insert(content);
|
||||
}else {
|
||||
source.updateColumn(content, SelectColumn.createIncludes("title", "digest", "content","cate"));
|
||||
source.updateColumn(content, SelectColumn.createIncludes("title", "digest", "content","type"));
|
||||
}
|
||||
|
||||
return RetResult.success();
|
||||
@ -118,6 +125,7 @@ public class ContentService extends BaseService{
|
||||
return contentInfo;
|
||||
}
|
||||
|
||||
@RestMapping(name = "upview", comment = "增加文章1个访问量")
|
||||
public void incrViewNum(int contentId){
|
||||
source.updateColumn(Content.class, contentId, ColumnValue.inc("viewNum", 1));
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import com.lxyer.bbs.base.entity.User;
|
||||
import com.lxyer.bbs.service.CommentService;
|
||||
import com.lxyer.bbs.service.ContentService;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.source.FilterExpress;
|
||||
import org.redkale.source.FilterNode;
|
||||
import org.redkale.source.Flipper;
|
||||
import org.redkale.util.Sheet;
|
||||
|
||||
@ -17,7 +19,7 @@ import java.util.function.Supplier;
|
||||
/**
|
||||
* Created by Lxy at 2017/11/25 12:31.
|
||||
*/
|
||||
@WebServlet({"/","/site"
|
||||
@WebServlet({"/","/column","/column/*"
|
||||
,"/user", "/user/*"
|
||||
,"/jie" ,"/jie/*"
|
||||
})
|
||||
@ -31,13 +33,14 @@ public class IndexServlet extends BaseServlet {
|
||||
|
||||
@HttpMapping(url = "/", auth = false, comment = "社区首页")
|
||||
public void abc(HttpRequest request, HttpResponse response){
|
||||
|
||||
//问答列表
|
||||
Flipper flipper = new Flipper().limit(30).sort("top DESC,createTime DESC");
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, "untop");
|
||||
|
||||
//置顶贴
|
||||
Sheet<ContentInfo> top = contentService.contentQuery(flipper, "top");
|
||||
FilterNode topNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1).and("top", 1);
|
||||
Sheet<ContentInfo> top = contentService.contentQuery(flipper, topNode);
|
||||
|
||||
//非置顶贴
|
||||
FilterNode untopNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1).and("top", 0);
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, untopNode);
|
||||
|
||||
//热帖
|
||||
/*Flipper flipper2 = new Flipper().limit(8).sort("viewNum DESC");
|
||||
@ -50,10 +53,30 @@ public class IndexServlet extends BaseServlet {
|
||||
//最新加入
|
||||
Sheet<UserInfo> lastReg = userService.lastReg();
|
||||
|
||||
Kv kv = Kv.by("top", top).set("contents", contents)/*.set("hotView", hotView)*/.set("hotReply", hotReply).set("lastReg", lastReg);
|
||||
Kv kv = Kv.by("top", top).set("contents", contents).set("hotReply", hotReply).set("lastReg", lastReg);
|
||||
finish("index.html", kv);
|
||||
}
|
||||
|
||||
@HttpMapping(url = "/column", auth = false, comment = "社区首页")
|
||||
public void column(HttpRequest request, HttpResponse response){
|
||||
String para = getPara();//空,qz,fx,jy,gg,dt,
|
||||
|
||||
Kv column = Kv.by("qz", 10).set("fx", 20).set("jy", 30).set("gg", 40).set("dt", 50);//栏目
|
||||
|
||||
Flipper flipper = new Flipper().limit(30).sort("top DESC,createTime DESC");
|
||||
//帖子列表
|
||||
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1).and("type", column.getAs(para));
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, filterNode);
|
||||
|
||||
//热议
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replyNum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "");
|
||||
|
||||
|
||||
Kv kv = Kv.by("contents", contents).set("hotReply", hotReply);
|
||||
finish("/jie/index.html", kv);
|
||||
}
|
||||
|
||||
@HttpMapping(url = "/site", auth = false, comment = "网站首页")
|
||||
public void site(HttpRequest request, HttpResponse response){
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user