package com.example.nto.controller; import com.example.nto.service.EmployeeService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api") @RequiredArgsConstructor public class EmployeeController { private final EmployeeService employeeService; /** * GET api/{code}/auth * * 400 – что-то пошло не так (пустой код и т.п.) * 401 – кода не существует * 200 – код существует */ @GetMapping("/{code}/auth") public ResponseEntity auth(@PathVariable("code") String code) { if (code == null || code.isBlank()) { return ResponseEntity.badRequest().build(); // 400 } boolean exists = employeeService.existsByCode(code); if (!exists) { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); // 401 } return ResponseEntity.ok().build(); // 200 } }