删除:JBean 工具类
This commit is contained in:
parent
13f46961aa
commit
c3bc62ca50
@ -1,91 +0,0 @@
|
||||
package net.tccn.bbs.base;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by liangxianyou
|
||||
*/
|
||||
public class JBean<T> /*extends RetResult*/ {
|
||||
private int retcode;
|
||||
private String retinfo = "";
|
||||
private T result;
|
||||
private Map<String, Object> attach;
|
||||
|
||||
public JBean(int retcode) {
|
||||
this.retcode = retcode;
|
||||
}
|
||||
|
||||
public JBean(int retcode, String retinfo) {
|
||||
this.retcode = retcode;
|
||||
this.retinfo = retinfo;
|
||||
}
|
||||
|
||||
public static JBean by(int retcode, String retinfo) {
|
||||
JBean jBean = new JBean(retcode, retinfo);
|
||||
return jBean;
|
||||
}
|
||||
|
||||
public static JBean by(int retcode, String retinfo, Object t) {
|
||||
JBean jBean = new JBean(retcode, retinfo);
|
||||
jBean.setResult(t);
|
||||
return jBean;
|
||||
}
|
||||
|
||||
public JBean(T result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public int getRetcode() {
|
||||
return retcode;
|
||||
}
|
||||
|
||||
public void setRetcode(int retcode) {
|
||||
this.retcode = retcode;
|
||||
}
|
||||
|
||||
public String getRetinfo() {
|
||||
return retinfo;
|
||||
}
|
||||
|
||||
public void setRetinfo(String retinfo) {
|
||||
this.retinfo = retinfo;
|
||||
}
|
||||
|
||||
public T getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(T result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public Map<String, Object> getAttach() {
|
||||
return attach;
|
||||
}
|
||||
|
||||
public void setAttach(Map<String, Object> attach) {
|
||||
this.attach = attach;
|
||||
}
|
||||
|
||||
public JBean attach(String key, Object object) {
|
||||
if (attach == null)
|
||||
attach = new HashMap<>();
|
||||
attach.put(key, object);
|
||||
return this;
|
||||
}
|
||||
|
||||
private static final JBean ok = new JBean(0);
|
||||
|
||||
public static JBean ok() {
|
||||
return ok;
|
||||
}
|
||||
|
||||
public static JBean faild(String retinfo) {
|
||||
return new JBean(-1, retinfo);
|
||||
}
|
||||
|
||||
public static JBean by(Object object) {
|
||||
return new JBean(object);
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package net.tccn.redim;
|
||||
|
||||
import net.tccn.bbs.base.JBean;
|
||||
import net.tccn.bbs.user.UserService;
|
||||
import net.tccn.redim.entity.MsgRecord;
|
||||
import net.tccn.redim.info.MsgInfo;
|
||||
import net.tccn.redim.service.ImFriendService;
|
||||
import net.tccn.redim.service.ImMsgService;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.service.RetResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@ -62,12 +62,12 @@ public class ChatWebSocket extends WebSocket {
|
||||
//接收离线信息
|
||||
int finalUserid = userid;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
JBean<List<MsgRecord>> list = chatService.offlineMsg(finalUserid);
|
||||
RetResult<List<MsgRecord>> list = chatService.offlineMsg(finalUserid);
|
||||
List<net.tccn.redim.entity.MsgRecord> recordList = list.getResult();
|
||||
|
||||
if (recordList != null && recordList.size() > 0) {
|
||||
recordList.forEach(msgRecord -> {
|
||||
JBean<net.tccn.redim.info.MsgInfo> msgInfo = chatService.createMsgInfo(msgRecord);
|
||||
RetResult<MsgInfo> msgInfo = chatService.createMsgInfo(msgRecord);
|
||||
send(msgInfo.getResult()).thenAccept(x -> {
|
||||
if ((Integer) x == 0) {//发送成功
|
||||
msgRecord.setStatus((short) 20);
|
||||
@ -91,7 +91,7 @@ public class ChatWebSocket extends WebSocket {
|
||||
public void onChatMessage(MsgRecord msg, Map<String, String> extmap) {
|
||||
msg.setFromuserid((Integer) getUserid());
|
||||
|
||||
JBean<MsgInfo> msgInfo = chatService.createMsgInfo(msg);
|
||||
RetResult<MsgInfo> msgInfo = chatService.createMsgInfo(msg);
|
||||
|
||||
sendMessage(msgInfo.getResult(), msg.getTouserid()).thenAccept(x -> {
|
||||
if ((Integer) x == 0) {//发送成功
|
||||
|
@ -2,7 +2,6 @@ package net.tccn.redim.impl;
|
||||
|
||||
import com.jfinal.kit.Kv;
|
||||
import net.tccn.bbs.base.BaseService;
|
||||
import net.tccn.bbs.base.JBean;
|
||||
import net.tccn.bbs.user.UserDetail;
|
||||
import net.tccn.bbs.user.UserInfo;
|
||||
import net.tccn.bbs.user.UserService;
|
||||
@ -11,6 +10,7 @@ import org.redkale.boot.Application;
|
||||
import org.redkale.net.TransportFactory;
|
||||
import org.redkale.net.TransportGroupInfo;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.source.FilterExpress;
|
||||
import org.redkale.source.FilterNode;
|
||||
import org.redkale.util.ResourceType;
|
||||
@ -33,7 +33,7 @@ public class ImFriendServiceImpl extends BaseService implements ImFriendService
|
||||
public static Application application;
|
||||
|
||||
@Override
|
||||
public JBean friends(String sessionid) {
|
||||
public RetResult friends(String sessionid) {
|
||||
List<UserDetail> records = dataSource.queryList(UserDetail.class, FilterNode.create("status", FilterExpress.NOTEQUAL, -10));
|
||||
|
||||
Kv data = Kv.create();
|
||||
@ -71,11 +71,11 @@ public class ImFriendServiceImpl extends BaseService implements ImFriendService
|
||||
|
||||
data.set("mine", mine).set("friend", friend).set("group", group);
|
||||
|
||||
return JBean.by(Kv.by("code", 0).set("msg", "").set("data", data));
|
||||
return RetResult.success(Kv.by("code", 0).set("msg", "").set("data", data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBean friendList(String sessionid) {
|
||||
public RetResult friendList(String sessionid) {
|
||||
|
||||
/*SncpClient sncpClient = new SncpClient("", ImFriendService.class, this, transportFactory,
|
||||
true, this.getClass(), new InetSocketAddress("192.168.227.1", 7070));*/
|
||||
@ -96,27 +96,27 @@ public class ImFriendServiceImpl extends BaseService implements ImFriendService
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBean groups(String sessionid) {
|
||||
public RetResult groups(String sessionid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBean itemSave(String sessionid) {
|
||||
public RetResult itemSave(String sessionid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBean addFriend(String sessionid) {
|
||||
public RetResult addFriend(String sessionid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBean groupSave(String sessionid) {
|
||||
public RetResult groupSave(String sessionid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBean addGroup(String sessionid) {
|
||||
public RetResult addGroup(String sessionid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package net.tccn.redim.impl;
|
||||
|
||||
import net.tccn.bbs.base.BaseService;
|
||||
import net.tccn.bbs.base.JBean;
|
||||
import net.tccn.bbs.user.UserDetail;
|
||||
import net.tccn.redim.entity.MsgRecord;
|
||||
import net.tccn.redim.info.MsgInfo;
|
||||
import net.tccn.redim.service.ImMsgService;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.source.FilterNode;
|
||||
import org.redkale.util.ResourceType;
|
||||
|
||||
@ -25,9 +25,9 @@ public class ImMsgServiceImpl extends BaseService implements ImMsgService {
|
||||
* @param msg
|
||||
*/
|
||||
@Override
|
||||
public JBean insert(MsgRecord... msg) {
|
||||
public RetResult insert(MsgRecord... msg) {
|
||||
dataSource.insertAsync(msg);
|
||||
return JBean.ok();
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,9 +36,9 @@ public class ImMsgServiceImpl extends BaseService implements ImMsgService {
|
||||
* @param msg
|
||||
*/
|
||||
@Override
|
||||
public JBean update(MsgRecord... msg) {
|
||||
public RetResult update(MsgRecord... msg) {
|
||||
dataSource.updateAsync(msg);
|
||||
return JBean.ok();
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,7 +47,7 @@ public class ImMsgServiceImpl extends BaseService implements ImMsgService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JBean list() {
|
||||
public RetResult list() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class ImMsgServiceImpl extends BaseService implements ImMsgService {
|
||||
* @param msg
|
||||
*/
|
||||
@Override
|
||||
public JBean<MsgInfo> createMsgInfo(MsgRecord msg) {
|
||||
public RetResult<MsgInfo> createMsgInfo(MsgRecord msg) {
|
||||
MsgInfo info = new MsgInfo();
|
||||
int fromuserid = msg.getFromuserid();
|
||||
|
||||
@ -80,13 +80,13 @@ public class ImMsgServiceImpl extends BaseService implements ImMsgService {
|
||||
info.setFromid(msg.getFromuserid());
|
||||
info.setTimestamp(msg.getCreatetime());
|
||||
|
||||
return JBean.by(info);
|
||||
return RetResult.success(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBean<List<MsgRecord>> offlineMsg(int userid) {
|
||||
public RetResult<List<MsgRecord>> offlineMsg(int userid) {
|
||||
List<MsgRecord> records = dataSource.queryList(MsgRecord.class, FilterNode.create("touserid", userid).and("status", 10));
|
||||
return JBean.by(records);
|
||||
return RetResult.success(records);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.tccn.redim.service;
|
||||
|
||||
import net.tccn.bbs.base.JBean;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.service.Service;
|
||||
|
||||
public interface ImFriendService extends Service {
|
||||
@ -12,21 +12,21 @@ public interface ImFriendService extends Service {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JBean friends(String sessionid);
|
||||
RetResult friends(String sessionid);
|
||||
|
||||
/**
|
||||
* 根据条件查询好友
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JBean friendList(String sessionid);
|
||||
RetResult friendList(String sessionid);
|
||||
|
||||
/**
|
||||
* 群组数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JBean groups(String sessionid);
|
||||
RetResult groups(String sessionid);
|
||||
|
||||
|
||||
//================ 操作好友相关 =================
|
||||
@ -36,14 +36,14 @@ public interface ImFriendService extends Service {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JBean itemSave(String sessionid);
|
||||
RetResult itemSave(String sessionid);
|
||||
|
||||
/**
|
||||
* 添加好友
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JBean addFriend(String sessionid);
|
||||
RetResult addFriend(String sessionid);
|
||||
|
||||
//================ 操作群组相关 =================
|
||||
|
||||
@ -52,14 +52,14 @@ public interface ImFriendService extends Service {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JBean groupSave(String sessionid);
|
||||
RetResult groupSave(String sessionid);
|
||||
|
||||
/**
|
||||
* 加入群组
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JBean addGroup(String sessionid);
|
||||
RetResult addGroup(String sessionid);
|
||||
|
||||
/**
|
||||
* 登录人用户id
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.tccn.redim.service;
|
||||
|
||||
import net.tccn.bbs.base.JBean;
|
||||
import net.tccn.redim.entity.MsgRecord;
|
||||
import net.tccn.redim.info.MsgInfo;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.service.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -15,26 +15,26 @@ public interface ImMsgService extends Service {
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
JBean insert(MsgRecord... msg);
|
||||
RetResult insert(MsgRecord... msg);
|
||||
|
||||
/**
|
||||
* 消息修改
|
||||
*/
|
||||
JBean update(MsgRecord... msg);
|
||||
RetResult update(MsgRecord... msg);
|
||||
|
||||
/**
|
||||
* 历史消息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
JBean list();
|
||||
RetResult list();
|
||||
|
||||
/**
|
||||
* 创建消息体
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
JBean<MsgInfo> createMsgInfo(MsgRecord msg);
|
||||
RetResult<MsgInfo> createMsgInfo(MsgRecord msg);
|
||||
|
||||
/**
|
||||
* 获取离线消息
|
||||
@ -42,5 +42,5 @@ public interface ImMsgService extends Service {
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
JBean<List<MsgRecord>> offlineMsg(int userid);
|
||||
RetResult<List<MsgRecord>> offlineMsg(int userid);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.tccn.redim.servlet;
|
||||
|
||||
import net.tccn.bbs.base.JBean;
|
||||
import net.tccn.redim.service.ImFriendService;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.service.RetResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.logging.Logger;
|
||||
@ -23,7 +23,7 @@ public class ImServlet extends HttpServlet {
|
||||
|
||||
String token = request.getParameter("token");
|
||||
|
||||
JBean jBean = imFriendService.friends(token);
|
||||
RetResult jBean = imFriendService.friends(token);
|
||||
response.finish(jBean.getResult());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user