package com.example.mapstruct.controller;

import com.example.mapstruct.dto.EmployeeGetDto;
import com.example.mapstruct.dto.EmployeePostDto;
import com.example.mapstruct.model.Employee;
import com.example.mapstruct.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/employees")
public class EmployeeController {

    @Autowired
    private EmployeeService service;

    @GetMapping("/{id}")
    public EmployeeGetDto getEmployeeById(@PathVariable int id) {
        return service.findEmployeeById(id);
    }

    @PostMapping
    public ResponseEntity<String> createEmployee(@RequestBody EmployeePostDto employeePostDto) {
        ResponseEntity<String> responseEntity;
        responseEntity = ResponseEntity.status(HttpStatus.OK).body("employee updated");
        return responseEntity;
    }
}