+api/{code}/info(<s>Почти работает</s>)
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user