Added support for CORS

This commit is contained in:
2020-04-02 01:01:38 +05:30
parent d250c94c50
commit 938a376077
3 changed files with 14 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ public class TruecallerAssignmentController {
@Autowired
private ChessBoardUtility utility;
@CrossOrigin()
@GetMapping("/findpath")
public List<CBRouteResponse> findPath(@RequestParam int row, @RequestParam int column) {
Set<Tile> allTiles = utility.populateAllTiles();
@@ -35,4 +36,4 @@ public class TruecallerAssignmentController {
}
}
}

View File

@@ -6,6 +6,18 @@ import org.springframework.stereotype.Service;
import com.truecaller.truecallerassignment.backend.entities.Tile;
/**
* Service to find out traversal path of a chess piece to traverse each tile without repeating any
*
* Rules:
* - A piece can move 3 tiles to north, south, east or west
* - A piece can move 2 tiles diagonally to North-East, North-West, South-East and South-West
* - A piece should not visit an already visited tile.
*
* @author Mohit Nagar
*
*/
@Service
public class ChessBoardService {

View File

@@ -58,11 +58,6 @@ public class ChessBoardUtility {
chessBoard[tile.getRow() - 1][tile.getColumn()-1] = displayValue;
}
System.out.println("Found a tour from the specified position:\n");
// Stream.of(chessBoard)
// .flatMap(Stream::of)
//// .map(t -> Integer.parseInt(t.substring(0, t.indexOf(":"))))
//// .sorted((t1, t2) -> Integer.compare(Integer.parseInt(t1.substring(0, t1.indexOf(":"))), Integer.parseInt(t2.substring(0, t2.indexOf(":")))))
// .forEach(System.out::print);
for (int i = 0; i < chessBoard.length; i++) {
System.out.println();
if (i == 9) {