Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Springboot/Springboot/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"configurations": [
{
"type": "java",
"name": "Spring Boot-SpringbootApplication<Springboot>",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "com.program.Springboot.SpringbootApplication",
"projectName": "Springboot",
"args": "",
"envFile": "${workspaceFolder}/.env"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long, Student> studentDB = new HashMap<>();
Expand All @@ -30,9 +32,9 @@ public Optional<Student> 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) {
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
spring.application.name=Springboot
server.port = 9O90
server.port = 9090
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
spring.application.name=Springboot
server.port = 9O90
server.port = 9090
Binary file not shown.
Binary file not shown.