|
@@ -2,16 +2,14 @@ package cn.efunbox.audio.controller;
|
|
|
|
|
|
import cn.efunbox.audio.entity.Channel;
|
|
|
import cn.efunbox.audio.entity.Device;
|
|
|
+import cn.efunbox.audio.entity.Grouping;
|
|
|
import cn.efunbox.audio.service.ChannelService;
|
|
|
import cn.efunbox.audio.service.DeviceService;
|
|
|
import cn.efunbox.audio.utils.ApiCode;
|
|
|
import cn.efunbox.audio.utils.HttpUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -53,28 +51,59 @@ public class DeviceController {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+// @RequestMapping(value = "/register" ,method = RequestMethod.POST)
|
|
|
+// public Map Register(HttpServletRequest request){
|
|
|
+// Map map = new HashMap<>();
|
|
|
+// String idChannel = request.getParameter("idChannel");
|
|
|
+// String idDevice = request.getParameter("idDevice");
|
|
|
+// if(idChannel==null || idDevice==null){
|
|
|
+// map.put("code", ApiCode.PARAMETER_ERROR.getCode());
|
|
|
+// map.put("msg", ApiCode.PARAMETER_ERROR.getMessage());
|
|
|
+// return map;
|
|
|
+// }
|
|
|
+// if(deviceService.CheckRegister(Long.valueOf(idChannel), Long.valueOf(idDevice))) {
|
|
|
+// map.put("code", ApiCode.RECORD_EXIST.getCode());
|
|
|
+// map.put("msg", ApiCode.RECORD_EXIST.getMessage());
|
|
|
+// return map;
|
|
|
+// }
|
|
|
+// List<Channel> channelList = channelService.SearchById(Long.valueOf(idChannel));
|
|
|
+// if(channelList==null || channelList.size()<1){
|
|
|
+// map.put("code", ApiCode.PARAMETER_ERROR.getCode());
|
|
|
+// map.put("msg", ApiCode.PARAMETER_ERROR.getMessage());
|
|
|
+// return map;
|
|
|
+// }
|
|
|
+// Device device = deviceService.Register(Long.valueOf(idChannel), Long.valueOf(idDevice));
|
|
|
+// if(device!=null){
|
|
|
+// map.put("code", ApiCode.OK.getCode());
|
|
|
+// Map data = new HashMap<>();
|
|
|
+// data.put("id", device.getId());
|
|
|
+// data.put("token", device.getTokenNew());
|
|
|
+// map.put("data", data);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return map;
|
|
|
+// }
|
|
|
+
|
|
|
@RequestMapping(value = "/register" ,method = RequestMethod.POST)
|
|
|
- public Map Register(HttpServletRequest request){
|
|
|
+ public Map Register(HttpServletRequest request, @RequestBody Device device){
|
|
|
Map map = new HashMap<>();
|
|
|
- String idChannel = request.getParameter("idChannel");
|
|
|
- String idDevice = request.getParameter("idDevice");
|
|
|
- if(idChannel==null || idDevice==null){
|
|
|
+ if(device.getIdChannel()==null || device.getIdDevice()==null){
|
|
|
map.put("code", ApiCode.PARAMETER_ERROR.getCode());
|
|
|
map.put("msg", ApiCode.PARAMETER_ERROR.getMessage());
|
|
|
return map;
|
|
|
}
|
|
|
- if(deviceService.CheckRegister(Long.valueOf(idChannel), Long.valueOf(idDevice))){
|
|
|
+ if(deviceService.CheckRegister(device.getIdChannel(), device.getIdDevice())){
|
|
|
map.put("code", ApiCode.RECORD_EXIST.getCode());
|
|
|
map.put("msg", ApiCode.RECORD_EXIST.getMessage());
|
|
|
return map;
|
|
|
}
|
|
|
- List<Channel> channelList = channelService.SearchById(Long.valueOf(idChannel));
|
|
|
+ List<Channel> channelList = channelService.SearchById(device.getIdChannel());
|
|
|
if(channelList==null || channelList.size()<1){
|
|
|
map.put("code", ApiCode.PARAMETER_ERROR.getCode());
|
|
|
map.put("msg", ApiCode.PARAMETER_ERROR.getMessage());
|
|
|
return map;
|
|
|
}
|
|
|
- Device device = deviceService.Register(Long.valueOf(idChannel), Long.valueOf(idDevice));
|
|
|
+ device = deviceService.Register(device.getIdChannel(), device.getIdDevice());
|
|
|
if(device!=null){
|
|
|
map.put("code", ApiCode.OK.getCode());
|
|
|
Map data = new HashMap<>();
|