content: package vmware.services.employee.controller;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.MediaType;
  import org.springframework.web.bind.annotation.*;
  import vmware.services.employee.model.Employee;
  import vmware.services.employee.repository.EmployeeRepository;
  
  import java.util.List;
  
  @RestController
  public class EmployeeController {
  
  	private static final Logger LOGGER = LoggerFactory.getLogger(EmployeeController.class);
  	
  	@Autowired
      EmployeeRepository repository;
  	
  	@PostMapping("/")
  	public Employee add(@RequestBody Employee employee) {
  		LOGGER.info("Employee add: {}", employee);
  		return repository.save(employee);
  	}
  	
  	@GetMapping("/{id}")
  	public Employee findById(@PathVariable("id") String id) {
  		LOGGER.info("Employee find: id={}", id);
  		return repository.findById(id).get();
  	}
  	
  	@GetMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE)
  	public Iterable<Employee> findAll() {
  		LOGGER.info("Employee find");
  		return repository.findAll();
  	}
  	
  	@GetMapping("/department/{departmentId}")
  	public List<Employee> findByDepartment(@PathVariable("departmentId") Long departmentId) {
  		LOGGER.info("Employee find: departmentId={}", departmentId);
  		return repository.findByDepartmentId(departmentId);
  	}
  	
  	@GetMapping("/organization/{organizationId}")
  	public List<Employee> findByOrganization(@PathVariable("organizationId") Long organizationId) {
  		LOGGER.info("Employee find: organizationId={}", organizationId);
  		return repository.findByOrganizationId(organizationId);
  	}
  	
  }
  