社区升级
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user