Compare commits
3 Commits
98c89f6247
...
ca926d9ada
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca926d9ada | ||
|
|
9c5b9a7150 | ||
|
|
7f7714b7a3 |
@ -254,7 +254,7 @@ public class RecipesControllerTests {
|
||||
final String updateBody = this.objectMapper.writeValueAsString(spec);
|
||||
|
||||
this.mockMvc.perform(
|
||||
post("/recipes/{username}/{slug}", owner.getUsername(), recipe.getSlug())
|
||||
put("/recipes/{username}/{slug}", owner.getUsername(), recipe.getSlug())
|
||||
.header("Authorization", "Bearer " + this.getAccessToken(owner))
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(updateBody)
|
||||
@ -318,7 +318,7 @@ public class RecipesControllerTests {
|
||||
|
||||
final String accessToken = this.getAccessToken(owner);
|
||||
this.mockMvc.perform(
|
||||
post("/recipes/{username}/{slug}", owner.getUsername(), recipe.getSlug())
|
||||
put("/recipes/{username}/{slug}", owner.getUsername(), recipe.getSlug())
|
||||
.header("Authorization", "Bearer " + accessToken)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(body)
|
||||
|
||||
@ -368,7 +368,7 @@ public class RecipeService {
|
||||
public Recipe publishDraft(UUID draftId, User modifier) {
|
||||
final RecipeDraft recipeDraft = this.recipeDraftRepository.findById(draftId)
|
||||
.orElseThrow(() -> new NoSuchEntityWithIdException(RecipeDraft.class, draftId));
|
||||
final RecipeCreateSpec spec = RecipeCreateSpec.builder()
|
||||
final var b = RecipeCreateSpec.builder()
|
||||
.slug(recipeDraft.getSlug())
|
||||
.title(recipeDraft.getTitle())
|
||||
.preparationTime(recipeDraft.getPreparationTime())
|
||||
@ -376,8 +376,21 @@ public class RecipeService {
|
||||
.totalTime(recipeDraft.getTotalTime())
|
||||
.rawText(recipeDraft.getRawText())
|
||||
.isPublic(false)
|
||||
.mainImage(recipeDraft.getMainImage())
|
||||
.build();
|
||||
.mainImage(recipeDraft.getMainImage());
|
||||
|
||||
if (recipeDraft.getIngredients() != null) {
|
||||
b.ingredients(recipeDraft.getIngredients().stream()
|
||||
.map(ingredientDraft -> RecipeCreateSpec.IngredientCreateSpec.builder()
|
||||
.amount(ingredientDraft.getAmount())
|
||||
.name(ingredientDraft.getName())
|
||||
.notes(ingredientDraft.getNotes())
|
||||
.build()
|
||||
)
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
|
||||
final RecipeCreateSpec spec = b.build();
|
||||
final Recipe recipe = this.create(recipeDraft.getOwner(), spec, true);
|
||||
this.recipeDraftRepository.deleteById(draftId); // delete old draft
|
||||
return recipe;
|
||||
|
||||
@ -66,7 +66,7 @@ public class RecipesController {
|
||||
return ResponseEntity.ok(this.getFullViewWrapper(username, slug, view, viewer));
|
||||
}
|
||||
|
||||
@PostMapping("/{username}/{slug}")
|
||||
@PutMapping("/{username}/{slug}")
|
||||
public ResponseEntity<Map<String, Object>> updateByUsernameAndSlug(
|
||||
@PathVariable String username,
|
||||
@PathVariable String slug,
|
||||
|
||||
@ -13,7 +13,7 @@ import java.time.OffsetDateTime;
|
||||
public class RecipeInfoView {
|
||||
Integer id;
|
||||
OffsetDateTime created;
|
||||
OffsetDateTime modified;
|
||||
@Nullable OffsetDateTime modified;
|
||||
String slug;
|
||||
String title;
|
||||
@Nullable Integer preparationTime;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user