调整包结构
This commit is contained in:
@@ -12,7 +12,6 @@ import java.io.File;
|
||||
public class BaseService implements Service {
|
||||
|
||||
protected final int sessionExpireSeconds = 30 * 60;
|
||||
protected final int contentinfoExpireSeconds = 30 * 60;
|
||||
|
||||
@Resource(name = "SERVER_ROOT")
|
||||
protected File webroot;
|
||||
|
@@ -3,7 +3,7 @@ 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 com.lxyer.bbs.base.user.UserService;
|
||||
import org.redkale.net.http.HttpContext;
|
||||
import org.redkale.net.http.HttpRequest;
|
||||
import org.redkale.net.http.HttpResponse;
|
||||
|
@@ -1,26 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
@@ -16,8 +16,8 @@ import java.nio.file.StandardCopyOption;
|
||||
@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 dir = "/var/www/upload/redbbs/";
|
||||
private static final String view = "http://img.1216.top/redbbs/";
|
||||
private static final String format = "%1$tY%1$tm%1$td%1$tH%1$tM%1$tS";
|
||||
|
||||
@RestMapping(name = "upload", comment = "文件上传")
|
||||
|
@@ -1,163 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@@ -1,154 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@@ -1,173 +0,0 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
|
||||
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 typeName;
|
||||
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 getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@@ -1,137 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@@ -1,199 +0,0 @@
|
||||
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;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable(interval = 5*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);
|
||||
}
|
||||
|
||||
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);
|
||||
info.setUserId(userId);
|
||||
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.setTypeName(types.getOrDefault(type, "其他").toString());
|
||||
info.setCreateTime(LxyKit.dateFmt(createTime));
|
||||
return info;
|
||||
}
|
||||
}
|
@@ -1,6 +1,5 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
package com.lxyer.bbs.base.user;
|
||||
|
||||
import com.lxyer.bbs.base.entity.User;
|
||||
import org.redkale.net.http.RestSessionid;
|
||||
import org.redkale.source.FilterBean;
|
||||
import org.redkale.util.Comment;
|
@@ -1,6 +1,5 @@
|
||||
package com.lxyer.bbs.base.entity;
|
||||
package com.lxyer.bbs.base.user;
|
||||
|
||||
import com.lxyer.bbs.base.bean.UserInfo;
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
import org.redkale.convert.ConvertType;
|
||||
import org.redkale.convert.json.JsonConvert;
|
@@ -1,4 +1,4 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
package com.lxyer.bbs.base.user;
|
||||
|
||||
import org.redkale.source.FilterBean;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.lxyer.bbs.base.bean;
|
||||
package com.lxyer.bbs.base.user;
|
||||
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
import org.redkale.convert.ConvertType;
|
160
src/com/lxyer/bbs/base/user/UserService.java
Normal file
160
src/com/lxyer/bbs/base/user/UserService.java
Normal file
@@ -0,0 +1,160 @@
|
||||
package com.lxyer.bbs.base.user;
|
||||
|
||||
import com.lxyer.bbs.base.BaseService;
|
||||
import com.lxyer.bbs.base.LxyKit;
|
||||
import com.lxyer.bbs.base.RetCodes;
|
||||
import com.lxyer.bbs.base.user.LoginBean;
|
||||
import com.lxyer.bbs.base.user.UserBean;
|
||||
import com.lxyer.bbs.base.user.UserInfo;
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import org.redkale.net.http.RestMapping;
|
||||
import org.redkale.net.http.RestParam;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.net.http.RestSessionid;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.source.CacheSource;
|
||||
import org.redkale.source.FilterFunc;
|
||||
import org.redkale.source.FilterNode;
|
||||
import org.redkale.source.Flipper;
|
||||
import org.redkale.util.SelectColumn;
|
||||
import org.redkale.util.Sheet;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.lxyer.bbs.base.RetCodes.*;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/3 14:02.
|
||||
*/
|
||||
@RestService(automapping = true, comment = "用户服务")
|
||||
public class UserService extends BaseService {
|
||||
|
||||
@Resource(name = "usersessions")
|
||||
protected CacheSource<Integer> sessions;
|
||||
|
||||
@Resource
|
||||
protected CacheSource<UserInfo> userInfos;
|
||||
|
||||
@RestMapping(auth = false, comment = "登录校验")
|
||||
public RetResult<UserInfo> login(@RestParam(name = "bean") LoginBean loginBean){
|
||||
if (loginBean == null || loginBean.emptyUsername()) return RetCodes.retResult(RetCodes.RET_PARAMS_ILLEGAL, "参数错误");
|
||||
|
||||
final RetResult retResult = new RetResult();
|
||||
|
||||
User user = source.find(User.class, "username", loginBean.getUsername());
|
||||
if (user == null || !Objects.equals(user.getPassword(), loginBean.getPassword())){
|
||||
//log(null, 0, "用户或密码错误");
|
||||
return RetCodes.retResult(RetCodes.RET_USER_ACCOUNT_PWD_ILLEGAL, "用户或密码错误");
|
||||
}
|
||||
|
||||
//log(user, 0, "用户登录成功.");
|
||||
UserInfo userInfo = user.createUserInfo();
|
||||
|
||||
this.sessions.set(sessionExpireSeconds, loginBean.getSessionid(), userInfo.getUserId());
|
||||
retResult.setRetcode(0);
|
||||
retResult.setResult(userInfo);
|
||||
retResult.setRetinfo("登录成功.");
|
||||
return retResult;
|
||||
}
|
||||
|
||||
public UserInfo current(String sessionid){
|
||||
Integer userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||
return userid == null ? null : findUserInfo(userid);
|
||||
}
|
||||
@RestMapping(name = "userid")
|
||||
public int currentUserId(String sessionid){
|
||||
Integer userid = sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||
return userid == null ? 0 : userid;
|
||||
}
|
||||
|
||||
@RestMapping(name = "info", comment = "用户信息")
|
||||
public UserInfo findUserInfo(int userid) {
|
||||
User user = source.find(User.class, userid);
|
||||
return user == null ? null : user.createUserInfo();
|
||||
}
|
||||
|
||||
@RestMapping(name = "logout", auth = false, comment = "退出登录")
|
||||
public RetResult logout(@RestSessionid String sessionid){
|
||||
sessions.remove(sessionid);
|
||||
|
||||
return RetResult.success();
|
||||
//return new HttpResult().header("Location", "/").status(302);
|
||||
}
|
||||
|
||||
@RestMapping(name = "query", auth = false, comment = "用户数据查询")
|
||||
public Sheet<User> queryUser(Flipper flipper, @RestParam(name = "bean", comment = "过滤条件") final UserBean userBean){
|
||||
Sheet<User> users = source.querySheet(User.class, flipper, userBean);
|
||||
|
||||
return users;
|
||||
}
|
||||
|
||||
@RestMapping(name = "changepwd", comment = "修改密码")
|
||||
public RetResult updatePwd(@RestSessionid String sessionid, String pass, String nowpass){
|
||||
UserInfo userInfo = current(sessionid);//不会为空
|
||||
|
||||
if (!Objects.equals(userInfo.getPassword(), User.md5IfNeed(nowpass)))
|
||||
return RetCodes.retResult(RET_USER_ACCOUNT_PWD_ILLEGAL, "密码错误");
|
||||
if (pass == null || pass.length() < 6 || Objects.equals(pass, nowpass))
|
||||
return RetCodes.retResult(RET_USER_PASSWORD_ILLEGAL, "密码设置无效");
|
||||
source.updateColumn(User.class, userInfo.getUserId(), "password", User.md5IfNeed(pass));
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
@RestMapping(name = "register", auth = false, comment = "用户注册")
|
||||
public RetResult register(@RestParam(name = "bean") User user){
|
||||
/*用户名、密码、邮箱*/
|
||||
if (user.getEmail() == null) return RetCodes.retResult(RET_USER_EMAIL_ILLEGAL, "邮件地址无效");
|
||||
if (user.getPassword() == null || user.getPassword().length() < 6) return RetCodes.retResult(RET_USER_PASSWORD_ILLEGAL, "密码设置无效");
|
||||
|
||||
User _user = source.find(User.class, FilterNode.create("email", user.getEmail()));
|
||||
if (_user != null) return RetCodes.retResult(RET_USER_USERNAME_EXISTS, "用户名已存在");
|
||||
|
||||
user.setCreateTime(System.currentTimeMillis());
|
||||
user.setPassword(user.passwordForMd5());
|
||||
user.setStatus(1);//待激活
|
||||
user.setUsername(user.getEmail());
|
||||
user.setAvatar("/res/images/avatar/"+ new Random().nextInt(21) +".jpg");//默认头像
|
||||
|
||||
int maxId = source.getNumberResult(User.class, FilterFunc.MAX, 10_0000, "userId").intValue();
|
||||
if (maxId < 10_0000) maxId = 10_0000;
|
||||
user.setUserId(maxId+1);
|
||||
source.insert(user);
|
||||
|
||||
//记录日志
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
@RestMapping(name = "update", comment = "用户信息修改")
|
||||
public RetResult userUpdate(@RestSessionid String sessionid, @RestParam(name = "bean") User user, String[] columns){
|
||||
source.updateColumn(user
|
||||
,FilterNode.create("userId", currentUserId(sessionid))
|
||||
,SelectColumn.createIncludes(columns)
|
||||
);
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
//最新加入
|
||||
public Sheet<UserInfo> lastReg(){
|
||||
Sheet<User> users = source.querySheet(User.class
|
||||
, SelectColumn.createIncludes("userId", "nickname", "avatar", "createTime")
|
||||
, new Flipper().sort("createTime DESC").limit(8)
|
||||
, FilterNode.create("status", 1));
|
||||
|
||||
Sheet<UserInfo> infos = new Sheet<>();
|
||||
ArrayList<UserInfo> list = new ArrayList<>();
|
||||
|
||||
users.forEach(x->{
|
||||
UserInfo info = x.createUserInfo();
|
||||
info.setTime(LxyKit.dateFmt(x.getCreateTime()));
|
||||
list.add(info);
|
||||
});
|
||||
|
||||
infos.setRows(list);
|
||||
infos.setTotal(users.getTotal());
|
||||
|
||||
return infos;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user