社区升级
1、表字段统一小写, 2、表模块划分 3、表状态等字段统一smallint 4、部分字段值重新定义
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import com.lxyer.bbs.base.user.UserRecord;
|
||||
import com.lxyer.bbs.base.user.UserInfo;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.source.CacheSource;
|
||||
@@ -62,11 +62,11 @@ public class BaseService<F extends UF,I extends UI> implements Service {
|
||||
* @return
|
||||
*/
|
||||
protected <I extends UI> Sheet<I> setIUser(Sheet<I> ufSheet){
|
||||
int[] userIds = ufSheet.stream().mapToInt(I::getUserId).toArray();
|
||||
int[] userIds = ufSheet.stream().mapToInt(I::getUserid).toArray();
|
||||
|
||||
List<User> users = source.queryList(User.class, FilterNode.create("userId", FilterExpress.IN, userIds));
|
||||
List<UserRecord> users = source.queryList(UserRecord.class, FilterNode.create("userId", FilterExpress.IN, userIds));
|
||||
ufSheet.forEach(x->{
|
||||
User user = users.stream().filter(u -> u.getUserId() == x.getUserId()).findAny().orElse(null);
|
||||
UserRecord user = users.stream().filter(u -> u.getUserid() == x.getUserid()).findAny().orElse(null);
|
||||
x.setUser(user);
|
||||
});
|
||||
return ufSheet;
|
||||
@@ -78,7 +78,7 @@ public class BaseService<F extends UF,I extends UI> implements Service {
|
||||
* @return
|
||||
*/
|
||||
protected I setIUser(I uf){
|
||||
User user = source.find(User.class, uf.getUserId());
|
||||
UserRecord user = source.find(UserRecord.class, uf.getUserid());
|
||||
|
||||
return (I) uf.setUser(user);
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ public class BaseServlet extends HttpServlet {
|
||||
private static final Kv _kv = Kv.create();
|
||||
private static Engine engine;
|
||||
protected String sessionid;
|
||||
protected int currentId;//登录人id
|
||||
protected int currentid;//登录人id
|
||||
|
||||
protected static final boolean winos = System.getProperty("os.name").contains("Window");
|
||||
|
||||
@@ -69,7 +69,7 @@ public class BaseServlet extends HttpServlet {
|
||||
sessionid = request.getSessionid(false);
|
||||
if (sessionid != null) {
|
||||
request.setCurrentUser(userService.current(sessionid));
|
||||
currentId = userService.currentUserId(sessionid);
|
||||
currentid = userService.currentUserId(sessionid);
|
||||
_kv.set("mine", request.currentUser());
|
||||
}
|
||||
|
||||
@@ -179,10 +179,10 @@ public class BaseServlet extends HttpServlet {
|
||||
protected FilterNode setPrivate(FilterNode node){
|
||||
UserInfo userInfo = request.currentUser();
|
||||
if (userInfo == null){
|
||||
node.and("status", FilterExpress.NOTEQUAL, 3);
|
||||
}else if (!userService.isAdmin(currentId)){
|
||||
//select * from content c where c.status != -1 and (c.status!=3 or (c.status=3 and c.userId=100001))
|
||||
node.and(FilterNode.create("status", FilterExpress.NOTEQUAL, 3).or(FilterNode.create("status", 3).and("userId", userInfo.getUserId())));
|
||||
node.and("status", FilterExpress.NOTEQUAL, 30);
|
||||
}else if (!userService.isAdmin(currentid)){
|
||||
//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", userInfo.getUserid())));
|
||||
}
|
||||
|
||||
return node;
|
||||
|
@@ -5,6 +5,6 @@ package com.lxyer.bbs.base;
|
||||
* Created by liangxianyou at 2018/6/9 14:50.
|
||||
*/
|
||||
public interface UF<I extends UI> {
|
||||
int getUserId();
|
||||
int getUserid();
|
||||
I createInfo();
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.lxyer.bbs.base;
|
||||
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import com.lxyer.bbs.base.user.UserRecord;
|
||||
|
||||
/**
|
||||
* Created by liangxianyou at 2018/6/9 13:45.
|
||||
@@ -8,9 +8,9 @@ import com.lxyer.bbs.base.user.User;
|
||||
public interface UI<I extends UI> {
|
||||
|
||||
//抽象方法
|
||||
int getUserId();
|
||||
User getUser();
|
||||
I setUser(User user);
|
||||
int getUserid();
|
||||
UserRecord getUser();
|
||||
I setUser(UserRecord user);
|
||||
|
||||
//默认实现方法
|
||||
default String getRealname(){
|
||||
|
@@ -1,15 +1,16 @@
|
||||
package com.lxyer.bbs.base.entity;
|
||||
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.*;
|
||||
import org.redkale.convert.json.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable
|
||||
@Table(catalog = "redbbs", name = "act_log")
|
||||
@Cacheable(interval = 5*60)
|
||||
@Table(catalog = "redbbs", name = "sys_actlog")
|
||||
public class ActLog implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@@ -17,49 +18,23 @@ public class ActLog implements java.io.Serializable {
|
||||
@Column(comment = "[日志id]")
|
||||
private int logid;
|
||||
|
||||
@Column(comment = "[日志类型]")
|
||||
private int cate;
|
||||
@Column(comment = "[日志类型]10赞,20收藏,30阅读")
|
||||
private short cate;
|
||||
|
||||
@Column(comment = "[目标数据id]")
|
||||
private int tid;
|
||||
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
private int userid;
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
@Column(updatable = false, comment = "[创建时间]")
|
||||
private long createtime;
|
||||
|
||||
@Column(length = 128, comment = "[说明]")
|
||||
private String remark = "";
|
||||
|
||||
@Column(comment = "[状态]-1删除 1正常")
|
||||
private int status = 1;
|
||||
|
||||
public ActLog cate(int cate){
|
||||
this.cate = cate;
|
||||
return this;
|
||||
}
|
||||
public ActLog tid(int tid){
|
||||
this.tid = tid;
|
||||
return this;
|
||||
}
|
||||
public ActLog userId(int userId){
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
public ActLog createTime(long createTime){
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
public ActLog remark(String remark){
|
||||
this.remark = remark;
|
||||
return this;
|
||||
}
|
||||
public ActLog status(int status){
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
private short status = 10;
|
||||
|
||||
public void setLogid(int logid) {
|
||||
this.logid = logid;
|
||||
@@ -69,11 +44,11 @@ public class ActLog implements java.io.Serializable {
|
||||
return this.logid;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
public void setCate(short cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
public short getCate() {
|
||||
return this.cate;
|
||||
}
|
||||
|
||||
@@ -85,20 +60,20 @@ public class ActLog implements java.io.Serializable {
|
||||
return this.tid;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
public void setUserid(int userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
public int getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
public void setCreatetime(long createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
public long getCreatetime() {
|
||||
return this.createtime;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
@@ -109,11 +84,11 @@ public class ActLog implements java.io.Serializable {
|
||||
return this.remark;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
public void setStatus(short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
public short getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@@ -121,4 +96,15 @@ public class ActLog implements java.io.Serializable {
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
|
||||
//----
|
||||
public ActLog() {
|
||||
|
||||
}
|
||||
|
||||
public ActLog(int cate, int tid, int userid) {
|
||||
this.cate = (short) cate;
|
||||
this.tid = tid;
|
||||
this.userid = userid;
|
||||
}
|
||||
}
|
||||
|
@@ -12,15 +12,15 @@ import javax.persistence.Table;
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable(interval = 5*60)
|
||||
@Table(catalog = "redbbs", name = "dyna_attr", comment = "[动态属性表]")
|
||||
public class DynaAttr implements java.io.Serializable {
|
||||
@Table(catalog = "redbbs", name = "sys_dynattr", comment = "[动态属性表]")
|
||||
public class DynAttr implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@Column(comment = "[目标数据id]")
|
||||
private int tid;
|
||||
|
||||
@Column(comment = "[类型]1文章, 2xx, 3...,")
|
||||
private int cate;
|
||||
private short cate;
|
||||
|
||||
@Column(length = 32, comment = "")
|
||||
private String attr = "";
|
||||
@@ -36,11 +36,11 @@ public class DynaAttr implements java.io.Serializable {
|
||||
return this.tid;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
public void setCate(short cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
public short getCate() {
|
||||
return this.cate;
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ public class LoginBean implements FilterBean {
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return User.md5IfNeed(password);
|
||||
return UserRecord.md5IfNeed(password);
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
|
@@ -15,7 +15,7 @@ public class UserInfo implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
private int userid;
|
||||
|
||||
private String username = "";
|
||||
private int sex = 1;
|
||||
@@ -25,21 +25,21 @@ public class UserInfo implements java.io.Serializable {
|
||||
private String avatar = "";
|
||||
private String relaname = "";
|
||||
private String email = "";
|
||||
private int roleId = 0;
|
||||
private int roleid = 0;
|
||||
private String site = "";
|
||||
private String git = "";
|
||||
private long createTime;
|
||||
private long createtime;
|
||||
private String sign = "";
|
||||
private String city = "";
|
||||
private int status = 1;
|
||||
private String time = "";
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
public void setUserid(int userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
public int getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
@@ -107,12 +107,12 @@ public class UserInfo implements java.io.Serializable {
|
||||
return this.email == null || this.email.isEmpty() ? "" : this.email;
|
||||
}
|
||||
|
||||
public int getRoleId() {
|
||||
return roleId;
|
||||
public int getRoleid() {
|
||||
return roleid;
|
||||
}
|
||||
|
||||
public void setRoleId(int roleId) {
|
||||
this.roleId = roleId;
|
||||
public void setRoleid(int roleid) {
|
||||
this.roleid = roleid;
|
||||
}
|
||||
|
||||
public String getSite() {
|
||||
@@ -131,12 +131,12 @@ public class UserInfo implements java.io.Serializable {
|
||||
this.git = git;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
public void setCreatetime(long createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
public long getCreatetime() {
|
||||
return this.createtime;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
|
@@ -1,14 +1,9 @@
|
||||
package com.lxyer.bbs.base.user;
|
||||
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
import org.redkale.convert.ConvertType;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import javax.persistence.*;
|
||||
import org.redkale.convert.json.*;
|
||||
import org.redkale.util.Utility;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@@ -17,23 +12,22 @@ import java.security.NoSuchAlgorithmException;
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable(interval = 5*60)
|
||||
@Table(catalog = "redbbs", name = "user")
|
||||
public class User implements java.io.Serializable {
|
||||
@Table(catalog = "redbbs", name = "sys_userrecord")
|
||||
public class UserRecord implements java.io.Serializable {
|
||||
|
||||
@Id
|
||||
//@GeneratedValue
|
||||
@Column(comment = "[用户id]", updatable = false)
|
||||
private int userId;
|
||||
@Column(comment = "[用户id]")
|
||||
private int userid;
|
||||
|
||||
@Column(length = 32, comment = "[登录名]")
|
||||
private String username = "";
|
||||
|
||||
@Column(comment = "[性别]默认1 1男,2女")
|
||||
private int sex = 1;
|
||||
|
||||
@Column(length = 64, comment = "[密码]")
|
||||
private String password = "";
|
||||
|
||||
@Column(comment = "[性别]默认 10男,20女")
|
||||
private short sex;
|
||||
|
||||
@Column(length = 32, comment = "[电话号码]")
|
||||
private String phone = "";
|
||||
|
||||
@@ -49,8 +43,8 @@ public class User implements java.io.Serializable {
|
||||
@Column(length = 32, comment = "[邮箱]")
|
||||
private String email = "";
|
||||
|
||||
@Column(length = 2, comment = "[用户角色]")
|
||||
private int roleId = 0;
|
||||
@Column(comment = "")
|
||||
private int roleid;
|
||||
|
||||
@Column(length = 128, comment = "[个人博客地址]")
|
||||
private String site = "";
|
||||
@@ -58,8 +52,8 @@ public class User implements java.io.Serializable {
|
||||
@Column(length = 128, comment = "[码云/GitHub]")
|
||||
private String git = "";
|
||||
|
||||
@Column(comment = "[创建时间]", updatable = false)
|
||||
private long createTime;
|
||||
@Column(updatable = false, comment = "[创建时间]")
|
||||
private long createtime;
|
||||
|
||||
@Column(length = 256, comment = "[签名]")
|
||||
private String sign = "";
|
||||
@@ -67,8 +61,164 @@ public class User implements java.io.Serializable {
|
||||
@Column(length = 64, comment = "[所在城市]")
|
||||
private String city = "";
|
||||
|
||||
@Column(comment = "[状态]")
|
||||
private int status = 1;
|
||||
@Column(comment = "[状态]-10删除 10正常")
|
||||
private short status = 10;
|
||||
|
||||
public void setUserid(int userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public int getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setSex(short sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public short getSex() {
|
||||
return this.sex;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return this.phone;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return this.nickname;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return this.avatar;
|
||||
}
|
||||
|
||||
public void setRealname(String realname) {
|
||||
this.realname = realname;
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return this.realname;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email;
|
||||
}
|
||||
|
||||
public void setRoleid(int roleid) {
|
||||
this.roleid = roleid;
|
||||
}
|
||||
|
||||
public int getRoleid() {
|
||||
return this.roleid;
|
||||
}
|
||||
|
||||
public void setSite(String site) {
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
public String getSite() {
|
||||
return this.site;
|
||||
}
|
||||
|
||||
public void setGit(String git) {
|
||||
this.git = git;
|
||||
}
|
||||
|
||||
public String getGit() {
|
||||
return this.git;
|
||||
}
|
||||
|
||||
public void setCreatetime(long createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public long getCreatetime() {
|
||||
return this.createtime;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return this.sign;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public void setStatus(short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public short getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
|
||||
//------
|
||||
|
||||
public UserInfo createUserInfo() {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setUserid(userid);
|
||||
userInfo.setUsername(username);
|
||||
userInfo.setSex(sex);
|
||||
userInfo.setPassword(password);
|
||||
userInfo.setPhone(phone);
|
||||
userInfo.setNickname(nickname);
|
||||
userInfo.setAvatar(avatar);
|
||||
userInfo.setRelaname(realname);
|
||||
userInfo.setEmail(email);
|
||||
userInfo.setRoleid(roleid);
|
||||
userInfo.setSite(site);
|
||||
userInfo.setGit(git);
|
||||
userInfo.setCreatetime(createtime);
|
||||
userInfo.setSign(sign);
|
||||
userInfo.setCity(city);
|
||||
userInfo.setStatus(getStatus());
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public String passwordForMd5(){
|
||||
return md5IfNeed(password);
|
||||
@@ -88,159 +238,4 @@ public class User implements java.io.Serializable {
|
||||
bytes = md5.digest(bytes);
|
||||
return new String(Utility.binToHex(bytes));
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public int getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(int sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
@ConvertColumn(ignore = true, type = ConvertType.JSON)
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return realname;
|
||||
}
|
||||
|
||||
public void setRealname(String realname) {
|
||||
this.realname = realname;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return (email == null || email.isEmpty()) ? " " : email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public int getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(int roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getSite() {
|
||||
return site;
|
||||
}
|
||||
|
||||
public void setSite(String site) {
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
public String getGit() {
|
||||
return git;
|
||||
}
|
||||
|
||||
public void setGit(String git) {
|
||||
this.git = git;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
|
||||
public UserInfo createUserInfo() {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setUserId(userId);
|
||||
userInfo.setUsername(username);
|
||||
userInfo.setSex(sex);
|
||||
userInfo.setPassword(password);
|
||||
userInfo.setPhone(phone);
|
||||
userInfo.setNickname(nickname);
|
||||
userInfo.setAvatar(avatar);
|
||||
userInfo.setRelaname(realname);
|
||||
userInfo.setEmail(email);
|
||||
userInfo.setRoleId(roleId);
|
||||
userInfo.setSite(site);
|
||||
userInfo.setGit(git);
|
||||
userInfo.setCreateTime(createTime);
|
||||
userInfo.setSign(sign);
|
||||
userInfo.setCity(city);
|
||||
userInfo.setStatus(getStatus());
|
||||
return userInfo;
|
||||
}
|
||||
}
|
@@ -31,7 +31,7 @@ public class UserService extends BaseService {
|
||||
|
||||
final RetResult retResult = new RetResult();
|
||||
|
||||
User user = source.find(User.class, "username", loginBean.getUsername());
|
||||
UserRecord user = source.find(UserRecord.class, "username", loginBean.getUsername());
|
||||
if (user == null || !Objects.equals(user.getPassword(), loginBean.getPassword())){
|
||||
//log(null, 0, "用户或密码错误");
|
||||
return RetCodes.retResult(RetCodes.RET_USER_ACCOUNT_PWD_ILLEGAL, "用户或密码错误");
|
||||
@@ -40,7 +40,7 @@ public class UserService extends BaseService {
|
||||
//log(user, 0, "用户登录成功.");
|
||||
UserInfo userInfo = user.createUserInfo();
|
||||
|
||||
sessions.setAsync(sessionExpireSeconds, loginBean.getSessionid(), userInfo.getUserId());
|
||||
sessions.setAsync(sessionExpireSeconds, loginBean.getSessionid(), userInfo.getUserid());
|
||||
retResult.setRetcode(0);
|
||||
retResult.setResult(userInfo);
|
||||
retResult.setRetinfo("登录成功.");
|
||||
@@ -61,7 +61,7 @@ public class UserService extends BaseService {
|
||||
|
||||
@RestMapping(name = "info", comment = "用户信息")
|
||||
public UserInfo findUserInfo(int userid) {
|
||||
User user = source.find(User.class, userid);
|
||||
UserRecord user = source.find(UserRecord.class, userid);
|
||||
return user == null ? null : user.createUserInfo();
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ public class UserService extends BaseService {
|
||||
}
|
||||
|
||||
@RestMapping(name = "query", auth = false, comment = "用户数据查询")
|
||||
public Sheet<User> queryUser(Flipper flipper, @RestParam(name = "bean", comment = "过滤条件") final UserBean userBean){
|
||||
Sheet<User> users = source.querySheet(User.class, flipper, userBean);
|
||||
public Sheet<UserRecord> queryUser(Flipper flipper, @RestParam(name = "bean", comment = "过滤条件") final UserBean userBean){
|
||||
Sheet<UserRecord> users = source.querySheet(UserRecord.class, flipper, userBean);
|
||||
|
||||
return users;
|
||||
}
|
||||
@@ -84,32 +84,32 @@ public class UserService extends BaseService {
|
||||
public RetResult updatePwd(@RestSessionid String sessionid, String pass, String nowpass){
|
||||
UserInfo userInfo = current(sessionid);//不会为空
|
||||
|
||||
if (!Objects.equals(userInfo.getPassword(), User.md5IfNeed(nowpass)))
|
||||
if (!Objects.equals(userInfo.getPassword(), UserRecord.md5IfNeed(nowpass)))
|
||||
return RetCodes.retResult(RET_USER_ACCOUNT_PWD_ILLEGAL, "密码错误");
|
||||
if (pass == null || pass.length() < 6 || Objects.equals(pass, nowpass))
|
||||
return RetCodes.retResult(RET_USER_PASSWORD_ILLEGAL, "密码设置无效");
|
||||
source.updateColumn(User.class, userInfo.getUserId(), "password", User.md5IfNeed(pass));
|
||||
source.updateColumn(UserRecord.class, userInfo.getUserid(), "password", UserRecord.md5IfNeed(pass));
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
@RestMapping(name = "register", auth = false, comment = "用户注册")
|
||||
public RetResult register(@RestParam(name = "bean") User user){
|
||||
public RetResult register(@RestParam(name = "bean") UserRecord user){
|
||||
/*用户名、密码、邮箱*/
|
||||
if (user.getEmail() == null) return RetCodes.retResult(RET_USER_EMAIL_ILLEGAL, "邮件地址无效");
|
||||
if (user.getPassword() == null || user.getPassword().length() < 6) return RetCodes.retResult(RET_USER_PASSWORD_ILLEGAL, "密码设置无效");
|
||||
|
||||
User _user = source.find(User.class, FilterNode.create("email", user.getEmail()));
|
||||
UserRecord _user = source.find(UserRecord.class, FilterNode.create("email", user.getEmail()));
|
||||
if (_user != null) return RetCodes.retResult(RET_USER_USERNAME_EXISTS, "用户名已存在");
|
||||
|
||||
user.setCreateTime(System.currentTimeMillis());
|
||||
user.setCreatetime(System.currentTimeMillis());
|
||||
user.setPassword(user.passwordForMd5());
|
||||
user.setStatus(1);
|
||||
user.setStatus((short) 10);
|
||||
user.setUsername(user.getEmail());
|
||||
user.setAvatar("/res/images/avatar/"+ new Random().nextInt(21) +".jpg");//默认头像
|
||||
|
||||
int maxId = source.getNumberResult(User.class, FilterFunc.MAX, 10_0000, "userId").intValue();
|
||||
int maxId = source.getNumberResult(UserRecord.class, FilterFunc.MAX, 10_0000, "userid").intValue();
|
||||
if (maxId < 10_0000) maxId = 10_0000;
|
||||
user.setUserId(maxId+1);
|
||||
user.setUserid(maxId+1);
|
||||
source.insert(user);
|
||||
|
||||
//记录日志
|
||||
@@ -117,19 +117,19 @@ public class UserService extends BaseService {
|
||||
}
|
||||
|
||||
@RestMapping(name = "update", comment = "用户信息修改")
|
||||
public RetResult userUpdate(@RestSessionid String sessionid, @RestParam(name = "bean") User user, String[] columns){
|
||||
public RetResult userUpdate(@RestSessionid String sessionid, @RestParam(name = "bean") UserRecord user, String[] columns){
|
||||
String nickname = user.getNickname();
|
||||
if (nickname == null && nickname.isEmpty())
|
||||
return RetCodes.retResult(RET_USER_NICKNAME_ILLEGAL, "昵称无效");
|
||||
|
||||
nickname = nickname.replace(" ", "");
|
||||
User _user = source.find(User.class, FilterNode.create("nickname", nickname));
|
||||
if (_user != null && _user.getUserId() != currentUserId(sessionid))
|
||||
UserRecord _user = source.find(UserRecord.class, FilterNode.create("nickname", nickname));
|
||||
if (_user != null && _user.getUserid() != currentUserId(sessionid))
|
||||
return RetCodes.retResult(RET_USER_NICKNAME_EXISTS, "昵称已存在");
|
||||
|
||||
user.setNickname(nickname);//去除昵称中的空格
|
||||
source.updateColumn(user
|
||||
,FilterNode.create("userId", currentUserId(sessionid))
|
||||
,FilterNode.create("userid", currentUserId(sessionid))
|
||||
,SelectColumn.createIncludes(columns)
|
||||
);
|
||||
return RetResult.success();
|
||||
@@ -137,17 +137,17 @@ public class UserService extends BaseService {
|
||||
|
||||
//最新加入
|
||||
public Sheet<UserInfo> lastReg(){
|
||||
Sheet<User> users = source.querySheet(User.class
|
||||
, SelectColumn.createIncludes("userId", "nickname", "avatar", "createTime")
|
||||
, new Flipper().sort("createTime DESC").limit(8)
|
||||
, FilterNode.create("status", 1));
|
||||
Sheet<UserRecord> users = source.querySheet(UserRecord.class
|
||||
, SelectColumn.createIncludes("userid", "nickname", "avatar", "createtime")
|
||||
, new Flipper().sort("createtime DESC").limit(8)
|
||||
, FilterNode.create("status", 10));
|
||||
|
||||
Sheet<UserInfo> infos = new Sheet<>();
|
||||
ArrayList<UserInfo> list = new ArrayList<>();
|
||||
|
||||
users.forEach(x->{
|
||||
UserInfo info = x.createUserInfo();
|
||||
info.setTime(LxyKit.dateFmt(x.getCreateTime()));
|
||||
info.setTime(LxyKit.dateFmt(x.getCreatetime()));
|
||||
list.add(info);
|
||||
});
|
||||
|
||||
@@ -167,16 +167,16 @@ public class UserService extends BaseService {
|
||||
|
||||
@RestMapping(name = "usercount", auth = false, comment = "用户数据统计")
|
||||
public Number userCount() {
|
||||
return source.getNumberResult(User.class, FilterFunc.COUNT, "userId", FilterNode.create("status", FilterExpress.NOTEQUAL, -1));
|
||||
return source.getNumberResult(UserRecord.class, FilterFunc.COUNT, "userid", FilterNode.create("status", FilterExpress.NOTEQUAL, -10));
|
||||
}
|
||||
|
||||
@RestMapping(ignore = true, comment = "判断用户是否是管理员")
|
||||
public boolean isAdmin(int userId){
|
||||
if (userId <= 0) return false;
|
||||
public boolean isAdmin(int userid){
|
||||
if (userid <= 0) return false;
|
||||
|
||||
List<Integer> userIds = source.queryColumnList("userId", User.class, FilterNode.create("roleId", 1));
|
||||
List<Integer> userIds = source.queryColumnList("userid", UserRecord.class, FilterNode.create("roleid", 1));
|
||||
for (Integer x : userIds) {
|
||||
if (userId == x) {
|
||||
if (userid == x) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,11 @@
|
||||
package com.lxyer.bbs.comment;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
import com.lxyer.bbs.base.UF;
|
||||
import com.lxyer.bbs.base.kit.LxyKit;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.convert.json.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -12,107 +13,107 @@ import java.io.Serializable;
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable(interval = 5*60)
|
||||
@Table(catalog = "redbbs", name = "comment", comment = "[评论表]")
|
||||
public class Comment implements UF<CommentInfo>,Serializable {
|
||||
@Table(catalog = "redbbs", name = "sys_comment", comment = "[评论表]")
|
||||
public class Comment implements Serializable, UF {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(comment = "[评论id]")
|
||||
private int commentId;
|
||||
private int commentid;
|
||||
|
||||
@Column(comment = "[评论用户id]")
|
||||
private int userId;
|
||||
private int userid;
|
||||
|
||||
@Column(comment = "[评论父id]")
|
||||
private int pid;
|
||||
|
||||
@Column(comment = "[评论的类型]")
|
||||
private int cate;
|
||||
private short cate = 1;
|
||||
|
||||
@Column(comment = "[被评论内容的id]")
|
||||
private int contentId;
|
||||
private int contentid;
|
||||
|
||||
@Column(comment = "[评论内容]")
|
||||
private String content = "";
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
@Column(updatable = false, comment = "[创建时间]")
|
||||
private long createtime;
|
||||
|
||||
@Column(comment = "[支持数]")
|
||||
private int supportNum;
|
||||
private int supportnum;
|
||||
|
||||
@Column(comment = "[状态]1正常,-1删除")
|
||||
private int status = 1;
|
||||
private short status = 10;
|
||||
|
||||
public void setCommentId(int commentId) {
|
||||
this.commentId = commentId;
|
||||
public void setCommentid(int commentid) {
|
||||
this.commentid = commentid;
|
||||
}
|
||||
|
||||
public int getCommentId() {
|
||||
return this.commentId;
|
||||
public int getCommentid() {
|
||||
return this.commentid;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
public void setUserid(int userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
return pid;
|
||||
public int getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
public void setPid(int pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return cate;
|
||||
public int getPid() {
|
||||
return this.pid;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
public void setCate(short cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
public short getCate() {
|
||||
return this.cate;
|
||||
}
|
||||
|
||||
public int getContentId() {
|
||||
return this.contentId;
|
||||
public void setContentid(int contentid) {
|
||||
this.contentid = contentid;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
public int getContentid() {
|
||||
return this.contentid;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
public String getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
public void setCreatetime(long createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public int getSupportNum() {
|
||||
return supportNum;
|
||||
public long getCreatetime() {
|
||||
return this.createtime;
|
||||
}
|
||||
|
||||
public void setSupportNum(int supportNum) {
|
||||
this.supportNum = supportNum;
|
||||
public void setSupportnum(int supportnum) {
|
||||
this.supportnum = supportnum;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
public int getSupportnum() {
|
||||
return this.supportnum;
|
||||
}
|
||||
|
||||
public void setStatus(short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
public short getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@@ -123,16 +124,16 @@ public class Comment implements UF<CommentInfo>,Serializable {
|
||||
|
||||
public CommentInfo createInfo(){
|
||||
CommentInfo info = new CommentInfo();
|
||||
info.setCommentId(commentId);
|
||||
info.setUserId(userId);
|
||||
info.setCommentid(commentid);
|
||||
info.setUserid(userid);
|
||||
info.setPid(pid);
|
||||
info.setCate(cate);
|
||||
info.setContentId(contentId);
|
||||
info.setContentid(contentid);
|
||||
info.setContent(content);
|
||||
info.setSupportNum(supportNum);
|
||||
info.setSupportnum(supportnum);
|
||||
info.setStatus(status);
|
||||
|
||||
info.setCreateTime(LxyKit.dateFmt(createTime));
|
||||
info.setCreatetime(LxyKit.dateFmt(createtime));
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.lxyer.bbs.comment;
|
||||
|
||||
import com.lxyer.bbs.base.UI;
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import com.lxyer.bbs.base.user.UserRecord;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
import javax.persistence.Column;
|
||||
@@ -14,10 +14,10 @@ import java.io.Serializable;
|
||||
public class CommentInfo implements UI<CommentInfo>,Serializable {
|
||||
|
||||
@Column(comment = "[评论id]")
|
||||
private int commentId;
|
||||
private int commentid;
|
||||
|
||||
@Column(comment = "[评论用户id]")
|
||||
private int userId;
|
||||
private int userid;
|
||||
|
||||
@Column(comment = "[评论父id]")
|
||||
private int pid;
|
||||
@@ -26,39 +26,39 @@ public class CommentInfo implements UI<CommentInfo>,Serializable {
|
||||
private int cate;
|
||||
|
||||
@Column(comment = "[被评论内容的id]")
|
||||
private int contentId;
|
||||
private int contentid;
|
||||
|
||||
@Column(comment = "[评论内容]")
|
||||
private String content = "";
|
||||
|
||||
@Column(comment = "[支持数]")
|
||||
private int supportNum;
|
||||
private int supportnum;
|
||||
|
||||
@Column(comment = "[状态]1正常,-1删除")
|
||||
private int status = 1;
|
||||
|
||||
|
||||
private String createTime;
|
||||
private String createtime;
|
||||
|
||||
private CommentInfo pCommentInfo;
|
||||
|
||||
private String title;
|
||||
private int hadSupport = -1;
|
||||
private int hadsupport = -1;
|
||||
|
||||
public void setCommentId(int commentId) {
|
||||
this.commentId = commentId;
|
||||
public void setCommentid(int commentid) {
|
||||
this.commentid = commentid;
|
||||
}
|
||||
|
||||
public int getCommentId() {
|
||||
return this.commentId;
|
||||
public int getCommentid() {
|
||||
return this.commentid;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
public void setUserid(int userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
public int getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
public int getPid() {
|
||||
@@ -77,12 +77,12 @@ public class CommentInfo implements UI<CommentInfo>,Serializable {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
public void setContentid(int contentid) {
|
||||
this.contentid = contentid;
|
||||
}
|
||||
|
||||
public int getContentId() {
|
||||
return this.contentId;
|
||||
public int getContentid() {
|
||||
return this.contentid;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
@@ -93,12 +93,12 @@ public class CommentInfo implements UI<CommentInfo>,Serializable {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getSupportNum() {
|
||||
return supportNum;
|
||||
public int getSupportnum() {
|
||||
return supportnum;
|
||||
}
|
||||
|
||||
public void setSupportNum(int supportNum) {
|
||||
this.supportNum = supportNum;
|
||||
public void setSupportnum(int supportnum) {
|
||||
this.supportnum = supportnum;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
@@ -109,12 +109,12 @@ public class CommentInfo implements UI<CommentInfo>,Serializable {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
public String getCreatetime() {
|
||||
return createtime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
public void setCreatetime(String createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public CommentInfo getpCommentInfo() {
|
||||
@@ -133,12 +133,12 @@ public class CommentInfo implements UI<CommentInfo>,Serializable {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getHadSupport() {
|
||||
return hadSupport;
|
||||
public int getHadsupport() {
|
||||
return hadsupport;
|
||||
}
|
||||
|
||||
public void setHadSupport(int hadSupport) {
|
||||
this.hadSupport = hadSupport;
|
||||
public void setHadsupport(int hadsupport) {
|
||||
this.hadsupport = hadsupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,15 +147,15 @@ public class CommentInfo implements UI<CommentInfo>,Serializable {
|
||||
}
|
||||
|
||||
//----
|
||||
private User user;
|
||||
private UserRecord user;
|
||||
|
||||
@Override
|
||||
public User getUser() {
|
||||
public UserRecord getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommentInfo setUser(User user) {
|
||||
public CommentInfo setUser(UserRecord user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
@@ -34,10 +34,10 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
||||
|
||||
@RestMapping(name = "save", comment = "评论保存")
|
||||
public RetResult commentSave(@RestSessionid String sessionid, @RestParam(name = "bean") Comment comment){
|
||||
int contentId = comment.getContentId();
|
||||
int contentid = comment.getContentid();
|
||||
|
||||
//数据校验
|
||||
if (contentId < 1)
|
||||
if (contentid < 1)
|
||||
return RetCodes.retResult(RET_COMMENT_PARA_ILLEGAL, "评论参数无效");
|
||||
if (comment.getContent() == null)
|
||||
return RetCodes.retResult(RET_COMMENT_CONTENT_ILLEGAL, "评论内容无效");
|
||||
@@ -45,16 +45,16 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
||||
if (content.isEmpty())
|
||||
return RetCodes.retResult(RET_COMMENT_CONTENT_ILLEGAL, "评论内容无效");
|
||||
|
||||
if (comment.getCommentId() < 1) {
|
||||
int userId = userService.currentUserId(sessionid);
|
||||
comment.setUserId(userId);
|
||||
comment.setCreateTime(System.currentTimeMillis());
|
||||
if (comment.getCommentid() < 1) {
|
||||
int userid = userService.currentUserId(sessionid);
|
||||
comment.setUserid(userid);
|
||||
comment.setCreatetime(System.currentTimeMillis());
|
||||
//todo:@用户处理
|
||||
source.insert(comment);
|
||||
|
||||
//update replyNum
|
||||
int count = source.getNumberResult(Comment.class, FilterFunc.COUNT, "commentId", FilterNode.create("contentId", contentId)).intValue();
|
||||
source.updateColumn(Content.class, contentId, ColumnValue.create("replyNum", count));
|
||||
int count = source.getNumberResult(Comment.class, FilterFunc.COUNT, "commentid", FilterNode.create("contentid", contentid)).intValue();
|
||||
source.updateColumn(Content.class, contentid, ColumnValue.create("replynum", count));
|
||||
}else {
|
||||
source.updateColumn(comment, SelectColumn.createIncludes("content"));
|
||||
}
|
||||
@@ -63,22 +63,22 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
||||
|
||||
@RestMapping(name = "query", auth = false,comment = "查询评论")
|
||||
public Sheet<CommentInfo> commentQuery(@RestSessionid String sessionid , int contentId, Flipper flipper){
|
||||
int userId = userService.currentUserId(sessionid);
|
||||
int userid = userService.currentUserId(sessionid);
|
||||
|
||||
flipper.setSort("supportNum DESC,commentId ASC");
|
||||
Sheet<Comment> comments = source.querySheet(Comment.class, flipper, FilterNode.create("contentId", contentId));
|
||||
flipper.setSort("supportnum DESC,commentid ASC");
|
||||
Sheet<Comment> comments = source.querySheet(Comment.class, flipper, FilterNode.create("contentid", contentId));
|
||||
|
||||
Sheet<CommentInfo> infos = createInfo(comments);
|
||||
setIUser(infos);
|
||||
|
||||
//用户点赞的评论
|
||||
if (userId > 0){
|
||||
int[] commentIds = comments.stream().mapToInt(Comment::getCommentId).toArray();
|
||||
FilterNode node = FilterNode.create("cate", 1).and("status", 1).and("userId", userId).and("tid", FilterExpress.IN, commentIds);
|
||||
if (userid > 0){
|
||||
int[] commentids = comments.stream().mapToInt(Comment::getCommentid).toArray();
|
||||
FilterNode node = FilterNode.create("cate", 10).and("status", 10).and("userid", userid).and("tid", FilterExpress.IN, commentids);
|
||||
List<Integer> hadSupport = source.queryColumnList("tid", ActLog.class, node);
|
||||
|
||||
infos.forEach(x->{
|
||||
x.setHadSupport(hadSupport.contains(x.getCommentId()) ? 1 : -1);//
|
||||
x.setHadsupport(hadSupport.contains(x.getCommentid()) ? 1 : -1);//
|
||||
});
|
||||
}
|
||||
|
||||
@@ -86,18 +86,18 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
int[] contentIds = comments.stream().mapToInt(x -> x.getContentId()).toArray();
|
||||
int[] contentIds = comments.stream().mapToInt(x -> x.getCommentid()).toArray();
|
||||
|
||||
List<Content> contents = source.queryList(Content.class, SelectColumn.createIncludes("contentId","title"), FilterNode.create("contentId", FilterExpress.IN, contentIds));
|
||||
List<Content> contents = source.queryList(Content.class, SelectColumn.createIncludes("contentid","title"), FilterNode.create("contentid", FilterExpress.IN, contentIds));
|
||||
|
||||
Sheet<CommentInfo> infos = new Sheet<>();
|
||||
List<CommentInfo> list = new ArrayList<>();
|
||||
|
||||
comments.forEach(x->{
|
||||
CommentInfo info = x.createInfo();
|
||||
Content content = contents.stream().filter(k -> k.getContentId() == x.getContentId()).findFirst().orElse(new Content());
|
||||
Content content = contents.stream().filter(k -> k.getContentid() == x.getContentid()).findFirst().orElse(new Content());
|
||||
info.setTitle(content.getTitle());
|
||||
list.add(info);
|
||||
});
|
||||
@@ -108,23 +108,23 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
||||
}
|
||||
|
||||
@RestMapping(name = "support", comment = "评论点赞")
|
||||
public RetResult support(@RestSessionid String sessionid, int commentId, int ok){
|
||||
int userId = userService.currentUserId(sessionid);
|
||||
public RetResult support(@RestSessionid String sessionid, int commentid, int ok){
|
||||
int userid = userService.currentUserId(sessionid);
|
||||
|
||||
ActLog actLog = source.find(ActLog.class, FilterNode.create("userId", userId).and("tid", commentId).and("cate", 1));
|
||||
ActLog actLog = source.find(ActLog.class, FilterNode.create("userid", userid).and("tid", commentid).and("cate", 10));
|
||||
if (actLog == null && ok == 1){
|
||||
actLog = new ActLog().cate(1).tid(commentId).userId(userId);
|
||||
actLog.setCreateTime(System.currentTimeMillis());
|
||||
actLog = new ActLog(10, commentid, userid);
|
||||
actLog.setCreatetime(System.currentTimeMillis());
|
||||
source.insert(actLog);
|
||||
}else if (actLog != null && actLog.getStatus() != ok){
|
||||
actLog.setStatus(ok);
|
||||
actLog.setStatus((short) -10);
|
||||
source.update(actLog);
|
||||
}else {
|
||||
return RetCodes.retResult(-1, ok == 1 ? "已赞" : "已取消赞");
|
||||
}
|
||||
|
||||
int count = source.getNumberResult(ActLog.class, FilterFunc.COUNT, 0, "logid", FilterNode.create("tid", commentId).and("status", 1)).intValue();
|
||||
source.updateColumn(Comment.class, commentId,"supportNum", count);
|
||||
int count = source.getNumberResult(ActLog.class, FilterFunc.COUNT, 0, "logid", FilterNode.create("tid", commentid).and("status", 10)).intValue();
|
||||
source.updateColumn(Comment.class, commentid,"supportnum", count);
|
||||
|
||||
return RetResult.success();
|
||||
}
|
||||
@@ -132,9 +132,9 @@ public class CommentService extends BaseService<Comment, CommentInfo> {
|
||||
@RestMapping(name = "rankuser", auth = false, comment = "评论榜")
|
||||
public Map<String, Number> commentRank(){
|
||||
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));
|
||||
|
||||
Map<String, Number> numberMap = source.getNumberMap(Comment.class, FilterFuncColumn.create(FilterFunc.DISTINCTCOUNT, "userId"));
|
||||
Map<String, Number> numberMap = source.getNumberMap(Comment.class, FilterFuncColumn.create(FilterFunc.DISTINCTCOUNT, "userid"));
|
||||
|
||||
return numberMap;
|
||||
}
|
||||
|
@@ -1,27 +1,29 @@
|
||||
package com.lxyer.bbs.content;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.lxyer.bbs.base.UF;
|
||||
import com.lxyer.bbs.base.kit.LxyKit;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.convert.json.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lxyer
|
||||
*/
|
||||
@Cacheable(interval = 5*60)
|
||||
@Table(catalog = "redbbs", name = "content", comment = "[内容表]")
|
||||
public class Content implements UF<ContentInfo>,java.io.Serializable {
|
||||
@Table(catalog = "redbbs", name = "sys_content", comment = "[内容表]")
|
||||
public class Content implements Serializable, UF<ContentInfo> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(comment = "[内容id]")
|
||||
private int contentId;
|
||||
private int contentid;
|
||||
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
private int userid;
|
||||
|
||||
@Column(length = 64, comment = "[标题]")
|
||||
private String title = "";
|
||||
@@ -32,47 +34,47 @@ public class Content implements UF<ContentInfo>,java.io.Serializable {
|
||||
@Column(comment = "[内容]")
|
||||
private String content = "";
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
@Column(updatable = false, comment = "[创建时间]")
|
||||
private long createtime;
|
||||
|
||||
@Column(comment = "[类别]")
|
||||
private int cate;
|
||||
private short cate;
|
||||
|
||||
@Column(comment = "[内容类型]1新闻,2作品")
|
||||
private int type;
|
||||
@Column(comment = "[内容栏目]10求助,20分享,30建议,40公告,50动态")
|
||||
private short type;
|
||||
|
||||
@Column(comment = "[评论数]")
|
||||
private int replyNum;
|
||||
private int replynum;
|
||||
|
||||
@Column(comment = "[阅读量]")
|
||||
private int viewNum;
|
||||
private int viewnum;
|
||||
|
||||
@Column(comment = "[精] 0否,1是")
|
||||
private int wonderful;
|
||||
@Column(comment = "[精] 10否,20是")
|
||||
private short wonderful = 10;
|
||||
|
||||
@Column(comment = "[置顶] 0否,1是")
|
||||
private int top;
|
||||
@Column(comment = "[置顶]10否,20是")
|
||||
private short top = 10;
|
||||
|
||||
@Column(comment = "[结帖]大于0结帖")
|
||||
private int solved;
|
||||
@Column(comment = "[结帖]10否,20是")
|
||||
private short solved = 10;
|
||||
|
||||
@Column(comment = "[状态]")
|
||||
private int status = 1;
|
||||
@Column(comment = "[状态] -10删除 10未结帖 20结帖 30私密")
|
||||
private short status = 10;
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
public void setContentid(int contentid) {
|
||||
this.contentid = contentid;
|
||||
}
|
||||
|
||||
public int getContentId() {
|
||||
return this.contentId;
|
||||
public int getContentid() {
|
||||
return this.contentid;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
public void setUserid(int userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
public int getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
@@ -91,84 +93,83 @@ public class Content implements UF<ContentInfo>,java.io.Serializable {
|
||||
return this.digest;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
public String getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
public void setCreatetime(long createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
return cate;
|
||||
public long getCreatetime() {
|
||||
return this.createtime;
|
||||
}
|
||||
|
||||
public void setCate(int cate) {
|
||||
public void setCate(short cate) {
|
||||
this.cate = cate;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
public short getCate() {
|
||||
return this.cate;
|
||||
}
|
||||
|
||||
public void setType(short type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
public short getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
public int getReplyNum() {
|
||||
return replyNum;
|
||||
public void setReplynum(int replynum) {
|
||||
this.replynum = replynum;
|
||||
}
|
||||
|
||||
public void setReplyNum(int replyNum) {
|
||||
this.replyNum = replyNum;
|
||||
public int getReplynum() {
|
||||
return this.replynum;
|
||||
}
|
||||
|
||||
public int getViewNum() {
|
||||
return viewNum;
|
||||
public void setViewnum(int viewnum) {
|
||||
this.viewnum = viewnum;
|
||||
}
|
||||
|
||||
public void setViewNum(int viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
public int getViewnum() {
|
||||
return this.viewnum;
|
||||
}
|
||||
|
||||
public int getWonderful() {
|
||||
return wonderful;
|
||||
}
|
||||
|
||||
public void setWonderful(int wonderful) {
|
||||
public void setWonderful(short wonderful) {
|
||||
this.wonderful = wonderful;
|
||||
}
|
||||
|
||||
public int getTop() {
|
||||
return top;
|
||||
public short getWonderful() {
|
||||
return this.wonderful;
|
||||
}
|
||||
|
||||
public void setTop(int top) {
|
||||
public void setTop(short top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public int getSolved() {
|
||||
return solved;
|
||||
public short getTop() {
|
||||
return this.top;
|
||||
}
|
||||
|
||||
public void setSolved(int solved) {
|
||||
public void setSolved(short solved) {
|
||||
this.solved = solved;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
public short getSolved() {
|
||||
return this.solved;
|
||||
}
|
||||
|
||||
public void setStatus(short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
public short getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@@ -182,21 +183,21 @@ public class Content implements UF<ContentInfo>,java.io.Serializable {
|
||||
@Override
|
||||
public ContentInfo createInfo() {
|
||||
ContentInfo info = new ContentInfo();
|
||||
info.setContentId(contentId);
|
||||
info.setUserId(userId);
|
||||
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.setViewnum(viewnum);
|
||||
info.setReplynum(replynum);
|
||||
info.setWonderful(wonderful);
|
||||
info.setTop(top);
|
||||
info.setSolved(solved);
|
||||
info.setStatus(status);
|
||||
|
||||
info.setTypeName(types.getOrDefault(type, "其他").toString());
|
||||
info.setCreateTime(LxyKit.dateFmt(createTime));
|
||||
info.setTypename(types.getOrDefault((int)type, "其他").toString());
|
||||
info.setCreatetime(LxyKit.dateFmt(createtime));
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
@@ -18,10 +18,10 @@ public class ContentBean implements FilterBean,java.io.Serializable {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(comment = "[内容id]")
|
||||
private int contentId;
|
||||
private int contentid;
|
||||
|
||||
@Column(comment = "[用户id]")
|
||||
private int userId;
|
||||
private int userid;
|
||||
|
||||
@Column(length = 64, comment = "[标题]")
|
||||
private String title = "";
|
||||
@@ -33,7 +33,7 @@ public class ContentBean implements FilterBean,java.io.Serializable {
|
||||
private String content = "";
|
||||
|
||||
@Column(comment = "[创建时间]")
|
||||
private long createTime;
|
||||
private long createtime;
|
||||
|
||||
@Column(comment = "[类别]")
|
||||
private int cate;
|
||||
@@ -42,10 +42,10 @@ public class ContentBean implements FilterBean,java.io.Serializable {
|
||||
private int type;
|
||||
|
||||
@Column(comment = "[评论数]")
|
||||
private int replyNum;
|
||||
private int replynum;
|
||||
|
||||
@Column(comment = "[阅读量]")
|
||||
private int viewNum;
|
||||
private int viewnum;
|
||||
|
||||
/* @Column(comment = "[精] 0否,1是")
|
||||
private int wonderful;
|
||||
@@ -59,20 +59,20 @@ public class ContentBean implements FilterBean,java.io.Serializable {
|
||||
@Column(comment = "[状态]")
|
||||
private int status = 1;*/
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
public void setContentid(int contentid) {
|
||||
this.contentid = contentid;
|
||||
}
|
||||
|
||||
public int getContentId() {
|
||||
return this.contentId;
|
||||
public int getContentid() {
|
||||
return this.contentid;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
public void setUserid(int userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
public int getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
@@ -99,12 +99,12 @@ public class ContentBean implements FilterBean,java.io.Serializable {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
public void setCreatetime(long createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
public long getCreatetime() {
|
||||
return this.createtime;
|
||||
}
|
||||
|
||||
public int getCate() {
|
||||
@@ -123,20 +123,20 @@ public class ContentBean implements FilterBean,java.io.Serializable {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public int getReplyNum() {
|
||||
return replyNum;
|
||||
public int getReplynum() {
|
||||
return replynum;
|
||||
}
|
||||
|
||||
public void setReplyNum(int replyNum) {
|
||||
this.replyNum = replyNum;
|
||||
public void setReplynum(int replynum) {
|
||||
this.replynum = replynum;
|
||||
}
|
||||
|
||||
public int getViewNum() {
|
||||
return viewNum;
|
||||
public int getViewnum() {
|
||||
return viewnum;
|
||||
}
|
||||
|
||||
public void setViewNum(int viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
public void setViewnum(int viewnum) {
|
||||
this.viewnum = viewnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.lxyer.bbs.content;
|
||||
|
||||
import com.lxyer.bbs.base.UI;
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import com.lxyer.bbs.base.user.UserRecord;
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -11,38 +11,38 @@ import java.io.Serializable;
|
||||
*/
|
||||
public class ContentInfo implements UI<ContentInfo>,Serializable {
|
||||
|
||||
private int contentId;
|
||||
private int userId;
|
||||
private int contentid;
|
||||
private int userid;
|
||||
private String title = "";
|
||||
private String digest = "";
|
||||
private String content = "";
|
||||
private String createTime;
|
||||
private String createtime;
|
||||
private int cate;
|
||||
private int type;
|
||||
private int replyNum;
|
||||
private int viewNum;
|
||||
private int replynum;
|
||||
private int viewnum;
|
||||
private int wonderful;
|
||||
private int top;
|
||||
private int solved;
|
||||
private int status = 1;
|
||||
private int status = 10;
|
||||
|
||||
private String typeName;
|
||||
private int hadCollect = -1;
|
||||
private String typename;
|
||||
private int hadcollect = -1;
|
||||
|
||||
public int getContentId() {
|
||||
return contentId;
|
||||
public int getContentid() {
|
||||
return contentid;
|
||||
}
|
||||
|
||||
public void setContentId(int contentId) {
|
||||
this.contentId = contentId;
|
||||
public void setContentid(int contentid) {
|
||||
this.contentid = contentid;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
public int getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
public void setUserid(int userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
@@ -85,20 +85,20 @@ public class ContentInfo implements UI<ContentInfo>,Serializable {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getReplyNum() {
|
||||
return replyNum;
|
||||
public int getReplynum() {
|
||||
return replynum;
|
||||
}
|
||||
|
||||
public void setReplyNum(int replyNum) {
|
||||
this.replyNum = replyNum;
|
||||
public void setReplynum(int replynum) {
|
||||
this.replynum = replynum;
|
||||
}
|
||||
|
||||
public int getViewNum() {
|
||||
return viewNum;
|
||||
public int getViewnum() {
|
||||
return viewnum;
|
||||
}
|
||||
|
||||
public void setViewNum(int viewNum) {
|
||||
this.viewNum = viewNum;
|
||||
public void setViewnum(int viewnum) {
|
||||
this.viewnum = viewnum;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
@@ -133,41 +133,41 @@ public class ContentInfo implements UI<ContentInfo>,Serializable {
|
||||
this.solved = solved;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
public String getCreatetime() {
|
||||
return createtime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
public void setCreatetime(String createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
public String getTypename() {
|
||||
return typename;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
public void setTypename(String typename) {
|
||||
this.typename = typename;
|
||||
}
|
||||
|
||||
public int getHadCollect() {
|
||||
return hadCollect;
|
||||
public int getHadcollect() {
|
||||
return hadcollect;
|
||||
}
|
||||
|
||||
public void setHadCollect(int hadCollect) {
|
||||
this.hadCollect = hadCollect;
|
||||
public void setHadcollect(int hadcollect) {
|
||||
this.hadcollect = hadcollect;
|
||||
}
|
||||
|
||||
|
||||
//-----------
|
||||
private User user;
|
||||
private UserRecord user;
|
||||
@ConvertColumn(ignore = true)
|
||||
@Override
|
||||
public User getUser() {
|
||||
public UserRecord getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentInfo setUser(User user) {
|
||||
public ContentInfo setUser(UserRecord user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
@@ -39,20 +39,20 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
||||
}
|
||||
|
||||
@RestMapping(name = "query", auth = false, comment = "内容列表")
|
||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, String actived, int currentId){
|
||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, String actived, int currentid){
|
||||
FilterNode filterNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1);
|
||||
switch (actived){
|
||||
case "top": filterNode.and("top", 1);break;
|
||||
case "untop": filterNode.and("top", 0);break;
|
||||
case "unsolved": filterNode.and("solved", 0);break;
|
||||
case "solved": filterNode.and("solved", 1);break;
|
||||
case "wonderful": filterNode.and("wonderful", 1);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)){//私密贴:非管理员限制查看
|
||||
filterNode.and(FilterNode.create("status", FilterExpress.NOTEQUAL, 3).or(FilterNode.create("status", 3).and("userId", currentId)));
|
||||
}else if (currentId <= 0){//私密贴:未登录限制查看
|
||||
filterNode.and("status", FilterExpress.NOTEQUAL, 3);
|
||||
if (!userService.isAdmin(currentid)){//私密贴:非管理员限制查看
|
||||
filterNode.and(FilterNode.create("status", FilterExpress.NOTEQUAL, 30).or(FilterNode.create("status", 30).and("userid", currentid)));
|
||||
}else if (currentid <= 0){//私密贴:未登录限制查看
|
||||
filterNode.and("status", FilterExpress.NOTEQUAL, 30);
|
||||
}
|
||||
|
||||
return contentQuery(flipper, filterNode);
|
||||
@@ -74,13 +74,13 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
||||
return RetCodes.retResult(-1, "少年你的文章标题太长啦,精简化标题吧,为了更好的SEO长度请少于64个字节");
|
||||
}
|
||||
|
||||
if (content.getContentId() < 1){
|
||||
int maxId = source.getNumberResult(Content.class, FilterFunc.MAX, 10_0000, "contentId").intValue();
|
||||
if (content.getContentid() < 1){
|
||||
int maxId = source.getNumberResult(Content.class, FilterFunc.MAX, 10_0000, "contentid").intValue();
|
||||
int userId = userService.currentUserId(sessionid);
|
||||
|
||||
content.setContentId(maxId+1);
|
||||
content.setCreateTime(System.currentTimeMillis());
|
||||
content.setUserId(userId);
|
||||
content.setContentid(maxId+1);
|
||||
content.setCreatetime(System.currentTimeMillis());
|
||||
content.setUserid(userId);
|
||||
|
||||
source.insert(content);
|
||||
}else {
|
||||
@@ -101,29 +101,29 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
||||
|
||||
//收藏状态
|
||||
if (userId > 0){
|
||||
ActLog actLog = source.find(ActLog.class, FilterNode.create("cate", 2).and("tid", contentid).and("status", 1));
|
||||
if (actLog != null) contentInfo.setHadCollect(1);
|
||||
ActLog actLog = source.find(ActLog.class, FilterNode.create("cate", 20).and("tid", contentid).and("status", 10));
|
||||
if (actLog != null) contentInfo.setHadcollect(1);
|
||||
}
|
||||
return contentInfo;
|
||||
}
|
||||
|
||||
@RestMapping(name = "upview", comment = "增加文章1个访问量")
|
||||
public void incrViewNum(int contentId){
|
||||
source.updateColumn(Content.class, contentId, ColumnValue.inc("viewNum", 1));
|
||||
source.updateColumn(Content.class, contentId, ColumnValue.inc("viewnum", 1));
|
||||
}
|
||||
|
||||
@RestMapping(name = "collect", comment = "内容收藏")
|
||||
public RetResult collect(@RestSessionid String sessionid, int contentId, int ok){
|
||||
int userId = userService.currentUserId(sessionid);//不会为空
|
||||
public RetResult collect(@RestSessionid String sessionid, int contentid, int ok){
|
||||
int userid = userService.currentUserId(sessionid);//不会为空
|
||||
|
||||
ActLog actLog = source.find(ActLog.class, FilterNode.create("userId", userId).and("tid", contentId).and("cate", 2));
|
||||
ActLog actLog = source.find(ActLog.class, FilterNode.create("userid", userid).and("tid", contentid).and("cate", 20));
|
||||
if (actLog == null && ok == 1){
|
||||
actLog = new ActLog().cate(2).tid(contentId).userId(userId);
|
||||
actLog.setCreateTime(System.currentTimeMillis());
|
||||
actLog = new ActLog(20, contentid, userid);//.cate(2).tid(contentId).userId(userId);
|
||||
actLog.setCreatetime(System.currentTimeMillis());
|
||||
source.insert(actLog);
|
||||
}else if (actLog != null && actLog.getStatus() != ok){
|
||||
actLog.setStatus(ok);
|
||||
actLog.setCreateTime(System.currentTimeMillis());
|
||||
actLog.setStatus((short) ok);
|
||||
actLog.setCreatetime(System.currentTimeMillis());
|
||||
source.update(actLog);
|
||||
}else {
|
||||
return RetCodes.retResult(-1, ok == 1 ? "已收藏" : "已取消收藏");
|
||||
@@ -134,14 +134,14 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
||||
|
||||
@RestMapping(name = "collectquery", comment = "收藏列表")
|
||||
public Sheet<ContentInfo> collectQuery(@RestSessionid String sessionid){
|
||||
int userId = userService.currentUserId(sessionid);
|
||||
int userid = userService.currentUserId(sessionid);
|
||||
|
||||
Flipper flipper = new Flipper().sort("createTime DESC");
|
||||
FilterNode filterNode = FilterNode.create("cate", 2).and("status", 1).and("userId", userId);
|
||||
Sheet<ActLog> actLogs = source.querySheet(ActLog.class, SelectColumn.createIncludes("tid", "createTime"), flipper, filterNode);
|
||||
Flipper flipper = new Flipper().sort("createtime DESC");
|
||||
FilterNode filterNode = FilterNode.create("cate", 20).and("status", 10).and("userid", userid);
|
||||
Sheet<ActLog> actLogs = source.querySheet(ActLog.class, SelectColumn.createIncludes("tid", "createtime"), flipper, filterNode);
|
||||
|
||||
int[] contentids = actLogs.stream().mapToInt(x -> x.getTid()).toArray();
|
||||
Sheet<Content> contents = source.querySheet(Content.class, SelectColumn.createIncludes("contentId", "title"), flipper.sort(null), FilterNode.create("contentId", FilterExpress.IN, contentids));
|
||||
Sheet<Content> contents = source.querySheet(Content.class, SelectColumn.createIncludes("contentid", "title"), flipper.sort(null), FilterNode.create("contentid", FilterExpress.IN, contentids));
|
||||
|
||||
Sheet<ContentInfo> infos = createInfo(contents);
|
||||
|
||||
@@ -149,7 +149,7 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
||||
}
|
||||
|
||||
@RestMapping(name = "set", comment = "内容操作")
|
||||
public RetResult contentSet(int id, String field, int v){
|
||||
public RetResult contentSet(int id, String field, short v){
|
||||
source.updateColumn(Content.class, id, field, v);
|
||||
return RetResult.success();
|
||||
}
|
||||
@@ -157,13 +157,13 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
||||
@RestMapping(name = "t",auth = false, comment = "测试HttpScope 模板使用")
|
||||
public HttpScope t(){
|
||||
ContentService contentService = this;
|
||||
Flipper flipper = new Flipper().limit(30).sort("top DESC,createTime DESC");
|
||||
Flipper flipper = new Flipper().limit(30).sort("top DESC,createtime DESC");
|
||||
//置顶贴
|
||||
FilterNode topNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1).and("top", FilterExpress.GREATERTHAN, 0);
|
||||
FilterNode topNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -10).and("top", FilterExpress.GREATERTHANOREQUALTO, 20);
|
||||
Sheet<ContentInfo> top = contentService.contentQuery(flipper, topNode);
|
||||
|
||||
//非置顶贴
|
||||
FilterNode untopNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -1).and("top", 0);
|
||||
FilterNode untopNode = FilterNode.create("status", FilterExpress.NOTEQUAL, -10).and("top", 0);
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, untopNode);
|
||||
|
||||
//热帖
|
||||
@@ -171,13 +171,16 @@ public class ContentService extends BaseService<Content,ContentInfo>{
|
||||
Sheet<ContentInfo> hotView = contentService.contentQuery(flipper2, "");*/
|
||||
|
||||
//热议
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replyNum DESC");
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", 0);
|
||||
|
||||
//最新加入
|
||||
Sheet<UserInfo> lastReg = userService.lastReg();
|
||||
|
||||
Kv kv = Kv.by("top", top).set("contents", contents).set("hotReply", hotReply).set("lastReg", lastReg);
|
||||
Kv kv = Kv.by("top", top)
|
||||
.set("contents", contents)
|
||||
.set("hotReply", hotReply)
|
||||
.set("lastReg", lastReg);
|
||||
|
||||
return HttpScope.refer("index.html").attr(kv);
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package com.lxyer.bbs.servlet;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.lxyer.bbs.base.BaseServlet;
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import com.lxyer.bbs.base.user.UserRecord;
|
||||
import com.lxyer.bbs.comment.CommentInfo;
|
||||
import com.lxyer.bbs.content.ContentInfo;
|
||||
import org.redkale.net.http.*;
|
||||
@@ -28,8 +28,8 @@ public class ContentServlet extends BaseServlet {
|
||||
int curr = request.getIntParameter("curr", 1);
|
||||
|
||||
//分页帖子列表
|
||||
Flipper flipper = new Flipper().offset((curr-1)*15).limit(15).sort("top DESC,createTime DESC");
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, actived, currentId);
|
||||
Flipper flipper = new Flipper().offset((curr-1)*15).limit(15).sort("top DESC,createtime DESC");
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, actived, currentid);
|
||||
|
||||
Kv kv = Kv.by("contents", contents).set("url", request.getRequestURI())
|
||||
.set("actived", actived).set("curr", curr);
|
||||
@@ -61,15 +61,15 @@ public class ContentServlet extends BaseServlet {
|
||||
//Sheet<ContentInfo> hotView = contentService.contentQuery(flipper2, "");
|
||||
|
||||
//热议
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replyNum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", currentId);
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", currentid);
|
||||
|
||||
//更新
|
||||
CompletableFuture.supplyAsync(new Supplier<String>() {
|
||||
@Override
|
||||
public String get() {
|
||||
User user = request.currentUser();
|
||||
if (user == null || user.getUserId() > 10_0003)
|
||||
UserRecord user = request.currentUser();
|
||||
if (user == null || user.getUserid() > 10_0003)
|
||||
contentService.incrViewNum(contentid);
|
||||
return "";
|
||||
}
|
||||
@@ -88,17 +88,17 @@ public class ContentServlet extends BaseServlet {
|
||||
|
||||
Kv column = Kv.by("qz", 10).set("fx", 20).set("jy", 30).set("gg", 40).set("dt", 50);//栏目
|
||||
|
||||
Flipper flipper = new Flipper().offset((curr-1) * 20).limit(20).sort("top DESC,createTime DESC");
|
||||
Flipper flipper = new Flipper().offset((curr-1) * 20).limit(20).sort("top DESC,createtime DESC");
|
||||
//帖子列表
|
||||
FilterNode filterNode = FilterNode.create("status", NOTEQUAL, -1).and("type", column.getAs(para));
|
||||
if (solved > -1) filterNode.and("solved", solved);
|
||||
if (wonderful > -1) filterNode.and("wonderful", wonderful);
|
||||
if (solved > 0) filterNode.and("solved", 20);
|
||||
if (wonderful > 0) filterNode.and("wonderful", 20);
|
||||
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, setPrivate(filterNode));
|
||||
|
||||
//热议
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replyNum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", currentId);
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", currentid);
|
||||
|
||||
|
||||
Kv kv = Kv.by("contents", contents).set("hotReply", hotReply)
|
||||
|
@@ -13,6 +13,7 @@ import org.redkale.source.Flipper;
|
||||
import org.redkale.util.Sheet;
|
||||
|
||||
import static org.redkale.source.FilterExpress.GREATERTHAN;
|
||||
import static org.redkale.source.FilterExpress.GREATERTHANOREQUALTO;
|
||||
import static org.redkale.source.FilterExpress.NOTEQUAL;
|
||||
|
||||
|
||||
@@ -26,13 +27,13 @@ public class IndexServlet extends BaseServlet {
|
||||
|
||||
@HttpMapping(url = "/", auth = false, comment = "社区首页")
|
||||
public void abc(HttpRequest request, HttpResponse response){
|
||||
Flipper flipper = new Flipper().limit(30).sort("top DESC,createTime DESC");
|
||||
Flipper flipper = new Flipper().limit(30).sort("top DESC,createtime DESC");
|
||||
//置顶贴
|
||||
FilterNode topNode = FilterNode.create("status", NOTEQUAL, -1).and("top", GREATERTHAN, 0);
|
||||
FilterNode topNode = FilterNode.create("status", NOTEQUAL, -10).and("top", GREATERTHANOREQUALTO, 20);
|
||||
Sheet<ContentInfo> top = contentService.contentQuery(flipper, setPrivate(topNode));
|
||||
|
||||
//非置顶贴
|
||||
FilterNode untopNode = FilterNode.create("status", NOTEQUAL, -1).and("top", 0);
|
||||
FilterNode untopNode = FilterNode.create("status", NOTEQUAL, -10).and("top", 10);
|
||||
Sheet<ContentInfo> contents = contentService.contentQuery(flipper, setPrivate(untopNode));
|
||||
|
||||
//热帖
|
||||
@@ -40,8 +41,8 @@ public class IndexServlet extends BaseServlet {
|
||||
Sheet<ContentInfo> hotView = contentService.contentQuery(flipper2, "");*/
|
||||
|
||||
//热议
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replyNum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", currentId);
|
||||
Flipper flipper3 = new Flipper().limit(8).sort("replynum DESC");
|
||||
Sheet<ContentInfo> hotReply = contentService.contentQuery(flipper3, "", currentid);
|
||||
|
||||
//最新加入
|
||||
Sheet<UserInfo> lastReg = userService.lastReg();
|
||||
|
@@ -2,7 +2,7 @@ package com.lxyer.bbs.servlet;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.lxyer.bbs.base.BaseServlet;
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import com.lxyer.bbs.base.user.UserRecord;
|
||||
import com.lxyer.bbs.base.user.UserBean;
|
||||
import com.lxyer.bbs.base.user.UserInfo;
|
||||
import com.lxyer.bbs.comment.CommentInfo;
|
||||
@@ -58,9 +58,9 @@ public class UserServlet extends BaseServlet {
|
||||
}
|
||||
|
||||
//创建的帖子
|
||||
Flipper flipper = new Flipper().limit(8).sort("createTime DESC");
|
||||
Flipper flipper = new Flipper().limit(8).sort("createtime DESC");
|
||||
ContentBean bean = new ContentBean();
|
||||
bean.setUserId(user.getUserId());
|
||||
bean.setUserid(user.getUserid());
|
||||
Sheet<ContentInfo> contents = contentService.queryByBean(flipper, bean);
|
||||
|
||||
//收藏的帖子
|
||||
@@ -72,30 +72,30 @@ public class UserServlet extends BaseServlet {
|
||||
}
|
||||
|
||||
//-------用户主页------
|
||||
int userId = 0;
|
||||
int userid = 0;
|
||||
if ("nick".equals(para)){//通过@ 点击跳转
|
||||
String nickname = request.getParameter("nickname");
|
||||
UserBean userBean = new UserBean();
|
||||
userBean.setNickname(nickname);
|
||||
Sheet<User> users = userService.queryUser(new Flipper().limit(1), userBean);
|
||||
Sheet<UserRecord> users = userService.queryUser(new Flipper().limit(1), userBean);
|
||||
if (users.getTotal() > 0){
|
||||
userId = users.stream().findFirst().orElse(null).getUserId();
|
||||
userid = users.stream().findFirst().orElse(null).getUserid();
|
||||
}
|
||||
}else {//直接访问
|
||||
userId = getParaToInt(0);
|
||||
userid = getParaToInt(0);
|
||||
}
|
||||
|
||||
//用户信息
|
||||
UserInfo user = userService.findUserInfo(userId);
|
||||
UserInfo user = userService.findUserInfo(userid);
|
||||
|
||||
//帖子
|
||||
Flipper flipper = new Flipper().limit(8).sort("createTime DESC");
|
||||
Flipper flipper = new Flipper().limit(8).sort("createtime DESC");
|
||||
ContentBean bean = new ContentBean();
|
||||
bean.setUserId(userId);
|
||||
bean.setUserid(userid);
|
||||
Sheet<ContentInfo> contents = contentService.queryByBean(flipper, bean);
|
||||
|
||||
//回复
|
||||
Sheet<CommentInfo> comments = commentService.queryByUserid(userId);
|
||||
Sheet<CommentInfo> comments = commentService.queryByUserid(userid);
|
||||
|
||||
Kv kv = Kv.by("contents", contents).set("user", user).set("comments", comments);
|
||||
finish("/user/home.html", kv);
|
||||
|
Reference in New Issue
Block a user