add location api
This commit is contained in:
@@ -59,8 +59,43 @@ public interface IDeviceService {
|
||||
@ApiOperation(value = "Deletes a device", authorizations = {@Authorization("device")})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device was deleted successfully."),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists"),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
|
||||
})
|
||||
Response deleteDevice(@ApiParam(value = "The device id", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
/**
|
||||
* Get the last known location of a device
|
||||
*
|
||||
* @param id The id of the device
|
||||
* @return The last known location
|
||||
*/
|
||||
@GET
|
||||
@Path("device/{id}/location")
|
||||
@ApiOperation(value = "Returns the last known location of a device", authorizations = {@Authorization("device")})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The request was successfully"),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists"),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges")
|
||||
})
|
||||
Response getDeviceLocation(@ApiParam(value = "The device id", required = true) @PathParam("id") @Valid @Min(0) long id);
|
||||
|
||||
/**
|
||||
* Set the last known location of a device
|
||||
*
|
||||
* @param id The id of the device
|
||||
* @param location The location to set
|
||||
*/
|
||||
@POST
|
||||
@Path("device/{id}/location")
|
||||
@ApiOperation(value = "Updates the last known location of a device", authorizations = {@Authorization("device")})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The request was successfully", response = Location.class),
|
||||
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists"),
|
||||
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges"),
|
||||
@ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "Invalid request parameter.")
|
||||
})
|
||||
Response setDeviceLocation(@ApiParam(value = "The device id", required = true) @PathParam("id") @Valid @Min(0) long id,
|
||||
@ApiParam(value = "The location to set", required = true) @Valid Location location);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.maptology.api.device;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* * A data transfer object for a device location with associated swagger and
|
||||
* jaxb annotations that supports xml and json serialization.
|
||||
*
|
||||
* @author Ole
|
||||
*/
|
||||
@XmlRootElement
|
||||
@ApiModel(description = "Represents a location.")
|
||||
public class Location {
|
||||
|
||||
@Min(-180)
|
||||
@Max(180)
|
||||
@XmlAttribute(required = true)
|
||||
@ApiModelProperty(value = "The longitude of a location", required = true)
|
||||
private double lon;
|
||||
|
||||
@Min(-90)
|
||||
@Max(90)
|
||||
@XmlAttribute(required = true)
|
||||
@ApiModelProperty(value = "The latitude of a location", required = true)
|
||||
private double lat;
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
@ApiModelProperty(value = "The timestamp of the location", required = true)
|
||||
private long timestamp;
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user