This commit is contained in:
2018-01-07 19:28:20 +08:00
parent b24d4be809
commit 4c7a0d6e91
170 changed files with 4155 additions and 32 deletions

View File

@@ -0,0 +1,9 @@
package com.lxyer.controller;
/**
* Created by JUECHENG at 2018/1/7 16:48.
*/
public class ContentController extends IController{
}

View File

@@ -0,0 +1,9 @@
package com.lxyer.controller;
/**
* 文件管理
* Created by JUECHENG at 2018/1/7 16:44.
*/
public class FileController extends IController{
}

View File

@@ -1,11 +1,9 @@
package com.lxyer.controller;
import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.SqlPara;
import com.jfinal.plugin.ehcache.CacheInterceptor;
import com.jfinal.plugin.redis.Cache;
import com.jfinal.plugin.redis.Redis;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.lxyer.model.Content;
import com.lxyer.model.User;
import java.util.List;
@@ -14,36 +12,71 @@ import java.util.List;
* Created by JUECHENG at 2018/1/7 14:40.
*/
public class HomeController extends IController {
public static final Kv column = Kv.by("qz", 10).set("fx", 20).set("jy", 30).set("gg", 40).set("dt", 50);//栏目
public void index(){
String para = getPara();
Cache cache = Redis.use();
String cacheKey = "user-" + para;
//置顶贴
List<Content> top = Content.dao.findPage(1, 5, Kv.by("top", 1)).getList();
User user = cache.get(cacheKey);
if (user == null)
cache.setex(cacheKey, 10, user = User.dao.findById(para+""));
//非置顶贴
List<Content> contents = Content.dao.findPage(1, 30,Kv.by("top", 0)).getList();
if (user != null)
System.out.println(user.toJson());
//热帖
renderText("hello fly");
//热议
List<Content> hotReply = Content.dao.findPage(1, 8, Kv.by("order", "replyNum DESC")).getList();
//最新加入
List<User> lastReg = User.dao.findPage(1, 8, Kv.by("order", "createTime DESC")).getList();
setAttr("top", top);
setAttr("contents", contents);
setAttr("hotReply", hotReply);
setAttr("lastReg", lastReg);
render("index.html");
}
/**
* 查询用户
* 帖子栏目列表
*/
@Before(CacheInterceptor.class)
public void query_user(){
public void column(){
String para = getPara(0, "");
int solved = getParaToInt("solved", -1);
int wonderful = getParaToInt("wonderful", -1);
//User.dao.find("select * from user")
Kv kv = Kv.by("type", column.get(para)).set("order", "top DESC,createTime DESC");
Page<Content> contents = Content.dao.findPage(getPn(), getPs(3), kv);
SqlPara sqlPara = Db.getSqlPara("user.list");
//热议
List<Content> hotReply = Content.dao.findPage(1, 8, Kv.by("order", "replyNum DESC")).getList();
setAttrs(Kv.by("contents", contents).set("hotReply", hotReply)
.set("solved", solved).set("wonderful", wonderful).set("column", para));
List<User> users = User.dao.find(sqlPara);
renderJson(users);
render("jie/index.html");
}
/**
* 帖子详情
*/
public void jie(){
int contentId = getParaToInt(0);
//ContentInfo content = contentService.contentInfo(sessionid, contentid);
//Sheet<CommentInfo> comments = commentService.commentQuery(request.getSessionid(false) ,contentid, new Flipper().limit(30));
Record content = Content.dao.findFirst(Kv.by("contentId", contentId));
//热议
List<Content> hotReply = Content.dao.findPage(1, 8, Kv.by("order", "replyNum DESC")).getList();
setAttr("bean", content);
setAttr("hotReply", hotReply);
render("jie/detail.html");
}
}

View File

@@ -3,6 +3,8 @@ package com.lxyer.controller;
import com.jfinal.core.Controller;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.*;
import com.jfinal.plugin.redis.Cache;
import com.jfinal.plugin.redis.Redis;
import com.lxyer.config.E;
import java.util.ArrayList;
@@ -15,6 +17,8 @@ import java.util.Map;
*/
public class IController extends Controller {
public static final Cache cache = Redis.use();
public Kv getParams(String... key) {
Kv kv = Kv.create();
for (String k : key) {

View File

@@ -0,0 +1,28 @@
package com.lxyer.controller;
/**
* Created by JUECHENG at 2018/1/7 16:40.
*/
public class UserController extends IController {
/**
* 注册
*/
public void create(){
}
/**
* 登录
*/
public void login(){
}
/**
* 修改
*/
public void update(){
}
}