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;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 管理端websocket模版
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/24
 */
@Component
public class WebSocketAdminMessageTemplete {
    private final static Logger log = LoggerFactory.getLogger(WebSocketAdminMessageTemplete.class);

    /**
     * 状态同步
     *
     * @param body
     * @return
     */
    public WebsocketDto syncStatus(String body) {
        JSONObject jsonObject = JSONObject.parseObject(body);
        log.info("syncStatus jsonObject:{}", jsonObject.toJSONString());
        return this.syncAck();
    }

    /**
     * 同步确认
     *
     * @return
     */
    public WebsocketDto syncAck() {
        return new WebsocketDto(this.getClass().getEnclosingMethod().getName(), Collections.singletonMap(SystemConstant.ACK_MESSAGE, System.currentTimeMillis()));
    }
}
