From 326e69240fbb0ac12aea028088d75d03af83cc1f Mon Sep 17 00:00:00 2001 From: rafaeliiee Date: Sat, 30 Aug 2025 21:01:01 +0800 Subject: [PATCH] fix: debug --- Springboot/Springboot/.vscode/launch.json | 14 ++++++++++++++ .../controller/StudentController.java | 4 ++-- .../service/impl/StudentServiceImpl.java | 12 +++++++----- .../src/main/resources/application.properties | 2 +- .../target/classes/application.properties | 2 +- .../controller/StudentController.class | Bin 2472 -> 2472 bytes .../service/impl/StudentServiceImpl.class | Bin 2892 -> 2574 bytes 7 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 Springboot/Springboot/.vscode/launch.json diff --git a/Springboot/Springboot/.vscode/launch.json b/Springboot/Springboot/.vscode/launch.json new file mode 100644 index 0000000..ecd0b8f --- /dev/null +++ b/Springboot/Springboot/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + "configurations": [ + { + "type": "java", + "name": "Spring Boot-SpringbootApplication", + "request": "launch", + "cwd": "${workspaceFolder}", + "mainClass": "com.program.Springboot.SpringbootApplication", + "projectName": "Springboot", + "args": "", + "envFile": "${workspaceFolder}/.env" + } + ] +} \ No newline at end of file diff --git a/Springboot/Springboot/src/main/java/com/program/Springboot/controller/StudentController.java b/Springboot/Springboot/src/main/java/com/program/Springboot/controller/StudentController.java index 6a371ac..cf8e60e 100644 --- a/Springboot/Springboot/src/main/java/com/program/Springboot/controller/StudentController.java +++ b/Springboot/Springboot/src/main/java/com/program/Springboot/controller/StudentController.java @@ -19,11 +19,11 @@ @RestController @RequestMapping("/api") // All endpoints will start with /api public class StudentController { - + @Autowired private final StudentService studentService; // Constructor Injection (best practice) - @Autowired + public StudentController(StudentService studentService) { this.studentService = studentService; } diff --git a/Springboot/Springboot/src/main/java/com/program/Springboot/service/impl/StudentServiceImpl.java b/Springboot/Springboot/src/main/java/com/program/Springboot/service/impl/StudentServiceImpl.java index a2b71b2..ad6b42e 100644 --- a/Springboot/Springboot/src/main/java/com/program/Springboot/service/impl/StudentServiceImpl.java +++ b/Springboot/Springboot/src/main/java/com/program/Springboot/service/impl/StudentServiceImpl.java @@ -11,7 +11,9 @@ import com.program.Springboot.model.Student; import com.program.Springboot.service.StudentService; -public class StudentServiceImpl extends StudentService { + +@Service +public class StudentServiceImpl implements StudentService { // Simulated database (key = pkStudentID, value = Student object) private final Map studentDB = new HashMap<>(); @@ -30,9 +32,9 @@ public Optional getStudentById(Long id) { @Override public Student addStudent(Student student) { - // store student using their ID as the key + studentDB.put(student.getPkStudentID(), student); return student; - } + } @Override public Student updateStudent(Long id, Student updatedStudent) { @@ -54,9 +56,9 @@ public Student updateStudent(Long id, Student updatedStudent) { public boolean deleteStudent(Long id) { if (studentDB.containsKey(id)) { studentDB.remove(id); - return false; + return true; } - return true; + return false; } } \ No newline at end of file diff --git a/Springboot/Springboot/src/main/resources/application.properties b/Springboot/Springboot/src/main/resources/application.properties index 6f582e0..9ab9860 100644 --- a/Springboot/Springboot/src/main/resources/application.properties +++ b/Springboot/Springboot/src/main/resources/application.properties @@ -1,2 +1,2 @@ spring.application.name=Springboot -server.port = 9O90 +server.port = 9090 diff --git a/Springboot/Springboot/target/classes/application.properties b/Springboot/Springboot/target/classes/application.properties index 6f582e0..9ab9860 100644 --- a/Springboot/Springboot/target/classes/application.properties +++ b/Springboot/Springboot/target/classes/application.properties @@ -1,2 +1,2 @@ spring.application.name=Springboot -server.port = 9O90 +server.port = 9090 diff --git a/Springboot/Springboot/target/classes/com/program/Springboot/controller/StudentController.class b/Springboot/Springboot/target/classes/com/program/Springboot/controller/StudentController.class index c7829b4ceeecacbcaafa87ab1b642ad1ff8e9e9d..842ea6aab349d9f0aee12003c635eac0a4baef46 100644 GIT binary patch delta 113 zcmZ1>yh3=wyoqyh3=wyoq1!Ce91zWpU0=N#$Z-X5i&vVBhS(Sjj5Rz`(}9$iU9P0TktAfbh5& z7$#p}%V6Z3Y{?!AB&V}i07(H35ZTGm3naxktHeR7g&3F^?18ic&0M*r&~3vh>nmHkX3MO#8xnY&RT$eZ%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