Commit b080949d authored by Kyle Muldoon's avatar Kyle Muldoon

Added example code to follow pattern from employeeservice project

parent 4fddf33f
......@@ -2,10 +2,10 @@ package com.StudentServices.MarksService.controller;
import com.StudentServices.MarksService.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@CrossOrigin(origins = "*")
@RestController
......@@ -26,6 +26,61 @@ public class StudentMarksController {
// (DELETE) delete studentmark by id
//////////////////////////////////
// EX CODE FROM EMPLOYEE SERVICE
//////////////////////////////////
// // Return all employees
// // GET: http://localhost:8080/api/v1/employees/
// @GetMapping("/employees")
// public List<Employee> getAllEmployees() {
// return employeeService.findAllEmployees();
// }
//
// // Create a new employee
// // POST: http://localhost:8080/api/v1/employees/create
// // send this in postman: {"id": "4", "firstName": "Kyle", "lastName": "Muldoon"}
// @PostMapping("/employees/create")
// public Employee createEmployee(@RequestBody Employee employee) {
// return employeeService.addEmployee(employee);
// }
//
// // Get a particular employee
// // GET: http://localhost:8080/api/v1/employees/__num__
// @GetMapping("/employees/{id}")
// public ResponseEntity<Employee> getEmployeeById(@PathVariable(value = "id") Long employeeId) throws ResourceNotFoundException {
// Employee employee = employeeService.getEmployeeById(employeeId)
// .orElseThrow(() -> new ResourceNotFoundException("Employee by Id Not Found" + employeeId));
// return ResponseEntity.ok().body(employee);
// }
//
// // Update a particular employee
// @PutMapping("/employees/update/")
// public ResponseEntity<Employee> updateEmployeeById(@RequestBody Employee employeeNew) throws ResourceNotFoundException {
// Employee employee = employeeService.getEmployeeById(employeeNew.getId())
// .orElseThrow(() -> new ResourceNotFoundException("Employee by Id Not Found" + employeeNew.getId()));
//
// employee.setLastName(employeeNew.getLastName());
// employee.setFirstName(employeeNew.getFirstName());
//
// employeeService.updateEmployee(employee);
//
// return ResponseEntity.ok().body(employee);
// }
//
//
// // Delete a particular employee
// @DeleteMapping("/employees/remove/{id}")
// public ResponseEntity<Employee> deleteEmployeeById(@PathVariable(value = "id") Long employeeId) throws ResourceNotFoundException {
//
// Employee employee = employeeService.getEmployeeById(employeeId)
// .orElseThrow(() -> new ResourceNotFoundException("Employee by Id Not Found" + employeeId));
// employeeService.deleteEmployeeById(employee.getId());
//
// return ResponseEntity.ok().body(employee);
// }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment