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
@@ -0,0 +1,9 @@
package com.nect.api.matching.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class MatchingController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.nect.api.matching.dto;

import com.nect.core.entity.matching.enums.MatchingRequestType;
import jakarta.validation.constraints.NotNull;

public class MatchingReqDto {

public record matchingReqDto(
Long targetUserId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetUserId는 null이어도 되나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네! targetUserId는 리더 -> 팀원 매칭 요청일 때만 받고, 팀원 -> 프로젝트 요청엔 projectId만 받아 서비스단에서 처리할 계획입니다.

@NotNull
Long projectId,
@NotNull
MatchingRequestType requestType
){}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.nect.api.matching.dto;

import com.nect.core.entity.matching.enums.MatchingRequestType;
import com.nect.core.entity.matching.enums.MatchingStatus;

import java.time.LocalDateTime;

public class MatchingResDto {

public record matchingResDto(
Long id,
Long requestUserId,
Long targetUserId,
Long projectId,
MatchingStatus matchingStatus,
MatchingRequestType requestType,
LocalDateTime expiresAt
){}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.nect.api.matching.enums.code;

import com.nect.api.global.code.ResponseCode;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum MatchingErrorCode implements ResponseCode {

MATCHING_APPLY_COUNT_EXCEEDED("M400_1", "이미 매칭 대기 중인 프로젝트가 있습니다."),
MATCHING_INVITE_COUNT_EXCEEDED("M400_2", "해당 프로젝트의 매칭 신청 가능 수를 초과하였습니다."),
;

private final String statusCode;
private final String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.nect.api.matching.exception;

import com.nect.api.global.code.ResponseCode;
import com.nect.api.global.exception.CustomException;

public class MatchingException extends CustomException {

public MatchingException(ResponseCode code) {
super(code);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nect.api.matching.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class MatchingService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.nect.core.entity.matching;

import com.nect.core.entity.BaseEntity;
import com.nect.core.entity.matching.enums.MatchingRequestType;
import com.nect.core.entity.matching.enums.MatchingStatus;
import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;

@Entity
@Table(name = "matching")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Matching extends BaseEntity {

@Builder
public Matching(
Copy link
Collaborator

@ggamnunq ggamnunq Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

외부에서 다루지 않을거라면 protected 혹은 private도 고려해보면 좋을 듯 합니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expiresAt이나 의도하지 않은 칼럼이 빌더에 의해 수정될 경우를 대비해서 따로 생성자를 정의했습니다. 이럴 경우 외부에서 빌더 패턴을 사용하려면 public으로 설정해야하는데, 혹시 더 좋은 패턴이나 선호하시는 방식이 있으시면 말씀해주세요!!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다 굿굿

Long requestUserId,
Long targetUserId,
Long projectId,
MatchingRequestType requestType
){
this.requestUserId = requestUserId;
this.targetUserId = targetUserId;
this.projectId = projectId;
this.requestType = requestType;
this.matchingStatus = MatchingStatus.PENDING;
}

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

@Column(name = "request_user_id", nullable = false)
Copy link
Collaborator

@ggamnunq ggamnunq Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컬럼 name을 명시 안 해줘도 requestUserId -> request_user_id로 jpa가 바꿔서 db에 저장해주는데 의도적으로 명시해준걸까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵! 의도대로 저장되지 않을 경우를 대비해서 명확하게 지정했습니다!

private Long requestUserId;

@Column(name = "target_user_id", nullable = false)
private Long targetUserId;

@Column(name = "project_id", nullable = false)
private Long projectId;

@Enumerated(EnumType.STRING)
@Column(name = "request_type", nullable = false)
private MatchingRequestType requestType;

@Enumerated(EnumType.STRING)
@Column(name = "matching_status", nullable = false)
private MatchingStatus matchingStatus;

@Column(name = "expires_at")
private LocalDateTime expiresAt;

@PrePersist
public void calculateExpiration() {
this.expiresAt = LocalDateTime.now().plusHours(24);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.nect.core.entity.matching.enums;

public enum MatchingRequestType {
USER_TO_PROJECT, // 회원 -> 프로젝트 요청
PROJECT_TO_USER // 프로젝트(리더) -> 요청
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nect.core.entity.matching.enums;

public enum MatchingStatus {
PENDING, // 진행
ACCEPTED, // 수락
REJECTED, // 거절
EXPIRED, // 만료
CANCELED // 취소
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.nect.core.repository.matching;

import com.nect.core.entity.matching.Matching;
import org.springframework.data.jpa.repository.JpaRepository;

public interface MatchingRepository extends JpaRepository<Matching, Long> {
}
Loading