Skip to content

Commit

Permalink
Merge pull request #76 from Kernel360/revert-75-develop
Browse files Browse the repository at this point in the history
Revert "deploy: 1.0.2"
  • Loading branch information
I-migi authored Sep 27, 2024
2 parents 12ff67e + d84e6b6 commit 366ae93
Show file tree
Hide file tree
Showing 36 changed files with 114 additions and 692 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.badminton.api.clubmember.model.dto.ClubMemberJoinResponse;
import org.badminton.api.common.exception.club.ClubNotExistException;
import org.badminton.api.common.exception.clubmember.ClubMemberDuplicateException;
import org.badminton.api.common.exception.clubmember.ClubMemberExistInClubException;
import org.badminton.api.common.exception.member.MemberNotExistException;
import org.badminton.domain.club.entity.ClubEntity;
import org.badminton.domain.club.repository.ClubRepository;
Expand Down Expand Up @@ -31,7 +31,7 @@ public ClubMemberJoinResponse joinClub(Long memberId, Long clubId) {
.orElseThrow(() -> new MemberNotExistException(memberId));

if (clubMemberRepository.existsByMember_MemberId(memberId)) {
throw new ClubMemberDuplicateException(clubId, memberId);
throw new ClubMemberExistInClubException(memberId);
}

ClubMemberEntity clubMemberEntity = new ClubMemberEntity(clubEntity, memberEntity, ClubMemberRole.ROLE_USER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,16 @@ public enum ErrorCode {
RESOURCE_NOT_EXIST(404, "특정 리소스를 찾을 수 없습니다."),
MEMBER_NOT_EXIST(404, "해당하는 회원이 존재하지 않습니다."),
CLUB_NOT_EXIST(404, "해당하는 동호회가 존재하지 않습니다."),
LEAGUE_NOT_EXIST(404, "해당하는 경기 일정이 존재하지 않습니다."),
CLUB_MEMBER_NOT_EXIST(404, "해당하는 회원은 해당 동호회에 아직 가입하지 않았습니다."),

// 409 Errors
CONFLICT(409, "리소스 충돌이 발생했습니다."),
ALREADY_EXIST(409, "리소스가 이미 존재합니다."),
CLUB_MEMBER_ALREADY_EXIST(409, "이미 해당 동호회에 가입을 완료한 회원입니다."),
MEMBER_ALREADY_EXIST_IN_CLUB(409, "동호회에 이미 멤버가 존재합니다"),

// RESOURCE_ALREADY_EXIST
RESOURCE_ALREADY_EXIST(409, "특정 리소스가 이미 존재합니다."),
CLUB_NAME_ALREADY_EXIST(409, "이미 존재하는 동호회 이름입니다."),
LEAGUE_ALREADY_EXIST(409, "이미 존재하는 경기 일정입니다."),
LEAGUE_ALREADY_PARTICIPATED(409, "이미 참여 신청을 완료한 경기 일정입니다."),
LEAGUE_NOT_PARTICIPATED(409, "참여 신청을 하지 않는 경기입니다."),
LEAGUE_PARTICIPATION_ALREADY_CANCELED(409, "이미 참여 신청을 취소한 경기 일정입니다."),

// 410 Errors
DELETED(410, "요청한 리소스가 삭제되었습니다."),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.badminton.api.common.exception.clubmember;

import org.badminton.api.common.error.ErrorCode;
import org.badminton.api.common.exception.BadmintonException;

public class ClubMemberExistInClubException extends BadmintonException {

public ClubMemberExistInClubException(Long memberId) {
super(ErrorCode.MEMBER_ALREADY_EXIST_IN_CLUB, "[회원 아이디 : " + memberId + "]");
}

public ClubMemberExistInClubException(Long memberId, Exception e) {
super(ErrorCode.MEMBER_ALREADY_EXIST_IN_CLUB, "[회원 아이디 : " + memberId + "]", e);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

public class LeagueNotExistException extends BadmintonException {

public LeagueNotExistException(Long clubId, Long leagueId) {
super(ErrorCode.LEAGUE_NOT_EXIST, "[동호회 아이디 : " + clubId + " 경기 일정 아이디 : " + leagueId + "]");
public LeagueNotExistException(Long leagueId) {
super(ErrorCode.LEAGUE_ALREADY_EXIST, "[경기 일정 아이디 : " + leagueId + "]");
}

public LeagueNotExistException(Long clubId, Long leagueId, Exception e) {
super(ErrorCode.LEAGUE_NOT_EXIST, "[동호회 아이디 : " + clubId + " 경기 일정 아이디 : " + leagueId + "]", e);
public LeagueNotExistException(Long leagueId, Exception e) {
super(ErrorCode.LEAGUE_ALREADY_EXIST, "[경기 일정 아이디 : " + leagueId + "]", e);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,23 @@ public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {

http
.oauth2Login(oauth2 -> oauth2
.userInfoEndpoint(userInfoEndpointConfig ->
userInfoEndpointConfig.userService(customOAuth2MemberService))
.userInfoEndpoint(
userInfoEndpointConfig -> userInfoEndpointConfig.userService(customOAuth2MemberService))
.successHandler(customSuccessHandler));

http
.authorizeHttpRequests(auth -> auth
.requestMatchers("/", "/groups", "/oauth2/**", "/login/**", "/error", "/api/*", "/swagger-ui/**",
"/v3/api-docs/**").permitAll()
.anyRequest().authenticated());
"/v3/api-docs/**")
.permitAll()
.anyRequest()
.authenticated());

http
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS));

return http.build();
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import org.badminton.api.league.model.dto.LeagueCreateRequest;
import org.badminton.api.league.model.dto.LeagueCreateResponse;
import org.badminton.api.league.model.dto.LeagueReadResponse;
import org.badminton.api.league.model.dto.LeagueStatusUpdateRequest;
import org.badminton.api.league.model.dto.LeagueStatusUpdateResponse;
import org.badminton.api.league.model.dto.LeagueUpdateRequest;
import org.badminton.api.league.service.LeagueService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -18,12 +18,11 @@
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@RestController
@RequestMapping("/v1/club/{clubId}/league")
@RequestMapping("/v1/league")
public class LeagueController {
private final LeagueService leagueService;

Expand All @@ -33,10 +32,8 @@ public class LeagueController {
tags = {"league"}
)
@PostMapping
public ResponseEntity<LeagueCreateResponse> createLeague(
@PathVariable Long clubId,
@Valid @RequestBody LeagueCreateRequest leagueCreateRequest) {
return ResponseEntity.ok(leagueService.createLeague(clubId, leagueCreateRequest));
public ResponseEntity<LeagueCreateResponse> leagueCreate(@RequestBody LeagueCreateRequest request) {
return ResponseEntity.ok(leagueService.createLeague(request));
}

@Operation(
Expand All @@ -45,34 +42,29 @@ public ResponseEntity<LeagueCreateResponse> createLeague(
tags = {"league"}
)
@GetMapping("/{leagueId}")
public ResponseEntity<LeagueReadResponse> leagueRead(@PathVariable Long clubId, @PathVariable Long leagueId) {
return ResponseEntity.ok(leagueService.getLeague(clubId, leagueId));
public ResponseEntity<LeagueReadResponse> leagueRead(@PathVariable("leagueId") Long leagueId) {
return ResponseEntity.ok(leagueService.getLeague(leagueId));
}

@Operation(
summary = "경기의 세부 정보를 변경합니다.",
description = "경기 제목, 경기 상태 등을 변경할 수 있습니다.",
summary = "특정 경기의 상태를 변경합니다.",
description = "특정 경기의 상태를 변경(진행 전, 진행 중, 취소, 진행완료)",
tags = {"league"}
)
@PatchMapping("/{leagueId}")
public ResponseEntity<LeagueStatusUpdateResponse> updateLeague(
@PathVariable Long clubId,
@PathVariable Long leagueId,
@Valid @RequestBody LeagueUpdateRequest leagueUpdateRequest) {
return ResponseEntity.ok(leagueService.updateLeague(clubId, leagueId, leagueUpdateRequest));
public ResponseEntity<LeagueStatusUpdateResponse> leagueChangeStatus(
@RequestBody LeagueStatusUpdateRequest request) {
return ResponseEntity.ok(leagueService.updateLeagueStatus(request));
}

@Operation(
summary = "특정 경기를 삭제합니다.",
description = "특정 경기를 데이터베이스 테이블에서 제거합니다.",
tags = {"league"}
)

@DeleteMapping("/{leagueId}")
public ResponseEntity<HttpStatus> deleteLeague(
@PathVariable Long clubId,
@PathVariable Long leagueId) {
leagueService.deleteLeague(clubId, leagueId);
public ResponseEntity<HttpStatus> leagueDelete(@PathVariable("leagueId") Long leagueId) {
leagueService.deleteLeague(leagueId);
return ResponseEntity.ok(HttpStatus.OK);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

import org.badminton.domain.common.enums.MatchType;
import org.badminton.domain.common.enums.MemberTier;
import org.badminton.domain.league.entity.LeagueEntity;
import org.badminton.domain.league.enums.LeagueStatus;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;

// TODO: 필드가 너무 많다. 분리 고민
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record LeagueCreateRequest(

@Schema(description = "경기 이름", example = "배드민턴 경기")
Expand All @@ -18,20 +21,15 @@ public record LeagueCreateRequest(
@Schema(description = "경기 설명", example = "이 경기는 지역 예선 경기입니다.")
String description,

//TODO: DTO 마다 검증 로직을 두지 않는 방법 알아보기
@Pattern(regexp = "GOLD|SILVER|BRONZE", message = "리그 상태 값이 올바르지 않습니다.")
@Schema(description = "최소 티어", example = "GOLD")
MemberTier tierLimit,

@Pattern(regexp = "OPEN|CLOSED", message = "리그 상태 값이 올바르지 않습니다.")
@Schema(description = "현재 경기 상태", example = "OPEN")
LeagueStatus leagueStatus,
LeagueStatus status,

@Pattern(regexp = "SINGLE|DOUBLES", message = "경기 방식 값이 올바르지 않습니다.")
@Schema(description = "경기 방식", example = "SINGLE")
MatchType matchType,

// TODO: 시간 예쁘게 만들기
@Schema(description = "경기 시작 날짜", example = "2024-09-10T15:30:00")
LocalDateTime leagueAt,

Expand All @@ -45,5 +43,9 @@ public record LeagueCreateRequest(
String matchingRequirement

) {

public LeagueEntity leagueCreateRequestToEntity() {
return new LeagueEntity(this.leagueName,
this.description, this.leagueAt, this.tierLimit, this.closedAt, this.status, this.playerCount,
this.matchType, this.matchingRequirement);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public LeagueCreateResponse(LeagueEntity entity) {
entity.getLeagueName(),
entity.getDescription(),
entity.getTierLimit(),
entity.getLeagueStatus(),
entity.getStatus(),
entity.getMatchType(),
entity.getLeagueAt(),
entity.getClosedAt(),
Expand Down
Loading

0 comments on commit 366ae93

Please sign in to comment.