+api/{code}/info(<s>Почти работает</s>)

This commit is contained in:
lynxwq2
2025-11-28 21:51:09 +03:00
parent a13f3ebf33
commit 482501b935
3 changed files with 28 additions and 11 deletions

View File

@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.*;
import java.net.http.HttpResponse; import java.net.http.HttpResponse;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional;
/** /**
* TODO: ДОРАБОТАТЬ в рамках задания * TODO: ДОРАБОТАТЬ в рамках задания
@@ -31,20 +33,30 @@ public class EmployeeController {
} }
@GetMapping("/{code}/auth") @GetMapping("/{code}/auth")
public ResponseEntity<?> Isauth(@PathVariable String code) { public HttpStatus Isauth(@PathVariable String code) {
if (employeeService.isCodeValid(code)) { if (employeeService.isCodeValid(code)) {
return ResponseEntity return HttpStatus.OK;
.status(HttpStatus.OK)
.body("данный код существует - можно пользоваться приложением");
} else if (code == null) { } else if (code == null) {
return ResponseEntity return
.status(HttpStatus.BAD_REQUEST) HttpStatus.BAD_REQUEST;
.body("что-то пошло не так");
} else { } else {
return ResponseEntity return
.status(HttpStatus.UNAUTHORIZED) HttpStatus.UNAUTHORIZED;
.body("кода не существует");
} }
} }
@GetMapping("/{code}/info")
public ResponseEntity<?> getInfo(@PathVariable String code){
Optional<Employee> employee = employeeService.getByCode(code);
if (employee.isPresent()) {
return ResponseEntity.ok(employee.get());
} else {
return ResponseEntity.notFound().build();
}
}
} }

View File

@@ -22,6 +22,7 @@ import java.time.LocalDate;
@Entity @Entity
public class Booking { public class Booking {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; private long id;
private LocalDate date; private LocalDate date;

View File

@@ -19,7 +19,6 @@ import lombok.NoArgsConstructor;
@Data @Data
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor
@Entity @Entity
public class Place { public class Place {
@@ -28,4 +27,9 @@ public class Place {
private long id; private long id;
private String place; private String place;
public Place(long id, String place){
this.id = id;
this.place = place;
}
} }