Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Code_Review")
@Table(name = "code_review")
public class CodeReview extends AuditedEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Comment")
@Table(name = "comment")
public class Comment extends AuditedEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Comment_Attachment")
@Table(name = "comment_attachment")
public class CommentAttachment {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public enum ErrorCode {
REPO_NOT_FOUND_BY_ID(HttpStatus.NOT_FOUND, "REPO-001", "ν•΄λ‹Ή ID둜 μš”μ²­ν•œ 리포지토리λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
REPO_NOT_FOUND_BY_URL(HttpStatus.NOT_FOUND, "REPO-002", "ν•΄λ‹Ή URL둜 μš”μ²­ν•œ 리포지토리λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),

// λ§ˆμΈλ“œλ§΅ κ΄€λ ¨
MINDMAP_NOT_FOUND(HttpStatus.NOT_FOUND, "MINDMAP-001", "μš”μ²­ν•œ λ§ˆμΈλ“œλ§΅μ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),

// S3 파일 κ΄€λ ¨
// Client Errors (4xx)
FILE_NOT_FOUND(HttpStatus.NOT_FOUND, "FILE-001", "μš”μ²­ν•œ νŒŒμΌμ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.teamEWSN.gitdeun.common.fastapi;

import com.teamEWSN.gitdeun.common.fastapi.dto.AnalysisResultDto;
import com.teamEWSN.gitdeun.common.fastapi.dto.FastApiCommitTimeResponse;
import com.teamEWSN.gitdeun.mindmap.entity.MindmapType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

import java.time.LocalDateTime;

Expand All @@ -16,6 +21,26 @@ public FastApiClient(@Qualifier("fastApiWebClient") WebClient webClient) {
this.webClient = webClient;
}

/**
* FastAPI μ„œλ²„μ— 리포지토리 뢄석을 μš”μ²­ν•˜κ³  κ·Έ κ²°κ³Όλ₯Ό λ°›μ•„μ˜΅λ‹ˆλ‹€.
* @param repoUrl 뢄석할 λ¦¬ν¬μ§€ν† λ¦¬μ˜ URL
* @param prompt 뢄석에 μ‚¬μš©ν•  ν”„λ‘¬ν”„νŠΈ
* @param type 뢄석 νƒ€μž… (DEV, CHECK)
* @return 뢄석 κ²°κ³Ό DTO
*/
public AnalysisResultDto analyze(String repoUrl, String prompt, MindmapType type) {
// FastAPI μš”μ²­ 본문을 μœ„ν•œ λ‚΄λΆ€ DTO
AnalysisRequest requestBody = new AnalysisRequest(repoUrl, prompt, type);

return webClient.post()
.uri("/analyze") // FastAPI에 μ •μ˜λœ 뢄석 μ—”λ“œν¬μΈνŠΈ
.body(Mono.just(requestBody), AnalysisRequest.class)
.retrieve() // 응닡을 λ°›μ•„μ˜΄
.bodyToMono(AnalysisResultDto.class) // 응닡 본문을 DTO둜 λ³€ν™˜
.block(); // 비동기 처리λ₯Ό λ™κΈ°μ μœΌλ‘œ λŒ€κΈ°
}


/**
* FastAPI μ„œλ²„μ— νŠΉμ • GitHub λ¦¬ν¬μ§€ν† λ¦¬μ˜ μ΅œμ‹  컀밋 μ‹œκ°„μ„ μš”μ²­ν•©λ‹ˆλ‹€.
* @param githubRepoUrl μ‘°νšŒν•  λ¦¬ν¬μ§€ν† λ¦¬μ˜ URL
Expand All @@ -41,4 +66,13 @@ public LocalDateTime fetchLatestCommitTime(String githubRepoUrl) {

// TODO: requestAnalysis λ“± λ‹€λ₯Έ FastAPI 호좜 λ©”μ„œλ“œλ“€λ„ 여기에 κ΅¬ν˜„



@Getter
@AllArgsConstructor
private static class AnalysisRequest {
private String url;
private String prompt;
private MindmapType type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class AnalysisResultDto {
private LocalDateTime githubLastUpdatedAt;

// FastAPIκ°€ λ°˜ν™˜ν•˜λŠ” Mindmap κ΄€λ ¨ 정보
private String mapData;
private String mapData; // JSON ν˜•νƒœμ˜ λ§ˆμΈλ“œλ§΅ 데이터
private MindmapType type;
private String prompt;
// TODO: FastAPI 응닡에 맞좰 ν•„λ“œ μ •μ˜
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Invitation")
@Table(name = "invitation")
public class Invitation {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Meeting")
@Table(name = "meeting")
public class Meeting extends CreatedEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Participant")
@Table(name = "participant")
@IdClass(ParticipantId.class)
public class Participant {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,65 @@
package com.teamEWSN.gitdeun.mindmap.controller;

import com.teamEWSN.gitdeun.common.jwt.CustomUserDetails;
import com.teamEWSN.gitdeun.mindmap.dto.MindmapCreateRequest;
import com.teamEWSN.gitdeun.mindmap.dto.MindmapDetailResponseDto;
import com.teamEWSN.gitdeun.mindmap.dto.MindmapResponseDto;
import com.teamEWSN.gitdeun.mindmap.service.MindmapService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequiredArgsConstructor
public class MindmapController {

private final MindmapService mindmapService;


// λ§ˆμΈλ“œλ§΅ 생성
@PostMapping
public ResponseEntity<MindmapResponseDto> createMindmap(
@RequestBody MindmapCreateRequest request,
@AuthenticationPrincipal CustomUserDetails userDetails
) {
MindmapResponseDto responseDto = mindmapService.createMindmap(request, userDetails.getId());
return ResponseEntity.status(HttpStatus.CREATED).body(responseDto);
}

// λ§ˆμΈλ“œλ§΅ 상세 쑰회(μœ μ € 인가 ν™•μΈν•„μš”)
@GetMapping("/{mapId}")
public ResponseEntity<MindmapDetailResponseDto> getMindmap(
@PathVariable Long mapId
) {
MindmapDetailResponseDto responseDto = mindmapService.getMindmap(mapId);
return ResponseEntity.ok(responseDto);
}

// λ§ˆμΈλ“œλ§΅ μƒˆλ‘œκ³ μΉ¨
@PostMapping("/{mapId}/refresh")
public ResponseEntity<MindmapDetailResponseDto> refreshMindmap(
@PathVariable Long mapId,
@AuthenticationPrincipal CustomUserDetails userDetails
) {
MindmapDetailResponseDto responseDto = mindmapService.refreshMindmap(mapId, userDetails.getId());
return ResponseEntity.ok(responseDto);
}

// λ§ˆμΈλ“œλ§΅ μ‚­μ œ
@DeleteMapping("/{mapId}")
public ResponseEntity<Void> deleteMindmap(
@PathVariable Long mapId,
@AuthenticationPrincipal CustomUserDetails userDetails
) {
mindmapService.deleteMindmap(mapId, userDetails.getId());
return ResponseEntity.ok().build(); // 성곡 μ‹œ 200 OK와 빈 body λ°˜ν™˜
}


// TODO: λ§ˆμΈλ“œλ§΅ λ‘œλ”© μ‹œ μžλ™ 확인 + μƒˆλ‘œκ³ μΉ¨ μ‹œ μž¬λ™κΈ°ν™”
// TODO: λ§ˆμΈλ“œλ§΅ λ°©λ¬Έ μ‹œ / μƒˆλ‘œκ³ μΉ¨ μ‹œ μ—…λŽƒ μžλ™ 확인 + μž¬λ™κΈ°ν™”

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.teamEWSN.gitdeun.mindmap.dto;

import com.teamEWSN.gitdeun.mindmap.entity.MindmapType;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class MindmapCreateRequest {
private String repoUrl;
private String prompt;
private MindmapType type;

private String field; // Optional, 'CHECK' νƒ€μž…μΌ λ•Œ μ‚¬μš©μžκ°€ μž…λ ₯ν•˜λŠ” 제λͺ©
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.teamEWSN.gitdeun.mindmap.dto;

import com.teamEWSN.gitdeun.mindmap.entity.MindmapType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@Builder
@AllArgsConstructor
public class MindmapDetailResponseDto {
private Long mindmapId;
private String field; // 제λͺ© ("개발용", "ν™•μΈμš©(n)" λ“±)
private MindmapType type;
private String branch;
private String prompt;
private String mapData; // 핡심 데이터인 λ§ˆμΈλ“œλ§΅ JSON
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.teamEWSN.gitdeun.mindmap.dto;

import com.teamEWSN.gitdeun.mindmap.entity.MindmapType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@Builder
@AllArgsConstructor
public class MindmapResponseDto {
private Long mindmapId;
private Long repoId;
private MindmapType type;
private String field;
private LocalDateTime createdAt;
}
15 changes: 8 additions & 7 deletions src/main/java/com/teamEWSN/gitdeun/mindmap/entity/Mindmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
import com.teamEWSN.gitdeun.repo.entity.Repo;
import com.teamEWSN.gitdeun.user.entity.User;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;
import lombok.*;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Mindmap")
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "mindmap")
public class Mindmap extends AuditedEntity {

@Id
Expand All @@ -41,11 +40,13 @@ public class Mindmap extends AuditedEntity {
private MindmapType type;

@Column(name = "Field", length = 255, nullable = false)
@ColumnDefault("'ν™•μΈμš© (n)'")
private String field;

@JdbcTypeCode(SqlTypes.JSON)
@Column(name = "map_data", columnDefinition = "json", nullable = false)
private String mapData;

public void updateMapData(String newMapData) {
this.mapData = newMapData;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
package com.teamEWSN.gitdeun.mindmap.mapper;

import com.teamEWSN.gitdeun.mindmap.dto.MindmapDetailResponseDto;
import com.teamEWSN.gitdeun.mindmap.dto.MindmapResponseDto;
import com.teamEWSN.gitdeun.mindmap.entity.Mindmap;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MindmapMapper {

@Mapping(source = "id", target = "mindmapId")
MindmapResponseDto toResponseDto(Mindmap mindmap);

@Mapping(source = "id", target = "mindmapId")
MindmapDetailResponseDto toDetailResponseDto(Mindmap mindmap);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
package com.teamEWSN.gitdeun.mindmap.repository;

import com.teamEWSN.gitdeun.mindmap.entity.Mindmap;
import com.teamEWSN.gitdeun.user.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface MindmapRepository extends JpaRepository<Mindmap, Integer> {

public interface MindmapRepository extends JpaRepository<Mindmap, Long> {

// μ‚¬μš©μžκ°€ μƒμ„±ν•œ ν™•μΈμš© λ§ˆμΈλ“œλ§΅ 쀑 κ°€μž₯ μ΅œκ·Όμ— μƒμ„±λœ 것(repo 무관)
@Query("SELECT m FROM Mindmap m " +
"WHERE m.user = :user AND m.type = 'CHECK' " +
"ORDER BY m.createdAt DESC LIMIT 1")
Optional<Mindmap> findTopByUserAndTypeOrderByCreatedAtDesc(
@Param("user") User user
);
}
Loading