package com.zhujizheng.IHome.msgnotify.net; import com.zhujizheng.IHome.msgnotify.service.PYMsgNotifyServer; import com.zhujizheng.IHome.msgnotify.vo.PYMsgNotifyVO; import com.zhujizheng.IHome.websocket.Net.Base.NetProtocolBase; import lombok.extern.slf4j.Slf4j; import net.sf.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Slf4j @Component public class NetUpdateMsgNotify extends NetProtocolBase { @Autowired private PYMsgNotifyServer msgNotifyServer; @Override public void dealWithJSONAndSid(JSONObject json, String sid) { super.dealWithJSONAndSid(json, sid); String operate = json.getString("operate"); int notifyId = json.getInt("notifyId"); int selfId = Integer.parseInt(sid); // 下发消息通知更新 NetMsgNotifyAck ack = new NetMsgNotifyAck(); if (operate.equals("delete")) { PYMsgNotifyVO vo = msgNotifyServer.deleteMsgNotify(notifyId); if (vo == null) { this.sendServerError(sid); } else { ack.sendObject(vo, sid); } } else if (operate.equals("clear")) { PYMsgNotifyVO vo = msgNotifyServer.clearMsgNotify(notifyId); if (vo == null) { this.sendServerError(sid); } else { ack.sendObject(vo, sid); } } else if (operate.equals("clearAll")) { int result = msgNotifyServer.clearAllMsgNotify(selfId); if (result == 0) { this.sendServerError(sid); } } } }