代码格式调整,升级优化

This commit is contained in:
2019-12-15 17:10:08 +08:00
parent eb12c48a78
commit 5e0c309aba
40 changed files with 340 additions and 303 deletions

36
pom.xml
View File

@@ -7,39 +7,26 @@
<groupId>com.lxyer</groupId>
<artifactId>redbbs</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<finalName>redbbs</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--maven 打包使用下面的包 -->
<dependency>
<groupId>org.redkale</groupId>
<artifactId>redkale</artifactId>
<version>2.0.0.alpha1</version>
<version>2.0.0.rc3</version>
</dependency>
<dependency>
<groupId>org.redkalex</groupId>
<artifactId>redkale-plugins</artifactId>
<version>2.0.0.alpha1</version>
<version>2.0.0.rc3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
<version>8.0.18</version>
</dependency>
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>enjoy</artifactId>
@@ -60,5 +47,18 @@
</dependency>-->
</dependencies>
<build>
<finalName>redbbs</finalName>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -22,11 +22,6 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'face'], f
if(device.ie && device.ie < 8){
layer.alert('如果您非得使用 IE 浏览器访问社区,那么请使用 IE8+');
}
//1216.top都统一访问到www.1216.top; 考虑SEO
var addr = window.location.href
if(addr.indexOf("1216.top") > -1 && addr.indexOf("www.1216.top") == -1){
window.location.href = addr.replace("1216.top", "www.1216.top");
}
layui.focusInsert = function(obj, str){
var result, val = obj.value;

View File

@@ -50,6 +50,7 @@ public class ArangoKit {
public static long findInt(String aql) {
return dbDev.query(aql, long.class).first();
}
public static long findInt(String aql, Map para) {
return dbDev.query(aql, long.class).first();
}

View File

@@ -45,6 +45,7 @@ public class ArangoService extends BaseService {
@Override
public void init(AnyValue config) {
CompletableFuture.runAsync(() -> {
System.out.println("isDev :" + isDev);
arangoDb = new ArangoDB.Builder().host(arangoHost, port).user(user).password(password).build();
@@ -57,6 +58,7 @@ public class ArangoService extends BaseService {
if (!colVisLog.exists()) {
colVisLog.create();
}
});
}
@RestMapping(auth = false)
@@ -79,6 +81,7 @@ public class ArangoService extends BaseService {
public static long findInt(String aql) {
return db.query(aql, long.class).first();
}
public static long findInt(String aql, Map para) {
return db.query(aql, long.class).first();
}

View File

@@ -22,6 +22,7 @@ import static net.tccn.bbs.base.kit.RetCodes.RET_USER_UNLOGIN;
/**
* Created by Lxy at 2017/10/3 13:39.
*/
@HttpUserType(UserInfo.class)
public class BaseServlet extends HttpServlet {
protected static final boolean winos = System.getProperty("os.name").contains("Window");
@@ -119,6 +120,7 @@ public class BaseServlet extends HttpServlet {
public int getLimit(HttpRequest request) {
return request.getIntParameter("limit", 1);
}
public int getOffset(HttpRequest request) {
return request.getIntParameter("offset", 10);
}
@@ -128,6 +130,7 @@ public class BaseServlet extends HttpServlet {
String subStr = requestURI.substring(requestURI.lastIndexOf("/") + 1);
return subStr.contains("-") ? subStr.substring(0, subStr.indexOf("-")) : subStr;
}
public String getPara(HttpRequest request, int index) {
String requestURI = request.getRequestURI();
String subStr = requestURI.substring(requestURI.lastIndexOf("/") + 1);
@@ -139,14 +142,17 @@ public class BaseServlet extends HttpServlet {
return paraArr.length < index + 1 ? null : paraArr[index];
}
}
public <T> T getPara(HttpRequest request, int index, T defaultValue) {
T para = (T) getPara(request, index);
return para == null || "".equals(para) ? defaultValue : para;
}
public int getParaToInt(HttpRequest request, int index, int defaultValue) {
String para = getPara(request, index);
return para == null || "".equals(para) ? defaultValue : Integer.parseInt(para);
}
public int getParaToInt(HttpRequest request, int index) {
int n = 0;
String para = getPara(request, index);

View File

@@ -76,6 +76,7 @@ public class JBean<T> /*extends RetResult*/ {
}
private static final JBean ok = new JBean(0);
public static JBean ok() {
return ok;
}

View File

@@ -8,5 +8,6 @@ import net.tccn.bbs.base.iface.UI;
*/
public interface UF<I extends UI> {
int getUserid();
I createInfo();
}

View File

@@ -7,7 +7,6 @@ import javax.persistence.Column;
import java.io.Serializable;
/**
*
* @author lxyer
*/
public class ActLogBean implements Serializable, FilterBean {

View File

@@ -1,10 +1,10 @@
package net.tccn.bbs.base.entity;
import org.redkale.convert.json.JsonConvert;
import javax.persistence.*;
import org.redkale.convert.json.*;
/**
*
* @author lxyer
*/
@Cacheable(interval = 5 * 60)
@@ -12,7 +12,6 @@ import org.redkale.convert.json.*;
public class ActLog implements java.io.Serializable {
@Id
@GeneratedValue
@Column(comment = "[日志id]")
private int logid;

View File

@@ -8,7 +8,6 @@ import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author lxyer
*/
@Cacheable(interval = 5 * 60)

View File

@@ -9,22 +9,28 @@ public interface UI<I extends UI> {
//抽象方法
int getUserid();
UserRecord getUser();
I setUser(UserRecord user);
//默认实现方法
default String getRealname() {
return getUser() == null ? null : getUser().getRealname();
}
default String getNickname() {
return getUser() == null ? null : getUser().getNickname();
}
default String getSite() {
return getUser() == null ? "" : getUser().getSite();
}
default String getGit() {
return getUser() == null ? "" : getUser().getGit();
}
default String getAvatar() {
return getUser() == null ? null : getUser().getAvatar();
}

View File

@@ -15,6 +15,7 @@ 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);
}

View File

@@ -55,7 +55,6 @@ public abstract class RetCodes {
public static final int RET_COMMENT_PARA_ILLEGAL = 3004_0002;
public static RetResult retResult(int retcode) {
return new RetResult(retcode);
}

View File

@@ -8,7 +8,6 @@ import javax.persistence.Column;
import javax.persistence.Id;
/**
*
* @author lxyer
*/
public class UserInfo implements java.io.Serializable {
@@ -178,6 +177,7 @@ public class UserInfo implements java.io.Serializable {
/**
* 检查用户权限
*
* @param moduleid
* @param actionid
* @return

View File

@@ -9,7 +9,6 @@ import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author lxyer
*/
@Cacheable(interval = 5 * 60)

View File

@@ -30,19 +30,19 @@ import static net.tccn.bbs.base.kit.RetCodes.*;
public class UserService extends BaseService {
@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, "参数错误");
public RetResult<UserInfo> login(LoginBean bean) {
if (bean == null || bean.emptyUsername()) return RetCodes.retResult(RetCodes.RET_PARAMS_ILLEGAL, "参数错误");
final RetResult retResult = new RetResult();
UserRecord user = source.find(UserRecord.class, "username", loginBean.getUsername());
if (user == null || !Objects.equals(user.getPassword(), loginBean.getPassword())){
UserRecord user = source.find(UserRecord.class, "username", bean.getUsername());
if (user == null || !Objects.equals(user.getPassword(), bean.getPassword())) {
//log(null, 0, "用户或密码错误");
return RetCodes.retResult(RetCodes.RET_USER_ACCOUNT_PWD_ILLEGAL, "用户名或密码错误");
}
sessions.setAsync(sessionExpireSeconds, loginBean.getSessionid(), (long)user.getUserid());
sessions.setAsync(sessionExpireSeconds, bean.getSessionid(), (long) user.getUserid());
retResult.setRetcode(0);
retResult.setResult(Kv.by("token", loginBean.getSessionid()));
retResult.setResult(Kv.by("token", bean.getSessionid()));
retResult.setRetinfo("登录成功.");
return retResult;
}
@@ -57,13 +57,14 @@ public class UserService extends BaseService {
} catch (Exception e) {
e.printStackTrace();
}
return userid == 0 ? null : findUserInfo((int)userid);
return userid == 0 ? null : find((int) userid);
}
@RestMapping(name = "info", comment = "用户信息")
public UserInfo findUserInfo(int userid) {
public UserInfo find(int userid) {
UserRecord user = source.find(UserRecord.class, userid);
return user == null ? null : user.createUserInfo();
UserInfo bean = user.createUserInfo();
return bean;
}
@RestMapping(name = "logout", auth = false, comment = "退出登录")
@@ -75,7 +76,7 @@ public class UserService extends BaseService {
}
@RestMapping(name = "query", auth = false, comment = "用户数据查询")
public Sheet<UserRecord> queryUser(Flipper flipper, @RestParam(name = "bean", comment = "过滤条件") final UserBean userBean){
public Sheet<UserRecord> query(Flipper flipper, @RestParam(name = "bean", comment = "过滤条件") final UserBean userBean) {
Sheet<UserRecord> users = source.querySheet(UserRecord.class, flipper, userBean);
return users;
@@ -94,43 +95,44 @@ public class UserService extends BaseService {
}
@RestMapping(name = "register", auth = false, comment = "用户注册")
public RetResult register(@RestParam(name = "bean") UserRecord user){
public RetResult register(UserRecord bean) {
/*用户名、密码、邮箱*/
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, "密码设置无效");
if (bean.getEmail() == null) return RetCodes.retResult(RET_USER_EMAIL_ILLEGAL, "邮件地址无效");
if (bean.getPassword() == null || bean.getPassword().length() < 6)
return RetCodes.retResult(RET_USER_PASSWORD_ILLEGAL, "密码设置无效");
UserRecord _user = source.find(UserRecord.class, FilterNode.create("email", user.getEmail()));
UserRecord _user = source.find(UserRecord.class, FilterNode.create("email", bean.getEmail()));
if (_user != null) return RetCodes.retResult(RET_USER_USERNAME_EXISTS, "用户名已存在");
user.setCreatetime(System.currentTimeMillis());
user.setPassword(user.passwordForMd5());
user.setStatus((short) 10);
user.setUsername(user.getEmail());
user.setAvatar("/res/images/avatar/"+ new Random().nextInt(21) +".jpg");//默认头像
bean.setCreatetime(System.currentTimeMillis());
bean.setPassword(bean.passwordForMd5());
bean.setStatus((short) 10);
bean.setUsername(bean.getEmail());
bean.setAvatar("/res/images/avatar/" + new Random().nextInt(21) + ".jpg");//默认头像
int maxId = source.getNumberResult(UserRecord.class, FilterFunc.MAX, 10_0000, "userid").intValue();
if (maxId < 10_0000) maxId = 10_0000;
user.setUserid(maxId+1);
source.insert(user);
bean.setUserid(maxId + 1);
source.insert(bean);
//记录日志
return RetResult.success();
}
@RestMapping(name = "update", comment = "用户信息修改")
public RetResult userUpdate(@RestSessionid String sessionid, @RestParam(name = "bean") UserRecord user, String[] columns){
String nickname = user.getNickname();
public RetResult userUpdate(UserInfo user, UserRecord bean, String[] columns) {
String nickname = bean.getNickname();
if (nickname == null && nickname.isEmpty())
return RetCodes.retResult(RET_USER_NICKNAME_ILLEGAL, "昵称无效");
nickname = nickname.replace(" ", "");
UserRecord _user = source.find(UserRecord.class, FilterNode.create("nickname", nickname));
if (_user != null && _user.getUserid() != currentUserid(sessionid))
if (_user != null && _user.getUserid() != user.getUserid())
return RetCodes.retResult(RET_USER_NICKNAME_EXISTS, "昵称已存在");
user.setNickname(nickname);//去除昵称中的空格
source.updateColumn(user
,FilterNode.create("userid", currentUserid(sessionid))
bean.setNickname(nickname);//去除昵称中的空格
source.updateColumn(bean
, FilterNode.create("userid", user.getUserid())
, SelectColumn.includes(columns)
);
return RetResult.success();

View File

@@ -1,15 +1,13 @@
package net.tccn.bbs.comment;
import javax.persistence.*;
import net.tccn.bbs.base.iface.C;
import net.tccn.bbs.base.kit.LxyKit;
import org.redkale.convert.json.*;
import org.redkale.convert.json.JsonConvert;
import javax.persistence.*;
import java.io.Serializable;
/**
*
* @author lxyer
*/
@Cacheable(interval = 5 * 60)
@@ -17,7 +15,6 @@ import java.io.Serializable;
public class Comment implements Serializable, C<CommentInfo> {
@Id
@GeneratedValue
@Column(comment = "[评论id]")
private int commentid;

View File

@@ -9,7 +9,6 @@ import javax.persistence.Column;
import java.io.Serializable;
/**
*
* @author lxyer
*/
public class CommentInfo implements UI<CommentInfo>, Serializable, CI<CommentInfo> {

View File

@@ -24,11 +24,11 @@ import static net.tccn.bbs.base.kit.RetCodes.RET_COMMENT_PARA_ILLEGAL;
/**
* Created by Lxy at 2017/11/29 10:00.
*/
@RestService(automapping = true, comment = "评论服务")
@RestService(name = "comment", comment = "评论服务")
public class CommentService extends BaseService implements UIService<CommentInfo> {
@RestMapping(name = "save", comment = "评论保存")
public RetResult commentSave(@RestSessionid String sessionid, @RestParam(name = "bean") Comment comment){
public RetResult save(@RestSessionid String sessionid, @RestParam(name = "bean") Comment comment) {
int contentid = comment.getContentid();
//数据校验
@@ -57,7 +57,7 @@ public class CommentService extends BaseService implements UIService<CommentInfo
}
@RestMapping(name = "query", auth = false, comment = "查询评论")
public Sheet<CommentInfo> commentQuery(@RestSessionid String sessionid , int contentId, Flipper flipper){
public Sheet<CommentInfo> query(@RestSessionid String sessionid, int contentId, Flipper flipper) {
int userid = currentUserid(sessionid);
flipper.setSort("supportnum DESC,commentid ASC");
@@ -80,7 +80,7 @@ public class CommentService extends BaseService implements UIService<CommentInfo
return infos;
}
@RestMapping(ignore = true, comment = "查询用户评论数据")
@org.redkale.util.Comment("查询用户评论数据")
public Sheet<CommentInfo> queryByUserid(int userid) {
Sheet<Comment> comments = source.querySheet(Comment.class, new Flipper().sort("createtime DESC"), FilterNode.create("userid", userid));
@@ -120,9 +120,10 @@ public class CommentService extends BaseService implements UIService<CommentInfo
/**
* todo:用户评论榜 待完成
*
* @return
*/
@RestMapping(ignore = true, name = "rankuser", auth = false, comment = "用户评论榜")
@org.redkale.util.Comment("用户评论榜")
public Map<String, Number> commentRank() {
Flipper flipper = new Flipper().limit(8);
source.querySheet(Comment.class, flipper, FilterNode.create("userid", FilterExpress.IN));

View File

@@ -9,7 +9,6 @@ import javax.persistence.*;
import java.io.Serializable;
/**
*
* @author lxyer
*/
@Cacheable(interval = 5 * 60)
@@ -17,7 +16,6 @@ import java.io.Serializable;
public class Content implements Serializable, C<ContentInfo> {
@Id
@GeneratedValue
@Column(comment = "[内容id]")
private int contentid;

View File

@@ -4,19 +4,16 @@ 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;

View File

@@ -161,6 +161,7 @@ public class ContentInfo implements UI<ContentInfo>,Serializable, CI {
//-----------
private UserRecord user;
@ConvertColumn(ignore = true)
@Override
public UserRecord getUser() {

View File

@@ -7,9 +7,15 @@ import net.tccn.bbs.base.iface.UIService;
import net.tccn.bbs.base.kit.RetCodes;
import net.tccn.bbs.base.user.UserInfo;
import net.tccn.bbs.base.user.UserService;
import org.redkale.net.http.*;
import org.redkale.net.http.HttpScope;
import org.redkale.net.http.RestMapping;
import org.redkale.net.http.RestService;
import org.redkale.net.http.RestSessionid;
import org.redkale.service.RetResult;
import org.redkale.source.*;
import org.redkale.source.FilterExpress;
import org.redkale.source.FilterFunc;
import org.redkale.source.FilterNode;
import org.redkale.source.Flipper;
import org.redkale.util.Comment;
import org.redkale.util.SelectColumn;
import org.redkale.util.Sheet;
@@ -19,13 +25,13 @@ import javax.annotation.Resource;
/**
* Created by Lxy at 2017/11/26 9:33.
*/
@RestService(automapping = true, comment = "文章帖子服务")
@RestService(name = "content", comment = "文章帖子服务")
public class ContentService extends BaseService implements UIService<ContentInfo> {
@Resource
protected UserService userService;
@RestMapping(ignore = true, comment = "根据条件查询帖子数据")
@Comment("根据条件查询帖子数据")
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode) {
Sheet<Content> contents = source.querySheet(Content.class, flipper, filterNode);
@@ -37,17 +43,27 @@ public class ContentService extends BaseService implements UIService<ContentInfo
}
@RestMapping(name = "query", auth = false, comment = "内容列表")
public Sheet<ContentInfo> contentQuery(Flipper flipper, String actived, String sessionid){
public Sheet<ContentInfo> query(Flipper flipper, String actived, String sessionid) {
UserInfo current = userService.current(sessionid);
int currentid = current == null ? 0 : current.getUserid();
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -10);
switch (actived) {
case "top": filterNode.and("top", FilterExpress.GREATERTHANOREQUALTO, 20);break;
case "untop": filterNode.and("top", 10);break;
case "unsolved": filterNode.and("solved", 10);break;
case "solved": filterNode.and("solved", 20);break;
case "wonderful": filterNode.and("wonderful", FilterExpress.GREATERTHANOREQUALTO, 20);break;
case "top":
filterNode.and("top", FilterExpress.GREATERTHANOREQUALTO, 20);
break;
case "untop":
filterNode.and("top", 10);
break;
case "unsolved":
filterNode.and("solved", 10);
break;
case "solved":
filterNode.and("solved", 20);
break;
case "wonderful":
filterNode.and("wonderful", FilterExpress.GREATERTHANOREQUALTO, 20);
break;
}
if (!userService.isAdmin(currentid)) {//私密贴:非管理员限制查看
@@ -61,25 +77,25 @@ public class ContentService extends BaseService implements UIService<ContentInfo
@RestMapping(name = "save", comment = "帖子保存")
public RetResult contentSave(@RestParam(name = "bean")Content content, @RestSessionid String sessionid){
public RetResult save(UserInfo user, Content bean) {
//数据校验
if (content.getTitle().isEmpty() || content.getTitle().length() > 64){
if (bean.getTitle().isEmpty() || bean.getTitle().length() > 64) {
return RetCodes.retResult(-1, "少年你的文章标题太长啦精简化标题吧为了更好的SEO长度请少于64个字节");
}
int userid = currentUserid(sessionid);
int userid = user.getUserid();
if (content.getContentid() < 1){
if (bean.getContentid() < 1) {
int maxId = source.getNumberResult(Content.class, FilterFunc.MAX, 10_0000, "contentid").intValue();
content.setContentid(maxId+1);
content.setCreatetime(System.currentTimeMillis());
content.setUserid(userid);
bean.setContentid(maxId + 1);
bean.setCreatetime(System.currentTimeMillis());
bean.setUserid(userid);
source.insert(content);
source.insert(bean);
} else {
source.findAsync(Content.class, content.getContentid()).thenAccept(x->{
source.findAsync(Content.class, bean.getContentid()).thenAccept(x -> {
if (x.getUserid() == userid || userService.isAdmin(userid)) {//身份验证 后修改内容
source.updateColumnAsync(content,SelectColumn.includes("title", "digest", "content","type", "status"));
source.updateColumnAsync(bean, SelectColumn.includes("title", "digest", "content", "type", "status"));
}
});
}
@@ -88,8 +104,8 @@ public class ContentService extends BaseService implements UIService<ContentInfo
}
@RestMapping(name = "info", auth = false, comment = "帖子详情")
public ContentInfo contentInfo(@RestSessionid String sessionid, int contentid){
int userId = userService.currentUserid(sessionid);
public ContentInfo info(UserInfo user, int contentid) {
int userId = user != null ? user.getUserid() : 0;
Content content = source.find(Content.class, contentid);
if (content == null) return null;
@@ -174,7 +190,7 @@ public class ContentService extends BaseService implements UIService<ContentInfo
//热议
Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", sessionid);
Sheet<ContentInfo> hotReply = contentService.query(flipper3, "", sessionid);
//最新加入
Sheet<UserInfo> lastReg = userService.lastReg();

View File

@@ -2,6 +2,7 @@ package net.tccn.bbs.servlet;
import com.jfinal.kit.Kv;
import net.tccn.bbs.base.BaseServlet;
import net.tccn.bbs.base.user.UserInfo;
import net.tccn.bbs.comment.CommentInfo;
import net.tccn.bbs.content.ContentInfo;
import org.redkale.net.http.*;
@@ -24,7 +25,7 @@ public class ContentServlet extends BaseServlet {
//分页帖子列表
Flipper flipper = new Flipper().offset((curr - 1) * 15).limit(15).sort("top DESC,createtime DESC");
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, actived, request.getSessionid(false));
Sheet<ContentInfo> contents = contentService.query(flipper, actived, request.getSessionid(false));
Kv kv = Kv.by("contents", contents).set("url", request.getRequestURI())
.set("actived", actived).set("curr", curr);
@@ -36,10 +37,12 @@ public class ContentServlet extends BaseServlet {
@HttpParam(name = "#", type = int.class, comment = "内容ID")
public void add(HttpRequest request, HttpResponse response) {
int contentid = getParaToInt(request, 0);
String sessionid = request.getSessionid(false);
UserInfo user = userService.current(sessionid);
ContentInfo contentInfo = null;
if (contentid > 0) {
contentInfo = contentService.contentInfo(request.getSessionid(false), contentid);
contentInfo = contentService.info(user, contentid);
}
Kv kv = Kv.by("bean", contentInfo);
@@ -50,9 +53,10 @@ public class ContentServlet extends BaseServlet {
public void detail(HttpRequest request, HttpResponse response) {
int contentid = getParaToInt(request, 0);
String sessionid = request.getSessionid(false);
UserInfo user = userService.current(sessionid);
ContentInfo content = contentService.contentInfo(sessionid, contentid);
Sheet<CommentInfo> comments = commentService.commentQuery(sessionid,contentid, new Flipper().limit(30));
ContentInfo content = contentService.info(user, contentid);
Sheet<CommentInfo> comments = commentService.query(sessionid, contentid, new Flipper().limit(30));
//热帖
//Flipper flipper2 = new Flipper().limit(8).sort("viewNum DESC");

View File

@@ -32,7 +32,7 @@ public class FileServlet extends BaseServlet {
String name = part.getName();
String suffix = name.substring(name.lastIndexOf("."));
String path = String.format(format, System.currentTimeMillis()) + suffix;
File destFile = new File((winos ? "D:/wk/_own/redbbs/root/tem/" : dir) + path);
File destFile = new File((winos ? "E:/wk/own/redbbs/root/tem/" : dir) + path);
destFile.getParentFile().mkdir();
part.save(destFile);

View File

@@ -71,10 +71,11 @@ public class IndexServlet extends BaseServlet {
@HttpMapping(url = "/project", auth = false, comment = "项目首页")
public void project(HttpRequest request, HttpResponse response) {
String sessionid = request.getSessionid(false);
UserInfo user = userService.current(sessionid);
int contentid = 22;
ContentInfo content = contentService.contentInfo(sessionid, contentid);
Sheet<CommentInfo> comments = commentService.commentQuery(sessionid,contentid, new Flipper().limit(30));
ContentInfo content = contentService.info(user, contentid);
Sheet<CommentInfo> comments = commentService.query(sessionid, contentid, new Flipper().limit(30));
Kv kv = Kv.by("bean", content).set("comments", comments);
response.finish(HttpScope.refer("/project/index.html").attr(kv));

View File

@@ -26,6 +26,7 @@ public class UserServlet extends BaseServlet {
response.finish(HttpScope.refer("/user/login.html"));
}
@HttpMapping(url = "/user/reg", auth = false, comment = "前往登录页")
public void reg(HttpRequest request, HttpResponse response) {
/*List<Kv> list = new ArrayList<>();
@@ -75,7 +76,7 @@ public class UserServlet extends BaseServlet {
String nickname = request.getParameter("nickname");
UserBean userBean = new UserBean();
userBean.setNickname(nickname);
Sheet<UserRecord> users = userService.queryUser(new Flipper().limit(1), userBean);
Sheet<UserRecord> users = userService.query(new Flipper().limit(1), userBean);
if (users.getTotal() > 0) {
userid = users.stream().findFirst().orElse(null).getUserid();
}
@@ -84,7 +85,7 @@ public class UserServlet extends BaseServlet {
}
//用户信息
UserInfo user = userService.findUserInfo(userid);
UserInfo user = userService.find(userid);
//帖子
Flipper flipper = new Flipper().limit(8).sort("createtime DESC");

View File

@@ -14,7 +14,6 @@ import java.util.Random;
import java.util.concurrent.CompletableFuture;
/**
*
* Created by liangxianyou at 2018/7/8 22:51.
*/
@RestWebSocket(name = "chat", catalog = "ws", comment = "文字聊天", anyuser = true)

View File

@@ -5,7 +5,6 @@ import org.redkale.convert.json.JsonConvert;
import javax.persistence.*;
/**
*
* @author lxyer
*/
@Cacheable(interval = 5 * 60)
@@ -13,7 +12,6 @@ import javax.persistence.*;
public class MsgRecord implements java.io.Serializable {
@Id
@GeneratedValue
@Column(comment = "[主键id]")
private int msgid;

View File

@@ -92,7 +92,6 @@ public class ImFriendServiceImpl extends BaseService implements ImFriendService
//sncpTransportFactory.addGroupInfo(groupInfo);
return friends(sessionid);
}

View File

@@ -6,52 +6,64 @@ import org.redkale.service.Service;
public interface ImFriendService extends Service {
//================ 查询相关 =================
/**
* 分组好友数据
*
* @return
*/
JBean friends(String sessionid);
/**
* 根据条件查询好友
*
* @return
*/
JBean friendList(String sessionid);
/**
* 群组数据
*
* @return
*/
JBean groups(String sessionid);
//================ 操作好友相关 =================
/**
* 保存好友分组
*
* @return
*/
JBean itemSave(String sessionid);
/**
* 添加好友
*
* @return
*/
JBean addFriend(String sessionid);
//================ 操作群组相关 =================
/**
* 保存群组
*
* @return
*/
JBean groupSave(String sessionid);
/**
* 加入群组
*
* @return
*/
JBean addGroup(String sessionid);
/**
* 登录人用户id
*
* @param sessionid
* @return
*/

View File

@@ -12,6 +12,7 @@ public interface ImMsgService extends Service {
/**
* 消息入库
*
* @param msg
*/
JBean insert(MsgRecord... msg);
@@ -23,6 +24,7 @@ public interface ImMsgService extends Service {
/**
* 历史消息
*
* @return
*/
JBean list();
@@ -36,6 +38,7 @@ public interface ImMsgService extends Service {
/**
* 获取离线消息
*
* @param userid
* @return
*/