.
This commit is contained in:
25
src/com/lxyer/bbs/base/BaseService.java
Normal file
25
src/com/lxyer/bbs/base/BaseService.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.source.DataSource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/3 13:50.
|
||||
*/
|
||||
public class BaseService implements Service {
|
||||
|
||||
protected final int sessionExpireSeconds = 30 * 60;
|
||||
protected final int contentinfoExpireSeconds = 30 * 60;
|
||||
|
||||
@Resource(name = "SERVER_ROOT")
|
||||
protected File webroot;
|
||||
|
||||
@Resource(name = "art123")
|
||||
protected DataSource source;
|
||||
|
||||
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
||||
|
||||
}
|
158
src/com/lxyer/bbs/base/BaseServlet.java
Normal file
158
src/com/lxyer/bbs/base/BaseServlet.java
Normal file
@@ -0,0 +1,158 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.jfinal.template.Engine;
|
||||
import com.jfinal.template.Template;
|
||||
import com.lxyer.bbs.service.UserService;
|
||||
import org.redkale.net.http.HttpContext;
|
||||
import org.redkale.net.http.HttpRequest;
|
||||
import org.redkale.net.http.HttpResponse;
|
||||
import org.redkale.net.http.HttpServlet;
|
||||
import org.redkale.util.AnyValue;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static com.lxyer.bbs.base.RetCodes.RET_USER_UNLOGIN;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/3 13:39.
|
||||
*/
|
||||
public class BaseServlet extends HttpServlet {
|
||||
|
||||
@Resource(name = "SERVER_ROOT")
|
||||
protected File webroot;
|
||||
|
||||
/*@Resource
|
||||
protected EnjoyService enjoyService;*/
|
||||
@Resource
|
||||
protected UserService userService;
|
||||
|
||||
private HttpRequest request;
|
||||
private HttpResponse response;
|
||||
private static final Kv _kv = Kv.create();
|
||||
private static Engine engine;
|
||||
protected String sessionid;
|
||||
|
||||
@Override
|
||||
public void init(HttpContext context, AnyValue config) {
|
||||
if (engine == null){
|
||||
engine = new Engine();
|
||||
engine.setBaseTemplatePath(webroot.getPath());
|
||||
engine.addSharedObject("EJ", new EJ());
|
||||
engine.addSharedFunction("/_t/layout.html");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preExecute(HttpRequest request, HttpResponse response) throws IOException {
|
||||
sessionid = request.getSessionid(false);
|
||||
if (sessionid != null) {
|
||||
request.setCurrentUser(userService.current(sessionid));
|
||||
_kv.set("mine", request.currentUser());
|
||||
}
|
||||
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
String uri = request.getRequestURI();
|
||||
if (uri.startsWith("/res")){
|
||||
File file = new File(webroot + uri);
|
||||
response.finish(file);
|
||||
return;
|
||||
}
|
||||
if (uri.endsWith(".html")){
|
||||
Kv kv = Kv.by("resSys", "resSys");
|
||||
finish(uri, kv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*if ("/".equals(uri)){
|
||||
finish("/front/index.html", Kv.by("",""));
|
||||
return;
|
||||
}*/
|
||||
|
||||
|
||||
response.nextEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void authenticate(HttpRequest request, HttpResponse response) throws IOException {
|
||||
if (request.currentUser() == null) {
|
||||
if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))){
|
||||
response.finish(RetCodes.retResult(RET_USER_UNLOGIN, "未登录,登录后重试").toString());
|
||||
}else {
|
||||
finish("/user/login.html");
|
||||
}
|
||||
return;
|
||||
}
|
||||
response.nextEvent();
|
||||
}
|
||||
|
||||
public void finish(String view, Kv kv) {
|
||||
if (request.currentUser() != null) kv.set("mine", request.currentUser());
|
||||
|
||||
Template template = engine.getTemplate(view);
|
||||
String str = template.renderToString(kv);
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
response.finish(str);
|
||||
}
|
||||
|
||||
public void finish(String view){
|
||||
finish(view, _kv);
|
||||
}
|
||||
|
||||
public int getLimit(){
|
||||
return request.getIntParameter("limit", 1);
|
||||
}
|
||||
public int getOffset(){
|
||||
return request.getIntParameter("offset", 10);
|
||||
}
|
||||
|
||||
/*
|
||||
测试用例
|
||||
System.out.println("sb="+getPara());
|
||||
System.out.println("sb(0)="+getPara(0));
|
||||
System.out.println("sb(1)="+getPara(1));
|
||||
System.out.println("sb(-1)="+getPara(-1));
|
||||
System.out.println("sb(-2)="+getPara(-2));
|
||||
* */
|
||||
public String getPara(){
|
||||
String requestURI = request.getRequestURI();
|
||||
String subStr = requestURI.substring(requestURI.lastIndexOf("/") + 1);
|
||||
return subStr.contains("-") ? subStr.substring(0, subStr.indexOf("-")) : subStr;
|
||||
}
|
||||
public String getPara(int index){
|
||||
String requestURI = request.getRequestURI();
|
||||
String subStr = requestURI.substring(requestURI.lastIndexOf("/") + 1);
|
||||
|
||||
String[] paraArr = subStr.split("-");
|
||||
if (index < 0){
|
||||
return paraArr.length < -index ? null : paraArr[paraArr.length+index];
|
||||
}else {
|
||||
return paraArr.length < index+1 ? null : paraArr[index];
|
||||
}
|
||||
}
|
||||
public <T> T getPara(int index, T defaultValue){
|
||||
T para = (T)getPara(index);
|
||||
return para == null || "".equals(para) ? defaultValue : para;
|
||||
}
|
||||
public int getParaToInt(int index, int defaultValue){
|
||||
String para = getPara(index);
|
||||
return para == null || "".equals(para) ? defaultValue : Integer.parseInt(para);
|
||||
}
|
||||
public int getParaToInt(int index){
|
||||
int n = 0;
|
||||
String para = getPara(index);
|
||||
if (para == null || "".equals(para)) n = 0;
|
||||
try {
|
||||
n = Integer.parseInt(para);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
48
src/com/lxyer/bbs/base/EJ.java
Normal file
48
src/com/lxyer/bbs/base/EJ.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import org.redkale.net.http.RestService;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/11/26 17:19.
|
||||
*/
|
||||
@RestService
|
||||
public class EJ {
|
||||
|
||||
public String date(long time){
|
||||
return date(time, "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
public String date(long time, String pattern){
|
||||
return new SimpleDateFormat(pattern).format(time);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
/*EJ ej = new EJ();
|
||||
|
||||
System.out.println(ej.date(1511682960591L));*/
|
||||
List<Kv> list = asList(
|
||||
Kv.by("k", 1).set("a", "1+1=?").set("q", 2)
|
||||
, Kv.by("k", 2).set("a", "1*1=?").set("q", 1)
|
||||
, Kv.by("k", 3).set("a", "3+2-5=?").set("q", 0)
|
||||
, Kv.by("k", 4).set("a", "Math.abs(-3)=?").set("q", 3)
|
||||
);
|
||||
|
||||
int k = 3;
|
||||
Kv kv = list.stream().filter(x -> x.getInt("k") == k).findFirst().orElse(Kv.create());
|
||||
|
||||
System.out.println(System.currentTimeMillis());
|
||||
System.out.println(kv.toString());
|
||||
System.out.println(kv.getStr("q").equals("0"));
|
||||
|
||||
}
|
||||
|
||||
}
|
26
src/com/lxyer/bbs/base/EnjoyService.java
Normal file
26
src/com/lxyer/bbs/base/EnjoyService.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import com.jfinal.template.Engine;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.util.AnyValue;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/1 8:41.
|
||||
*/
|
||||
@RestService(automapping = false)
|
||||
public class EnjoyService extends Engine implements Service {
|
||||
@Resource(name = "SERVER_ROOT")
|
||||
protected File webroot;
|
||||
|
||||
@Override
|
||||
public void init(AnyValue config) {
|
||||
setBaseTemplatePath(webroot.getPath());
|
||||
|
||||
addSharedObject("EJ", new EJ());
|
||||
addSharedFunction("/_t/layout.html");
|
||||
}
|
||||
}
|
41
src/com/lxyer/bbs/base/FileService.java
Normal file
41
src/com/lxyer/bbs/base/FileService.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import org.redkale.net.http.RestMapping;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.net.http.RestUploadFile;
|
||||
import org.redkale.service.RetResult;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/3 13:48.
|
||||
*/
|
||||
@RestService(automapping = true, comment = "文件服务")
|
||||
public class FileService extends BaseService {
|
||||
|
||||
private static final String dir = "/var/www/upload/bbs/";
|
||||
private static final String view = "http://img.1216.top/bbs/";
|
||||
private static final String format = "%1$tY%1$tm%1$td%1$tH%1$tM%1$tS";
|
||||
|
||||
@RestMapping(name = "upload", comment = "文件上传")
|
||||
public RetResult upload(@RestUploadFile File tmpFile) throws IOException {
|
||||
String name = tmpFile.getName();
|
||||
String suffix = name.substring(name.lastIndexOf("."));
|
||||
String path = String.format(format, System.currentTimeMillis()) + suffix;
|
||||
File destFile = new File((winos ? "E:/wk/_own/bbs/root/tem/" : dir) + path);
|
||||
destFile.getParentFile().mkdir();
|
||||
if (!tmpFile.renameTo(destFile)){
|
||||
try{
|
||||
Files.copy(tmpFile.toPath(), destFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
|
||||
}finally {
|
||||
tmpFile.delete();//删除临时文件
|
||||
}
|
||||
}
|
||||
RetResult result = RetResult.success();
|
||||
result.setRetinfo((winos ? "/tem/": view) + path);
|
||||
return result;
|
||||
}
|
||||
}
|
33
src/com/lxyer/bbs/base/LxyKit.java
Normal file
33
src/com/lxyer/bbs/base/LxyKit.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/11/29 15:17.
|
||||
*/
|
||||
public final class LxyKit {
|
||||
|
||||
public static String dateFmt(long time){
|
||||
/**
|
||||
* 刚刚 60秒内 60 * 1000
|
||||
* x分钟前 1小时候内 60 * 60*1000
|
||||
* x小时前 1天内 24 * 60*60*1000
|
||||
* x天前 1周内 7 * 24*60*60*1000
|
||||
* 年-月-日 1周前
|
||||
*/
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
long diff = now - time;
|
||||
if (diff < 60 * 1000)
|
||||
return "刚刚";
|
||||
else if (diff < 60 * 60 *1000)
|
||||
return Math.floorDiv(diff, 60 *1000) + "分钟前";
|
||||
else if (diff < 24 * 60*60*1000)
|
||||
return Math.floorDiv(diff, 60 *60*1000) + "小时前";
|
||||
else if (diff > 24 * 60*60*1000 && diff < 7 * 24*60*60*1000)
|
||||
return Math.floorDiv(diff, 24 * 60*60*1000) + "天前";
|
||||
else
|
||||
return new SimpleDateFormat("yyyy-MM-dd").format(time);
|
||||
|
||||
}
|
||||
}
|
60
src/com/lxyer/bbs/base/RetCodes.java
Normal file
60
src/com/lxyer/bbs/base/RetCodes.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import org.redkale.service.RetLabel;
|
||||
import org.redkale.service.RetResult;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/1 11:21.
|
||||
*/
|
||||
public abstract class RetCodes {
|
||||
|
||||
@RetLabel("参数无效")
|
||||
public static final int RET_PARAMS_ILLEGAL = 3001_0001;
|
||||
|
||||
//------------------------------------- 用户模块 -----------------------------------------
|
||||
@RetLabel("未登陆")
|
||||
public static final int RET_USER_UNLOGIN = 3002_0001;
|
||||
|
||||
@RetLabel("用户或密码错误")
|
||||
public static final int RET_USER_ACCOUNT_PWD_ILLEGAL = 3002_0002;
|
||||
|
||||
@RetLabel("用户权限不够")
|
||||
public static final int RET_USER_AUTH_ILLEGAL = 3002_0003;
|
||||
|
||||
@RetLabel("密码设置无效")
|
||||
public static final int RET_USER_PASSWORD_ILLEGAL = 3002_0004;
|
||||
|
||||
@RetLabel("用户不存在")
|
||||
public static final int RET_USER_NOTEXISTS = 3002_0005;
|
||||
|
||||
@RetLabel("用户名已存在")
|
||||
public static final int RET_USER_USERNAME_EXISTS = 3002_0006;
|
||||
|
||||
@RetLabel("用户名无效")
|
||||
public static final int RET_USER_USERNAME_ILLEGAL = 3002_0007;
|
||||
|
||||
@RetLabel("邮箱已存在")
|
||||
public static final int RET_USER_EMAIL_EXISTS = 3002_0008;
|
||||
|
||||
@RetLabel("邮箱无效")
|
||||
public static final int RET_USER_EMAIL_ILLEGAL = 3002_0009;
|
||||
|
||||
//------------------------------------- 内容模块 -----------------------------------------
|
||||
|
||||
//------------------------------------- 评论模块 -----------------------------------------
|
||||
@RetLabel("评论内容无效")
|
||||
public static final int RET_COMMENT_CONTENT_ILLEGAL = 3004_0001;
|
||||
|
||||
@RetLabel("评论参数无效")
|
||||
public static final int RET_COMMENT_PARA_ILLEGAL = 3004_0002;
|
||||
|
||||
|
||||
|
||||
public static RetResult retResult(int retcode) {
|
||||
return new RetResult(retcode);
|
||||
}
|
||||
|
||||
public static RetResult retResult(int retcode, String retinfo) {
|
||||
return new RetResult(retcode, retinfo);
|
||||
}
|
||||
}
|
98
src/com/lxyer/bbs/base/bean/ActLogBean.java
Normal file
98
src/com/lxyer/bbs/base/bean/ActLogBean.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.source.FilterBean;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Table(catalog = "db_redbbs", name = "act_log")
|
||||
public class ActLogBean implements Serializable, FilterBean {
|
||||
|
||||
@Column(comment = "[日志id]")
|
||||
private int logid;
|
||||
|
||||
@Column(comment = "[日志类型]")
|
||||
private int cate;
|
||||
|
||||
@Column(comment = "[目标数据id]")
|
||||
private int tid;
|
||||
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
|
||||
@Column(length = 128, comment = "[说明]")
|
||||
private String remark = "";
|
||||
|
||||
@Column(comment = "[状态]-1删除 1正常")
|
||||
private int status = 1;
|
||||
|
||||
public void setLogid(int logid) {
|
||||
this.logid = logid;
|
||||
}
|
||||
|
||||
public int getLogid() {
|
||||
return this.logid;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return this.cate;
|
||||
}
|
||||
|
||||
public void setTid(int tid) {
|
||||
this.tid = tid;
|
||||
}
|
||||
|
||||
public int getTid() {
|
||||
return this.tid;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return this.remark;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
}
|
163
src/com/lxyer/bbs/base/bean/CommentInfo.java
Normal file
163
src/com/lxyer/bbs/base/bean/CommentInfo.java
Normal file
@@ -0,0 +1,163 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
public class CommentInfo implements java.io.Serializable {
|
||||
|
||||
@Column(comment = "[评论id]")
|
||||
private int commentId;
|
||||
|
||||
@Column(comment = "[评论用户id]")
|
||||
private int userId;
|
||||
|
||||
@Column(comment = "[评论父id]")
|
||||
private int pid;
|
||||
|
||||
@Column(comment = "[评论的类型]")
|
||||
private int cate;
|
||||
|
||||
@Column(comment = "[被评论内容的id]")
|
||||
private int contentId;
|
||||
|
||||
@Column(comment = "[评论内容]")
|
||||
private String content = "";
|
||||
|
||||
@Column(comment = "[支持数]")
|
||||
private int supportNum;
|
||||
|
||||
@Column(comment = "[状态]1正常,-1删除")
|
||||
private int status = 1;
|
||||
|
||||
|
||||
private String createTime;
|
||||
|
||||
private CommentInfo pCommentInfo;
|
||||
private String nickname = "";
|
||||
private String avatar = "";
|
||||
|
||||
private String title;
|
||||
private int hadSupport = -1;
|
||||
|
||||
public void setCommentId(int commentId) {
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
public int getCommentId() {
|
||||
return this.commentId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return cate;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
}
|
||||
|
||||
public int getContentId() {
|
||||
return this.contentId;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getSupportNum() {
|
||||
return supportNum;
|
||||
}
|
||||
|
||||
public void setSupportNum(int supportNum) {
|
||||
this.supportNum = supportNum;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public CommentInfo getpCommentInfo() {
|
||||
return pCommentInfo;
|
||||
}
|
||||
|
||||
public void setpCommentInfo(CommentInfo pCommentInfo) {
|
||||
this.pCommentInfo = pCommentInfo;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getHadSupport() {
|
||||
return hadSupport;
|
||||
}
|
||||
|
||||
public void setHadSupport(int hadSupport) {
|
||||
this.hadSupport = hadSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
}
|
154
src/com/lxyer/bbs/base/bean/ContentBean.java
Normal file
154
src/com/lxyer/bbs/base/bean/ContentBean.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.source.FilterBean;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Table(catalog = "db_redbbs", name = "content", comment = "[内容表]")
|
||||
public class ContentBean implements FilterBean,java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(comment = "[内容id]")
|
||||
private int contentId;
|
||||
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
|
||||
@Column(length = 64, comment = "[标题]")
|
||||
private String title = "";
|
||||
|
||||
@Column(length = 256, comment = "[摘要]")
|
||||
private String digest = "";
|
||||
|
||||
@Column(comment = "[内容]")
|
||||
private String content = "";
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
|
||||
@Column(comment = "[类别]")
|
||||
private int cate;
|
||||
|
||||
@Column(comment = "[内容类型]1新闻,2作品")
|
||||
private int type;
|
||||
|
||||
@Column(comment = "[评论数]")
|
||||
private int replyNum;
|
||||
|
||||
@Column(comment = "[阅读量]")
|
||||
private int viewNum;
|
||||
|
||||
/* @Column(comment = "[精] 0否,1是")
|
||||
private int wonderful;
|
||||
|
||||
@Column(comment = "[置顶] 0否,1是")
|
||||
private int top;
|
||||
|
||||
@Column(comment = "[结帖]大于0结帖")
|
||||
private int solved;*/
|
||||
|
||||
@Column(comment = "[状态]")
|
||||
private int status = 1;
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
}
|
||||
|
||||
public int getContentId() {
|
||||
return this.contentId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
public String getDigest() {
|
||||
return this.digest;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return cate;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public int getReplyNum() {
|
||||
return replyNum;
|
||||
}
|
||||
|
||||
public void setReplyNum(int replyNum) {
|
||||
this.replyNum = replyNum;
|
||||
}
|
||||
|
||||
public int getViewNum() {
|
||||
return viewNum;
|
||||
}
|
||||
|
||||
public void setViewNum(int viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
}
|
174
src/com/lxyer/bbs/base/bean/ContentInfo.java
Normal file
174
src/com/lxyer/bbs/base/bean/ContentInfo.java
Normal file
@@ -0,0 +1,174 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/11/26 20:52.
|
||||
*/
|
||||
public class ContentInfo implements Serializable {
|
||||
|
||||
private int contentId;
|
||||
private int userId;
|
||||
private String title = "";
|
||||
private String digest = "";
|
||||
private String content = "";
|
||||
private int cate;
|
||||
private int type;
|
||||
private int replyNum;
|
||||
private int viewNum;
|
||||
private int wonderful;
|
||||
private int top;
|
||||
private int solved;
|
||||
private int status = 1;
|
||||
|
||||
private String createTime;
|
||||
private String cateName;
|
||||
private String nickname = "";
|
||||
private String avatar = "";
|
||||
private int hadCollect = -1;
|
||||
|
||||
public int getContentId() {
|
||||
return contentId;
|
||||
}
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDigest() {
|
||||
return digest;
|
||||
}
|
||||
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return cate;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getReplyNum() {
|
||||
return replyNum;
|
||||
}
|
||||
|
||||
public void setReplyNum(int replyNum) {
|
||||
this.replyNum = replyNum;
|
||||
}
|
||||
|
||||
public int getViewNum() {
|
||||
return viewNum;
|
||||
}
|
||||
|
||||
public void setViewNum(int viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getWonderful() {
|
||||
return wonderful;
|
||||
}
|
||||
|
||||
public void setWonderful(int wonderful) {
|
||||
this.wonderful = wonderful;
|
||||
}
|
||||
|
||||
public int getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(int top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public int getSolved() {
|
||||
return solved;
|
||||
}
|
||||
|
||||
public void setSolved(int solved) {
|
||||
this.solved = solved;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getCateName() {
|
||||
return cateName;
|
||||
}
|
||||
|
||||
public void setCateName(String cateName) {
|
||||
this.cateName = cateName;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public int getHadCollect() {
|
||||
return hadCollect;
|
||||
}
|
||||
|
||||
public void setHadCollect(int hadCollect) {
|
||||
this.hadCollect = hadCollect;
|
||||
}
|
||||
}
|
49
src/com/lxyer/bbs/base/bean/LoginBean.java
Normal file
49
src/com/lxyer/bbs/base/bean/LoginBean.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
import com.lxyer.bbs.base.entity.User;
|
||||
import org.redkale.net.http.RestSessionid;
|
||||
import org.redkale.source.FilterBean;
|
||||
import org.redkale.util.Comment;
|
||||
|
||||
import javax.persistence.Transient;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/1 10:40.
|
||||
*/
|
||||
public class LoginBean implements FilterBean {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
@Transient
|
||||
@Comment("会话SESSIONID")
|
||||
@RestSessionid(create = true)
|
||||
private String sessionid = "";
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return User.md5IfNeed(password);
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSessionid() {
|
||||
return sessionid;
|
||||
}
|
||||
|
||||
public void setSessionid(String sessionid) {
|
||||
this.sessionid = sessionid;
|
||||
}
|
||||
|
||||
public boolean emptyUsername() {
|
||||
return username == null || username.isEmpty();
|
||||
}
|
||||
}
|
67
src/com/lxyer/bbs/base/bean/UserBean.java
Normal file
67
src/com/lxyer/bbs/base/bean/UserBean.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
import org.redkale.source.FilterBean;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/10 8:30.
|
||||
*/
|
||||
public class UserBean implements FilterBean {
|
||||
|
||||
|
||||
@Column(length = 32, comment = "[登录名]")
|
||||
private String username;
|
||||
|
||||
@Column(length = 32, comment = "[电话号码]")
|
||||
private String phone;
|
||||
|
||||
@Column(length = 64, comment = "[昵称]")
|
||||
private String nickname;
|
||||
|
||||
@Column(length = 32, comment = "[真实姓名]")
|
||||
private String realname;
|
||||
|
||||
@Column(length = 32, comment = "[邮箱]")
|
||||
private String email;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return realname;
|
||||
}
|
||||
|
||||
public void setRealname(String realname) {
|
||||
this.realname = realname;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
174
src/com/lxyer/bbs/base/bean/UserInfo.java
Normal file
174
src/com/lxyer/bbs/base/bean/UserInfo.java
Normal file
@@ -0,0 +1,174 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
import org.redkale.convert.ConvertType;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
public class UserInfo implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
|
||||
private String username = "";
|
||||
|
||||
private int sex = 1;
|
||||
|
||||
private String password = "";
|
||||
|
||||
private String phone = "";
|
||||
|
||||
private String nickname = "";
|
||||
|
||||
private String avatar = "";
|
||||
|
||||
private String relaname = "";
|
||||
|
||||
private String email = "";
|
||||
|
||||
private long createTime;
|
||||
|
||||
private String sign = "";
|
||||
|
||||
private String city = "";
|
||||
|
||||
private int status = 1;
|
||||
|
||||
private String time = "";
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public int getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
@ConvertColumn(type = ConvertType.JSON)
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return this.phone;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return this.nickname;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return this.avatar;
|
||||
}
|
||||
|
||||
public void setRelaname(String relaname) {
|
||||
this.relaname = relaname;
|
||||
}
|
||||
|
||||
public String getRelaname() {
|
||||
return this.relaname;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email == null || this.email.isEmpty() ? "" : this.email;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户权限
|
||||
* @param moduleid
|
||||
* @param actionid
|
||||
* @return
|
||||
*/
|
||||
public boolean checkAuth(int moduleid, int actionid) {
|
||||
|
||||
return !(moduleid == 2 && actionid == 1);
|
||||
}
|
||||
}
|
124
src/com/lxyer/bbs/base/entity/ActLog.java
Normal file
124
src/com/lxyer/bbs/base/entity/ActLog.java
Normal file
@@ -0,0 +1,124 @@
|
||||
package com.lxyer.bbs.base.entity;
|
||||
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable
|
||||
@Table(catalog = "db_redbbs", name = "act_log")
|
||||
public class ActLog implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(comment = "[日志id]")
|
||||
private int logid;
|
||||
|
||||
@Column(comment = "[日志类型]")
|
||||
private int cate;
|
||||
|
||||
@Column(comment = "[目标数据id]")
|
||||
private int tid;
|
||||
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
|
||||
@Column(length = 128, comment = "[说明]")
|
||||
private String remark = "";
|
||||
|
||||
@Column(comment = "[状态]-1删除 1正常")
|
||||
private int status = 1;
|
||||
|
||||
public ActLog cate(int cate){
|
||||
this.cate = cate;
|
||||
return this;
|
||||
}
|
||||
public ActLog tid(int tid){
|
||||
this.tid = tid;
|
||||
return this;
|
||||
}
|
||||
public ActLog userId(int userId){
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
public ActLog createTime(long createTime){
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
public ActLog remark(String remark){
|
||||
this.remark = remark;
|
||||
return this;
|
||||
}
|
||||
public ActLog status(int status){
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public void setLogid(int logid) {
|
||||
this.logid = logid;
|
||||
}
|
||||
|
||||
public int getLogid() {
|
||||
return this.logid;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return this.cate;
|
||||
}
|
||||
|
||||
public void setTid(int tid) {
|
||||
this.tid = tid;
|
||||
}
|
||||
|
||||
public int getTid() {
|
||||
return this.tid;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return this.remark;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
}
|
137
src/com/lxyer/bbs/base/entity/Comment.java
Normal file
137
src/com/lxyer/bbs/base/entity/Comment.java
Normal file
@@ -0,0 +1,137 @@
|
||||
package com.lxyer.bbs.base.entity;
|
||||
|
||||
import com.lxyer.bbs.base.LxyKit;
|
||||
import com.lxyer.bbs.base.bean.CommentInfo;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable(interval = 5*60)
|
||||
@Table(catalog = "db_redbbs", name = "comment", comment = "[评论表]")
|
||||
public class Comment implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(comment = "[评论id]")
|
||||
private int commentId;
|
||||
|
||||
@Column(comment = "[评论用户id]")
|
||||
private int userId;
|
||||
|
||||
@Column(comment = "[评论父id]")
|
||||
private int pid;
|
||||
|
||||
@Column(comment = "[评论的类型]")
|
||||
private int cate;
|
||||
|
||||
@Column(comment = "[被评论内容的id]")
|
||||
private int contentId;
|
||||
|
||||
@Column(comment = "[评论内容]")
|
||||
private String content = "";
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
|
||||
@Column(comment = "[支持数]")
|
||||
private int supportNum;
|
||||
|
||||
@Column(comment = "[状态]1正常,-1删除")
|
||||
private int status = 1;
|
||||
|
||||
public void setCommentId(int commentId) {
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
public int getCommentId() {
|
||||
return this.commentId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return cate;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
}
|
||||
|
||||
public int getContentId() {
|
||||
return this.contentId;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public int getSupportNum() {
|
||||
return supportNum;
|
||||
}
|
||||
|
||||
public void setSupportNum(int supportNum) {
|
||||
this.supportNum = supportNum;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
|
||||
public CommentInfo createCommentInfo(){
|
||||
CommentInfo info = new CommentInfo();
|
||||
info.setCommentId(commentId);
|
||||
info.setUserId(userId);
|
||||
info.setPid(pid);
|
||||
info.setCate(cate);
|
||||
info.setContentId(contentId);
|
||||
info.setContent(content);
|
||||
info.setSupportNum(supportNum);
|
||||
info.setStatus(status);
|
||||
|
||||
info.setCreateTime(LxyKit.dateFmt(createTime));
|
||||
return info;
|
||||
}
|
||||
}
|
207
src/com/lxyer/bbs/base/entity/Content.java
Normal file
207
src/com/lxyer/bbs/base/entity/Content.java
Normal file
@@ -0,0 +1,207 @@
|
||||
package com.lxyer.bbs.base.entity;
|
||||
|
||||
import com.lxyer.bbs.base.LxyKit;
|
||||
import com.lxyer.bbs.base.bean.ContentInfo;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable(interval = 60)
|
||||
@Table(catalog = "db_redbbs", name = "content", comment = "[内容表]")
|
||||
public class Content implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(comment = "[内容id]")
|
||||
private int contentId;
|
||||
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
|
||||
@Column(length = 64, comment = "[标题]")
|
||||
private String title = "";
|
||||
|
||||
@Column(length = 256, comment = "[摘要]")
|
||||
private String digest = "";
|
||||
|
||||
@Column(comment = "[内容]")
|
||||
private String content = "";
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
|
||||
@Column(comment = "[类别]")
|
||||
private int cate;
|
||||
|
||||
@Column(comment = "[内容类型]1新闻,2作品")
|
||||
private int type;
|
||||
|
||||
@Column(comment = "[评论数]")
|
||||
private int replyNum;
|
||||
|
||||
@Column(comment = "[阅读量]")
|
||||
private int viewNum;
|
||||
|
||||
@Column(comment = "[精] 0否,1是")
|
||||
private int wonderful;
|
||||
|
||||
@Column(comment = "[置顶] 0否,1是")
|
||||
private int top;
|
||||
|
||||
@Column(comment = "[结帖]大于0结帖")
|
||||
private int solved;
|
||||
|
||||
@Column(comment = "[状态]")
|
||||
private int status = 1;
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
}
|
||||
|
||||
public int getContentId() {
|
||||
return this.contentId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
|
||||
public String getDigest() {
|
||||
return this.digest;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return cate;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
public int getReplyNum() {
|
||||
return replyNum;
|
||||
}
|
||||
|
||||
public void setReplyNum(int replyNum) {
|
||||
this.replyNum = replyNum;
|
||||
}
|
||||
|
||||
public int getViewNum() {
|
||||
return viewNum;
|
||||
}
|
||||
|
||||
public void setViewNum(int viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
}
|
||||
|
||||
public int getWonderful() {
|
||||
return wonderful;
|
||||
}
|
||||
|
||||
public void setWonderful(int wonderful) {
|
||||
this.wonderful = wonderful;
|
||||
}
|
||||
|
||||
public int getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(int top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public int getSolved() {
|
||||
return solved;
|
||||
}
|
||||
|
||||
public void setSolved(int solved) {
|
||||
this.solved = solved;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
|
||||
public ContentInfo createContentInfo(){
|
||||
ContentInfo info = new ContentInfo();
|
||||
info.setContentId(contentId);
|
||||
info.setUserId(userId);
|
||||
info.setTitle(title);
|
||||
info.setContent(content);
|
||||
info.setCate(cate);
|
||||
info.setViewNum(viewNum);
|
||||
info.setReplyNum(replyNum);
|
||||
info.setWonderful(wonderful);
|
||||
info.setTop(top);
|
||||
info.setSolved(solved);
|
||||
|
||||
info.setCateName(cateName());
|
||||
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 "其他";
|
||||
}
|
||||
}
|
||||
}
|
65
src/com/lxyer/bbs/base/entity/DynaAttr.java
Normal file
65
src/com/lxyer/bbs/base/entity/DynaAttr.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package com.lxyer.bbs.base.entity;
|
||||
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Table(catalog = "db_art_red", name = "dyna_attr", comment = "[动态属性表]")
|
||||
public class DynaAttr implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@Column(comment = "[目标数据id]")
|
||||
private int tid;
|
||||
|
||||
@Column(comment = "[类型]1文章, 2xx, 3...,")
|
||||
private int cate;
|
||||
|
||||
@Column(length = 32, comment = "")
|
||||
private String attr = "";
|
||||
|
||||
@Column(comment = "[属性值]")
|
||||
private String value = "";
|
||||
|
||||
public void setTid(int tid) {
|
||||
this.tid = tid;
|
||||
}
|
||||
|
||||
public int getTid() {
|
||||
return this.tid;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return this.cate;
|
||||
}
|
||||
|
||||
public void setAttr(String attr) {
|
||||
this.attr = attr;
|
||||
}
|
||||
|
||||
public String getAttr() {
|
||||
return this.attr;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
}
|
211
src/com/lxyer/bbs/base/entity/User.java
Normal file
211
src/com/lxyer/bbs/base/entity/User.java
Normal file
@@ -0,0 +1,211 @@
|
||||
package com.lxyer.bbs.base.entity;
|
||||
|
||||
import com.lxyer.bbs.base.bean.UserInfo;
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
import org.redkale.convert.ConvertType;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.Utility;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable(interval = 60)
|
||||
@Table(catalog = "db_redbbs", name = "user")
|
||||
public class User implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
//@GeneratedValue
|
||||
@Column(comment = "[用户id]", updatable = false)
|
||||
private int userId;
|
||||
|
||||
@Column(length = 32, comment = "[登录名]")
|
||||
private String username = "";
|
||||
|
||||
@Column(comment = "[性别]默认1 1男,2女")
|
||||
private int sex = 1;
|
||||
|
||||
@Column(length = 64, comment = "[密码]")
|
||||
private String password = "";
|
||||
|
||||
@Column(length = 32, comment = "[电话号码]")
|
||||
private String phone = "";
|
||||
|
||||
@Column(length = 64, comment = "[昵称]")
|
||||
private String nickname = "";
|
||||
|
||||
@Column(length = 128, comment = "[头像地址]")
|
||||
private String avatar = "";
|
||||
|
||||
@Column(length = 32, comment = "[真实姓名]")
|
||||
private String realname = "";
|
||||
|
||||
@Column(length = 32, comment = "[邮箱]")
|
||||
private String email = "";
|
||||
|
||||
@Column(comment = "[创建时间]", updatable = false)
|
||||
private long createTime;
|
||||
|
||||
@Column(length = 256, comment = "[签名]")
|
||||
private String sign = "";
|
||||
|
||||
@Column(length = 64, comment = "[所在城市]")
|
||||
private String city = "";
|
||||
|
||||
@Column(comment = "[状态]")
|
||||
private int status = 1;
|
||||
|
||||
public String passwordForMd5(){
|
||||
return md5IfNeed(password);
|
||||
}
|
||||
|
||||
public static String md5IfNeed(String password){
|
||||
if (password == null || password.isEmpty()) return "";
|
||||
if (password.length() == 32) return password;
|
||||
MessageDigest md5 = null;
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
byte[] bytes = password.trim().getBytes();
|
||||
bytes = md5.digest(bytes);
|
||||
return new String(Utility.binToHex(bytes));
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public int getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
@ConvertColumn(ignore = true, type = ConvertType.JSON)
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return realname;
|
||||
}
|
||||
|
||||
public void setRealname(String realname) {
|
||||
this.realname = realname;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return (email == null || email.isEmpty()) ? " " : email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
|
||||
public UserInfo createUserInfo() {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setUserId(userId);
|
||||
userInfo.setUsername(username);
|
||||
userInfo.setSex(sex);
|
||||
userInfo.setPassword(password);
|
||||
userInfo.setPhone(phone);
|
||||
userInfo.setNickname(nickname);
|
||||
userInfo.setAvatar(avatar);
|
||||
userInfo.setRelaname(realname);
|
||||
userInfo.setEmail(email);
|
||||
userInfo.setCreateTime(createTime);
|
||||
userInfo.setSign(sign);
|
||||
userInfo.setCity(city);
|
||||
userInfo.setStatus(getStatus());
|
||||
return userInfo;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user