-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathStudentController.java
47 lines (37 loc) · 1.43 KB
/
StudentController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.circleci.demojavaspring.controller;
import com.circleci.demojavaspring.model.Student;
import com.circleci.demojavaspring.service.Student_Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@RestController
@CrossOrigin(origins="http://localhost:4200")
@RequestMapping(value="/api")
public class StudentController {
@Autowired
private Student_Service studentservice;
@PostMapping("save-student")
public boolean saveStudent(@RequestBody Student student) {
return studentservice.saveStudent(student);
}
@GetMapping("students-list")
public List<Student> allstudents() {
return studentservice.getStudents();
}
@DeleteMapping("delete-student/{student_id}")
public boolean deleteStudent(@PathVariable("student_id") int student_id,Student student) {
student.setStudent_id(student_id);
return studentservice.deleteStudent(student);
}
@GetMapping("student/{student_id}")
public List<Student> allstudentByID(@PathVariable("student_id") int student_id, Student student) {
student.setStudent_id(student_id);
return studentservice.getStudentByID(student);
}
@PostMapping("update-student/{student_id}")
public boolean updateStudent(@RequestBody Student student,@PathVariable("student_id") int student_id) {
student.setStudent_id(student_id);
return studentservice.updateStudent(student);
}
}