Search in sources :

Example 6 with TestMsgVo

use of com.ngtesting.platform.vo.TestMsgVo in project ngtesting-platform by aaronchen2k.

the class OptFacade method opt.

public void opt(JSONObject json, String userId) {
    Map<String, Object> ret = new HashMap<>();
    String type = json.getString("type");
    try {
        if (WsConstant.WS_OPEN.equals(type) || WsConstant.WS_TODO.equals(type)) {
            List<TestMsgVo> msgs = msgService.list(Long.valueOf(userId), false);
            List<TestAlertVo> alerts = alertService.list(Long.valueOf(userId), false);
            ret.put("msgs", msgs);
            ret.put("alerts", alerts);
            ret.put("type", WsConstant.WS_MSG_AND_ALERT_LASTEST);
        } else if (WsConstant.WS_OPT_ENTER_CHAT_ROOM.equals(type)) {
            ret = optChat.enter(json);
        } else if (WsConstant.WS_OPT_CHAT.equals(type)) {
            ret = optChat.chat(json);
        }
    } catch (Exception e) {
        logger.error(ExceptionUtil.GetExceptionInfo(e));
        if (e.getCause() instanceof TimeoutException) {
            ret.put("code", RespCode.BIZ_FAIL.getCode());
            ret.put("msg", "操作超时!");
        } else {
            ret.put("msg", "操作出错,请稍后重试");
        }
    }
    ret.put("code", 1);
    if (ret.get("type") != null) {
        scopeBean.sendMessageToClient(userId, new TextMessage(JSON.toJSONString(ret)));
    }
}
Also used : TestMsgVo(com.ngtesting.platform.vo.TestMsgVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestAlertVo(com.ngtesting.platform.vo.TestAlertVo) TimeoutException(java.util.concurrent.TimeoutException) TextMessage(org.springframework.web.socket.TextMessage) TimeoutException(java.util.concurrent.TimeoutException)

Example 7 with TestMsgVo

use of com.ngtesting.platform.vo.TestMsgVo in project ngtesting-platform by aaronchen2k.

the class MsgServiceImpl method genVo.

@Override
public TestMsgVo genVo(TestMsg po) {
    TestMsgVo vo = new TestMsgVo();
    BeanUtilEx.copyProperties(vo, po);
    TestUser user = (TestUser) get(TestUser.class, po.getUserId());
    vo.setAvatar(user.getAvatar());
    return vo;
}
Also used : TestMsgVo(com.ngtesting.platform.vo.TestMsgVo) TestUser(com.ngtesting.platform.entity.TestUser)

Aggregations

TestMsgVo (com.ngtesting.platform.vo.TestMsgVo)7 TestMsg (com.ngtesting.platform.entity.TestMsg)4 JSONObject (com.alibaba.fastjson.JSONObject)3 HashMap (java.util.HashMap)3 AuthPassport (com.ngtesting.platform.util.AuthPassport)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 TestUser (com.ngtesting.platform.entity.TestUser)1 TestAlertVo (com.ngtesting.platform.vo.TestAlertVo)1 UserVo (com.ngtesting.platform.vo.UserVo)1 LinkedList (java.util.LinkedList)1 TimeoutException (java.util.concurrent.TimeoutException)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1 TextMessage (org.springframework.web.socket.TextMessage)1