Skip to content

Commit

Permalink
feat: add route to test auth
Browse files Browse the repository at this point in the history
Signed-off-by: PhilippFruh <[email protected]>
  • Loading branch information
PhilippFr committed Jul 5, 2022
1 parent d4d73e4 commit 5193aeb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
import com.vi.appointmentservice.repository.TeamToAgencyRepository;
import com.vi.appointmentservice.service.CalComTeamService;
import com.vi.appointmentservice.service.CalComUserService;
import com.vi.appointmentservice.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;
import org.keycloak.authorization.client.util.Http;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

Expand All @@ -31,15 +30,17 @@ public class ConsultantController implements ConsultantsApi {

CalComUserService calComUserService;
CalComTeamService calComTeamService;
UserService userService;

CalcomUserToConsultantRepository calcomUserToConsultantRepository;
TeamToAgencyRepository teamToAgencyRepository;


@Autowired
public ConsultantController(CalComUserService calComUserService, CalComTeamService calComTeamService, CalcomUserToConsultantRepository calcomUserToConsultantRepository, TeamToAgencyRepository teamToAgencyRepository) {
public ConsultantController(CalComUserService calComUserService, CalComTeamService calComTeamService, UserService userService, CalcomUserToConsultantRepository calcomUserToConsultantRepository, TeamToAgencyRepository teamToAgencyRepository) {
this.calComUserService = calComUserService;
this.calComTeamService = calComTeamService;
this.userService = userService;
this.calcomUserToConsultantRepository = calcomUserToConsultantRepository;
this.teamToAgencyRepository = teamToAgencyRepository;
}
Expand Down Expand Up @@ -70,6 +71,16 @@ ResponseEntity<CalcomUserToConsultant> associateConsultant(@ApiParam(value = "ID
}
}

@GetMapping(
value = "/consultants",
produces = {"application/json"}
)
ResponseEntity<String> getAllConsultants() {
com.vi.appointmentservice.userservice.generated.web.model.ConsultantSearchResultDTO consultants = this.userService.getAllConsultants();
JSONObject jsonObject = new JSONObject(consultants);
return new ResponseEntity<>(jsonObject.toString(), HttpStatus.OK);
}

@Override
public ResponseEntity<CalcomUser> createConsultant(UserDTO userDTO) {
CalcomUser creationUser = new CalcomUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class UserService {
@Value("${keycloakService.technical.password}")
private String keycloakTechnicalPassword;

public void getAllConsultants() {
public ConsultantSearchResultDTO getAllConsultants() {
addTechnicalUserHeaders(userControllerApi.getApiClient());
ConsultantSearchResultDTO consultants = userControllerApi.searchConsultants(
"",
Expand All @@ -42,6 +42,7 @@ public void getAllConsultants() {
""
);
log.debug(String.valueOf(consultants));
return consultants;
}

private void addTechnicalUserHeaders(ApiClient apiClient) {
Expand Down

0 comments on commit 5193aeb

Please sign in to comment.