Remove extra controller
This commit is contained in:
parent
6331a5e5e9
commit
5e6888c904
@ -1,29 +0,0 @@
|
||||
package com.example.servicedemo;
|
||||
|
||||
public class Student {
|
||||
private String name;
|
||||
private String className;
|
||||
|
||||
|
||||
public Student(String name, String className) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public void setClassName(String className) {
|
||||
this.className = className;
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package com.example.servicedemo.controller;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.example.servicedemo.Student;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class StudentServiceController {
|
||||
|
||||
private static Map<String, List<Student>> schooDB = new HashMap<String, List<Student>>();
|
||||
|
||||
static {
|
||||
schooDB = new HashMap<String, List<Student>>();
|
||||
|
||||
List<Student> lst = new ArrayList<Student>();
|
||||
Student std = new Student("Sajal", "Class IV");
|
||||
lst.add(std);
|
||||
std = new Student("Lokesh", "Class V");
|
||||
lst.add(std);
|
||||
|
||||
schooDB.put("abcschool", lst);
|
||||
|
||||
lst = new ArrayList<Student>();
|
||||
std = new Student("Kajal", "Class III");
|
||||
lst.add(std);
|
||||
std = new Student("Sukesh", "Class VI");
|
||||
lst.add(std);
|
||||
|
||||
schooDB.put("xyzschool", lst);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getStudentDetailsForSchool/{schoolname}", method = RequestMethod.GET)
|
||||
public List<Student> getStudents(@PathVariable String schoolname) {
|
||||
System.out.println("Getting Student details for " + schoolname);
|
||||
|
||||
List<Student> studentList = schooDB.get(schoolname);
|
||||
if (studentList == null) {
|
||||
studentList = new ArrayList<Student>();
|
||||
Student std = new Student("Not Found", "N/A");
|
||||
studentList.add(std);
|
||||
}
|
||||
return studentList;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user