Skip to content

Instantly share code, notes, and snippets.

@SuvidhaMalaviya
Created February 7, 2023 17:42
Show Gist options
  • Save SuvidhaMalaviya/df34d49a6f2d9777ebf464f00c931047 to your computer and use it in GitHub Desktop.
Save SuvidhaMalaviya/df34d49a6f2d9777ebf464f00c931047 to your computer and use it in GitHub Desktop.
Controller
@RestController
public class EmployeeController {
@Autowired
private EmployeeRepository repository;
@GetMapping("/employees")
public List<Employee> getAllEmployees() {
return repository.findAll();
}
@PostMapping("/employees")
public Employee createEmployee(@RequestBody Employee employee) {
return repository.save(employee);
}
// other methods to handle the CRUD operations
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment