Skip to content

Commit bfc5de6

Browse files
committed
(TP-124) refactor: delete extra methods from ImageController
1 parent c701b28 commit bfc5de6

1 file changed

Lines changed: 0 additions & 57 deletions

File tree

rentplace/src/main/java/kattsyn/dev/rentplace/controllers/ImageController.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
1010
import io.swagger.v3.oas.annotations.tags.Tag;
1111
import kattsyn.dev.rentplace.entities.Image;
12-
import kattsyn.dev.rentplace.enums.ImageType;
1312
import kattsyn.dev.rentplace.services.ImageService;
1413
import lombok.extern.slf4j.Slf4j;
1514
import org.springframework.beans.factory.annotation.Value;
@@ -20,14 +19,11 @@
2019
import org.springframework.http.ResponseEntity;
2120
import org.springframework.security.access.prepost.PreAuthorize;
2221
import org.springframework.web.bind.annotation.*;
23-
import org.springframework.web.multipart.MultipartFile;
2422

2523
import java.io.IOException;
2624
import java.nio.file.Files;
2725
import java.nio.file.Path;
2826
import java.nio.file.Paths;
29-
import java.util.ArrayList;
30-
import java.util.List;
3127

3228
@RestController
3329
@RequestMapping("${api.path}/images")
@@ -70,59 +66,6 @@ public ResponseEntity<Resource> getImage(
7066
}
7167
}
7268

73-
@Operation(
74-
summary = "Загрузка фотографии",
75-
description = "Загрузка фотографии"
76-
)
77-
@ApiResponses(value = {
78-
@ApiResponse(responseCode = "200", description = "Успешно", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Image.class))),
79-
@ApiResponse(responseCode = "500", description = "Непредвиденная ошибка со стороны сервера", content = @Content)
80-
})
81-
@SecurityRequirement(name = "JWT")
82-
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
83-
@PostMapping(path = "/", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
84-
public ResponseEntity<Image> uploadImage(
85-
@Parameter(
86-
description = "Файл фотографии",
87-
required = true,
88-
content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE)
89-
) @RequestParam("file") MultipartFile file,
90-
@Parameter(
91-
description = "Тип изображения",
92-
required = true,
93-
schema = @Schema(
94-
implementation = ImageType.class)
95-
) @RequestParam ImageType imageType) { //todo: delete method
96-
return ResponseEntity.ok(imageService.uploadImage(file, imageType));
97-
}
98-
99-
100-
101-
@PostMapping(value = "/multiple/", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
102-
@Operation(
103-
summary = "Массовая загрузка фотографий",
104-
description = "Загружает несколько фотографий за один запрос. Максимальное количество файлов - 10. Максимальный размер каждого файла - 10MB.")
105-
@ApiResponses(value = {
106-
@ApiResponse(responseCode = "200", description = "Фотографии успешно загружены", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Image[].class))),
107-
@ApiResponse(responseCode = "400", description = "Некорректный запрос (превышено кол-во файлов, неверный формат и т.д.)", content = @Content),
108-
@ApiResponse(responseCode = "413", description = "Превышен максимальный размер запроса"),
109-
@ApiResponse(responseCode = "500", description = "Внутренняя ошибка сервера")
110-
})
111-
@SecurityRequirement(name = "JWT")
112-
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
113-
public ResponseEntity<List<Image>> uploadMultipleImages(@Parameter(
114-
description = "Массив файлов фотографий",
115-
required = true,
116-
content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE, schema = @Schema(type = "string", format = "binary"))
117-
) @RequestPart("files") MultipartFile[] files) {
118-
List<Image> savedImages = new ArrayList<>();
119-
120-
for (MultipartFile file : files) {
121-
savedImages.add(imageService.uploadImage(file));
122-
}
123-
124-
return ResponseEntity.ok(savedImages);
125-
}
12669

12770
@Operation(
12871
summary = "Получить фотографию",

0 commit comments

Comments
 (0)