diff --git a/ApproveService/pom.xml b/ApproveService/pom.xml
index 70c1028..f3d38bd 100644
--- a/ApproveService/pom.xml
+++ b/ApproveService/pom.xml
@@ -28,8 +28,13 @@
17
+ 2024.0.0-M2
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
org.springframework.boot
spring-boot-starter-web
@@ -47,7 +52,27 @@
mysql-connector-j
9.1.0
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
@@ -57,5 +82,25 @@
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
diff --git a/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/ApproveServiceApplication.java b/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/ApproveServiceApplication.java
index 6063ed2..8b2ffa6 100644
--- a/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/ApproveServiceApplication.java
+++ b/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/ApproveServiceApplication.java
@@ -2,9 +2,18 @@ package fr.insa_toulouse.mas.benevolat.ApproveService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.client.RestTemplate;
@SpringBootApplication
public class ApproveServiceApplication {
+
+ @Bean
+ @LoadBalanced
+ public RestTemplate restTemplate() {
+ return new RestTemplate();
+ }
public static void main(String[] args) {
SpringApplication.run(ApproveServiceApplication.class, args);
diff --git a/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/model/Task.java b/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/model/Task.java
index 72d4f93..e2c3918 100644
--- a/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/model/Task.java
+++ b/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/model/Task.java
@@ -60,10 +60,10 @@ public class Task {
return tasks;
}
- static public void approveTask(int id) {
+ static public void approveTask(int id, int adminId) {
try {
Statement statement = Task.connection.createStatement();
- statement.addBatch("UPDATE task SET approved = true, isCompleted = false WHERE id = " + id + ";");
+ statement.addBatch("UPDATE task SET approved = true, isCompleted = false, assignedAdmin = " + adminId + " WHERE id = " + id + ";");
statement.executeBatch();
statement.close();
} catch (SQLException e) {
@@ -71,10 +71,10 @@ public class Task {
}
}
- static public void disapproveTask(int id) {
+ static public void disapproveTask(int id, int adminId) {
try {
Statement statement = Task.connection.createStatement();
- statement.addBatch("UPDATE task SET approved = false, isCompleted = true WHERE id = " + id + ";");
+ statement.addBatch("UPDATE task SET approved = false, isCompleted = true, assignedAdmin = " + adminId + " WHERE id = " + id + ";");
statement.executeBatch();
statement.close();
} catch (SQLException e) {
diff --git a/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/ressource/ApproveServiceRessource.java b/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/ressource/ApproveServiceRessource.java
index 633a070..f98c0da 100644
--- a/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/ressource/ApproveServiceRessource.java
+++ b/ApproveService/src/main/java/fr/insa_toulouse/mas/benevolat/ApproveService/ressource/ApproveServiceRessource.java
@@ -17,31 +17,29 @@ import fr.insa_toulouse.mas.benevolat.ApproveService.model.Task;
public class ApproveServiceRessource {
- //@Autowired
- //private RestTemplate restTemplate;
+ @Autowired
+ private RestTemplate restTemplate;
@GetMapping("getTasks/{adminId}")
public ArrayList getTasks(@PathVariable("adminId") Integer id) {
- //if (restTemplate.getForObject("http://Authentification/auth/isAdmin/" + id, Boolean.class)) {
+ if (restTemplate.getForObject("http://Authentication/auth/isAdmin/" + id, Boolean.class)) {
return Task.getTasks();
- //}
- //return null;
+ }
+ return null;
}
@PutMapping("approveTask/{adminId}/{taskId}")
public void approveTask(@PathVariable("adminId") Integer adminId, @PathVariable("taskId") Integer taskId) {
- //if (restTemplate.getForObject("http://Authentification/auth/isAdmin/" + id, Boolean.class)) {
- Task.approveTask(taskId);
- //}
- //return null;
+ if (restTemplate.getForObject("http://Authentication/auth/isAdmin/" + adminId, Boolean.class)) {
+ Task.approveTask(taskId, adminId);
+ }
}
@PutMapping("disapproveTask/{adminId}/{taskId}")
public void disapproveTask(@PathVariable("adminId") Integer adminId, @PathVariable("taskId") Integer taskId) {
- //if (restTemplate.getForObject("http://Authentification/auth/isAdmin/" + id, Boolean.class)) {
- Task.disapproveTask(taskId);
- //}
- //return null;
+ if (restTemplate.getForObject("http://Authentication/auth/isAdmin/" + adminId, Boolean.class)) {
+ Task.disapproveTask(taskId, adminId);
+ }
}
}
diff --git a/ApproveService/src/main/resources/application.properties b/ApproveService/src/main/resources/application.properties
index 2e13751..b1db0e4 100644
--- a/ApproveService/src/main/resources/application.properties
+++ b/ApproveService/src/main/resources/application.properties
@@ -1,2 +1,3 @@
spring.application.name=ApproveService
-server.port=8092
\ No newline at end of file
+server.port=8092
+eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
\ No newline at end of file
diff --git a/Authentication/pom.xml b/Authentication/pom.xml
index 8837193..c68882b 100644
--- a/Authentication/pom.xml
+++ b/Authentication/pom.xml
@@ -28,8 +28,13 @@
17
+ 2024.0.0-M2
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
org.springframework.boot
spring-boot-starter-web
@@ -46,8 +51,27 @@
mysql-connector-j
9.1.0
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
diff --git a/Authentication/src/main/java/fr/insa_toulouse/mas/benevolat/Authentication/AuthenticationApplication.java b/Authentication/src/main/java/fr/insa_toulouse/mas/benevolat/Authentication/AuthenticationApplication.java
index d70f8ee..7d4055f 100644
--- a/Authentication/src/main/java/fr/insa_toulouse/mas/benevolat/Authentication/AuthenticationApplication.java
+++ b/Authentication/src/main/java/fr/insa_toulouse/mas/benevolat/Authentication/AuthenticationApplication.java
@@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AuthenticationApplication {
+
public static void main(String[] args) {
SpringApplication.run(AuthenticationApplication.class, args);
diff --git a/Authentication/src/main/java/fr/insa_toulouse/mas/benevolat/Authentication/ressource/AuthentificationResource.java b/Authentication/src/main/java/fr/insa_toulouse/mas/benevolat/Authentication/ressource/AuthentificationResource.java
index 904031f..6292490 100644
--- a/Authentication/src/main/java/fr/insa_toulouse/mas/benevolat/Authentication/ressource/AuthentificationResource.java
+++ b/Authentication/src/main/java/fr/insa_toulouse/mas/benevolat/Authentication/ressource/AuthentificationResource.java
@@ -3,9 +3,14 @@ package fr.insa_toulouse.mas.benevolat.Authentication.ressource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
import fr.insa_toulouse.mas.benevolat.Authentication.model.User;
+
+@RestController
+@RequestMapping("auth")
public class AuthentificationResource {
@PostMapping("add/{name}/{password}/{isAdmin}")
diff --git a/Authentication/src/main/resources/application.properties b/Authentication/src/main/resources/application.properties
index eab390a..5b0525e 100644
--- a/Authentication/src/main/resources/application.properties
+++ b/Authentication/src/main/resources/application.properties
@@ -1,2 +1,3 @@
spring.application.name=Authentication
-server.port=8091
\ No newline at end of file
+server.port=8091
+eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
\ No newline at end of file
diff --git a/taskCreator/pom.xml b/taskCreator/pom.xml
index c25aa58..6709bad 100755
--- a/taskCreator/pom.xml
+++ b/taskCreator/pom.xml
@@ -28,8 +28,13 @@
17
+ 2024.0.0-M2
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
org.springframework.boot
spring-boot-starter
@@ -56,6 +61,18 @@
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
diff --git a/taskCreator/src/main/java/fr/insa/mas/taskCreator/controller/taskRessource.java b/taskCreator/src/main/java/fr/insa/mas/taskCreator/controller/taskRessource.java
index 1a373d4..6f208ed 100644
--- a/taskCreator/src/main/java/fr/insa/mas/taskCreator/controller/taskRessource.java
+++ b/taskCreator/src/main/java/fr/insa/mas/taskCreator/controller/taskRessource.java
@@ -20,16 +20,14 @@ import fr.insa.mas.taskCreator.model.task;
public class taskRessource {
- @PostMapping("propose/{condition}/{approval}/{assignedAdmin}/{assignedHelper}/{assignedRequester}/{Description}")
- public void addTask(@PathVariable("condition") Boolean condition, @PathVariable("approval") Boolean approval , @PathVariable("assignedAdmin") int Adminid, @PathVariable("assignedHelper") int Helperid, @PathVariable("assignedRequester") int Requesterid, @PathVariable("description") String Description) {
+ @PostMapping("propose/{assignedHelper}/{description}")
+ public void addTask(@PathVariable("assignedHelper") int Helperid, @PathVariable("description") String Description) {
task.saveTask(false, false, null, Helperid, null, Description);
}
- @PostMapping("request/{condition}/{approval}/{assignedAdmin}/{assignedHelper}/{assignedRequester}/{Description}")
- public void propTask(@PathVariable("condition") Boolean condition, @PathVariable("approval") Boolean approval ,
- @PathVariable("assignedAdmin") int Adminid, @PathVariable("assignedHelper") int Helperid,
- @PathVariable("assignedRequester") int Requesterid, @PathVariable("description") String Description) {
+ @PostMapping("request/{assignedRequester}/{description}")
+ public void propTask(@PathVariable("assignedRequester") int Requesterid, @PathVariable("description") String Description) {
task.saveTask(false, false, null, null, Requesterid, Description);
}
diff --git a/taskCreator/src/main/java/fr/insa/mas/taskCreator/model/task.java b/taskCreator/src/main/java/fr/insa/mas/taskCreator/model/task.java
index 721a50b..211f9b7 100644
--- a/taskCreator/src/main/java/fr/insa/mas/taskCreator/model/task.java
+++ b/taskCreator/src/main/java/fr/insa/mas/taskCreator/model/task.java
@@ -31,7 +31,7 @@ public class task {
}
}
- public task(int id, boolean condition, boolean approval, int assignedAdmin, int assignedHelper,
+ public task(Integer id, boolean condition, boolean approval, int assignedAdmin, int assignedHelper,
int assignedRequester, String description) {
super();
this.id = id;
@@ -49,10 +49,9 @@ public class task {
Integer assignedHelper, Integer assignedRequester,String Description ) {
Random rand = new Random();
int id = rand.nextInt(500000);
- task task = new task(id, condition, approval, assignedAdmin, assignedHelper, assignedRequester, Description);
try {
Statement statement = (Statement) task.connection.createStatement();
- statement.addBatch("INSERT INTO task (id, approved, assignedAdmin, helper, helped, description, isCompleted) VALUES ("+ id +", \"" + task.approval + "\",\"" + task.assignedAdmin + "\",\"" + task.assignedHelper + "\"," + task.assignedRequester +"\", " + task.Description + " );");
+ statement.addBatch("INSERT INTO task (id, approved, assignedAdmin, helper, helped, description, isCompleted) VALUES ("+ id +", " + approval + "," + assignedAdmin + "," + assignedHelper + "," + assignedRequester +", " + Description + ", 0 );");
statement.executeBatch();
statement.close();
}catch(SQLException e){
@@ -66,7 +65,7 @@ public class task {
Statement statement;
try {
statement = task.connection.createStatement();
- ResultSet res = statement.executeQuery("SELECT * from task WHERE helped = NULL AND isCompleted = FALSE");
+ ResultSet res = statement.executeQuery("SELECT * from task WHERE helped IS NULL AND isCompleted = 0;");
while (res.next()) {
unansweredTasks.add(new task(res.getInt("id"), res.getBoolean("isCompleted"), res.getBoolean("approved"),
res.getInt("assignedAdmin"), res.getInt("helper"),
@@ -84,7 +83,7 @@ public class task {
Statement statement;
try {
statement = task.connection.createStatement();
- ResultSet res = statement.executeQuery("SELECT * from task WHERE helper = NULL AND isCompleted = FALSE");
+ ResultSet res = statement.executeQuery("SELECT * from task WHERE helper IS NULL AND isCompleted = 0;");
while (res.next()) {
unasignedTasks.add(new task(res.getInt("id"), res.getBoolean("isCompleted"), res.getBoolean("approved"),
res.getInt("assignedAdmin"), res.getInt("helper"),
@@ -117,6 +116,8 @@ public class task {
try {
Statement statement = task.connection.createStatement();
statement.addBatch("UPDATE task SET isCompleted = true WHERE id = " + id + ";");
+ statement.executeBatch();
+ statement.close();
} catch(SQLException e){
throw new RuntimeException(e);
}
@@ -126,6 +127,8 @@ public class task {
try {
Statement statement = task.connection.createStatement();
statement.addBatch("UPDATE task SET helper = " + helperid + " WHERE id = " + id + ";");
+ statement.executeBatch();
+ statement.close();
} catch(SQLException e){
throw new RuntimeException(e);
}
@@ -134,7 +137,9 @@ public class task {
static public void assignHelped(int id, int helpedid) {
try {
Statement statement = task.connection.createStatement();
- statement.addBatch("UPDATE task SET helper = " + helpedid + " WHERE id = " + id + ";");
+ statement.addBatch("UPDATE task SET helped = " + helpedid + " WHERE id = " + id + ";");
+ statement.executeBatch();
+ statement.close();
} catch(SQLException e){
throw new RuntimeException(e);
}
diff --git a/taskCreator/src/main/resources/application.properties b/taskCreator/src/main/resources/application.properties
index 211c1d5..6d7cb21 100755
--- a/taskCreator/src/main/resources/application.properties
+++ b/taskCreator/src/main/resources/application.properties
@@ -1 +1,3 @@
spring.application.name=taskCreator
+server.port=8093
+eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
\ No newline at end of file