This commit is contained in:
lxyer 2019-06-17 23:41:47 +08:00
parent e1f3052174
commit 42bbbac170
33 changed files with 608 additions and 618 deletions

View File

@ -8,27 +8,31 @@ public class E {
public enum DynamicAttr {
//table,id_k,gk, cate
NEWS("dyna_attr", "contentId", "tid", 1),
USER("dyna_attr", "userId", "tid", 3)
;
USER("dyna_attr", "userId", "tid", 3);
private String table;
private String id_k;
private String gk;
private int cate;
DynamicAttr(String table, String id_k, String gk, int cate) {
this.table = table;
this.id_k = id_k;
this.gk = gk;
this.cate = cate;
}
public String table() {
return this.table;
}
public String id_k() {
return this.id_k;
}
public String gk() {
return this.gk;
}
public int getCate() {
return cate;
}

View File

@ -24,6 +24,7 @@ public class FlyConfig extends JFinalConfig {
@Override
public void configConstant(Constants me) {
me.setDevMode(true);
me.setInjectDependency(true);
PropKit.use("config.properties");
}
@ -54,8 +55,9 @@ public class FlyConfig extends JFinalConfig {
DbMap.mapping(arp);
DbMap.addSqlTemplate(arp);
me.add(new RedisPlugin(getProperty("redis.cache_name"), getProperty("redis.host"), getPropertyToInt("redis.port"), getPropertyToInt("redis.timeout"), getProperty("redis.password")));
me.add(new EhCachePlugin());
//redis 配置
//me.add(new RedisPlugin(getProperty("redis.cache_name"), getProperty("redis.host"), getPropertyToInt("redis.port"), getPropertyToInt("redis.timeout"), getProperty("redis.password")));
//me.add(new EhCachePlugin());
}
@Override

View File

@ -28,6 +28,7 @@ public class JBean {
this.code = code;
this.msg = msg;
}
public JBean(int code, String msg, Object obj) {
this.code = code;
this.msg = msg;
@ -61,6 +62,7 @@ public class JBean {
this.msg = msg;
return this;
}
public JBean setCode(int code, String msg, Object obj) {
this.code = code;
this.msg = msg;
@ -76,6 +78,7 @@ public class JBean {
this.obj = obj;
return this;
}
public <K, V> JBean set(Object k, Object v) {
if (!(obj instanceof Map)) {
obj = new HashMap();
@ -92,9 +95,11 @@ public class JBean {
public static JBean success(Object obj) {
return new JBean(1, "操作成功", obj);
}
public static JBean success(int code, String msg) {
return new JBean(1, msg);
}
public static JBean success(int code, String msg, Object obj) {
return new JBean(1, msg, obj);
}
@ -102,9 +107,11 @@ public class JBean {
public static JBean error(int code, String msg) {
return new JBean(code, msg);
}
public static JBean error(int code, String msg, Object obj) {
return new JBean(code, msg, obj);
}
public static JBean error(String msg) {
return new JBean(-1, msg);
}

View File

@ -1,26 +0,0 @@
package com.lxyer.config;
/**
* Created by JUECHENG at 2018/1/7 23:45.
*/
public class MyException extends RuntimeException {
public MyException() {
super();
}
public MyException(String message) {
super(message);
}
public MyException(String message, Throwable cause) {
super(message, cause);
}
public MyException(Throwable cause) {
super(cause);
}
protected MyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -1,10 +1,7 @@
package com.lxyer.config.route;
import com.jfinal.config.Routes;
import com.lxyer.controller.CommentController;
import com.lxyer.controller.HomeController;
import com.lxyer.controller.JieController;
import com.lxyer.controller.UserController;
import com.lxyer.controller.*;
/**
* Created by JUECHENG at 2018/1/7 11:16.

View File

@ -1,7 +1,6 @@
package com.lxyer.controller;
import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.aop.*;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.lxyer.config.JBean;
@ -15,7 +14,9 @@ import com.lxyer.service.CommentService;
@Before(LoginInterceptor.class)
public class CommentController extends IController {
CommentService service = CommentService.me;
@Inject
CommentService service;
/**
* 评论列表
*/

View File

@ -1,5 +1,6 @@
package com.lxyer.controller;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.lxyer.model.Content;
@ -13,21 +14,26 @@ import java.util.List;
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);//栏目
@Inject
Content contentDao;
@Inject
User userDao;
public void index() {
//置顶贴
List<Content> top = Content.dao.findPage(1, 5, Kv.by("top", 1)).getList();
List<Content> top = contentDao.findPage(1, 5, Kv.by("top", 1)).getList();
//非置顶贴
List<Content> contents = Content.dao.findPage(1, 30,Kv.by("top", 0)).getList();
List<Content> contents = contentDao.findPage(1, 30, Kv.by("top", 0)).getList();
//热帖
//热议
List<Content> hotReply = Content.dao.findPage(1, 8, Kv.by("order", "replyNum DESC")).getList();
List<Content> hotReply = contentDao.findPage(1, 8, Kv.by("order", "replyNum DESC")).getList();
//最新加入
List<User> lastReg = User.dao.findPage(1, 8, Kv.by("order", "createTime DESC")).getList();
List<User> lastReg = userDao.findPage(1, 8, Kv.by("order", "createTime DESC")).getList();
setAttr("top", top);
setAttr("contents", contents);

View File

@ -9,10 +9,7 @@ import com.lxyer.config.E;
import com.lxyer.config.JBean;
import com.lxyer.model.User;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* Created by Lxyer at 2017/9/10 13:55.
@ -59,18 +56,22 @@ public class IController extends Controller {
public int getPn() {
return getParaToInt("pn", 1);
}
public int getPs() {
return getParaToInt("ps", 15);
}
public int getPn(int pn) {
return getParaToInt("pn", pn);
}
public int getPs(int ps) {
return getParaToInt("ps", ps);
}
/**
* 设置动态属性
*
* @param page
* @param dynAttr
*/
@ -104,6 +105,7 @@ public class IController extends Controller {
/**
* 设置动态属性
*
* @param model
* @param dynAttr
*/

View File

@ -1,7 +1,6 @@
package com.lxyer.controller;
import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.aop.*;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.lxyer.config.JBean;
@ -18,8 +17,8 @@ import java.util.List;
@Before(LoginInterceptor.class)
public class JieController extends IController {
private ContentService service = ContentService.me;
private int userId;
@Inject
private ContentService service;
/**
* 帖子详情

View File

@ -1,5 +1,6 @@
package com.lxyer.controller;
import com.jfinal.aop.Inject;
import com.lxyer.config.JBean;
import com.lxyer.model.User;
import com.lxyer.service.UserService;
@ -9,7 +10,8 @@ import com.lxyer.service.UserService;
*/
public class UserController extends IController {
private UserService userService = UserService.me;
@Inject
private UserService userService;
/**
* 注册

View File

@ -7,7 +7,6 @@ import com.lxyer.model.base.BaseComment;
/**
* Generated by JFinal.
*/
@SuppressWarnings("serial")
public class Comment extends BaseComment<Comment> {
public static final Comment dao = new Comment().dao();
@ -23,6 +22,7 @@ public class Comment extends BaseComment<Comment> {
/**
* 更新点赞数
*
* @param commentId
*/
public static void upSupportNum(Integer commentId) {

View File

@ -7,7 +7,6 @@ import com.lxyer.model.base.BaseContent;
/**
* Generated by JFinal.
*/
@SuppressWarnings("serial")
public class Content extends BaseContent<Content> {
public static final Content dao = new Content().dao();

View File

@ -5,7 +5,6 @@ import com.lxyer.model.base.BaseContentItem;
/**
* Generated by JFinal.
*/
@SuppressWarnings("serial")
public class ContentItem extends BaseContentItem<ContentItem> {
}

View File

@ -5,7 +5,6 @@ import com.lxyer.model.base.BaseDynaAttr;
/**
* Generated by JFinal.
*/
@SuppressWarnings("serial")
public class DynaAttr extends BaseDynaAttr<DynaAttr> {
}

View File

@ -5,7 +5,6 @@ import com.lxyer.model.base.BaseUser;
/**
* Generated by JFinal.
*/
@SuppressWarnings("serial")
public class User extends BaseUser<User> {
public static final User dao = new User().dao();

View File

@ -6,7 +6,6 @@ import com.lxyer.model.base.BaseUserPwd;
/**
* Generated by JFinal.
*/
@SuppressWarnings("serial")
public class UserPwd extends BaseUserPwd<UserPwd> {
public static final UserPwd dao = new UserPwd().dao();

View File

@ -1,12 +1,12 @@
/**
* 请勿将俱乐部专享资源复制给其他人保护知识产权即是保护我们所在的行业进而保护我们自己的利益
* 即便是公司的同事也请尊重 JFinal 作者的努力与付出不要复制给同事
*
* <p>
* 如果你尚未加入俱乐部请立即删除该项目或者现在加入俱乐部http://jfinal.com/club
*
* <p>
* 俱乐部将提供 jfinal-club 项目文档与设计资源专用 QQ 以及作者在俱乐部定期的分享与答疑
* 价值远比仅仅拥有 jfinal club 项目源代码要大得多
*
* <p>
* JFinal 俱乐部是五年以来首次寻求外部资源的尝试以便于有资源创建更加
* 高品质的产品与服务为大家带来更大的价值所以请大家多多支持不要将
* 首次的尝试扼杀在了摇篮之中
@ -25,7 +25,6 @@ import javax.sql.DataSource;
/**
* ModelBaseModel_MappingKit 生成器
*/
@SuppressWarnings("ALL")
public class _Generator {
/**

View File

@ -1,7 +1,7 @@
package com.lxyer.model.base;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
/**
* Generated by JFinal, do not modify this file.

View File

@ -1,7 +1,7 @@
package com.lxyer.model.base;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
/**
* Generated by JFinal, do not modify this file.

View File

@ -1,8 +1,7 @@
package com.lxyer.model.base;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
/**
* Generated by JFinal, do not modify this file.

View File

@ -1,7 +1,7 @@
package com.lxyer.model.base;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
/**
* Generated by JFinal, do not modify this file.

View File

@ -1,7 +1,7 @@
package com.lxyer.model.base;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
/**
* Generated by JFinal, do not modify this file.

View File

@ -1,7 +1,7 @@
package com.lxyer.model.base;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
/**
* Generated by JFinal, do not modify this file.

View File

@ -1,7 +1,7 @@
package com.lxyer.model.base;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
/**
* Generated by JFinal, do not modify this file.

View File

@ -11,6 +11,7 @@ import java.util.List;
public interface IModel<M extends Model<M>> {
String sqlSpace();
M getDao();
default List<M> findList(Kv kv) {

View File

@ -1,16 +1,12 @@
package com.lxyer.service;
import com.jfinal.kit.Kv;
import com.lxyer.model.ActLog;
import com.lxyer.model.Comment;
import com.lxyer.model.Content;
import com.lxyer.model.*;
/**
* Created by JUECHENG at 2018/1/9 11:59.
*/
public class CommentService {
public static final CommentService me = new CommentService();
public class CommentService extends IService {
public void save(Comment comment, Integer userId) {
if (comment.getCommentId() == null) {
@ -27,6 +23,7 @@ public class CommentService {
/**
* 评论点赞
*
* @param commentId
* @param ok
* @param userId

View File

@ -7,12 +7,13 @@ import com.lxyer.model.Content;
/**
* Created by JUECHENG at 2018/1/7 16:49.
*/
public class ContentService {
public class ContentService extends IService {
public static final ContentService me = new ContentService();
/**
* 帖子保存
*
* @param content
* @param userId
*/
@ -28,6 +29,7 @@ public class ContentService {
/**
* 删除帖子
*
* @param contentId
* @param userId
* @throws Exception
@ -47,6 +49,7 @@ public class ContentService {
/**
* 帖子收藏
*
* @param contentId
* @param userId
* @param status
@ -79,6 +82,7 @@ public class ContentService {
/**
* 帖子置顶/加精
*
* @param contentId
* @param field
* @param v

View File

@ -11,11 +11,11 @@ import java.util.Random;
/**
* Created by JUECHENG at 2018/1/7 22:59.
*/
public class UserService {
public static final UserService me = new UserService();
public class UserService extends IService {
/**
* 创建用户
*
* @param email
* @param pwd
* @param nickname
@ -68,6 +68,7 @@ public class UserService {
/**
* 修改密码
*
* @param userId
* @param pwd
*/

View File

@ -111,7 +111,7 @@
#(x.content)
</div>
<div class="jieda-reply">
#if(x.hadSupport > 1)
#if(x.hadSupport??0 > 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>