Minor Changes
This commit is contained in:
parent
8d0ec2ea63
commit
2b93ffa07b
2 changed files with 13 additions and 1 deletions
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
@ -37,6 +38,12 @@ public class SecurityCameraController {
|
||||||
return securityCameraService.findById(id).orElseThrow(NotFoundException::new);
|
return securityCameraService.findById(id).orElseThrow(NotFoundException::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}/video")
|
||||||
|
public FileSystemResource getVideo(@PathVariable("id") long id) throws NotFoundException {
|
||||||
|
SecurityCamera s = findById(id);
|
||||||
|
return s.getSurveillanceVideo();
|
||||||
|
}
|
||||||
|
|
||||||
private SecurityCamera save(SecurityCamera newSC, SecurityCameraSaveRequest sc) {
|
private SecurityCamera save(SecurityCamera newSC, SecurityCameraSaveRequest sc) {
|
||||||
newSC.setName(sc.getName());
|
newSC.setName(sc.getName());
|
||||||
newSC.setRoomId(sc.getRoomId());
|
newSC.setRoomId(sc.getRoomId());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
@ -21,8 +22,12 @@ public class SecurityCamera extends Switchable {
|
||||||
@NotNull
|
@NotNull
|
||||||
private String path = "backend/media/security_camera_videos/security_camera_1.mp4";
|
private String path = "backend/media/security_camera_videos/security_camera_1.mp4";
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
public FileSystemResource getSurveillanceVideo() {
|
public FileSystemResource getSurveillanceVideo() {
|
||||||
return new FileSystemResource(path);
|
return new FileSystemResource(new File(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue