main #10

Closed
student-20690 wants to merge 26 commits from (deleted):main into main
3 changed files with 28 additions and 11 deletions
Showing only changes of commit 482501b935 - Show all commits

View File

@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.*;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* TODO: ДОРАБОТАТЬ в рамках задания
@@ -31,20 +33,30 @@ public class EmployeeController {
}
@GetMapping("/{code}/auth")
public ResponseEntity<?> Isauth(@PathVariable String code) {
public HttpStatus Isauth(@PathVariable String code) {
if (employeeService.isCodeValid(code)) {
return ResponseEntity
.status(HttpStatus.OK)
.body("данный код существует - можно пользоваться приложением");
return HttpStatus.OK;
} else if (code == null) {
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
.body("что-то пошло не так");
return
HttpStatus.BAD_REQUEST;
} else {
return ResponseEntity
.status(HttpStatus.UNAUTHORIZED)
.body("кода не существует");
return
HttpStatus.UNAUTHORIZED;
}
}
@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
public class Booking {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private LocalDate date;

View File

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