Skip to content

Commit

Permalink
Merge branch 'feat/#30-cards_list_up_by_zone' of https://github.com/O…
Browse files Browse the repository at this point in the history
…pen-Eye-Im-Developer/MoGakGo-BE into feat/#30-cards_list_up_by_zone
  • Loading branch information
JIN-076 committed Feb 19, 2024
2 parents 1c8c41d + a4a74fa commit a14c337
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public interface ProjectJoinRequestSwagger {
examples = {
@ExampleObject(name = "E090101",
value = SwaggerProjectJoinRequestErrorExamples.PROJECT_JOIN_REQUEST_ALREADY_EXIST),
@ExampleObject(name = "E090103",
@ExampleObject(name = "E090102",
value = SwaggerProjectJoinRequestErrorExamples.PROJECT_JOIN_REQUEST_INVALID_REGION)
})),
@ApiResponse(responseCode = "403", description = "프로젝트 매칭 요청 권한이 없음",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E090201",
examples = @ExampleObject(name = "E050201",
value = SwaggerProjectJoinRequestErrorExamples.PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION))),
@ApiResponse(responseCode = "404", description = "요청한 데이터가 존재하지 않음",
content = @Content(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

public class SwaggerProjectJoinRequestErrorExamples {

public static final String PROJECT_JOIN_REQUEST_ALREADY_EXIST = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":403,\"code\":\"E090201\",\"message\":\"프로젝트 생성자는 해당 프로젝트에 매칭 요청을 보낼 수 없습니다.\"}";
public static final String PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":403,\"code\":\"E090101\",\"message\":\"이미 매칭 요청을 보낸 프로젝트에 매칭 요청을 보낼 수 없습니다..\"}";
public static final String PROJECT_JOIN_REQUEST_INVALID_REGION = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":403,\"code\":\"E090102\",\"message\":\"프로젝트 매칭 서비스는 동네 인증되지 않은 구역에서 진행할 수 없습니다..\"}";
public static final String PROJECT_JOIN_REQUEST_ALREADY_EXIST = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":400,\"code\":\"E050201\",\"message\":\"이미 매칭 요청을 보낸 프로젝트에 매칭 요청을 보낼 수 없습니다.\"}";
public static final String PROJECT_JOIN_REQUEST_INVALID_REGION = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":400,\"code\":\"E090102\",\"message\":\"프로젝트 매칭 서비스는 동네 인증되지 않은 구역에서 진행할 수 없습니다.\"}";
public static final String PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":403,\"code\":\"E090101\",\"message\":\"프로젝트 생성자는 해당 프로젝트에 매칭 요청을 보낼 수 없습니다.\"}";
private SwaggerProjectJoinRequestErrorExamples() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.oeid.mogakgo.domain.project.infrastructure.ProjectJpaRepository;
import io.oeid.mogakgo.domain.project.presentation.dto.req.ProjectCreateReq;
import io.oeid.mogakgo.domain.project_join_req.exception.ProjectJoinRequestException;
import io.oeid.mogakgo.domain.project_join_req.infrastruture.ProjectJoinRequestJpaRepository;
import io.oeid.mogakgo.domain.project_join_req.infrastructure.ProjectJoinRequestJpaRepository;
import io.oeid.mogakgo.domain.project_join_req.presentation.projectJoinRequestRes;
import io.oeid.mogakgo.domain.user.domain.User;
import io.oeid.mogakgo.domain.user.exception.UserException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package io.oeid.mogakgo.domain.project_join_req.application;

import static io.oeid.mogakgo.exception.code.ErrorCode400.INVALID_PROJECT_JOIN_REQUEST;
import static io.oeid.mogakgo.exception.code.ErrorCode400.INVALID_PROJECT_JOIN_REQUEST_REGION;
import static io.oeid.mogakgo.exception.code.ErrorCode400.PROJECT_JOIN_REQUEST_ALREADY_EXIST;
import static io.oeid.mogakgo.exception.code.ErrorCode403.PROJECT_JOIN_FORBIDDEN_OPERATION;
import static io.oeid.mogakgo.exception.code.ErrorCode403.PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION;
import static io.oeid.mogakgo.exception.code.ErrorCode404.PROJECT_NOT_FOUND;
import static io.oeid.mogakgo.exception.code.ErrorCode404.USER_NOT_FOUND;

Expand All @@ -13,7 +12,7 @@
import io.oeid.mogakgo.domain.project_join_req.application.dto.req.ProjectJoinCreateReq;
import io.oeid.mogakgo.domain.project_join_req.domain.entity.ProjectJoinRequest;
import io.oeid.mogakgo.domain.project_join_req.exception.ProjectJoinRequestException;
import io.oeid.mogakgo.domain.project_join_req.infrastruture.ProjectJoinRequestJpaRepository;
import io.oeid.mogakgo.domain.project_join_req.infrastructure.ProjectJoinRequestJpaRepository;
import io.oeid.mogakgo.domain.user.domain.User;
import io.oeid.mogakgo.domain.user.exception.UserException;
import io.oeid.mogakgo.domain.user.infrastructure.UserJpaRepository;
Expand Down Expand Up @@ -50,7 +49,7 @@ private User validateToken(Long userId) {

private void validateSender(User tokenUser, Long userId) {
if (!tokenUser.getId().equals(userId)) {
throw new ProjectJoinRequestException(PROJECT_JOIN_FORBIDDEN_OPERATION);
throw new ProjectJoinRequestException(PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION);
}
}

Expand All @@ -61,12 +60,12 @@ private Project validateProjectExist(Long projectId) {

private void validateProjectCreator(Project project, Long userId) {
if (project.getCreator().getId().equals(userId)) {
throw new ProjectJoinRequestException(INVALID_PROJECT_JOIN_REQUEST);
throw new ProjectJoinRequestException(PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION);
}
}

private void validateAlreadyExistRequest(Long userId, Long projectId) {
projectJoinRequestRepository.findAlreadyExists(userId, projectId)
private ProjectJoinRequest validateAlreadyExistRequest(Long userId, Long projectId) {
return projectJoinRequestRepository.findAlreadyExists(userId, projectId)
.orElseGet(() -> {
throw new ProjectJoinRequestException(PROJECT_JOIN_REQUEST_ALREADY_EXIST);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.oeid.mogakgo.domain.project_join_req.infrastruture;
package io.oeid.mogakgo.domain.project_join_req.infrastructure;

import io.oeid.mogakgo.domain.project_join_req.domain.entity.ProjectJoinRequest;
import java.util.Optional;
Expand All @@ -10,6 +10,6 @@ public interface ProjectJoinRequestJpaRepository extends JpaRepository<ProjectJo

boolean existsByProjectId(Long projectId);

@Query("select pjr from ProjectJoinRequest pjr where pjr.sender.id = :id and pjr.project.id = :projectId")
@Query("select pjr from ProjectJoinRequest pjr where pjr.sender.id = :userId and pjr.project.id = :projectId")
Optional<ProjectJoinRequest> findAlreadyExists(Long userId, Long projectId);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.oeid.mogakgo.domain.project_join_req.infrastruture;
package io.oeid.mogakgo.domain.project_join_req.infrastructure;

import io.oeid.mogakgo.common.base.CursorPaginationInfoReq;
import io.oeid.mogakgo.common.base.CursorPaginationResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.oeid.mogakgo.domain.project_join_req.infrastruture;
package io.oeid.mogakgo.domain.project_join_req.infrastructure;

import static io.oeid.mogakgo.domain.project_join_req.domain.entity.QProjectJoinRequest.projectJoinRequest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
public enum ErrorCode403 implements ErrorCode {
AUTH_ACCESS_DENIED("E010203", "접근 권한이 없습니다."),
PROJECT_FORBIDDEN_OPERATION("E030201", "해당 프로젝트에 대한 권한이 없습니다."),
PROJECT_JOIN_FORBIDDEN_OPERATION("E090201", "해당 프로젝트에 매칭을 요청할 권한이 없습니다."),
PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION("E050201", "해당 프로젝트 요청에 대한 권한이 없습니다."),
CERT_INVALID_INFORMATION("E070201", "동네 인증을 수행할 권한이 없습니다."),
;
Expand Down

0 comments on commit a14c337

Please sign in to comment.