added advertising

This commit is contained in:
SlimusMinus
2026-09-23 23:34:05 +03:00
parent 05d93d6b0a
commit 942cd09585
83 changed files with 2546 additions and 46 deletions

View File

@@ -0,0 +1,31 @@
package com.krylov.refound.controller.advertising;
import com.krylov.refound.service.advertising.AdvertisingMediaService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Публичный прокси-эндпоинт медиа рекламы. Ключи объектов содержат слэши
* (например "images/<uuid>.jpg"), поэтому используем wildcard {*key},
* как в FileStorageController для картинок постов.
*/
@Slf4j
@RestController
@RequestMapping("/api/v1/ads-media")
@RequiredArgsConstructor
public class AdvertisingMediaController {
private final AdvertisingMediaService mediaService;
@GetMapping("/{*key}")
public ResponseEntity<byte[]> getMedia(@PathVariable String key) {
String mediaKey = key.startsWith("/") ? key.substring(1) : key;
log.info("GET ads-media: key={} -> mediaKey={}", key, mediaKey);
return mediaService.downloadMedia(mediaKey);
}
}