This commit is contained in:
2017-12-10 23:14:18 +08:00
parent 97a1796287
commit 66404fad9d
15 changed files with 143 additions and 91 deletions

View File

@@ -22,7 +22,7 @@ public class ContentInfo implements Serializable {
private int status = 1;
private String createTime;
private String cateName;
private String typeName;
private String nickname = "";
private String avatar = "";
private int hadCollect = -1;
@@ -139,12 +139,12 @@ public class ContentInfo implements Serializable {
this.createTime = createTime;
}
public String getCateName() {
return cateName;
public String getTypeName() {
return typeName;
}
public void setCateName(String cateName) {
this.cateName = cateName;
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public String getNickname() {

View File

@@ -1,5 +1,6 @@
package com.lxyer.bbs.base.entity;
import com.jfinal.kit.Kv;
import com.lxyer.bbs.base.LxyKit;
import com.lxyer.bbs.base.bean.ContentInfo;
import org.redkale.convert.json.JsonConvert;
@@ -176,6 +177,7 @@ public class Content implements java.io.Serializable {
return JsonConvert.root().convertTo(this);
}
private static final Kv types = Kv.by(10, "求助").set(20, "分享").set(30, "建议").set(40, "公告").set(50, "动态");
public ContentInfo createContentInfo(){
ContentInfo info = new ContentInfo();
info.setContentId(contentId);
@@ -183,24 +185,15 @@ public class Content implements java.io.Serializable {
info.setTitle(title);
info.setContent(content);
info.setCate(cate);
info.setType(type);
info.setViewNum(viewNum);
info.setReplyNum(replyNum);
info.setWonderful(wonderful);
info.setTop(top);
info.setSolved(solved);
info.setCateName(cateName());
info.setTypeName(types.getOrDefault(type, "其他").toString());
info.setCreateTime(LxyKit.dateFmt(createTime));
return info;
}
public String cateName(){
switch (cate){
case 1: return "Redkale框架综合";
case 2: return "JFinal框架综合";
case 3: return "Layui框架综合";
case 4: return "JSON解析";
default: return "其他";
}
}
}

View File

@@ -179,4 +179,10 @@ public class ContentService extends BaseService{
return infos;
}
@RestMapping(name = "set", comment = "内容操作")
public RetResult contentSet(int id, String field, int v){
source.updateColumn(Content.class, id, field, v);
return RetResult.success();
}
}

View File

@@ -60,12 +60,18 @@ public class IndexServlet extends BaseServlet {
@HttpMapping(url = "/column", auth = false, comment = "社区首页")
public void column(HttpRequest request, HttpResponse response){
String para = getPara();//空qzfxjyggdt
int solved = request.getIntParameter("solved", -1);
int wonderful = request.getIntParameter("wonderful", -1);
int curr = request.getIntParameter("curr", 1);
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");
Flipper flipper = new Flipper().offset((curr-1) * 5).limit(5).sort("top DESC,createTime DESC");
//帖子列表
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1).and("type", column.getAs(para));
if (solved > -1) filterNode.and("solved", solved);
if (wonderful > -1) filterNode.and("wonderful", wonderful);
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, filterNode);
//热议
@@ -73,7 +79,8 @@ public class IndexServlet extends BaseServlet {
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "");
Kv kv = Kv.by("contents", contents).set("hotReply", hotReply);
Kv kv = Kv.by("contents", contents).set("hotReply", hotReply)
.set("solved", solved).set("wonderful", wonderful).set("column", para).set("curr", curr);
finish("/jie/index.html", kv);
}