Skip to content

Commit

Permalink
충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
soeunnPark committed Nov 22, 2024
2 parents 3f50d77 + b98cbf4 commit 566a5d9
Show file tree
Hide file tree
Showing 25 changed files with 197 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ logs/api
/my/
/logback-api-test.xml

domain/src/main/generated
domain/src/main/generated
10 changes: 10 additions & 0 deletions admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# badminton-admin Dockerfile

FROM amazoncorretto:17

LABEL authors="hit team"

COPY build/libs/admin.jar /admin.jar

ENTRYPOINT ["java", "-jar", "/admin.jar"]
24 changes: 24 additions & 0 deletions admin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
dependencies {
implementation project(':domain')
implementation project(':infrastructure')
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.6.0'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.5.RELEASE'

runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3'

}

test {
useJUnitPlatform()
}

bootJar {
enabled = true
}

jar {
enabled = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.badminton.admin;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class BadmintonAdminApplication {
public static void main(String[] args) {
SpringApplication.run(BadmintonAdminApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.badminton.admin.application.board;

public class BoardFacade {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.badminton.admin.interfaces.board;

public class BoardController {
}
36 changes: 36 additions & 0 deletions admin/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
spring:
application:
name: badminton
jpa:
properties:
hibernate:
format_sql: true
dialect: org.hibernate.dialect.MySQL8Dialect
hibernate:
ddl-auto: ${DDL_METHOD_API}
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
defer-datasource-initialization: true
messages:
encoding: UTF-8
basename: messages
sql:
init:
mode: ${SQL_MODE}
datasource:
url: ${DATABASE_URL}
username: ${DATABASE_USER_NAME}
password: ${DATABASE_USER_PASSWORD}
driver-class-name: ${DATABASE_DRIVER}

cloud:
aws:
credentials:
access-key: ${S3_ACCESS_KEY}
secret-key: ${S3_SECRET_KEY}
region:
static: ap-northeast-2 # 버킷의 리전
s3:
bucket: badminton-team # 버킷 이름
stack:
auto: false
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ClubMemberFacade {
private final MailService mailService;

public ApplyClubInfo applyClub(String memberToken, String clubToken, ClubApplyCommand command) {
mailService.prepareClubApplyEmail(clubToken);
mailService.prepareClubApplyEmail(clubToken, memberToken);
return clubApplyService.applyClub(memberToken, clubToken, command.applyReason());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.badminton.domain.domain.league.LeagueService;
import org.badminton.domain.domain.league.command.LeagueCreateNoIncludeClubCommand;
import org.badminton.domain.domain.league.command.LeagueUpdateCommand;
import org.badminton.domain.domain.league.info.IsLeagueParticipantInfo;
import org.badminton.domain.domain.league.info.LeagueByDateInfo;
import org.badminton.domain.domain.league.info.LeagueByDateInfoWithParticipantCountInfo;
import org.badminton.domain.domain.league.info.LeagueCancelInfo;
Expand Down Expand Up @@ -57,13 +58,16 @@ public LeagueCreateInfo createLeague(String memberToken, String clubToken,
return leagueCreateInfo;
}

public LeagueDetailsInfo getLeague(String clubToken, Long leagueId, String memberToken) {
public LeagueDetailsInfo getLeague(String clubToken, Long leagueId) {
LeagueSummaryInfo leagueSummaryInfo = leagueService.getLeague(clubToken, leagueId);
MatchStrategy matchStrategy = matchRetrieveService.makeSinglesOrDoublesMatchStrategy(leagueId);
boolean isMatchCreated = matchRetrieveService.isMatchInLeague(matchStrategy, leagueId);
boolean isParticipatedInLeague = leagueParticipantService.isParticipant(memberToken, leagueId);
int recruitedMemberCount = leagueParticipantService.countParticipantMember(leagueId);
return LeagueDetailsInfo.from(leagueSummaryInfo, isMatchCreated, isParticipatedInLeague, recruitedMemberCount);
return LeagueDetailsInfo.from(leagueSummaryInfo, isMatchCreated, recruitedMemberCount);
}

public IsLeagueParticipantInfo isLeagueParticipant(String memberToken, Long leagueId) {
return leagueParticipantService.isParticipant(memberToken, leagueId);
}

public LeagueUpdateInfoWithParticipantCountInfo updateLeague(String clubToken, Long leagueId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public SecurityFilterChain jwtOnlyFilterChain(HttpSecurity http) throws Exceptio
|| request.getRequestURI().equals("/v1/clubs/{clubToken}/clubMembers/check")
|| request.getRequestURI().equals("/v1/clubs/{clubToken}/leagues/month")
|| request.getRequestURI().equals("/v1/clubs/{clubToken}/leagues/date")
|| request.getRequestURI().equals("/v1/clubs/{clubToken}/leagues/{leagueId}/check")
)
.csrf(AbstractHttpConfigurer::disable)
.cors(this::corsConfigurer)
Expand Down Expand Up @@ -135,7 +136,7 @@ public SecurityFilterChain clubFilterChain(HttpSecurity http) throws Exception {
.requestMatchers(HttpMethod.PATCH, "/v1/clubs/{clubToken}")
.access(hasClubRole("OWNER", "MANAGER"))
.requestMatchers(HttpMethod.GET, "/v1/clubs/{clubToken}/leagues/{leagueId}")
.access(hasClubRole("OWNER", "MANAGER", "USER"))
.permitAll()
.requestMatchers(HttpMethod.GET, "/v1/clubs/{clubToken}/clubMembers")
.access(hasClubRole("OWNER", "MANAGER", "USER"))
.requestMatchers(HttpMethod.GET, "/v1/clubs/{clubToken}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
Expand All @@ -18,7 +19,12 @@
@Slf4j
@Component
public class FailedAuthenticationEntryPoint implements AuthenticationEntryPoint {
private final ObjectMapper objectMapper = new ObjectMapper();
private final ObjectMapper objectMapper;

public FailedAuthenticationEntryPoint(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
this.objectMapper.setPropertyNamingStrategy(new PropertyNamingStrategies.SnakeCaseStrategy());
}

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ public record ClubApplicantResponse(
@Schema(description = "가입 사유", requiredMode = Schema.RequiredMode.REQUIRED)
String applyReason,
@Schema(description = "동호회 가입 상태 (APPROVED | PENDING | REJECTED", requiredMode = Schema.RequiredMode.REQUIRED)
ClubApply.ApplyStatus status
ClubApply.ApplyStatus status,
@Schema(description = "프로필 이미지", requiredMode = Schema.RequiredMode.REQUIRED)
String profileImage

) {
public static ClubApplicantResponse from(ClubApplicantInfo clubApply) {
return new ClubApplicantResponse(
clubApply.clubApplyId(),
clubApply.name(),
clubApply.tier(),
clubApply.applyReason(),
clubApply.status()
clubApply.status(),
clubApply.profileImage()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.badminton.api.application.league.LeagueFacade;
import org.badminton.api.common.response.CommonResponse;
import org.badminton.api.interfaces.auth.dto.CustomOAuth2Member;
import org.badminton.api.interfaces.league.dto.IsLeagueParticipantResponse;
import org.badminton.api.interfaces.league.dto.LeagueByDateResponse;
import org.badminton.api.interfaces.league.dto.LeagueCancelResponse;
import org.badminton.api.interfaces.league.dto.LeagueCreateRequest;
Expand All @@ -13,6 +14,7 @@
import org.badminton.api.interfaces.league.dto.LeagueReadResponse;
import org.badminton.api.interfaces.league.dto.LeagueUpdateRequest;
import org.badminton.api.interfaces.league.dto.LeagueUpdateResponse;
import org.badminton.domain.domain.league.info.IsLeagueParticipantInfo;
import org.badminton.domain.domain.league.info.LeagueByDateInfoWithParticipantCountInfo;
import org.badminton.domain.domain.league.info.LeagueCancelInfo;
import org.badminton.domain.domain.league.info.LeagueDetailsInfo;
Expand Down Expand Up @@ -82,7 +84,7 @@ public CommonResponse<List<LeagueByDateResponse>> getLeagueByDate(@PathVariable
summary = "경기를 생성합니다.",
description = """
경기 생성하고를 데이터베이스에 저장합니다.
1. 경기 이름 2 ~ 20 글자
2. 경기 설명 2 ~ 1000 글자
3. 경기 장소 2 ~ 100 글자
Expand All @@ -93,7 +95,7 @@ public CommonResponse<List<LeagueByDateResponse>> getLeagueByDate(@PathVariable
토너먼트 더블: 참가자 수/2 가 2의 제곱
프리 싱글: 2의 배수
프리 더블: 4의 배수
""",
tags = {"league"}
)
Expand All @@ -117,27 +119,42 @@ public CommonResponse<LeagueCreateResponse> createLeague(
)
@GetMapping("/{leagueId}")
public CommonResponse<LeagueDetailsResponse> leagueRead(@PathVariable String clubToken,
@PathVariable Long leagueId,
@AuthenticationPrincipal CustomOAuth2Member member) {
@PathVariable Long leagueId) {
LeagueDetailsInfo leagueDetailsInfo =
leagueFacade.getLeague(clubToken, leagueId, member.getMemberToken());
leagueFacade.getLeague(clubToken, leagueId);
LeagueDetailsResponse leagueDetailsResponse = leagueDtoMapper.of(leagueDetailsInfo);
return CommonResponse.success(leagueDetailsResponse);
}

@Operation(
summary = "경기의 참여자인지 확인합니다",
description = "경기 아이디를 통해 경기 참가자인지 확인합니다.",
tags = {"league"}
)
@GetMapping("/{leagueId}/check")
public CommonResponse<IsLeagueParticipantResponse> checkLeagueParticipant(@PathVariable String clubToken,
@PathVariable Long leagueId,
@AuthenticationPrincipal CustomOAuth2Member member) {
IsLeagueParticipantInfo isLeagueParticipantInfo = leagueFacade.isLeagueParticipant(member.getMemberToken(),
leagueId);

IsLeagueParticipantResponse isLeagueParticipantResponse = leagueDtoMapper.of(isLeagueParticipantInfo);
return CommonResponse.success(isLeagueParticipantResponse);
}

@Operation(
summary = "경기의 세부 정보를 변경합니다.",
description = """
경기 이름, 설명, 참가자, 싱글/더블, 프리/토너먼트 변경
1. 경기 이름 2 ~ 20 글자
2. 경기 설명 2 ~ 1000 글자
3. 참가인원:
토너먼트 싱글: 2의 제곱
토너먼트 더블: 참가자 수/2 가 2의 제곱
프리 싱글: 2의 배수
프리 더블: 4의 배수
""",
tags = {"league"}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.badminton.api.interfaces.league.dto.IsLeagueParticipantResponse;
import org.badminton.api.interfaces.league.dto.LeagueByDateResponse;
import org.badminton.api.interfaces.league.dto.LeagueCancelResponse;
import org.badminton.api.interfaces.league.dto.LeagueCreateRequest;
Expand All @@ -14,6 +15,7 @@
import org.badminton.api.interfaces.league.dto.LeagueUpdateResponse;
import org.badminton.domain.domain.league.command.LeagueCreateNoIncludeClubCommand;
import org.badminton.domain.domain.league.command.LeagueUpdateCommand;
import org.badminton.domain.domain.league.info.IsLeagueParticipantInfo;
import org.badminton.domain.domain.league.info.LeagueByDateInfoWithParticipantCountInfo;
import org.badminton.domain.domain.league.info.LeagueCancelInfo;
import org.badminton.domain.domain.league.info.LeagueCreateInfo;
Expand Down Expand Up @@ -54,4 +56,6 @@ public interface LeagueDtoMapper {
LeagueUpdateResponse of(LeagueUpdateInfoWithParticipantCountInfo leagueUpdateInfo);

List<LeagueByDateResponse> of(List<LeagueByDateInfoWithParticipantCountInfo> responseInfo);

IsLeagueParticipantResponse of(IsLeagueParticipantInfo isLeagueParticipantInfo);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.badminton.api.interfaces.league.dto;

import io.swagger.v3.oas.annotations.media.Schema;

public record IsLeagueParticipantResponse(
@Schema(description = "해당하는 경기에 참여 신청을 했는지 여부", requiredMode = Schema.RequiredMode.REQUIRED)
boolean isParticipatedInLeague
) {
}
10 changes: 10 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ services:
networks:
- backend
image: speech2/badminton:batch

badminton-admin:
build:
context: ./admin
platform: linux/amd64 # x86 아키텍처
ports:
- "8090:8090"
networks:
- backend
image: speech2/badminton:admin
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ public record ClubApplicantInfo(
String name,
Member.MemberTier tier,
String applyReason,
ClubApply.ApplyStatus status
ClubApply.ApplyStatus status,
String profileImage
) {
public static ClubApplicantInfo from(ClubApply clubApply) {
return new ClubApplicantInfo(
clubApply.getClubApplyId(),
clubApply.getMember().getName(),
clubApply.getMember().getTier(),
clubApply.getApplyReason(),
clubApply.getStatus()
clubApply.getStatus(),
clubApply.getMember().getProfileImage()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import java.util.Map;
import java.util.TreeMap;

import org.badminton.domain.domain.club.entity.Club;
import org.badminton.domain.common.exception.clubmember.ClubOwnerCannotWithdraw;
import org.badminton.domain.common.exception.clubmember.ClubMemberOwnerException;
import org.badminton.domain.common.exception.clubmember.ClubOwnerCannotWithdraw;
import org.badminton.domain.domain.club.entity.Club;
import org.badminton.domain.domain.club.info.ClubCardInfo;
import org.badminton.domain.domain.club.info.ClubCreateInfo;
import org.badminton.domain.domain.clubmember.ClubMemberReader;
Expand Down Expand Up @@ -57,7 +57,6 @@ public ClubMemberInfo updateClubMemberRole(ClubMemberRoleUpdateCommand command,

ClubMember clubMember = clubMemberReader.getClubMember(clubMemberId);
clubMember.updateClubMemberRole(command.role());
clubOwnerProtect(clubMember);
clubMemberStore.store(clubMember);

return ClubMemberInfo.valueOf(clubMember);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.badminton.domain.domain.league;

import org.badminton.domain.domain.league.info.IsLeagueParticipantInfo;
import org.badminton.domain.domain.league.info.LeagueParticipantCancelInfo;
import org.badminton.domain.domain.league.info.LeagueParticipantInfo;

public interface LeagueParticipantService {
boolean isParticipant(String memberToken, Long leagueId);
IsLeagueParticipantInfo isParticipant(String memberToken, Long leagueId);

int countParticipantMember(Long leagueId);

Expand Down
Loading

0 comments on commit 566a5d9

Please sign in to comment.