Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.teamEWSN.gitdeun.codereference.controller;

public class CodeReferenceController {

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
package com.teamEWSN.gitdeun.codereference.entity;

import com.teamEWSN.gitdeun.mindmapnode.entity.MindmapNode;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "code_reference")
public class CodeReference {


@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "node_id", nullable = false)
private MindmapNode node;

@Column(name = "file_path", columnDefinition = "TEXT", nullable = false)
private String filePath;

@Column(name = "start_line", length = 255)
private String startLine;

@Column(name = "end_line", length = 255)
private String endLine;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
package com.teamEWSN.gitdeun.codereview.entity;

public class CodeReview {

import com.teamEWSN.gitdeun.common.util.AuditedEntity;
import com.teamEWSN.gitdeun.mindmapnode.entity.MindmapNode;
import com.teamEWSN.gitdeun.user.entity.User;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Code_Review")
public class CodeReview extends AuditedEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "author_id", nullable = false)
private User author;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "node_id", nullable = false)
private MindmapNode node;

@Column(name = "ref_id")
private Long refId;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
@ColumnDefault("'PENDING'")
private CodeReviewStatus status;

@Column(name = "comment_cnt")
@ColumnDefault("0")
private Integer commentCount;

@Column(name = "unresolved_thread_cnt")
@ColumnDefault("0")
private Integer unresolvedThreadCount;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.teamEWSN.gitdeun.codereview.entity;

public enum CodeReviewStatus {
PENDING,
RESOLVED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.teamEWSN.gitdeun.comment.controller;

public class CommentController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.teamEWSN.gitdeun.comment.dto;

public class CommentResponseDto {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.teamEWSN.gitdeun.comment.entity;

public enum AttachmentType {
IMAGE,
FILE
}
44 changes: 44 additions & 0 deletions src/main/java/com/teamEWSN/gitdeun/comment/entity/Comment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.teamEWSN.gitdeun.comment.entity;

import com.teamEWSN.gitdeun.codereview.entity.CodeReview;
import com.teamEWSN.gitdeun.common.util.AuditedEntity;
import com.teamEWSN.gitdeun.user.entity.User;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Comment")
public class Comment extends AuditedEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "code_review_id", nullable = false)
private CodeReview codeReview;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
private User user;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_comment_id")
private Comment parentComment;

@Column(columnDefinition = "TEXT", nullable = false)
private String content;

@Enumerated(EnumType.STRING)
@Column(name = "emoji_type")
private EmojiType emojiType;

@Column(name = "resolved_at")
private LocalDateTime resolvedAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.teamEWSN.gitdeun.comment.entity;

import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "Comment_Attachment")
public class CommentAttachment {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "comment_id", nullable = false)
private Comment comment;

@Column(length = 255, nullable = false)
private String url;

@Column(name = "file_name", length = 200, nullable = false)
private String fileName;

@Column(name = "mime_type", length = 100, nullable = false)
private String mimeType;

@Column(nullable = false)
private Long size;

@Enumerated(EnumType.STRING)
@Column(name = "attachment_type", nullable = false)
private AttachmentType attachmentType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.teamEWSN.gitdeun.comment.entity;

public enum EmojiType {
QUESTION,
IDEA,
BUG,
IMPORTANT,
LOVE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.teamEWSN.gitdeun.comment.repository;

public class CommentRepository {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.teamEWSN.gitdeun.comment.service;

public class CommentService {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.teamEWSN.gitdeun.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
public class FastApiConfig {

@Value("${fastapi.base-url}")
private String baseUrl;

// FastAPI μ„œλ²„μ™€ ν†΅μ‹ ν•˜κΈ° μœ„ν•œ μ „μš© WebClient Bean
@Bean("fastApiWebClient")
public WebClient webClient() {
return WebClient.builder()
.baseUrl(baseUrl)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
@Configuration
public class WebClientConfig {

@Bean
// OAuth 및 기타 μ™ΈλΆ€ API 톡신을 μœ„ν•œ λ²”μš© WebClient Bean
@Bean("oauthWebClient")
public WebClient webClient() {
return WebClient.builder().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public enum ErrorCode {
SOCIAL_ACCOUNT_CONNECT_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "OAUTH-006", "μ†Œμ…œ 계정 연동에 μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€."),
SOCIAL_TOKEN_REFRESH_NOT_SUPPORTED(HttpStatus.BAD_REQUEST, "OAUTH-007", "λ¦¬ν”„λ ˆμ‹œ 토큰 갱신은 μ§€μ›ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 재인증이 ν•„μš”ν•©λ‹ˆλ‹€."),

// 리포지토리 κ΄€λ ¨
REPO_NOT_FOUND_BY_ID(HttpStatus.NOT_FOUND, "REPO-001", "ν•΄λ‹Ή ID둜 μš”μ²­ν•œ 리포지토리λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
REPO_NOT_FOUND_BY_URL(HttpStatus.NOT_FOUND, "REPO-002", "ν•΄λ‹Ή URL둜 μš”μ²­ν•œ 리포지토리λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),

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

import com.teamEWSN.gitdeun.common.fastapi.dto.FastApiCommitTimeResponse;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;

import java.time.LocalDateTime;

@Component
public class FastApiClient {

private final WebClient webClient; // FastApiConfigμ—μ„œ μƒμ„±ν•œ Bean을 μ£Όμž…λ°›μŒ

public FastApiClient(@Qualifier("fastApiWebClient") WebClient webClient) {
this.webClient = webClient;
}

/**
* FastAPI μ„œλ²„μ— νŠΉμ • GitHub λ¦¬ν¬μ§€ν† λ¦¬μ˜ μ΅œμ‹  컀밋 μ‹œκ°„μ„ μš”μ²­ν•©λ‹ˆλ‹€.
* @param githubRepoUrl μ‘°νšŒν•  λ¦¬ν¬μ§€ν† λ¦¬μ˜ URL
* @return μ΅œμ‹  컀밋 μ‹œκ°„
*/
public LocalDateTime fetchLatestCommitTime(String githubRepoUrl) {
// FastAPI의 κ°€λ²Όμš΄ μ—”λ“œν¬μΈνŠΈ(예: /check-commit-time)λ₯Ό ν˜ΈμΆœν•©λ‹ˆλ‹€.
FastApiCommitTimeResponse response = webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/check-commit-time") // FastAPI에 μ •μ˜λœ μ—”λ“œν¬μΈνŠΈ 경둜
.queryParam("url", githubRepoUrl) // 쿼리 νŒŒλΌλ―Έν„°λ‘œ URL 전달
.build())
.retrieve() // 응닡을 λ°›μ•„μ˜΄
.bodyToMono(FastApiCommitTimeResponse.class) // 응닡 본문을 DTO둜 λ³€ν™˜
.block(); // 비동기 응닡을 λ™κΈ°μ μœΌλ‘œ κΈ°λ‹€λ¦Ό

// null 체크 ν›„ λ‚ μ§œ λ°˜ν™˜
if (response == null) {
throw new RuntimeException("FastAPI μ„œλ²„λ‘œλΆ€ν„° μ΅œμ‹  컀밋 μ‹œκ°„ 정보λ₯Ό λ°›μ•„μ˜€μ§€ λͺ»ν–ˆμŠ΅λ‹ˆλ‹€.");
}
return response.getLatestCommitAt();
}

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

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

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

import java.time.LocalDateTime;

@Getter
public class AnalysisResultDto {
// FastAPIκ°€ λ°˜ν™˜ν•˜λŠ” Repo κ΄€λ ¨ 정보
private String defaultBranch;
private String language;
private String description;
private LocalDateTime githubLastUpdatedAt;

// FastAPIκ°€ λ°˜ν™˜ν•˜λŠ” Mindmap κ΄€λ ¨ 정보
private String mapData;
private MindmapType type;
private String prompt;
// TODO: FastAPI 응닡에 맞좰 ν•„λ“œ μ •μ˜
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.teamEWSN.gitdeun.common.fastapi.dto;

import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter // JSON 역직렬화λ₯Ό μœ„ν•΄ ν•„μš”
public class FastApiCommitTimeResponse {
private LocalDateTime latestCommitAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public enum OauthProvider {
GOOGLE,
GITHUB,
GITHUB
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.teamEWSN.gitdeun.common.exception.ErrorCode;
import com.teamEWSN.gitdeun.common.exception.GlobalException;
import com.teamEWSN.gitdeun.common.oauth.dto.GitHubEmailDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
Expand All @@ -20,11 +20,14 @@

@Slf4j
@Component
@RequiredArgsConstructor
public class GitHubApiHelper {

private final WebClient webClient;

public GitHubApiHelper(@Qualifier("oauthWebClient") WebClient webClient) {
this.webClient = webClient;
}

@Value("${spring.security.oauth2.client.registration.github.client-id}")
private String clientId;

Expand Down
Loading