1、用户资料加入[个人博客地址、码云/GitHub地址](部分用户开放设置)
2、加入用户信息接口UF/UI,优化用户信息设置代码
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.lxyer.bbs.content;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.lxyer.bbs.base.UF;
|
||||
import com.lxyer.bbs.base.kit.LxyKit;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
@@ -12,7 +13,7 @@ import javax.persistence.*;
|
||||
*/
|
||||
@Cacheable(interval = 5*60)
|
||||
@Table(catalog = "redbbs", name = "content", comment = "[内容表]")
|
||||
public class Content implements java.io.Serializable {
|
||||
public class Content implements UF<ContentInfo>,java.io.Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@@ -177,7 +178,9 @@ public class Content implements java.io.Serializable {
|
||||
}
|
||||
|
||||
private static final Kv types = Kv.by(10, "求助").set(20, "分享").set(30, "讨论").set(40, "公告").set(50, "动态");
|
||||
public ContentInfo createContentInfo(){
|
||||
|
||||
@Override
|
||||
public ContentInfo createInfo() {
|
||||
ContentInfo info = new ContentInfo();
|
||||
info.setContentId(contentId);
|
||||
info.setUserId(userId);
|
||||
|
@@ -1,17 +1,22 @@
|
||||
package com.lxyer.bbs.content;
|
||||
|
||||
import com.lxyer.bbs.base.UI;
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import org.redkale.convert.ConvertColumn;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/11/26 20:52.
|
||||
*/
|
||||
public class ContentInfo implements Serializable {
|
||||
public class ContentInfo implements UI<ContentInfo>,Serializable {
|
||||
|
||||
private int contentId;
|
||||
private int userId;
|
||||
private String title = "";
|
||||
private String digest = "";
|
||||
private String content = "";
|
||||
private String createTime;
|
||||
private int cate;
|
||||
private int type;
|
||||
private int replyNum;
|
||||
@@ -21,10 +26,7 @@ public class ContentInfo implements Serializable {
|
||||
private int solved;
|
||||
private int status = 1;
|
||||
|
||||
private String createTime;
|
||||
private String typeName;
|
||||
private String nickname = "";
|
||||
private String avatar = "";
|
||||
private int hadCollect = -1;
|
||||
|
||||
public int getContentId() {
|
||||
@@ -147,22 +149,6 @@ public class ContentInfo implements Serializable {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
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 int getHadCollect() {
|
||||
return hadCollect;
|
||||
}
|
||||
@@ -170,4 +156,19 @@ public class ContentInfo implements Serializable {
|
||||
public void setHadCollect(int hadCollect) {
|
||||
this.hadCollect = hadCollect;
|
||||
}
|
||||
|
||||
|
||||
//-----------
|
||||
private User user;
|
||||
@ConvertColumn(ignore = true)
|
||||
@Override
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentInfo setUser(User user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@@ -2,10 +2,8 @@ package com.lxyer.bbs.content;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.lxyer.bbs.base.BaseService;
|
||||
import com.lxyer.bbs.base.kit.LxyKit;
|
||||
import com.lxyer.bbs.base.kit.RetCodes;
|
||||
import com.lxyer.bbs.base.entity.ActLog;
|
||||
import com.lxyer.bbs.base.user.User;
|
||||
import com.lxyer.bbs.base.kit.RetCodes;
|
||||
import com.lxyer.bbs.base.user.UserInfo;
|
||||
import com.lxyer.bbs.base.user.UserService;
|
||||
import org.redkale.net.http.*;
|
||||
@@ -15,14 +13,12 @@ import org.redkale.util.SelectColumn;
|
||||
import org.redkale.util.Sheet;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/11/26 9:33.
|
||||
*/
|
||||
@RestService(automapping = true, comment = "内容管理")
|
||||
public class ContentService extends BaseService{
|
||||
public class ContentService extends BaseService<Content,ContentInfo>{
|
||||
|
||||
@Resource
|
||||
protected UserService userService;
|
||||
@@ -36,22 +32,9 @@ public class ContentService extends BaseService{
|
||||
public Sheet<ContentInfo> contentQuery(Flipper flipper, FilterNode filterNode){
|
||||
Sheet<Content> contents = source.querySheet(Content.class, flipper, filterNode);
|
||||
|
||||
int[] userids = contents.stream().mapToInt(x -> x.getUserId()).distinct().toArray();
|
||||
Sheet<ContentInfo> infos = createInfo(contents);
|
||||
setIUser(infos);
|
||||
|
||||
Sheet<ContentInfo> infos = new Sheet<>();
|
||||
List<ContentInfo> list = new ArrayList<>();
|
||||
|
||||
List<User> users = source.queryList(User.class, SelectColumn.createIncludes("userId","avatar", "nickname"), FilterNode.create("userId", FilterExpress.IN, userids));
|
||||
contents.forEach(x->{
|
||||
ContentInfo contentInfo = x.createContentInfo();
|
||||
User user = users.stream().filter(k -> k.getUserId() == x.getUserId()).findFirst().orElse(new User());
|
||||
contentInfo.setAvatar(user.getAvatar());
|
||||
contentInfo.setNickname(user.getNickname());
|
||||
list.add(contentInfo);
|
||||
});
|
||||
|
||||
infos.setRows(list);
|
||||
infos.setTotal(contents.getTotal());
|
||||
return infos;
|
||||
}
|
||||
|
||||
@@ -79,15 +62,7 @@ public class ContentService extends BaseService{
|
||||
public Sheet<ContentInfo> queryByBean(Flipper flipper, FilterBean bean){
|
||||
Sheet<Content> contents = source.querySheet(Content.class, flipper, bean);
|
||||
|
||||
Sheet<ContentInfo> infos = new Sheet<>();
|
||||
List<ContentInfo> list = new ArrayList<>();
|
||||
|
||||
contents.forEach(x->{
|
||||
list.add(x.createContentInfo());
|
||||
});
|
||||
|
||||
infos.setRows(list);
|
||||
infos.setTotal(contents.getTotal());
|
||||
Sheet<ContentInfo> infos = createInfo(contents);
|
||||
|
||||
return infos;
|
||||
}
|
||||
@@ -122,10 +97,7 @@ public class ContentService extends BaseService{
|
||||
Content content = source.find(Content.class, contentid);
|
||||
if (content == null) return null;
|
||||
|
||||
ContentInfo contentInfo = content.createContentInfo();
|
||||
User user = source.find(User.class, content.getUserId());
|
||||
contentInfo.setAvatar(user.getAvatar());
|
||||
contentInfo.setNickname(user.getNickname());
|
||||
ContentInfo contentInfo = setIUser(content.createInfo());
|
||||
|
||||
//收藏状态
|
||||
if (userId > 0){
|
||||
@@ -171,20 +143,7 @@ public class ContentService extends BaseService{
|
||||
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<ContentInfo> infos = new Sheet<>();
|
||||
ArrayList<ContentInfo> list = new ArrayList<>();
|
||||
|
||||
actLogs.forEach(x->{
|
||||
Content content = contents.stream().filter(k -> k.getContentId() == x.getTid()).findFirst().orElse(null);
|
||||
if (content != null){
|
||||
ContentInfo info = content.createContentInfo();
|
||||
info.setCreateTime(LxyKit.dateFmt(x.getCreateTime()));
|
||||
list.add(info);
|
||||
}
|
||||
});
|
||||
|
||||
infos.setRows(list);
|
||||
infos.setTotal(actLogs.getTotal());
|
||||
Sheet<ContentInfo> infos = createInfo(contents);
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
Reference in New Issue
Block a user