|
@@ -20,7 +20,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.client.ResourceAccessException;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import es.uv.garcosda.shared.User;
|
|
|
import es.uv.garcosda.shared.Video;
|
|
|
+import es.uv.garcosda.shared.VideoDTO;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/api/v1/videos")
|
|
@@ -28,9 +30,13 @@ import es.uv.garcosda.shared.Video;
|
|
|
public class VideosController {
|
|
|
|
|
|
private RestTemplate template;
|
|
|
+
|
|
|
@Value("${api.uri.videos}")
|
|
|
private String videosApi;
|
|
|
|
|
|
+ @Value("${api.uri.users}")
|
|
|
+ private String usersApi;
|
|
|
+
|
|
|
public VideosController() {
|
|
|
this.template = new RestTemplate();
|
|
|
}
|
|
@@ -65,7 +71,9 @@ public class VideosController {
|
|
|
try {
|
|
|
Video v = template.getForObject(videosApi+"/"+id, Video.class);
|
|
|
if(v.getId() != null) {
|
|
|
- return new ResponseEntity<Video>(v, HttpStatus.OK);
|
|
|
+ User u = template.getForObject(usersApi+"/"+v.getUserId(), User.class);
|
|
|
+ VideoDTO vo = new VideoDTO(v, u);
|
|
|
+ return new ResponseEntity<VideoDTO>(vo, HttpStatus.OK);
|
|
|
}
|
|
|
return new ResponseEntity<String>("Video not found", HttpStatus.NOT_FOUND);
|
|
|
}
|