升级:redkale-2.8
This commit is contained in:
parent
d8b0879bba
commit
e1b1b35552
29
conf/application.properties
Normal file
29
conf/application.properties
Normal file
@ -0,0 +1,29 @@
|
||||
redkale.name=app_local
|
||||
redkale.port=2060
|
||||
redkale.excludelibs.value=^.*mysql.*$;^.*google.*$
|
||||
redkale.properties.load=config.properties
|
||||
# --- executor ---
|
||||
# redkale.executor.threads = 32
|
||||
# redkale.executor.hash = true
|
||||
# --- listener ---
|
||||
# redkale.listener[0].value =
|
||||
# ========================== server ===============================
|
||||
redkale.server[0].protocol=HTTP
|
||||
redkale.server[0].port=6060
|
||||
redkale.server[0].host=0.0.0.0
|
||||
redkale.server[0].maxbody=2m
|
||||
redkale.server[0].services[0].autoload=true
|
||||
# --- rest ---
|
||||
redkale.server[0].rest.path=os
|
||||
redkale.server[0].rest.autoload=true
|
||||
redkale.server[0].rest.base=net.tccn.bbs.base.BaseServlet
|
||||
# --- request ---
|
||||
redkale.server[0].request.remoteaddr=request.headers.X-Real-IP
|
||||
# --- servlets ---
|
||||
redkale.server[0].servlets.autoload=true
|
||||
redkale.server[0].render.value=net.tccn.bbs.base.TplRender
|
||||
#redkale.server[0].render.suffixs = .html
|
||||
# --- response ---
|
||||
# redkale.server[0].response.addheader[0].name = X-Node
|
||||
# redkale.server[0].response.addheader[0].value = system.property.APP_NODE
|
||||
# =================================================================
|
@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<application port="5002">
|
||||
<resources>
|
||||
<listener value="net.tccn.redim.RedbbsListener"/>
|
||||
<source name="redis" value="org.redkalex.cache.RedisCacheSource" xxx="16">
|
||||
<node addr="127.0.0.1" password="123456" port="6379"/>
|
||||
</source>
|
||||
<properties load="conf.txt"/>
|
||||
</resources>
|
||||
|
||||
<server host="0.0.0.0" port="80" protocol="HTTP" root="root">
|
||||
<services autoload="true"/>
|
||||
<rest autoload="true" base="net.tccn.bbs.base.BaseServlet" path="os"/>
|
||||
|
||||
<request>
|
||||
<remoteaddr value="request.headers.X-Real-IP"/>
|
||||
</request>
|
||||
<response>
|
||||
<addheader name="Access-Control-Allow-Origin" value="request.headers.Origin"/>
|
||||
<setheader name="Access-Control-Allow-Headers" value="request.headers.Access-Control-Request-Headers"/>
|
||||
<setheader name="Access-Control-Allow-Credentials" value="true"/>
|
||||
<options auto="true"/>
|
||||
</response>
|
||||
|
||||
<servlets autoload="true" path=""/>
|
||||
<render value="net.tccn.bbs.base.TplRender"/>
|
||||
</server>
|
||||
|
||||
</application>
|
||||
|
@ -1,3 +1,3 @@
|
||||
----------- file conf ----------
|
||||
# upload config
|
||||
file.upload_dir=${APP_HOME}/root/upload/
|
||||
file.view_path=http://127.0.0.1/upload/
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
|
||||
|
||||
<persistence-unit name="redbbs" transaction-type="RESOURCE_LOCAL">
|
||||
<shared-cache-mode>ALL</shared-cache-mode>
|
||||
<properties>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306"/>
|
||||
<property name="javax.persistence.jdbc.user" value="root"/>
|
||||
<property name="javax.persistence.jdbc.password" value="123456"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
|
||||
</persistence>
|
9
conf/source.properties
Normal file
9
conf/source.properties
Normal file
@ -0,0 +1,9 @@
|
||||
############ DataSource @Resource(name="redbbs") ############
|
||||
# redbbs
|
||||
redkale.datasource[redbbs].url=jdbc:mysql://127.0.0.1:3306/redbbs
|
||||
redkale.datasource[redbbs].user=root
|
||||
redkale.datasource[redbbs].password=123456
|
||||
############ CacheSource @Resource(name="redis_cache") ############
|
||||
redkale.cachesource[redis_cache].node[0].url=redis://127.0.0.1:6379
|
||||
redkale.cachesource[redis_cache].node[0].password=123456
|
||||
redkale.cachesource[redis_cache].node[0].db=0
|
9
pom.xml
9
pom.xml
@ -17,12 +17,12 @@
|
||||
<dependency>
|
||||
<groupId>org.redkale</groupId>
|
||||
<artifactId>redkale</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.8.0-dev</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.redkalex</groupId>
|
||||
<artifactId>redkale-plugins</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.8.0-dev</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -40,6 +40,7 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -52,8 +53,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -15,17 +15,12 @@ public class BaseService implements Service {
|
||||
|
||||
protected final int sessionExpireSeconds = 7 * 24 * 60 * 60;
|
||||
|
||||
protected static final RetResult RET_SUCCESS = RetResult.success();
|
||||
protected final static RetResult RET_SUCCESS = RetResult.success();
|
||||
|
||||
@Resource(name = "redbbs")
|
||||
protected DataSource dataSource;
|
||||
|
||||
/* 使用redis 代码中配置此处即可
|
||||
@Resource(name = "redis")*/
|
||||
@Resource(name = "cacheSource")
|
||||
protected CacheSource<Long> sessions;
|
||||
|
||||
@Resource(name = "cacheSource")
|
||||
@Resource(name = "redis_cache")
|
||||
protected CacheSource cacheSource;
|
||||
|
||||
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
||||
@ -38,4 +33,5 @@ public class BaseService implements Service {
|
||||
protected RetResult retError(String info) {
|
||||
return new RetResult<>(-1, info);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ public class BaseServlet extends HttpServlet {
|
||||
|
||||
@Override
|
||||
protected void preExecute(HttpRequest request, HttpResponse response) throws IOException {
|
||||
|
||||
String sessionid = request.getSessionid(true);
|
||||
int currentid = 0;
|
||||
if (sessionid != null) {
|
||||
@ -64,6 +63,10 @@ public class BaseServlet extends HttpServlet {
|
||||
response.finish(HttpScope.refer(uri));
|
||||
return;
|
||||
}
|
||||
if (uri.startsWith("/upload/")) {
|
||||
response.finish(HttpScope.refer(uri));
|
||||
return;
|
||||
}
|
||||
|
||||
//异步记录访问日志
|
||||
final int userid = currentid;
|
||||
@ -74,9 +77,7 @@ public class BaseServlet extends HttpServlet {
|
||||
para.set(key, request.getParameter(key));
|
||||
}
|
||||
Kv headers = Kv.create();
|
||||
request.getHeaders().forEach((k, v) -> {
|
||||
headers.set(k, request.getHeader(k));
|
||||
});
|
||||
request.getHeaders().forEach((k, v) -> headers.set(k, request.getHeader(k)));
|
||||
|
||||
VisLog visLog = new VisLog();
|
||||
visLog.setIp(request.getRemoteAddr());
|
||||
@ -99,7 +100,7 @@ public class BaseServlet extends HttpServlet {
|
||||
|
||||
@Override
|
||||
protected void authenticate(HttpRequest request, HttpResponse response) throws IOException {
|
||||
if (request.currentUser() == null) {
|
||||
if (request.currentIntUserid() == 0) {
|
||||
if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) {
|
||||
response.finish(RetCodes.retResult(RET_USER_UNLOGIN, "未登录,登录后重试").toString());
|
||||
} else {
|
||||
@ -141,10 +142,6 @@ public class BaseServlet extends HttpServlet {
|
||||
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;
|
||||
@ -155,19 +152,19 @@ public class BaseServlet extends HttpServlet {
|
||||
try {
|
||||
n = Integer.parseInt(para);
|
||||
} catch (Exception e) {
|
||||
|
||||
//throw new RuntimeException(e);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
//设置私密帖子过滤
|
||||
protected FilterNode setPrivate(HttpRequest request, FilterNode node) {
|
||||
UserInfo user = request.currentUser();
|
||||
if (user == null) {
|
||||
UserInfo userInfo = request.currentUser();
|
||||
if (userInfo == null) {
|
||||
node.and("status", FilterExpress.NOTEQUAL, 30);
|
||||
} else if (!userService.isAdmin(user.getUserid())) {
|
||||
} else if (!userService.isAdmin(userInfo.getUserid())) {
|
||||
//select * from content c where c.status != -1 and (c.status!=30 or (c.status=30 and c.userid=100001))
|
||||
node.and(FilterNode.create("status", FilterExpress.NOTEQUAL, 30).or(FilterNode.create("status", 30).and("userid", user.getUserid())));
|
||||
node.and(FilterNode.create("status", FilterExpress.NOTEQUAL, 30).or(FilterNode.create("status", 30).and("userid", userInfo.getUserid())));
|
||||
}
|
||||
|
||||
return node;
|
||||
|
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Created by JUECHENG at 2018/1/30 0:18.
|
||||
*/
|
||||
public class TplRender implements HttpRender<HttpScope> {
|
||||
public class TplRender implements HttpRender {
|
||||
|
||||
@Resource(name = "SERVER_ROOT")
|
||||
protected File webroot;
|
||||
@ -37,25 +37,17 @@ public class TplRender implements HttpRender<HttpScope> {
|
||||
|
||||
@Override
|
||||
public void renderTo(HttpRequest request, HttpResponse response, Convert convert, HttpScope scope) {
|
||||
//UserInfo mine = request.currentUser();//当前登录人
|
||||
String sessionid = request.getSessionid(false);
|
||||
UserInfo mine = userService.current(sessionid);//当前登录人
|
||||
|
||||
Template template = engine.getTemplate(scope.getReferid());
|
||||
Map attr = scope.getAttributes();
|
||||
if (attr == null) {
|
||||
attr = Kv.create();
|
||||
}
|
||||
|
||||
UserInfo userInfo = userService.find(request.currentUserid(int.class));
|
||||
attr.put("mine", userInfo);
|
||||
attr.put("token", request.getSessionid(false));
|
||||
if (attr == null) attr = Kv.create();
|
||||
attr.put("mine", mine);
|
||||
attr.put("token", sessionid);
|
||||
|
||||
String str = template.renderToString(attr);
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
response.finish(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getType() {
|
||||
return HttpScope.class;
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,6 @@
|
||||
package net.tccn.bbs.base;
|
||||
|
||||
import net.tccn.bbs.base.util.Kv;
|
||||
import org.redkale.source.DataJdbcSource;
|
||||
import org.redkale.source.DataSource;
|
||||
import org.redkale.source.Flipper;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.util.Reproduce;
|
||||
import org.redkale.util.Sheet;
|
||||
@ -42,7 +39,7 @@ public final class Utils {
|
||||
}
|
||||
|
||||
public static String dateFmt(long time) {
|
||||
/**
|
||||
/*
|
||||
* 刚刚 60秒内 60 * 1000
|
||||
* x分钟前 1小时候内 60 * 60*1000
|
||||
* x小时前 1天内 24 * 60*60*1000
|
||||
@ -86,15 +83,15 @@ public final class Utils {
|
||||
}
|
||||
|
||||
public static <T> T[] listToArray(List list, T[] ts) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ts[0] = (T) list.get(i);
|
||||
for (Object o : list) {
|
||||
ts[0] = (T) o;
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
public static int[] listToArray(List list, int[] ts) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ts[0] = (int) list.get(i);
|
||||
for (Object o : list) {
|
||||
ts[0] = (int) o;
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
@ -121,7 +118,7 @@ public final class Utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Map<String, Reproduce> reproduceMap = new HashMap<>();
|
||||
private static final Map<String, Reproduce> reproduceMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @param d 目标对象
|
||||
@ -134,11 +131,9 @@ public final class Utils {
|
||||
String reproductKey = d.getClass().getName() + "_" + s.getClass().getName();
|
||||
|
||||
Reproduce<D, S> reproduce = reproduceMap.get(reproductKey);
|
||||
if (reproduce == null) {
|
||||
if (reproduce == null) {
|
||||
reproduceMap.put(reproductKey, reproduce = (Reproduce<D, S>) Reproduce.create(d.getClass(), s.getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
return reproduce.apply(d, s);
|
||||
}
|
||||
@ -169,6 +164,7 @@ public final class Utils {
|
||||
Kv row = Kv.of();
|
||||
for (int i = 1; i <= count; i++) {
|
||||
String columnTypeName = metaData.getColumnTypeName(i);
|
||||
//String columnName = metaData.getColumnName(i);
|
||||
String columnLabel = metaData.getColumnLabel(i);
|
||||
row.put(columnLabel, null);
|
||||
|
||||
@ -231,7 +227,6 @@ public final class Utils {
|
||||
*/
|
||||
public static <T> List<T> mix(List<T> list) {
|
||||
int len = list.size();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < len; i++) {
|
||||
int r = random.nextInt(len);
|
||||
if (i == r) continue;
|
||||
@ -255,7 +250,6 @@ public final class Utils {
|
||||
@Comment("获取随机数字符")
|
||||
public static String randomNumber(int len) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < len; i++) {
|
||||
sb.append(random.nextInt(9));
|
||||
}
|
||||
@ -265,7 +259,6 @@ public final class Utils {
|
||||
@Comment("获取随机数集合")
|
||||
private static List<Integer> getRandoms(int max, int len) {
|
||||
Set<Integer> randoms = new HashSet<>();
|
||||
Random random = new Random();
|
||||
while (randoms.size() < len && randoms.size() < max) {
|
||||
randoms.add(random.nextInt(max));
|
||||
}
|
||||
@ -298,7 +291,7 @@ public final class Utils {
|
||||
*/
|
||||
public static int strLength(String value) {
|
||||
int valueLength = 0;
|
||||
String chinese = "[\u4e00-\u9fa5]";
|
||||
String chinese = "[一-龥]";
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
String temp = value.substring(i, i + 1);
|
||||
if (temp.matches(chinese)) {
|
||||
@ -552,9 +545,9 @@ public final class Utils {
|
||||
|
||||
@Comment("对象转GET请求参数转换为字符,结果:p1=v1&p2=v2&p3=v3")
|
||||
public static String convertHttpParams(Object o, List<String> removeFields, boolean encode) {
|
||||
Class<? extends Object> c = o.getClass();
|
||||
Class<?> c = o.getClass();
|
||||
Field[] fields = c.getDeclaredFields();
|
||||
Map<String, Object> map = new TreeMap<String, Object>();
|
||||
Map<String, Object> map = new TreeMap<>();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
String name = field.getName();
|
||||
@ -579,13 +572,13 @@ public final class Utils {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
Set<String> sortSet = new TreeSet<String>();
|
||||
Set<String> sortSet = new TreeSet<>();
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
sortSet.add(entry.getKey());
|
||||
}
|
||||
|
||||
// 参数名按ASCII码从小到大排序(字典序),然后使用( & )连接排好序的key=value集合
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean isFirst = true;
|
||||
for (String key : sortSet) {
|
||||
if (isFirst) {
|
||||
@ -601,7 +594,7 @@ public final class Utils {
|
||||
|
||||
@Comment("对象转map")
|
||||
public static Map<String, Object> convertToMap(Object o, List<String> removeFields) {
|
||||
Class<? extends Object> c = o.getClass();
|
||||
Class<?> c = o.getClass();
|
||||
List<Field> fields = Stream.of(c.getDeclaredFields()).collect(Collectors.toList());
|
||||
if (c.getSuperclass() != null) {
|
||||
Field[] superFields = c.getSuperclass().getDeclaredFields();
|
||||
@ -654,32 +647,6 @@ public final class Utils {
|
||||
return String.format("{%s}", builder.deleteCharAt(builder.length() - 1).toString());
|
||||
}
|
||||
|
||||
public static <T> Sheet<T> querySheetBySql(DataSource dataSource, String sql, Flipper flipper, Class<T> type) {
|
||||
DataJdbcSource jdbcSource = (DataJdbcSource) dataSource;
|
||||
//总条数
|
||||
int total = jdbcSource.directQuery("select count(0) c from (" + sql + ") c", rs -> {
|
||||
int result = 0;
|
||||
try {
|
||||
while (rs.next()) {
|
||||
result = rs.getInt(1);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
if (total == 0) {
|
||||
return new Sheet<>(0, new ArrayList<>());
|
||||
}
|
||||
|
||||
if (flipper != null) {
|
||||
sql = String.format("%s %s limit %s,%s ", sql, Utils.isEmpty(flipper.getSort()) ? "" : "order by " + flipper.getSort(), flipper.getOffset(), flipper.getLimit());
|
||||
}
|
||||
List<T> dataList = jdbcSource.directQuery(sql, rs -> Utils.queryList(rs, type));
|
||||
return new Sheet<>(total, dataList);
|
||||
}
|
||||
|
||||
@Comment("获取次日0点0分0秒时间戳")
|
||||
public static long getNextDayZero() {
|
||||
LocalDate localDate = LocalDate.now();
|
||||
@ -710,7 +677,7 @@ public final class Utils {
|
||||
return count;
|
||||
}
|
||||
|
||||
private static Random random = new Random();
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static int randomNum(int len) {
|
||||
int rs = random.nextInt(9);
|
||||
|
@ -13,7 +13,7 @@ import javax.persistence.*;
|
||||
@Setter
|
||||
@Getter
|
||||
@Cacheable(interval = 5 * 60)
|
||||
@Table(catalog = "redbbs", name = "commentinfo", comment = "[评论表]")
|
||||
@Table(comment = "[评论表]")
|
||||
public class CommentInfo extends BaseEntity {
|
||||
|
||||
@Id
|
||||
@ -44,9 +44,6 @@ public class CommentInfo extends BaseEntity {
|
||||
@Column(comment = "[状态]1正常,-1删除")
|
||||
private short status = 10;
|
||||
|
||||
/*@Transient
|
||||
private CommentBean pCommentInfo;*/
|
||||
|
||||
@Transient
|
||||
private String title;
|
||||
@Transient
|
||||
@ -55,19 +52,4 @@ public class CommentInfo extends BaseEntity {
|
||||
@Transient
|
||||
private UserInfo user;
|
||||
|
||||
|
||||
/*public CommentBean createInfo() {
|
||||
CommentBean info = new CommentBean();
|
||||
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(Utils.dateFmt(createtime));
|
||||
return info;
|
||||
}*/
|
||||
}
|
||||
|
@ -85,9 +85,7 @@ public class CommentService extends BaseService {
|
||||
List<Integer> commentids = Utils.toList(comments, x -> x.getCommentid());
|
||||
FilterNode node = FilterNode.create("cate", 10).and("status", 10).and("userid", userid).and("tid", IN, (Serializable) commentids);
|
||||
List<Integer> supports = dataSource.queryColumnList("tid", ActLog.class, node);
|
||||
comments.forEach(x -> {
|
||||
x.setHadsupport(supports.contains(x.getCommentid()) ? 1 : 0);
|
||||
});
|
||||
comments.forEach(x -> x.setHadsupport(supports.contains(x.getCommentid()) ? 1 : 0));
|
||||
|
||||
return comments;
|
||||
}
|
||||
@ -138,17 +136,10 @@ public class CommentService extends BaseService {
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* todo:用户评论榜 待完成
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Comment("用户评论榜")
|
||||
public Map<String, Number> commentRank() {
|
||||
dataSource.querySheet(CommentInfo.class, new Flipper(8), FilterNode.create("userid", IN));
|
||||
|
||||
Map<String, Number> numberMap = dataSource.getNumberMap(CommentInfo.class, FilterFuncColumn.create(FilterFunc.DISTINCTCOUNT, "userid"));
|
||||
|
||||
return numberMap;
|
||||
return dataSource.getNumberMap(CommentInfo.class, FilterFuncColumn.create(FilterFunc.DISTINCTCOUNT, "userid"));
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import javax.persistence.*;
|
||||
@Setter
|
||||
@Getter
|
||||
@Cacheable(interval = 5 * 60)
|
||||
@Table(catalog = "redbbs", name = "contentinfo", comment = "[内容表]")
|
||||
@Table(comment = "[内容表]")
|
||||
public class ContentInfo extends BaseEntity {
|
||||
|
||||
@Id
|
||||
@ -72,24 +72,4 @@ public class ContentInfo extends BaseEntity {
|
||||
|
||||
|
||||
private static final Kv types = Kv.by(10, "求助").set(20, "分享").set(30, "讨论").set(40, "公告").set(50, "动态");
|
||||
|
||||
/*public ContentInfo createInfo() {
|
||||
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.setStatus(status);
|
||||
|
||||
info.setTypename(types.getOrDefault((int) type, "其他").toString());
|
||||
info.setCreatetime(Utils.dateFmt(createtime));
|
||||
return info;
|
||||
}*/
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import static org.redkale.source.FilterExpress.NOTEQUAL;
|
||||
/**
|
||||
* Created by Lxy at 2017/11/26 9:33.
|
||||
*/
|
||||
@SuppressWarnings("Convert2MethodRef")
|
||||
@RestService(name = "content", comment = "文章帖子服务")
|
||||
public class ContentService extends BaseService {
|
||||
|
||||
|
@ -16,7 +16,7 @@ import javax.persistence.Table;
|
||||
@Setter
|
||||
@Getter
|
||||
@Cacheable(interval = 5 * 60)
|
||||
@Table(catalog = "redbbs", name = "userdetail")
|
||||
@Table(comment = "用户表")
|
||||
public class UserDetail implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@ -47,7 +47,7 @@ public class UserDetail implements java.io.Serializable {
|
||||
@Column(length = 32, comment = "[邮箱]")
|
||||
private String email = "";
|
||||
|
||||
@Column(comment = "")
|
||||
@Column()
|
||||
private int roleid;
|
||||
|
||||
@Column(length = 128, comment = "[个人博客地址]")
|
||||
@ -77,24 +77,24 @@ public class UserDetail implements java.io.Serializable {
|
||||
//------
|
||||
|
||||
public UserInfo createUserInfo() {
|
||||
UserInfo user = new UserInfo();
|
||||
user.setUserid(userid);
|
||||
user.setUsername(username);
|
||||
user.setSex(sex);
|
||||
user.setPassword(password);
|
||||
user.setPhone(phone);
|
||||
user.setNickname(nickname);
|
||||
user.setAvatar(avatar);
|
||||
user.setRelaname(realname);
|
||||
user.setEmail(email);
|
||||
user.setRoleid(roleid);
|
||||
user.setSite(site);
|
||||
user.setGit(git);
|
||||
user.setCreatetime(createtime);
|
||||
user.setSign(sign);
|
||||
user.setCity(city);
|
||||
user.setStatus(getStatus());
|
||||
return user;
|
||||
UserInfo info = new UserInfo();
|
||||
info.setUserid(userid);
|
||||
info.setUsername(username);
|
||||
info.setSex(sex);
|
||||
info.setPassword(password);
|
||||
info.setPhone(phone);
|
||||
info.setNickname(nickname);
|
||||
info.setAvatar(avatar);
|
||||
info.setRelaname(realname);
|
||||
info.setEmail(email);
|
||||
info.setRoleid(roleid);
|
||||
info.setSite(site);
|
||||
info.setGit(git);
|
||||
info.setCreatetime(createtime);
|
||||
info.setSign(sign);
|
||||
info.setCity(city);
|
||||
info.setStatus(getStatus());
|
||||
return info;
|
||||
}
|
||||
|
||||
public String passwordForMd5() {
|
||||
|
@ -35,15 +35,4 @@ public class UserInfo extends BaseEntity {
|
||||
private int status = 1;
|
||||
private String time = "";
|
||||
|
||||
/**
|
||||
* 检查用户权限
|
||||
*
|
||||
* @param moduleid
|
||||
* @param actionid
|
||||
* @return
|
||||
*/
|
||||
public boolean checkAuth(int moduleid, int actionid) {
|
||||
|
||||
return !(moduleid == 2 && actionid == 1);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import static net.tccn.bbs.base.util.RetCodes.RET_USER_ACCOUNT_PWD_ILLEGAL;
|
||||
public class UserService extends BaseService {
|
||||
|
||||
@RestMapping(name = "login", auth = false, comment = "登录校验")
|
||||
public RetResult<UserInfo> login(LoginBean bean) {
|
||||
public RetResult login(LoginBean bean) {
|
||||
if (bean == null || bean.emptyUsername()) {
|
||||
return retError("参数错误");
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class UserService extends BaseService {
|
||||
//log(null, 0, "用户或密码错误");
|
||||
return RetCodes.retResult(RET_USER_ACCOUNT_PWD_ILLEGAL, "用户名或密码错误");
|
||||
}
|
||||
sessions.setAsync(sessionExpireSeconds, bean.getSessionid(), (long) user.getUserid());
|
||||
cacheSource.setexLongAsync(bean.getSessionid(), sessionExpireSeconds, user.getUserid());
|
||||
retResult.setRetcode(0);
|
||||
retResult.setResult(Kv.by("token", bean.getSessionid()));
|
||||
retResult.setRetinfo("登录成功.");
|
||||
@ -50,9 +50,10 @@ public class UserService extends BaseService {
|
||||
if (sessionid == null) return 0;
|
||||
long userid = 0;
|
||||
try {
|
||||
userid = sessions.getLong(sessionid, 0);
|
||||
userid = cacheSource.getLong(sessionid, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
return (int) userid;
|
||||
}
|
||||
@ -64,8 +65,7 @@ public class UserService extends BaseService {
|
||||
|
||||
long userid = 0;
|
||||
try {
|
||||
userid = sessions.getLong(sessionid, 0);
|
||||
sessions.getAndRefresh(sessionid, sessionExpireSeconds);
|
||||
userid = cacheSource.getLongAndRefresh(sessionid, sessionExpireSeconds, 0L);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -73,8 +73,7 @@ public class UserService extends BaseService {
|
||||
if (userid == 0) {
|
||||
return null;
|
||||
}
|
||||
UserInfo user = find((int) userid);
|
||||
return user;
|
||||
return find((int) userid);
|
||||
}
|
||||
|
||||
@RestMapping(name = "info", comment = "用户信息")
|
||||
@ -83,8 +82,7 @@ public class UserService extends BaseService {
|
||||
return null;
|
||||
}
|
||||
UserDetail user = dataSource.find(UserDetail.class, userid);
|
||||
UserInfo bean = user.createUserInfo();
|
||||
return bean;
|
||||
return user.createUserInfo();
|
||||
}
|
||||
|
||||
@Comment("根据用户ID, 批量查询一批用户信息")
|
||||
@ -95,13 +93,12 @@ public class UserService extends BaseService {
|
||||
|
||||
FilterNode node = FilterNode.create("userid", (Serializable) userids);
|
||||
List<UserDetail> records = dataSource.queryList(UserDetail.class, node);
|
||||
Map<Integer, UserInfo> map = Utils.toMap(records, x -> x.getUserid(), x -> x.createUserInfo());
|
||||
return map;
|
||||
return Utils.toMap(records, x -> x.getUserid(), x -> x.createUserInfo());
|
||||
}
|
||||
|
||||
@RestMapping(name = "logout", auth = false, comment = "退出登录")
|
||||
public RetResult logout(@RestSessionid String sessionid) {
|
||||
sessions.remove(sessionid);
|
||||
cacheSource.remove(sessionid);
|
||||
|
||||
return RetResult.success();
|
||||
//return new HttpResult().header("Location", "/").status(302);
|
||||
@ -109,9 +106,7 @@ public class UserService extends BaseService {
|
||||
|
||||
@RestMapping(name = "query", auth = false, comment = "用户数据查询")
|
||||
public Sheet<UserDetail> query(Flipper flipper, @RestParam(name = "bean", comment = "过滤条件") final UserBean userBean) {
|
||||
Sheet<UserDetail> users = dataSource.querySheet(UserDetail.class, flipper, userBean);
|
||||
|
||||
return users;
|
||||
return dataSource.querySheet(UserDetail.class, flipper, userBean);
|
||||
}
|
||||
|
||||
@RestMapping(name = "changepwd", comment = "修改密码")
|
||||
|
@ -81,12 +81,12 @@ public class ImFriendServiceImpl extends BaseService implements ImFriendService
|
||||
true, this.getClass(), new InetSocketAddress("192.168.227.1", 7070));*/
|
||||
|
||||
|
||||
TransportFactory sncpTransportFactory = application.getSncpTransportFactory();
|
||||
/*TransportFactory sncpTransportFactory = application.getSncpTransportFactory();
|
||||
TransportGroupInfo groupInfo = sncpTransportFactory.findGroupInfo("ALL");
|
||||
|
||||
System.out.println(groupInfo.toString());
|
||||
|
||||
groupInfo.putAddress(new InetSocketAddress("120.24.230.60", 7070));
|
||||
groupInfo.putAddress(new InetSocketAddress("120.24.230.60", 7070));*/
|
||||
|
||||
|
||||
//sncpTransportFactory.addGroupInfo(groupInfo);
|
||||
|
Loading…
Reference in New Issue
Block a user