2026-07-11 08:07:43 +09:00
|
|
|
package com.dog.dognation.api;
|
|
|
|
|
|
2026-07-11 13:44:46 +09:00
|
|
|
import com.dog.dognation.api.dto.SpotDtos.AiMateResponse;
|
2026-07-11 08:07:43 +09:00
|
|
|
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;
|
2026-07-11 13:44:46 +09:00
|
|
|
import com.dog.dognation.domain.spot.MateAiService;
|
2026-07-11 08:07:43 +09:00
|
|
|
import com.dog.dognation.domain.spot.SpotService;
|
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
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.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
2026-07-11 13:44:46 +09:00
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
2026-07-11 08:07:43 +09:00
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/spots")
|
|
|
|
|
public class SpotController {
|
|
|
|
|
|
|
|
|
|
private final SpotService spotService;
|
2026-07-11 13:44:46 +09:00
|
|
|
private final MateAiService mateAiService;
|
2026-07-11 08:07:43 +09:00
|
|
|
|
2026-07-11 13:44:46 +09:00
|
|
|
public SpotController(SpotService spotService, MateAiService mateAiService) {
|
2026-07-11 08:07:43 +09:00
|
|
|
this.spotService = spotService;
|
2026-07-11 13:44:46 +09:00
|
|
|
this.mateAiService = mateAiService;
|
2026-07-11 08:07:43 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 스팟 목록 */
|
|
|
|
|
@GetMapping
|
|
|
|
|
public List<SpotResponse> list() {
|
|
|
|
|
return spotService.listSpots().stream().map(SpotResponse::from).toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 스팟 체크인 ("나 지금 여기 도착!") */
|
|
|
|
|
@PostMapping("/{id}/checkins")
|
|
|
|
|
public ResponseEntity<CheckInResponse> checkIn(@PathVariable Long id,
|
|
|
|
|
@Valid @RequestBody CheckInRequest req) {
|
|
|
|
|
CheckInResponse body = CheckInResponse.from(
|
|
|
|
|
spotService.checkIn(id, req.userId(), req.dogId()));
|
|
|
|
|
return ResponseEntity.status(HttpStatus.CREATED).body(body);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 스팟에 현재 체크인 중인 메이트 목록 */
|
|
|
|
|
@GetMapping("/{id}/mates")
|
|
|
|
|
public List<MateResponse> mates(@PathVariable Long id) {
|
|
|
|
|
return spotService.activeMates(id).stream().map(MateResponse::from).toList();
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-11 13:44:46 +09:00
|
|
|
/** AI 궁합 메이트 추천 — 내 강아지(dogId)와 사이좋게 지낼 만한 스팟 내 강아지 목록 */
|
|
|
|
|
@GetMapping("/{id}/ai-mates")
|
|
|
|
|
public List<AiMateResponse> aiMates(@PathVariable Long id, @RequestParam Long dogId) {
|
|
|
|
|
return mateAiService.compatibleMates(id, dogId);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-11 08:07:43 +09:00
|
|
|
/** 스팟 한줄평 목록 */
|
|
|
|
|
@GetMapping("/{id}/reviews")
|
|
|
|
|
public List<ReviewResponse> reviews(@PathVariable Long id) {
|
|
|
|
|
return spotService.reviews(id).stream().map(ReviewResponse::from).toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 스팟 한줄평 작성 */
|
|
|
|
|
@PostMapping("/{id}/reviews")
|
|
|
|
|
public ResponseEntity<ReviewResponse> addReview(@PathVariable Long id,
|
|
|
|
|
@Valid @RequestBody ReviewCreateRequest req) {
|
|
|
|
|
ReviewResponse body = ReviewResponse.from(
|
|
|
|
|
spotService.addReview(id, req.userId(), req.tag(), req.content()));
|
|
|
|
|
return ResponseEntity.status(HttpStatus.CREATED).body(body);
|
|
|
|
|
}
|
|
|
|
|
}
|