Skip to content

Commit

Permalink
merge with Vicky
Browse files Browse the repository at this point in the history
  • Loading branch information
Simeline committed Dec 14, 2023
1 parent 0a33366 commit 3c11d18
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 92 deletions.
16 changes: 0 additions & 16 deletions api/main.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app;
package ch.heig.dai;

public class Constellation {

Expand All @@ -13,6 +13,6 @@ public Constellation(String name, String latinName, String abr, String origin) {
this.name = name;
this.latinName = name;
this.abr = abr;
this.origin = origin
this.origin = origin;
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package app;
package ch.heig.dai;

import io.javalin.http.Context;
import java.util.concurrent.ConcurrentHashMap;

class ConstellationController {
public class ConstellationController {

// "Database" of constellations
// Since the server is multi-threaded, we need to use a thread-safe data structure
private ConcurrentHashMap<Integer, Constellation> constellations = new ConcurrentHashMap<Integer, Constellation>();
private int lastId = 0;

public UserController() {
public ConstellationController() {
// Add some constellation to the "database"
String name, String latinName, String abr, String origin)

constellations.put(++lastId, new Constellation("L'Aigle", "Aquila/Aquilae", "Aql", "Ptolémée"));
constellations.put(++lastId, new Constellation("Le Burin", "Caelum/Caeli", "Cae", "Lacaille"));
constellations.put(++lastId, new Constellation("Le Caméléon", "Chamaeleon/Chamaeleontis", "Cha", "Bayer"));
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/ch/heig/dai/Main.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package ch.heig.dai;

import ch.heig.dai.ConstellationController;
import io.javalin.*;

public class Main {
public static void main(String[] args) {
Javalin app = Javalin.create().start(7000);

Javalin app = Javalin.create().start(8000);

UserController userController = new UserController();
app.get("/api/users", userController::getAll);
app.get("/api/users/{id}", userController::getOne);
app.post("/api/users/", userController::create);
app.put("/api/users/{id}", userController::update);
app.delete("/api/users/{id}", userController::delete);
ConstellationController controller = new ConstellationController();
app.get("/api/constellations", controller::getAll);
app.get("/api/constellations/{id}", controller::getOne);
app.post("/api/constellations/", controller::create);
app.put("/api/constellations/{id}", controller::update);
app.delete("/api/constellations/{id}", controller::delete);
}
}
13 changes: 0 additions & 13 deletions src/main/java/ch/heig/dai/User.java

This file was deleted.

49 changes: 0 additions & 49 deletions src/main/java/ch/heig/dai/UserController.java

This file was deleted.

0 comments on commit 3c11d18

Please sign in to comment.