代码格式调整,升级优化
This commit is contained in:
36
pom.xml
36
pom.xml
@@ -7,39 +7,26 @@
|
|||||||
<groupId>com.lxyer</groupId>
|
<groupId>com.lxyer</groupId>
|
||||||
<artifactId>redbbs</artifactId>
|
<artifactId>redbbs</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<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>
|
<dependencies>
|
||||||
<!--maven 打包使用下面的包 -->
|
<!--maven 打包使用下面的包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.redkale</groupId>
|
<groupId>org.redkale</groupId>
|
||||||
<artifactId>redkale</artifactId>
|
<artifactId>redkale</artifactId>
|
||||||
<version>2.0.0.alpha1</version>
|
<version>2.0.0.rc3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.redkalex</groupId>
|
<groupId>org.redkalex</groupId>
|
||||||
<artifactId>redkale-plugins</artifactId>
|
<artifactId>redkale-plugins</artifactId>
|
||||||
<version>2.0.0.alpha1</version>
|
<version>2.0.0.rc3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>5.1.34</version>
|
<version>8.0.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jfinal</groupId>
|
<groupId>com.jfinal</groupId>
|
||||||
<artifactId>enjoy</artifactId>
|
<artifactId>enjoy</artifactId>
|
||||||
@@ -60,5 +47,18 @@
|
|||||||
</dependency>-->
|
</dependency>-->
|
||||||
</dependencies>
|
</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>
|
</project>
|
@@ -22,11 +22,6 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'face'], f
|
|||||||
if(device.ie && device.ie < 8){
|
if(device.ie && device.ie < 8){
|
||||||
layer.alert('如果您非得使用 IE 浏览器访问社区,那么请使用 IE8+');
|
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){
|
layui.focusInsert = function(obj, str){
|
||||||
var result, val = obj.value;
|
var result, val = obj.value;
|
||||||
|
@@ -50,6 +50,7 @@ public class ArangoKit {
|
|||||||
public static long findInt(String aql) {
|
public static long findInt(String aql) {
|
||||||
return dbDev.query(aql, long.class).first();
|
return dbDev.query(aql, long.class).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long findInt(String aql, Map para) {
|
public static long findInt(String aql, Map para) {
|
||||||
return dbDev.query(aql, long.class).first();
|
return dbDev.query(aql, long.class).first();
|
||||||
}
|
}
|
||||||
|
@@ -45,6 +45,7 @@ public class ArangoService extends BaseService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(AnyValue config) {
|
public void init(AnyValue config) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
System.out.println("isDev :" + isDev);
|
System.out.println("isDev :" + isDev);
|
||||||
|
|
||||||
arangoDb = new ArangoDB.Builder().host(arangoHost, port).user(user).password(password).build();
|
arangoDb = new ArangoDB.Builder().host(arangoHost, port).user(user).password(password).build();
|
||||||
@@ -57,6 +58,7 @@ public class ArangoService extends BaseService {
|
|||||||
if (!colVisLog.exists()) {
|
if (!colVisLog.exists()) {
|
||||||
colVisLog.create();
|
colVisLog.create();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(auth = false)
|
@RestMapping(auth = false)
|
||||||
@@ -79,6 +81,7 @@ public class ArangoService extends BaseService {
|
|||||||
public static long findInt(String aql) {
|
public static long findInt(String aql) {
|
||||||
return db.query(aql, long.class).first();
|
return db.query(aql, long.class).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long findInt(String aql, Map para) {
|
public static long findInt(String aql, Map para) {
|
||||||
return db.query(aql, long.class).first();
|
return db.query(aql, long.class).first();
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import static net.tccn.bbs.base.kit.RetCodes.RET_USER_UNLOGIN;
|
|||||||
/**
|
/**
|
||||||
* Created by Lxy at 2017/10/3 13:39.
|
* Created by Lxy at 2017/10/3 13:39.
|
||||||
*/
|
*/
|
||||||
|
@HttpUserType(UserInfo.class)
|
||||||
public class BaseServlet extends HttpServlet {
|
public class BaseServlet extends HttpServlet {
|
||||||
|
|
||||||
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
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) {
|
public int getLimit(HttpRequest request) {
|
||||||
return request.getIntParameter("limit", 1);
|
return request.getIntParameter("limit", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOffset(HttpRequest request) {
|
public int getOffset(HttpRequest request) {
|
||||||
return request.getIntParameter("offset", 10);
|
return request.getIntParameter("offset", 10);
|
||||||
}
|
}
|
||||||
@@ -128,6 +130,7 @@ public class BaseServlet extends HttpServlet {
|
|||||||
String subStr = requestURI.substring(requestURI.lastIndexOf("/") + 1);
|
String subStr = requestURI.substring(requestURI.lastIndexOf("/") + 1);
|
||||||
return subStr.contains("-") ? subStr.substring(0, subStr.indexOf("-")) : subStr;
|
return subStr.contains("-") ? subStr.substring(0, subStr.indexOf("-")) : subStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPara(HttpRequest request, int index) {
|
public String getPara(HttpRequest request, int index) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
String subStr = requestURI.substring(requestURI.lastIndexOf("/") + 1);
|
String subStr = requestURI.substring(requestURI.lastIndexOf("/") + 1);
|
||||||
@@ -139,14 +142,17 @@ public class BaseServlet extends HttpServlet {
|
|||||||
return paraArr.length < index + 1 ? null : paraArr[index];
|
return paraArr.length < index + 1 ? null : paraArr[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getPara(HttpRequest request, int index, T defaultValue) {
|
public <T> T getPara(HttpRequest request, int index, T defaultValue) {
|
||||||
T para = (T) getPara(request, index);
|
T para = (T) getPara(request, index);
|
||||||
return para == null || "".equals(para) ? defaultValue : para;
|
return para == null || "".equals(para) ? defaultValue : para;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getParaToInt(HttpRequest request, int index, int defaultValue) {
|
public int getParaToInt(HttpRequest request, int index, int defaultValue) {
|
||||||
String para = getPara(request, index);
|
String para = getPara(request, index);
|
||||||
return para == null || "".equals(para) ? defaultValue : Integer.parseInt(para);
|
return para == null || "".equals(para) ? defaultValue : Integer.parseInt(para);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getParaToInt(HttpRequest request, int index) {
|
public int getParaToInt(HttpRequest request, int index) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
String para = getPara(request, index);
|
String para = getPara(request, index);
|
||||||
|
@@ -76,6 +76,7 @@ public class JBean<T> /*extends RetResult*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final JBean ok = new JBean(0);
|
private static final JBean ok = new JBean(0);
|
||||||
|
|
||||||
public static JBean ok() {
|
public static JBean ok() {
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@@ -8,5 +8,6 @@ import net.tccn.bbs.base.iface.UI;
|
|||||||
*/
|
*/
|
||||||
public interface UF<I extends UI> {
|
public interface UF<I extends UI> {
|
||||||
int getUserid();
|
int getUserid();
|
||||||
|
|
||||||
I createInfo();
|
I createInfo();
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ import javax.persistence.Column;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
public class ActLogBean implements Serializable, FilterBean {
|
public class ActLogBean implements Serializable, FilterBean {
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
package net.tccn.bbs.base.entity;
|
package net.tccn.bbs.base.entity;
|
||||||
|
|
||||||
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import org.redkale.convert.json.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
@Cacheable(interval = 5 * 60)
|
@Cacheable(interval = 5 * 60)
|
||||||
@@ -12,7 +12,6 @@ import org.redkale.convert.json.*;
|
|||||||
public class ActLog implements java.io.Serializable {
|
public class ActLog implements java.io.Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
|
||||||
@Column(comment = "[日志id]")
|
@Column(comment = "[日志id]")
|
||||||
private int logid;
|
private int logid;
|
||||||
|
|
||||||
|
@@ -8,7 +8,6 @@ import javax.persistence.Id;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
@Cacheable(interval = 5 * 60)
|
@Cacheable(interval = 5 * 60)
|
||||||
|
@@ -9,22 +9,28 @@ public interface UI<I extends UI> {
|
|||||||
|
|
||||||
//抽象方法
|
//抽象方法
|
||||||
int getUserid();
|
int getUserid();
|
||||||
|
|
||||||
UserRecord getUser();
|
UserRecord getUser();
|
||||||
|
|
||||||
I setUser(UserRecord user);
|
I setUser(UserRecord user);
|
||||||
|
|
||||||
//默认实现方法
|
//默认实现方法
|
||||||
default String getRealname() {
|
default String getRealname() {
|
||||||
return getUser() == null ? null : getUser().getRealname();
|
return getUser() == null ? null : getUser().getRealname();
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getNickname() {
|
default String getNickname() {
|
||||||
return getUser() == null ? null : getUser().getNickname();
|
return getUser() == null ? null : getUser().getNickname();
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getSite() {
|
default String getSite() {
|
||||||
return getUser() == null ? "" : getUser().getSite();
|
return getUser() == null ? "" : getUser().getSite();
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getGit() {
|
default String getGit() {
|
||||||
return getUser() == null ? "" : getUser().getGit();
|
return getUser() == null ? "" : getUser().getGit();
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getAvatar() {
|
default String getAvatar() {
|
||||||
return getUser() == null ? null : getUser().getAvatar();
|
return getUser() == null ? null : getUser().getAvatar();
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@ public class EJ {
|
|||||||
public String date(long time) {
|
public String date(long time) {
|
||||||
return date(time, "yyyy-MM-dd HH:mm:ss");
|
return date(time, "yyyy-MM-dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String date(long time, String pattern) {
|
public String date(long time, String pattern) {
|
||||||
return new SimpleDateFormat(pattern).format(time);
|
return new SimpleDateFormat(pattern).format(time);
|
||||||
}
|
}
|
||||||
|
@@ -55,7 +55,6 @@ public abstract class RetCodes {
|
|||||||
public static final int RET_COMMENT_PARA_ILLEGAL = 3004_0002;
|
public static final int RET_COMMENT_PARA_ILLEGAL = 3004_0002;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static RetResult retResult(int retcode) {
|
public static RetResult retResult(int retcode) {
|
||||||
return new RetResult(retcode);
|
return new RetResult(retcode);
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@ import javax.persistence.Column;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
public class UserInfo implements java.io.Serializable {
|
public class UserInfo implements java.io.Serializable {
|
||||||
@@ -178,6 +177,7 @@ public class UserInfo implements java.io.Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用户权限
|
* 检查用户权限
|
||||||
|
*
|
||||||
* @param moduleid
|
* @param moduleid
|
||||||
* @param actionid
|
* @param actionid
|
||||||
* @return
|
* @return
|
||||||
|
@@ -9,7 +9,6 @@ import javax.persistence.Id;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
@Cacheable(interval = 5 * 60)
|
@Cacheable(interval = 5 * 60)
|
||||||
|
@@ -30,19 +30,19 @@ import static net.tccn.bbs.base.kit.RetCodes.*;
|
|||||||
public class UserService extends BaseService {
|
public class UserService extends BaseService {
|
||||||
|
|
||||||
@RestMapping(auth = false, comment = "登录校验")
|
@RestMapping(auth = false, comment = "登录校验")
|
||||||
public RetResult<UserInfo> login(@RestParam(name = "bean") LoginBean loginBean){
|
public RetResult<UserInfo> login(LoginBean bean) {
|
||||||
if (loginBean == null || loginBean.emptyUsername()) return RetCodes.retResult(RetCodes.RET_PARAMS_ILLEGAL, "参数错误");
|
if (bean == null || bean.emptyUsername()) return RetCodes.retResult(RetCodes.RET_PARAMS_ILLEGAL, "参数错误");
|
||||||
|
|
||||||
final RetResult retResult = new RetResult();
|
final RetResult retResult = new RetResult();
|
||||||
|
|
||||||
UserRecord user = source.find(UserRecord.class, "username", loginBean.getUsername());
|
UserRecord user = source.find(UserRecord.class, "username", bean.getUsername());
|
||||||
if (user == null || !Objects.equals(user.getPassword(), loginBean.getPassword())){
|
if (user == null || !Objects.equals(user.getPassword(), bean.getPassword())) {
|
||||||
//log(null, 0, "用户或密码错误");
|
//log(null, 0, "用户或密码错误");
|
||||||
return RetCodes.retResult(RetCodes.RET_USER_ACCOUNT_PWD_ILLEGAL, "用户名或密码错误");
|
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.setRetcode(0);
|
||||||
retResult.setResult(Kv.by("token", loginBean.getSessionid()));
|
retResult.setResult(Kv.by("token", bean.getSessionid()));
|
||||||
retResult.setRetinfo("登录成功.");
|
retResult.setRetinfo("登录成功.");
|
||||||
return retResult;
|
return retResult;
|
||||||
}
|
}
|
||||||
@@ -57,13 +57,14 @@ public class UserService extends BaseService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return userid == 0 ? null : findUserInfo((int)userid);
|
return userid == 0 ? null : find((int) userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "info", comment = "用户信息")
|
@RestMapping(name = "info", comment = "用户信息")
|
||||||
public UserInfo findUserInfo(int userid) {
|
public UserInfo find(int userid) {
|
||||||
UserRecord user = source.find(UserRecord.class, 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 = "退出登录")
|
@RestMapping(name = "logout", auth = false, comment = "退出登录")
|
||||||
@@ -75,7 +76,7 @@ public class UserService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "query", auth = false, comment = "用户数据查询")
|
@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);
|
Sheet<UserRecord> users = source.querySheet(UserRecord.class, flipper, userBean);
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
@@ -94,43 +95,44 @@ public class UserService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "register", auth = false, comment = "用户注册")
|
@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 (bean.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.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, "用户名已存在");
|
if (_user != null) return RetCodes.retResult(RET_USER_USERNAME_EXISTS, "用户名已存在");
|
||||||
|
|
||||||
user.setCreatetime(System.currentTimeMillis());
|
bean.setCreatetime(System.currentTimeMillis());
|
||||||
user.setPassword(user.passwordForMd5());
|
bean.setPassword(bean.passwordForMd5());
|
||||||
user.setStatus((short) 10);
|
bean.setStatus((short) 10);
|
||||||
user.setUsername(user.getEmail());
|
bean.setUsername(bean.getEmail());
|
||||||
user.setAvatar("/res/images/avatar/"+ new Random().nextInt(21) +".jpg");//默认头像
|
bean.setAvatar("/res/images/avatar/" + new Random().nextInt(21) + ".jpg");//默认头像
|
||||||
|
|
||||||
int maxId = source.getNumberResult(UserRecord.class, FilterFunc.MAX, 10_0000, "userid").intValue();
|
int maxId = source.getNumberResult(UserRecord.class, FilterFunc.MAX, 10_0000, "userid").intValue();
|
||||||
if (maxId < 10_0000) maxId = 10_0000;
|
if (maxId < 10_0000) maxId = 10_0000;
|
||||||
user.setUserid(maxId+1);
|
bean.setUserid(maxId + 1);
|
||||||
source.insert(user);
|
source.insert(bean);
|
||||||
|
|
||||||
//记录日志
|
//记录日志
|
||||||
return RetResult.success();
|
return RetResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "update", comment = "用户信息修改")
|
@RestMapping(name = "update", comment = "用户信息修改")
|
||||||
public RetResult userUpdate(@RestSessionid String sessionid, @RestParam(name = "bean") UserRecord user, String[] columns){
|
public RetResult userUpdate(UserInfo user, UserRecord bean, String[] columns) {
|
||||||
String nickname = user.getNickname();
|
String nickname = bean.getNickname();
|
||||||
if (nickname == null && nickname.isEmpty())
|
if (nickname == null && nickname.isEmpty())
|
||||||
return RetCodes.retResult(RET_USER_NICKNAME_ILLEGAL, "昵称无效");
|
return RetCodes.retResult(RET_USER_NICKNAME_ILLEGAL, "昵称无效");
|
||||||
|
|
||||||
nickname = nickname.replace(" ", "");
|
nickname = nickname.replace(" ", "");
|
||||||
UserRecord _user = source.find(UserRecord.class, FilterNode.create("nickname", nickname));
|
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, "昵称已存在");
|
return RetCodes.retResult(RET_USER_NICKNAME_EXISTS, "昵称已存在");
|
||||||
|
|
||||||
user.setNickname(nickname);//去除昵称中的空格
|
bean.setNickname(nickname);//去除昵称中的空格
|
||||||
source.updateColumn(user
|
source.updateColumn(bean
|
||||||
,FilterNode.create("userid", currentUserid(sessionid))
|
, FilterNode.create("userid", user.getUserid())
|
||||||
, SelectColumn.includes(columns)
|
, SelectColumn.includes(columns)
|
||||||
);
|
);
|
||||||
return RetResult.success();
|
return RetResult.success();
|
||||||
|
@@ -1,15 +1,13 @@
|
|||||||
package net.tccn.bbs.comment;
|
package net.tccn.bbs.comment;
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
|
|
||||||
import net.tccn.bbs.base.iface.C;
|
import net.tccn.bbs.base.iface.C;
|
||||||
import net.tccn.bbs.base.kit.LxyKit;
|
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;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
@Cacheable(interval = 5 * 60)
|
@Cacheable(interval = 5 * 60)
|
||||||
@@ -17,7 +15,6 @@ import java.io.Serializable;
|
|||||||
public class Comment implements Serializable, C<CommentInfo> {
|
public class Comment implements Serializable, C<CommentInfo> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
|
||||||
@Column(comment = "[评论id]")
|
@Column(comment = "[评论id]")
|
||||||
private int commentid;
|
private int commentid;
|
||||||
|
|
||||||
|
@@ -9,7 +9,6 @@ import javax.persistence.Column;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
public class CommentInfo implements UI<CommentInfo>, Serializable, CI<CommentInfo> {
|
public class CommentInfo implements UI<CommentInfo>, Serializable, CI<CommentInfo> {
|
||||||
|
@@ -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.
|
* 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> {
|
public class CommentService extends BaseService implements UIService<CommentInfo> {
|
||||||
|
|
||||||
@RestMapping(name = "save", comment = "评论保存")
|
@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();
|
int contentid = comment.getContentid();
|
||||||
|
|
||||||
//数据校验
|
//数据校验
|
||||||
@@ -57,7 +57,7 @@ public class CommentService extends BaseService implements UIService<CommentInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(name = "query", auth = false, comment = "查询评论")
|
@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);
|
int userid = currentUserid(sessionid);
|
||||||
|
|
||||||
flipper.setSort("supportnum DESC,commentid ASC");
|
flipper.setSort("supportnum DESC,commentid ASC");
|
||||||
@@ -80,7 +80,7 @@ public class CommentService extends BaseService implements UIService<CommentInfo
|
|||||||
return infos;
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RestMapping(ignore = true, comment = "查询用户评论数据")
|
@org.redkale.util.Comment("查询用户评论数据")
|
||||||
public Sheet<CommentInfo> queryByUserid(int userid) {
|
public Sheet<CommentInfo> queryByUserid(int userid) {
|
||||||
Sheet<Comment> comments = source.querySheet(Comment.class, new Flipper().sort("createtime DESC"), FilterNode.create("userid", 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:用户评论榜 待完成
|
* todo:用户评论榜 待完成
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RestMapping(ignore = true, name = "rankuser", auth = false, comment = "用户评论榜")
|
@org.redkale.util.Comment("用户评论榜")
|
||||||
public Map<String, Number> commentRank() {
|
public Map<String, Number> commentRank() {
|
||||||
Flipper flipper = new Flipper().limit(8);
|
Flipper flipper = new Flipper().limit(8);
|
||||||
source.querySheet(Comment.class, flipper, FilterNode.create("userid", FilterExpress.IN));
|
source.querySheet(Comment.class, flipper, FilterNode.create("userid", FilterExpress.IN));
|
||||||
|
@@ -9,7 +9,6 @@ import javax.persistence.*;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
@Cacheable(interval = 5 * 60)
|
@Cacheable(interval = 5 * 60)
|
||||||
@@ -17,7 +16,6 @@ import java.io.Serializable;
|
|||||||
public class Content implements Serializable, C<ContentInfo> {
|
public class Content implements Serializable, C<ContentInfo> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
|
||||||
@Column(comment = "[内容id]")
|
@Column(comment = "[内容id]")
|
||||||
private int contentid;
|
private int contentid;
|
||||||
|
|
||||||
|
@@ -4,19 +4,16 @@ import org.redkale.convert.json.JsonConvert;
|
|||||||
import org.redkale.source.FilterBean;
|
import org.redkale.source.FilterBean;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
@Table(catalog = "db_redbbs", name = "content", comment = "[内容表]")
|
@Table(catalog = "db_redbbs", name = "content", comment = "[内容表]")
|
||||||
public class ContentBean implements FilterBean, java.io.Serializable {
|
public class ContentBean implements FilterBean, java.io.Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
|
||||||
@Column(comment = "[内容id]")
|
@Column(comment = "[内容id]")
|
||||||
private int contentid;
|
private int contentid;
|
||||||
|
|
||||||
|
@@ -161,6 +161,7 @@ public class ContentInfo implements UI<ContentInfo>,Serializable, CI {
|
|||||||
|
|
||||||
//-----------
|
//-----------
|
||||||
private UserRecord user;
|
private UserRecord user;
|
||||||
|
|
||||||
@ConvertColumn(ignore = true)
|
@ConvertColumn(ignore = true)
|
||||||
@Override
|
@Override
|
||||||
public UserRecord getUser() {
|
public UserRecord getUser() {
|
||||||
|
@@ -7,9 +7,15 @@ import net.tccn.bbs.base.iface.UIService;
|
|||||||
import net.tccn.bbs.base.kit.RetCodes;
|
import net.tccn.bbs.base.kit.RetCodes;
|
||||||
import net.tccn.bbs.base.user.UserInfo;
|
import net.tccn.bbs.base.user.UserInfo;
|
||||||
import net.tccn.bbs.base.user.UserService;
|
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.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.Comment;
|
||||||
import org.redkale.util.SelectColumn;
|
import org.redkale.util.SelectColumn;
|
||||||
import org.redkale.util.Sheet;
|
import org.redkale.util.Sheet;
|
||||||
@@ -19,13 +25,13 @@ import javax.annotation.Resource;
|
|||||||
/**
|
/**
|
||||||
* Created by Lxy at 2017/11/26 9:33.
|
* 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> {
|
public class ContentService extends BaseService implements UIService<ContentInfo> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected UserService userService;
|
protected UserService userService;
|
||||||
|
|
||||||
@RestMapping(ignore = true, comment = "根据条件查询帖子数据")
|
@Comment("根据条件查询帖子数据")
|
||||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode) {
|
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode) {
|
||||||
Sheet<Content> contents = source.querySheet(Content.class, flipper, 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 = "内容列表")
|
@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);
|
UserInfo current = userService.current(sessionid);
|
||||||
int currentid = current == null ? 0 : current.getUserid();
|
int currentid = current == null ? 0 : current.getUserid();
|
||||||
|
|
||||||
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -10);
|
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -10);
|
||||||
switch (actived) {
|
switch (actived) {
|
||||||
case "top": filterNode.and("top", FilterExpress.GREATERTHANOREQUALTO, 20);break;
|
case "top":
|
||||||
case "untop": filterNode.and("top", 10);break;
|
filterNode.and("top", FilterExpress.GREATERTHANOREQUALTO, 20);
|
||||||
case "unsolved": filterNode.and("solved", 10);break;
|
break;
|
||||||
case "solved": filterNode.and("solved", 20);break;
|
case "untop":
|
||||||
case "wonderful": filterNode.and("wonderful", FilterExpress.GREATERTHANOREQUALTO, 20);break;
|
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)) {//私密贴:非管理员限制查看
|
if (!userService.isAdmin(currentid)) {//私密贴:非管理员限制查看
|
||||||
@@ -61,25 +77,25 @@ public class ContentService extends BaseService implements UIService<ContentInfo
|
|||||||
|
|
||||||
|
|
||||||
@RestMapping(name = "save", comment = "帖子保存")
|
@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个字节");
|
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();
|
int maxId = source.getNumberResult(Content.class, FilterFunc.MAX, 10_0000, "contentid").intValue();
|
||||||
content.setContentid(maxId+1);
|
bean.setContentid(maxId + 1);
|
||||||
content.setCreatetime(System.currentTimeMillis());
|
bean.setCreatetime(System.currentTimeMillis());
|
||||||
content.setUserid(userid);
|
bean.setUserid(userid);
|
||||||
|
|
||||||
source.insert(content);
|
source.insert(bean);
|
||||||
} else {
|
} else {
|
||||||
source.findAsync(Content.class, content.getContentid()).thenAccept(x->{
|
source.findAsync(Content.class, bean.getContentid()).thenAccept(x -> {
|
||||||
if (x.getUserid() == userid || userService.isAdmin(userid)) {//身份验证 后修改内容
|
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 = "帖子详情")
|
@RestMapping(name = "info", auth = false, comment = "帖子详情")
|
||||||
public ContentInfo contentInfo(@RestSessionid String sessionid, int contentid){
|
public ContentInfo info(UserInfo user, int contentid) {
|
||||||
int userId = userService.currentUserid(sessionid);
|
int userId = user != null ? user.getUserid() : 0;
|
||||||
|
|
||||||
Content content = source.find(Content.class, contentid);
|
Content content = source.find(Content.class, contentid);
|
||||||
if (content == null) return null;
|
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");
|
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();
|
Sheet<UserInfo> lastReg = userService.lastReg();
|
||||||
|
@@ -2,6 +2,7 @@ package net.tccn.bbs.servlet;
|
|||||||
|
|
||||||
import com.jfinal.kit.Kv;
|
import com.jfinal.kit.Kv;
|
||||||
import net.tccn.bbs.base.BaseServlet;
|
import net.tccn.bbs.base.BaseServlet;
|
||||||
|
import net.tccn.bbs.base.user.UserInfo;
|
||||||
import net.tccn.bbs.comment.CommentInfo;
|
import net.tccn.bbs.comment.CommentInfo;
|
||||||
import net.tccn.bbs.content.ContentInfo;
|
import net.tccn.bbs.content.ContentInfo;
|
||||||
import org.redkale.net.http.*;
|
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");
|
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())
|
Kv kv = Kv.by("contents", contents).set("url", request.getRequestURI())
|
||||||
.set("actived", actived).set("curr", curr);
|
.set("actived", actived).set("curr", curr);
|
||||||
@@ -36,10 +37,12 @@ public class ContentServlet extends BaseServlet {
|
|||||||
@HttpParam(name = "#", type = int.class, comment = "内容ID")
|
@HttpParam(name = "#", type = int.class, comment = "内容ID")
|
||||||
public void add(HttpRequest request, HttpResponse response) {
|
public void add(HttpRequest request, HttpResponse response) {
|
||||||
int contentid = getParaToInt(request, 0);
|
int contentid = getParaToInt(request, 0);
|
||||||
|
String sessionid = request.getSessionid(false);
|
||||||
|
UserInfo user = userService.current(sessionid);
|
||||||
|
|
||||||
ContentInfo contentInfo = null;
|
ContentInfo contentInfo = null;
|
||||||
if (contentid > 0) {
|
if (contentid > 0) {
|
||||||
contentInfo = contentService.contentInfo(request.getSessionid(false), contentid);
|
contentInfo = contentService.info(user, contentid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Kv kv = Kv.by("bean", contentInfo);
|
Kv kv = Kv.by("bean", contentInfo);
|
||||||
@@ -50,9 +53,10 @@ public class ContentServlet extends BaseServlet {
|
|||||||
public void detail(HttpRequest request, HttpResponse response) {
|
public void detail(HttpRequest request, HttpResponse response) {
|
||||||
int contentid = getParaToInt(request, 0);
|
int contentid = getParaToInt(request, 0);
|
||||||
String sessionid = request.getSessionid(false);
|
String sessionid = request.getSessionid(false);
|
||||||
|
UserInfo user = userService.current(sessionid);
|
||||||
|
|
||||||
ContentInfo content = contentService.contentInfo(sessionid, contentid);
|
ContentInfo content = contentService.info(user, contentid);
|
||||||
Sheet<CommentInfo> comments = commentService.commentQuery(sessionid,contentid, new Flipper().limit(30));
|
Sheet<CommentInfo> comments = commentService.query(sessionid, contentid, new Flipper().limit(30));
|
||||||
|
|
||||||
//热帖
|
//热帖
|
||||||
//Flipper flipper2 = new Flipper().limit(8).sort("viewNum DESC");
|
//Flipper flipper2 = new Flipper().limit(8).sort("viewNum DESC");
|
||||||
|
@@ -32,7 +32,7 @@ public class FileServlet extends BaseServlet {
|
|||||||
String name = part.getName();
|
String name = part.getName();
|
||||||
String suffix = name.substring(name.lastIndexOf("."));
|
String suffix = name.substring(name.lastIndexOf("."));
|
||||||
String path = String.format(format, System.currentTimeMillis()) + suffix;
|
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();
|
destFile.getParentFile().mkdir();
|
||||||
|
|
||||||
part.save(destFile);
|
part.save(destFile);
|
||||||
|
@@ -71,10 +71,11 @@ public class IndexServlet extends BaseServlet {
|
|||||||
@HttpMapping(url = "/project", auth = false, comment = "项目首页")
|
@HttpMapping(url = "/project", auth = false, comment = "项目首页")
|
||||||
public void project(HttpRequest request, HttpResponse response) {
|
public void project(HttpRequest request, HttpResponse response) {
|
||||||
String sessionid = request.getSessionid(false);
|
String sessionid = request.getSessionid(false);
|
||||||
|
UserInfo user = userService.current(sessionid);
|
||||||
int contentid = 22;
|
int contentid = 22;
|
||||||
|
|
||||||
ContentInfo content = contentService.contentInfo(sessionid, contentid);
|
ContentInfo content = contentService.info(user, contentid);
|
||||||
Sheet<CommentInfo> comments = commentService.commentQuery(sessionid,contentid, new Flipper().limit(30));
|
Sheet<CommentInfo> comments = commentService.query(sessionid, contentid, new Flipper().limit(30));
|
||||||
|
|
||||||
Kv kv = Kv.by("bean", content).set("comments", comments);
|
Kv kv = Kv.by("bean", content).set("comments", comments);
|
||||||
response.finish(HttpScope.refer("/project/index.html").attr(kv));
|
response.finish(HttpScope.refer("/project/index.html").attr(kv));
|
||||||
|
@@ -26,6 +26,7 @@ public class UserServlet extends BaseServlet {
|
|||||||
|
|
||||||
response.finish(HttpScope.refer("/user/login.html"));
|
response.finish(HttpScope.refer("/user/login.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@HttpMapping(url = "/user/reg", auth = false, comment = "前往登录页")
|
@HttpMapping(url = "/user/reg", auth = false, comment = "前往登录页")
|
||||||
public void reg(HttpRequest request, HttpResponse response) {
|
public void reg(HttpRequest request, HttpResponse response) {
|
||||||
/*List<Kv> list = new ArrayList<>();
|
/*List<Kv> list = new ArrayList<>();
|
||||||
@@ -75,7 +76,7 @@ public class UserServlet extends BaseServlet {
|
|||||||
String nickname = request.getParameter("nickname");
|
String nickname = request.getParameter("nickname");
|
||||||
UserBean userBean = new UserBean();
|
UserBean userBean = new UserBean();
|
||||||
userBean.setNickname(nickname);
|
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) {
|
if (users.getTotal() > 0) {
|
||||||
userid = users.stream().findFirst().orElse(null).getUserid();
|
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");
|
Flipper flipper = new Flipper().limit(8).sort("createtime DESC");
|
||||||
|
@@ -14,7 +14,6 @@ import java.util.Random;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Created by liangxianyou at 2018/7/8 22:51.
|
* Created by liangxianyou at 2018/7/8 22:51.
|
||||||
*/
|
*/
|
||||||
@RestWebSocket(name = "chat", catalog = "ws", comment = "文字聊天", anyuser = true)
|
@RestWebSocket(name = "chat", catalog = "ws", comment = "文字聊天", anyuser = true)
|
||||||
|
@@ -5,7 +5,6 @@ import org.redkale.convert.json.JsonConvert;
|
|||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author lxyer
|
* @author lxyer
|
||||||
*/
|
*/
|
||||||
@Cacheable(interval = 5 * 60)
|
@Cacheable(interval = 5 * 60)
|
||||||
@@ -13,7 +12,6 @@ import javax.persistence.*;
|
|||||||
public class MsgRecord implements java.io.Serializable {
|
public class MsgRecord implements java.io.Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
|
||||||
@Column(comment = "[主键id]")
|
@Column(comment = "[主键id]")
|
||||||
private int msgid;
|
private int msgid;
|
||||||
|
|
||||||
|
@@ -92,7 +92,6 @@ public class ImFriendServiceImpl extends BaseService implements ImFriendService
|
|||||||
//sncpTransportFactory.addGroupInfo(groupInfo);
|
//sncpTransportFactory.addGroupInfo(groupInfo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return friends(sessionid);
|
return friends(sessionid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,52 +6,64 @@ import org.redkale.service.Service;
|
|||||||
public interface ImFriendService extends Service {
|
public interface ImFriendService extends Service {
|
||||||
|
|
||||||
//================ 查询相关 =================
|
//================ 查询相关 =================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分组好友数据
|
* 分组好友数据
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JBean friends(String sessionid);
|
JBean friends(String sessionid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件查询好友
|
* 根据条件查询好友
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JBean friendList(String sessionid);
|
JBean friendList(String sessionid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 群组数据
|
* 群组数据
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JBean groups(String sessionid);
|
JBean groups(String sessionid);
|
||||||
|
|
||||||
|
|
||||||
//================ 操作好友相关 =================
|
//================ 操作好友相关 =================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存好友分组
|
* 保存好友分组
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JBean itemSave(String sessionid);
|
JBean itemSave(String sessionid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加好友
|
* 添加好友
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JBean addFriend(String sessionid);
|
JBean addFriend(String sessionid);
|
||||||
|
|
||||||
//================ 操作群组相关 =================
|
//================ 操作群组相关 =================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存群组
|
* 保存群组
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JBean groupSave(String sessionid);
|
JBean groupSave(String sessionid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加入群组
|
* 加入群组
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JBean addGroup(String sessionid);
|
JBean addGroup(String sessionid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录人用户id
|
* 登录人用户id
|
||||||
|
*
|
||||||
* @param sessionid
|
* @param sessionid
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@@ -12,6 +12,7 @@ public interface ImMsgService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息入库
|
* 消息入库
|
||||||
|
*
|
||||||
* @param msg
|
* @param msg
|
||||||
*/
|
*/
|
||||||
JBean insert(MsgRecord... msg);
|
JBean insert(MsgRecord... msg);
|
||||||
@@ -23,6 +24,7 @@ public interface ImMsgService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 历史消息
|
* 历史消息
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JBean list();
|
JBean list();
|
||||||
@@ -36,6 +38,7 @@ public interface ImMsgService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取离线消息
|
* 获取离线消息
|
||||||
|
*
|
||||||
* @param userid
|
* @param userid
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user