-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed controller in car and polygon service to search specific cont…
…roller since the client facing apis of the services are read only in nature, implemented end to end flow of polygon service for all search functionalities
- Loading branch information
1 parent
d374ef0
commit 79dc25d
Showing
10 changed files
with
211 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...com/teenthofabud/codingchallenge/sharenow/polygon/controller/PolygonSearchController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,81 @@ | ||
package com.teenthofabud.codingchallenge.sharenow.polygon.controller; | ||
|
||
import com.teenthofabud.codingchallenge.sharenow.polygon.model.error.PolygonServiceException; | ||
import com.teenthofabud.codingchallenge.sharenow.polygon.model.vo.StrategicPolygonDetailedVO; | ||
import com.teenthofabud.codingchallenge.sharenow.polygon.model.vo.StrategicPolygonVO; | ||
import com.teenthofabud.codingchallenge.sharenow.polygon.service.PolygonService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("search") | ||
public class PolygonSearchController { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(PolygonSearchController.class); | ||
|
||
@Autowired | ||
private PolygonService service; | ||
|
||
@GetMapping | ||
public ResponseEntity<?> getAllPolygons() { | ||
LOGGER.info("Requesting all polygons"); | ||
List<StrategicPolygonVO> voList = this.service.retrieveAll(); | ||
ResponseEntity<List<StrategicPolygonVO>> response = ResponseEntity.ok(voList); | ||
LOGGER.info("Responding with all available polygons"); | ||
return response; | ||
} | ||
|
||
@GetMapping("cityid/{cityId}") | ||
public ResponseEntity<?> getAllPolygonsByCityId(@PathVariable String cityId) throws PolygonServiceException { | ||
LOGGER.info("Requesting all polygons with cityId: {}", cityId); | ||
List<StrategicPolygonVO> voList = this.service.retrieveByCityId(cityId); | ||
ResponseEntity<List<StrategicPolygonVO>> response = ResponseEntity.ok(voList); | ||
LOGGER.info("Responding with all available polygons with cityId: {}", cityId); | ||
return response; | ||
} | ||
|
||
@GetMapping("type/{type}") | ||
public ResponseEntity<?> getAllPolygonsByType(@PathVariable String type) throws PolygonServiceException { | ||
LOGGER.info("Requesting all polygons of type: {}", type); | ||
List<StrategicPolygonVO> voList = this.service.retrieveByType(type); | ||
ResponseEntity<List<StrategicPolygonVO>> response = ResponseEntity.ok(voList); | ||
LOGGER.info("Responding with all available polygons with type: {}", type); | ||
return response; | ||
} | ||
|
||
@GetMapping("name/{name}") | ||
public ResponseEntity<?> getPolygonByName(@PathVariable String name) throws PolygonServiceException { | ||
LOGGER.info("Requesting all polygons with name: {}", name); | ||
List<StrategicPolygonVO> voList = this.service.retrieveByName(name); | ||
ResponseEntity<List<StrategicPolygonVO>> response = ResponseEntity.ok(voList); | ||
LOGGER.info("Responding with all available polygons with name: {}", name); | ||
return response; | ||
} | ||
|
||
@GetMapping("id/{id}") | ||
public ResponseEntity<?> getPolygonById(@PathVariable String id) throws PolygonServiceException { | ||
LOGGER.info("Requesting polygon with id: {}", id); | ||
StrategicPolygonDetailedVO vo = this.service.retrieveById(id); | ||
ResponseEntity<StrategicPolygonDetailedVO> response = ResponseEntity.ok(vo); | ||
LOGGER.info("Responding with polygon of id: {}", id); | ||
return response; | ||
} | ||
|
||
@GetMapping("legacyid/{legacyId}") | ||
public ResponseEntity<?> getPolygonByCityId(@PathVariable String legacyId) throws PolygonServiceException { | ||
LOGGER.info("Requesting polygon with legacyId: {}", legacyId); | ||
StrategicPolygonDetailedVO vo = this.service.retrieveByLegacyId(legacyId); | ||
ResponseEntity<StrategicPolygonDetailedVO> response = ResponseEntity.ok(vo); | ||
LOGGER.info("Responding with polygon of legacyId: {}", legacyId); | ||
return response; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.