Merge branch 'master' of https://github.com/esensar/steleks_web_app
commit
5314f4b944
2
config
2
config
|
@ -1 +1 @@
|
|||
Subproject commit 0d028147e90627b077c5435b557d6b3d7d19623c
|
||||
Subproject commit 75a784ba6ed8f6e70ee91808d3752443e3a04d1d
|
|
@ -5,6 +5,8 @@ import ba.steleks.model.Event;
|
|||
import ba.steleks.model.EventTeam;
|
||||
import ba.steleks.repository.EventTeamJpaRepository;
|
||||
import ba.steleks.repository.EventsJpaRepository;
|
||||
import ba.steleks.service.Service;
|
||||
import ba.steleks.service.discovery.ServiceDiscoveryClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.data.rest.webmvc.RepositoryRestController;
|
||||
|
@ -31,19 +33,22 @@ public class EventTeamController {
|
|||
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
private ServiceDiscoveryClient discoveryClient;
|
||||
|
||||
@Autowired
|
||||
public EventTeamController(RestTemplateBuilder restTemplateBuilder, EventTeamJpaRepository repository) {
|
||||
this.restTemplate = restTemplateBuilder.build();
|
||||
public EventTeamController(EventTeamJpaRepository repository, RestTemplateBuilder restTemplateBuilder, ServiceDiscoveryClient discoveryClient) {
|
||||
this.repository = repository;
|
||||
this.restTemplate = restTemplateBuilder.build();
|
||||
this.discoveryClient = discoveryClient;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/eventTeams", method = RequestMethod.POST)
|
||||
public ResponseEntity<?> add(@RequestBody EventTeam eventTeam) throws ExternalServiceException {
|
||||
|
||||
String oviTimoviNeki = "http://localhost:9010/teams/{id}";
|
||||
String teamsServiceBase = discoveryClient.getServiceUrl(Service.TEAMS);
|
||||
try {
|
||||
|
||||
String response = restTemplate.getForObject(oviTimoviNeki, String.class, eventTeam.getTeamId());
|
||||
String response = restTemplate.getForObject(teamsServiceBase + "/teams/{id}", String.class, eventTeam.getTeamId());
|
||||
EventTeam result = repository.save(eventTeam);
|
||||
URI location = ServletUriComponentsBuilder
|
||||
.fromCurrentRequest().path("/{id}")
|
||||
|
|
|
@ -6,6 +6,8 @@ import ba.steleks.error.exception.ExternalServiceException;
|
|||
import ba.steleks.model.Event;
|
||||
import ba.steleks.model.Media;
|
||||
import ba.steleks.repository.MediaJpaRepository;
|
||||
import ba.steleks.service.Service;
|
||||
import ba.steleks.service.discovery.ServiceDiscoveryClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.data.rest.webmvc.RepositoryRestController;
|
||||
|
@ -25,19 +27,21 @@ public class MediaController {
|
|||
|
||||
private MediaJpaRepository repository;
|
||||
private RestTemplate restTemplate;
|
||||
private ServiceDiscoveryClient discoveryClient;
|
||||
|
||||
@Autowired
|
||||
public MediaController(RestTemplateBuilder restTemplateBuilder, MediaJpaRepository repository) {
|
||||
public MediaController(MediaJpaRepository repository, RestTemplateBuilder restTemplateBuilder, ServiceDiscoveryClient discoveryClient) {
|
||||
this.repository = repository;
|
||||
this.restTemplate = restTemplateBuilder.build();
|
||||
this.discoveryClient = discoveryClient;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/medias", method = RequestMethod.POST)
|
||||
public ResponseEntity<?> add(@RequestBody Media media) throws ExternalServiceException {
|
||||
|
||||
String oviUseriNeki = "http://localhost:8090/users/{id}";
|
||||
String usersServiceBase = discoveryClient.getServiceUrl(Service.USERS);
|
||||
try {
|
||||
String response = restTemplate.getForObject(oviUseriNeki, String.class, media.getCreatedById());
|
||||
String response = restTemplate.getForObject(usersServiceBase + "/users/{id}", String.class, media.getCreatedById());
|
||||
Media result = repository.save(media);
|
||||
URI location = ServletUriComponentsBuilder
|
||||
.fromCurrentRequest().path("/{id}")
|
||||
|
|
Reference in New Issue