wangliang 4 tahun lalu
induk
melakukan
dbae15993c

+ 5 - 3
themis-backend/src/main/java/com/qmth/themis/backend/websocketTemplete/WebSocketAdminMessageTemplete.java

@@ -2,6 +2,7 @@ package com.qmth.themis.backend.websocketTemplete;
 
 import com.alibaba.fastjson.JSONObject;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.dto.WebsocketDto;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import org.slf4j.Logger;
@@ -30,7 +31,7 @@ public class WebSocketAdminMessageTemplete {
      * @return
      */
     @Transactional
-    public Result syncStatus(String body) {
+    public WebsocketDto syncStatus(String body) {
         JSONObject jsonObject = JSONObject.parseObject(body);
         log.info("syncStatus jsonObject:{}", jsonObject.toJSONString());
         return this.syncAck();
@@ -41,9 +42,10 @@ public class WebSocketAdminMessageTemplete {
      *
      * @return
      */
-    public Result syncAck() {
+    public WebsocketDto syncAck() {
         Map map = new HashMap<>();
         map.put(SystemConstant.ACK_MESSAGE, System.currentTimeMillis());
-        return ResultUtil.ok(map);
+        WebsocketDto websocketDto = new WebsocketDto(this.getClass().getEnclosingMethod().getName(), map);
+        return websocketDto;
     }
 }

+ 1 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -69,6 +69,7 @@ public class SystemConstant {
     public static final String EXCEL_PREFIX = ".xlsx";
     public static final String TXT_PREFIX = ".txt";
     public static final String GLOBAL = "global";
+    public static final String OK = "ok";
     /**
      * session过期时间
      */

+ 59 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/WebsocketDto.java

@@ -0,0 +1,59 @@
+package com.qmth.themis.business.dto;
+
+import com.qmth.themis.business.constant.SystemConstant;
+
+import java.io.Serializable;
+
+/**
+* @Description: websocket dto
+* @Param:
+* @return:
+* @Author: wangliang
+* @Date: 2020/7/28
+*/
+public class WebsocketDto implements Serializable {
+
+    private String type; //类型
+    private Long time; //时间戳
+    private Object body; //内容
+
+    public WebsocketDto(){
+
+    }
+
+    public WebsocketDto(String type,Object body){
+        this.type = type;
+        this.time = System.currentTimeMillis();
+        this.body = body;
+    }
+
+    public WebsocketDto(Object body){
+        this.type = SystemConstant.OK;
+        this.time = System.currentTimeMillis();
+        this.body = body;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public Long getTime() {
+        return time;
+    }
+
+    public void setTime(Long time) {
+        this.time = time;
+    }
+
+    public Object getBody() {
+        return body;
+    }
+
+    public void setBody(Object body) {
+        this.body = body;
+    }
+}

+ 13 - 10
themis-exam/src/main/java/com/qmth/themis/exam/websocketTemplete/WebSocketOeMessageTemplete.java

@@ -2,6 +2,7 @@ package com.qmth.themis.exam.websocketTemplete;
 
 import com.alibaba.fastjson.JSONObject;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.dto.WebsocketDto;
 import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.util.JacksonUtil;
@@ -40,7 +41,7 @@ public class WebSocketOeMessageTemplete {
      * @return
      */
     @Transactional
-    public Result clientPaperDownload(String body) {
+    public WebsocketDto clientPaperDownload(String body) {
         JSONObject jsonObject = JSONObject.parseObject(body);
         log.info("clientPaperDownload jsonObject:{}", jsonObject.toJSONString());
         if (Objects.isNull(jsonObject.get("recordId")) || Objects.equals(jsonObject.get("recordId"), "")) {
@@ -54,7 +55,7 @@ public class WebSocketOeMessageTemplete {
         tOeExamRecord.setPaperDownload(0);
         tOeExamRecordService.updateById(tOeExamRecord);
         //todo 更新redis考试记录缓存
-        return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
+        return new WebsocketDto(SystemConstant.SUCCESS);
     }
 
     /**
@@ -64,7 +65,7 @@ public class WebSocketOeMessageTemplete {
      * @return
      */
     @Transactional
-    public Result syncStatus(String body) {
+    public WebsocketDto syncStatus(String body) {
         JSONObject jsonObject = JSONObject.parseObject(body);
         log.info("syncStatus jsonObject:{}", jsonObject.toJSONString());
         if (Objects.isNull(jsonObject.get("recordId")) || Objects.equals(jsonObject.get("recordId"), "")) {
@@ -94,10 +95,11 @@ public class WebSocketOeMessageTemplete {
      *
      * @return
      */
-    public Result syncAck() {
+    public WebsocketDto syncAck() {
         Map map = new HashMap<>();
         map.put(SystemConstant.ACK_MESSAGE, System.currentTimeMillis());
-        return ResultUtil.ok(map);
+        WebsocketDto websocketDto = new WebsocketDto(this.getClass().getEnclosingMethod().getName(), map);
+        return websocketDto;
     }
 
     /**
@@ -106,7 +108,7 @@ public class WebSocketOeMessageTemplete {
      * @param body
      * @return
      */
-    public Result invigilateLivenessVerify(String body) {
+    public WebsocketDto invigilateLivenessVerify(String body) {
         return null;
     }
 
@@ -116,7 +118,7 @@ public class WebSocketOeMessageTemplete {
      * @param body
      * @return
      */
-    public Result invigilateNotice(String body) {
+    public WebsocketDto invigilateNotice(String body) {
         return null;
     }
 
@@ -125,10 +127,11 @@ public class WebSocketOeMessageTemplete {
      *
      * @return
      */
-    public Result invigilateNoticeAck() {
+    public WebsocketDto invigilateNoticeAck() {
         Map map = new HashMap<>();
         map.put(SystemConstant.ACK_MESSAGE, System.currentTimeMillis());
-        return ResultUtil.ok(map);
+        WebsocketDto websocketDto = new WebsocketDto(this.getClass().getEnclosingMethod().getName(), map);
+        return websocketDto;
     }
 
     /**
@@ -137,7 +140,7 @@ public class WebSocketOeMessageTemplete {
      * @param body
      * @return
      */
-    public Result invigilateStopExam(String body) {
+    public WebsocketDto invigilateStopExam(String body) {
         return null;
     }
 }