| Line 15... |
Line 15... |
| 15 |
import org.springframework.web.bind.annotation.RequestMapping;
|
15 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 16 |
import org.springframework.web.bind.annotation.RequestMethod;
|
16 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 17 |
|
17 |
|
| 18 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
18 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 19 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
19 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| - |
|
20 |
import com.spice.profitmandi.dao.entity.dtr.GpsLocation;
|
| - |
|
21 |
import com.spice.profitmandi.dao.entity.dtr.GpsLocationModel;
|
| 20 |
import com.spice.profitmandi.dao.entity.user.Device;
|
22 |
import com.spice.profitmandi.dao.entity.user.Device;
|
| 21 |
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
|
23 |
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
|
| - |
|
24 |
import com.spice.profitmandi.dao.repository.user.GpsLocationRepository;
|
| 22 |
import com.spice.profitmandi.web.req.AddDevicesRequest;
|
25 |
import com.spice.profitmandi.web.req.AddDevicesRequest;
|
| 23 |
|
26 |
|
| 24 |
import io.swagger.annotations.ApiImplicitParam;
|
27 |
import io.swagger.annotations.ApiImplicitParam;
|
| 25 |
import io.swagger.annotations.ApiImplicitParams;
|
28 |
import io.swagger.annotations.ApiImplicitParams;
|
| 26 |
import io.swagger.annotations.ApiOperation;
|
29 |
import io.swagger.annotations.ApiOperation;
|
| Line 32... |
Line 35... |
| 32 |
@Autowired
|
35 |
@Autowired
|
| 33 |
ResponseSender<?> responseSender;
|
36 |
ResponseSender<?> responseSender;
|
| 34 |
|
37 |
|
| 35 |
@Autowired
|
38 |
@Autowired
|
| 36 |
private DeviceRepository deviceRepository;
|
39 |
private DeviceRepository deviceRepository;
|
| - |
|
40 |
|
| - |
|
41 |
@Autowired
|
| - |
|
42 |
private GpsLocationRepository gpsLocationRepository;
|
| 37 |
|
43 |
|
| 38 |
private static final Logger LOGGER = LogManager.getLogger(RetailerController.class);
|
44 |
private static final Logger LOGGER = LogManager.getLogger(RetailerController.class);
|
| 39 |
|
45 |
|
| - |
|
46 |
@RequestMapping(value = "/devices/add-new", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
47 |
@ApiImplicitParams({
|
| - |
|
48 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| - |
|
49 |
@ApiOperation(value = "")
|
| - |
|
50 |
public ResponseEntity<?> devicesInfo1(HttpServletRequest request, @RequestBody AddDevicesRequest addDevicesRequest) {
|
| - |
|
51 |
Device device = this.deviceInfo(request, addDevicesRequest);
|
| - |
|
52 |
return responseSender.ok(device.getId());
|
| - |
|
53 |
}
|
| 40 |
@RequestMapping(value = "/devices/add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
54 |
@RequestMapping(value = "/devices/add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 41 |
@ApiImplicitParams({
|
55 |
@ApiImplicitParams({
|
| 42 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
56 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 43 |
@ApiOperation(value = "")
|
57 |
@ApiOperation(value = "")
|
| 44 |
public ResponseEntity<?> devicesInfo(HttpServletRequest request, @RequestBody AddDevicesRequest addDevicesRequest)
|
58 |
public ResponseEntity<?> devicesInfo(HttpServletRequest request, @RequestBody AddDevicesRequest addDevicesRequest)
|
| 45 |
throws ProfitMandiBusinessException {
|
59 |
throws ProfitMandiBusinessException {
|
| - |
|
60 |
this.deviceInfo(request, addDevicesRequest);
|
| - |
|
61 |
return responseSender.ok(true);
|
| - |
|
62 |
}
|
| - |
|
63 |
|
| - |
|
64 |
private Device deviceInfo(HttpServletRequest request, AddDevicesRequest addDevicesRequest) {
|
| 46 |
Device device = deviceRepository.selectByImeiNumber(addDevicesRequest.getImeinumber());
|
65 |
Device device = deviceRepository.selectByImeiNumber(addDevicesRequest.getImeinumber());
|
| 47 |
LOGGER.info("divices" + device);
|
66 |
LOGGER.info("devices" + device);
|
| 48 |
if (device == null) {
|
67 |
if (device == null) {
|
| 49 |
device = new Device();
|
68 |
device = new Device();
|
| 50 |
device.setImeiNumber(addDevicesRequest.getImeinumber());
|
69 |
device.setImeiNumber(addDevicesRequest.getImeinumber());
|
| 51 |
}
|
70 |
}
|
| 52 |
device.setUser_id(addDevicesRequest.getUser_id());
|
71 |
device.setUser_id(addDevicesRequest.getUser_id());
|
| Line 60... |
Line 79... |
| 60 |
if(addDevicesRequest.getGcm_regid() == null)
|
79 |
if(addDevicesRequest.getGcm_regid() == null)
|
| 61 |
LOGGER.info("gcm" + addDevicesRequest.getGcm_regid());
|
80 |
LOGGER.info("gcm" + addDevicesRequest.getGcm_regid());
|
| 62 |
else {
|
81 |
else {
|
| 63 |
device.setFcmId(addDevicesRequest.getGcm_regid());
|
82 |
device.setFcmId(addDevicesRequest.getGcm_regid());
|
| 64 |
}
|
83 |
}
|
| 65 |
|
- |
|
| 66 |
|
- |
|
| 67 |
device.setModified(LocalDateTime.now());
|
84 |
device.setModified(LocalDateTime.now());
|
| 68 |
deviceRepository.persist(device);
|
85 |
deviceRepository.persist(device);
|
| - |
|
86 |
return device;
|
| - |
|
87 |
}
|
| - |
|
88 |
|
| - |
|
89 |
|
| - |
|
90 |
@RequestMapping(value = "/devices/location", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| - |
|
91 |
public ResponseEntity<?> deviceLocation(HttpServletRequest request, @RequestBody GpsLocationModel locationModel) {
|
| - |
|
92 |
GpsLocation gpsLocation = new GpsLocation();
|
| - |
|
93 |
gpsLocation.setGps(locationModel.isGps());
|
| - |
|
94 |
gpsLocation.setDeviceId(locationModel.getDeviceId());
|
| - |
|
95 |
gpsLocation.setLat(locationModel.getLat());
|
| - |
|
96 |
gpsLocation.setLng(locationModel.getLng());
|
| - |
|
97 |
gpsLocation.setUserId(locationModel.getUserId());
|
| - |
|
98 |
gpsLocation.setCreateTime(LocalDateTime.now());
|
| - |
|
99 |
gpsLocationRepository.persist(gpsLocation);
|
| 69 |
return responseSender.ok(true);
|
100 |
return responseSender.ok(true);
|
| 70 |
}
|
101 |
}
|
| 71 |
}
|
102 |
}
|