feat - 전반적인 기능 추가
SpecialSource Backend CI/CD / build-and-deploy (push) Successful in 2m14s

This commit is contained in:
sungjin.choi
2026-07-16 10:20:45 +09:00
parent d23d649b2b
commit 4a97610eaf
12 changed files with 393 additions and 0 deletions
@@ -0,0 +1,27 @@
package company.specialsource.controller;
import company.specialsource.service.AnalyticsService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@RequestMapping("/api/analytics")
@RequiredArgsConstructor
public class AnalyticsController {
private final AnalyticsService analyticsService;
/**
* Vue 3 프론트엔드가 대시보드 진입 시 호출할 실시간 유저 수 조회용 엔드포인트
*/
@GetMapping("/live")
public ResponseEntity<Map<String, Long>> getLiveNetworkStats() {
Map<String, Long> liveStats = analyticsService.getRealTimeDashboardStats();
return ResponseEntity.ok(liveStats);
}
}
@@ -0,0 +1,52 @@
package company.specialsource.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
@RestController
@RequestMapping("/api/sync")
@Slf4j
public class FileSyncController {
// ⚠️ 나스 스토리지와 볼륨 마운트해 둔 백엔드 컨테이너 내부의 실제 저장 경로
private final String NAS_STORAGE_PATH = "/app/storage/sync-folder/";
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> uploadFileFromPhone(@RequestParam("file") MultipartFile file) {
if (file.isEmpty()) {
log.warn("⚠️ [Sync] 수신된 파일이 비어 있습니다.");
return ResponseEntity.badRequest().body("ERR: EMPTY_FILE");
}
try {
// 저장 경로 폴더가 없으면 자동으로 생성
File directory = new File(NAS_STORAGE_PATH);
if (!directory.exists()) {
directory.mkdirs();
log.info("📁 [Sync] 업로드 저장 폴더를 새로 생성했습니다: {}", NAS_STORAGE_PATH);
}
// 핸드폰에서 온 원본 파일명 그대로 파일 객체 생성
File destination = new File(directory, file.getOriginalFilename());
// 물리 디스크(나스 HDD/SSD)에 실제 파일 쓰기 수행
file.transferTo(destination);
log.info("📱 [Sync] 스마트폰 동기화 완료! 파일명: {} (크기: {} bytes)",
file.getOriginalFilename(), file.getSize());
return ResponseEntity.ok("SUCCESS: INJECTED_TO_NAS");
} catch (IOException e) {
log.error("❌ [Sync] 나스 파일 저장 중 치명적 오류 발생", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("ERR: " + e.getMessage());
}
}
}