NoticeController.java
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cn.com.glsx.consumer.controller;
import cn.com.glsx.consumer.common.Contants;
import cn.com.glsx.consumer.entity.AqaraEvent;
import cn.com.glsx.consumer.service.DeviceEventService;
import cn.com.glsx.consumer.service.InfoService;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author zhouhaibao
* @date 2021/4/18 10:39
*/
@Controller
@RequestMapping("/notice")
@Slf4j
public class NoticeController {
@Autowired
private DeviceEventService deviceEventService;
@RequestMapping(value = "/deviceInfo",method = RequestMethod.POST)
@ResponseBody
public String deviceInfo(@RequestBody String requestBody){
// 解密请求体信息
try {
log.info("消息内容{}",requestBody);
// 解密传过来的状态值
AqaraEvent aqaraEvent = JSONObject.parseObject(requestBody, AqaraEvent.class);
if(Contants.MSG_TYPE_RESOURCE.equals(aqaraEvent.getMsgType())){
deviceEventService.processResMessage(aqaraEvent);
}else if(Contants.MSG_TYPE_DEIVCE.equals(aqaraEvent.getMsgType())){
deviceEventService.processDevMessage(aqaraEvent);
}
JSONObject jsonObject=new JSONObject();
jsonObject.put("code",0);
jsonObject.put("result","glsxtest");
return jsonObject.toJSONString();
}catch (Exception e){
e.printStackTrace();
return null;
}
}
}