diff --git a/nect-api/src/main/java/com/nect/api/matching/controller/MatchingController.java b/nect-api/src/main/java/com/nect/api/matching/controller/MatchingController.java new file mode 100644 index 0000000..31e95ef --- /dev/null +++ b/nect-api/src/main/java/com/nect/api/matching/controller/MatchingController.java @@ -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 { +} diff --git a/nect-api/src/main/java/com/nect/api/matching/dto/MatchingReqDto.java b/nect-api/src/main/java/com/nect/api/matching/dto/MatchingReqDto.java new file mode 100644 index 0000000..b1b0c7e --- /dev/null +++ b/nect-api/src/main/java/com/nect/api/matching/dto/MatchingReqDto.java @@ -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, + @NotNull + Long projectId, + @NotNull + MatchingRequestType requestType + ){} +} diff --git a/nect-api/src/main/java/com/nect/api/matching/dto/MatchingResDto.java b/nect-api/src/main/java/com/nect/api/matching/dto/MatchingResDto.java new file mode 100644 index 0000000..3eb2aab --- /dev/null +++ b/nect-api/src/main/java/com/nect/api/matching/dto/MatchingResDto.java @@ -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 + ){} +} diff --git a/nect-api/src/main/java/com/nect/api/matching/enums/code/MatchingErrorCode.java b/nect-api/src/main/java/com/nect/api/matching/enums/code/MatchingErrorCode.java new file mode 100644 index 0000000..c0602d7 --- /dev/null +++ b/nect-api/src/main/java/com/nect/api/matching/enums/code/MatchingErrorCode.java @@ -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; +} diff --git a/nect-api/src/main/java/com/nect/api/matching/exception/MatchingException.java b/nect-api/src/main/java/com/nect/api/matching/exception/MatchingException.java new file mode 100644 index 0000000..024d2fc --- /dev/null +++ b/nect-api/src/main/java/com/nect/api/matching/exception/MatchingException.java @@ -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); + } +} diff --git a/nect-api/src/main/java/com/nect/api/matching/service/MatchingService.java b/nect-api/src/main/java/com/nect/api/matching/service/MatchingService.java new file mode 100644 index 0000000..bb31c85 --- /dev/null +++ b/nect-api/src/main/java/com/nect/api/matching/service/MatchingService.java @@ -0,0 +1,9 @@ +package com.nect.api.matching.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class MatchingService { +} diff --git a/nect-core/src/main/java/com/nect/core/entity/matching/Matching.java b/nect-core/src/main/java/com/nect/core/entity/matching/Matching.java new file mode 100644 index 0000000..db54541 --- /dev/null +++ b/nect-core/src/main/java/com/nect/core/entity/matching/Matching.java @@ -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( + 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) + 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); + } +} diff --git a/nect-core/src/main/java/com/nect/core/entity/matching/enums/MatchingRequestType.java b/nect-core/src/main/java/com/nect/core/entity/matching/enums/MatchingRequestType.java new file mode 100644 index 0000000..227ada6 --- /dev/null +++ b/nect-core/src/main/java/com/nect/core/entity/matching/enums/MatchingRequestType.java @@ -0,0 +1,6 @@ +package com.nect.core.entity.matching.enums; + +public enum MatchingRequestType { + USER_TO_PROJECT, // 회원 -> 프로젝트 요청 + PROJECT_TO_USER // 프로젝트(리더) -> 요청 +} diff --git a/nect-core/src/main/java/com/nect/core/entity/matching/enums/MatchingStatus.java b/nect-core/src/main/java/com/nect/core/entity/matching/enums/MatchingStatus.java new file mode 100644 index 0000000..40ae182 --- /dev/null +++ b/nect-core/src/main/java/com/nect/core/entity/matching/enums/MatchingStatus.java @@ -0,0 +1,9 @@ +package com.nect.core.entity.matching.enums; + +public enum MatchingStatus { + PENDING, // 진행 + ACCEPTED, // 수락 + REJECTED, // 거절 + EXPIRED, // 만료 + CANCELED // 취소 +} diff --git a/nect-core/src/main/java/com/nect/core/repository/matching/MatchingRepository.java b/nect-core/src/main/java/com/nect/core/repository/matching/MatchingRepository.java new file mode 100644 index 0000000..d2c84b9 --- /dev/null +++ b/nect-core/src/main/java/com/nect/core/repository/matching/MatchingRepository.java @@ -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 { +}