체크인한 스팟의 활성 강아지(Redis 24h) 중 내 강아지와 사이좋게 지낼 만한
강아지만 Gemini 로 골라 궁합점수·이유와 함께 반환.
GET /api/spots/{id}/ai-mates?dogId=...
- GeminiClient: responseSchema 로 구조화 JSON 강제(gemini-flash-latest)
- MateAiService: 후보 성향/크기로 프롬프트 구성, 후보 밖 dogId(환각) 필터, 점수 내림차순
- application.yml: app.ai.gemini (env GEMINI_API_KEY, 미설정 시 503)
- 키 없이도 컨텍스트/테스트 통과 → CI 안전
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package com.dog.dognation.api;
|
||||
|
||||
import com.dog.dognation.api.dto.SpotDtos.AiMateResponse;
|
||||
import com.dog.dognation.api.dto.SpotDtos.CheckInRequest;
|
||||
import com.dog.dognation.api.dto.SpotDtos.CheckInResponse;
|
||||
import com.dog.dognation.api.dto.SpotDtos.MateResponse;
|
||||
import com.dog.dognation.api.dto.SpotDtos.ReviewCreateRequest;
|
||||
import com.dog.dognation.api.dto.SpotDtos.ReviewResponse;
|
||||
import com.dog.dognation.api.dto.SpotDtos.SpotResponse;
|
||||
import com.dog.dognation.domain.spot.MateAiService;
|
||||
import com.dog.dognation.domain.spot.SpotService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -24,9 +27,11 @@ import java.util.List;
|
||||
public class SpotController {
|
||||
|
||||
private final SpotService spotService;
|
||||
private final MateAiService mateAiService;
|
||||
|
||||
public SpotController(SpotService spotService) {
|
||||
public SpotController(SpotService spotService, MateAiService mateAiService) {
|
||||
this.spotService = spotService;
|
||||
this.mateAiService = mateAiService;
|
||||
}
|
||||
|
||||
/** 스팟 목록 */
|
||||
@@ -50,6 +55,12 @@ public class SpotController {
|
||||
return spotService.activeMates(id).stream().map(MateResponse::from).toList();
|
||||
}
|
||||
|
||||
/** AI 궁합 메이트 추천 — 내 강아지(dogId)와 사이좋게 지낼 만한 스팟 내 강아지 목록 */
|
||||
@GetMapping("/{id}/ai-mates")
|
||||
public List<AiMateResponse> aiMates(@PathVariable Long id, @RequestParam Long dogId) {
|
||||
return mateAiService.compatibleMates(id, dogId);
|
||||
}
|
||||
|
||||
/** 스팟 한줄평 목록 */
|
||||
@GetMapping("/{id}/reviews")
|
||||
public List<ReviewResponse> reviews(@PathVariable Long id) {
|
||||
|
||||
Reference in New Issue
Block a user