-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
439 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ava/io/oeid/mogakgo/core/properties/swagger/error/SwaggerProjectJoinReqErrorExamples.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.oeid.mogakgo.core.properties.swagger.error; | ||
|
||
public class SwaggerProjectJoinReqErrorExamples { | ||
|
||
public static final String INVALID_PROJECT_STATUS_TO_ACCEPT = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":400,\"code\":\"E050101\",\"message\":\"프로젝트가 대기중이 아니여서 참여 요청을 수락할 수 없습니다.\"}"; | ||
public static final String INVALID_PROJECT_REQ_STATUS_TO_CANCEL = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":400,\"code\":\"E050105\",\"message\":\"\"프로젝트 참여 요청이 대기중이 아니여서 참여 요청을 취소할 수 없습니다.\"}"; | ||
public static final String INVALID_PROJECT_REQ_STATUS_TO_ACCEPT = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":400,\"code\":\"E050102\",\"message\":\"프로젝트 참가 요청이 대기중이 아니여서 수락할 수 없습니다.\"}"; | ||
public static final String INVALID_MATCHING_USER_TO_ACCEPT = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":400,\"code\":\"E050103\",\"message\":\"매칭이 진행 중인 유저는 프로젝트 참여 요청을 수락할 수 없습니다.\"}"; | ||
public static final String INVALID_SENDER_TO_ACCEPT = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":400,\"code\":\"E050104\",\"message\":\"요청 보낸 상대가 이미 매칭중이기 때문에 프로젝트 참여 요청을 수락할 수 없습니다.\"}"; | ||
public static final String PROJECT_JOIN_REQUEST_NOT_FOUND = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":404,\"code\":\"E050301\",\"message\":\"프로젝트 참가 요청이 존재하지 않습니다.\"}"; | ||
|
||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/io/oeid/mogakgo/domain/matching/application/MatchingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.oeid.mogakgo.domain.matching.application; | ||
|
||
import io.oeid.mogakgo.domain.matching.domain.entity.Matching; | ||
import io.oeid.mogakgo.domain.matching.infrastructure.MatchingJpaRepository; | ||
import io.oeid.mogakgo.domain.project_join_req.domain.entity.ProjectJoinRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
@Service | ||
public class MatchingService { | ||
|
||
private final MatchingJpaRepository matchingJpaRepository; | ||
|
||
@Transactional | ||
public Long create(ProjectJoinRequest projectJoinRequest) { | ||
Matching matching = Matching.builder() | ||
.project(projectJoinRequest.getProject()) | ||
.sender(projectJoinRequest.getSender()) | ||
.build(); | ||
|
||
matchingJpaRepository.save(matching); | ||
|
||
return matching.getId(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/io/oeid/mogakgo/domain/matching/application/UserMatchingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.oeid.mogakgo.domain.matching.application; | ||
|
||
import io.oeid.mogakgo.domain.matching.infrastructure.MatchingJpaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
@Service | ||
public class UserMatchingService { | ||
|
||
private final MatchingJpaRepository matchingJpaRepository; | ||
|
||
public boolean hasProgressMatching(Long userId) { | ||
return !matchingJpaRepository.findProgressOneByUserId(userId, PageRequest.of(0, 1)) | ||
.isEmpty(); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/io/oeid/mogakgo/domain/matching/domain/entity/Matching.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.oeid.mogakgo.domain.matching.domain.entity; | ||
|
||
import static io.oeid.mogakgo.domain.matching.domain.entity.enums.MatchingStatus.PROGRESS; | ||
|
||
import io.oeid.mogakgo.domain.matching.domain.entity.enums.MatchingStatus; | ||
import io.oeid.mogakgo.domain.project.domain.entity.Project; | ||
import io.oeid.mogakgo.domain.user.domain.User; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.persistence.Table; | ||
import java.time.LocalDateTime; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
@Getter | ||
@Entity | ||
@Table(name = "matching_tb") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class Matching { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id") | ||
private Long id; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "project_id", updatable = false) | ||
private Project project; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "sender_id", updatable = false) | ||
private User sender; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(name = "matching_status") | ||
private MatchingStatus matchingStatus; | ||
|
||
@CreatedDate | ||
@Column(name = "created_at") | ||
private LocalDateTime createdAt; | ||
|
||
@Builder | ||
private Matching( | ||
Long id, Project project, User sender | ||
) { | ||
this.id = id; | ||
this.project = project; | ||
this.sender = sender; | ||
this.matchingStatus = PROGRESS; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/io/oeid/mogakgo/domain/matching/domain/entity/enums/MatchingStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.oeid.mogakgo.domain.matching.domain.entity.enums; | ||
|
||
public enum MatchingStatus { | ||
PROGRESS, | ||
CANCELED, | ||
FINISHED | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/io/oeid/mogakgo/domain/matching/infrastructure/MatchingJpaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.oeid.mogakgo.domain.matching.infrastructure; | ||
|
||
import io.oeid.mogakgo.domain.matching.domain.entity.Matching; | ||
import java.util.List; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface MatchingJpaRepository extends JpaRepository<Matching, Long> { | ||
|
||
@Query("select m from Matching m join Project p on m.project.id = p.id " | ||
+ "where (m.sender.id = :userId or p.creator.id = :userId) and m.matchingStatus = 'PROGRESS'") | ||
List<Matching> findProgressOneByUserId(Long userId, Pageable pageable); | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/io/oeid/mogakgo/domain/matching/presentation/dto/res/MatchingId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.oeid.mogakgo.domain.matching.presentation.dto.res; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Getter; | ||
|
||
@Schema(description = "매칭 ID") | ||
@Getter | ||
public class MatchingId { | ||
|
||
@Schema(description = "매칭 ID", example = "1") | ||
private final Long matchingId; | ||
|
||
public MatchingId(Long matchingId) { | ||
this.matchingId = matchingId; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.