Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ out/

### VS Code ###
.vscode/
/mysql-data/
9 changes: 7 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
version: "3"
services:
mysql:
image: 'mysql:latest'
image: mysql:8.0
container_name: festimate-mysql-1
env_file:
- .env
ports:
- '3306:3306'
- "3306:3306"
volumes:
- ./mysql-data:/var/lib/mysql
restart: unless-stopped
27 changes: 8 additions & 19 deletions src/main/java/org/festimate/team/api/admin/AdminController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.festimate.team.api.point.dto.PointHistoryResponse;
import org.festimate.team.global.response.ApiResponse;
import org.festimate.team.global.response.ResponseBuilder;
import org.festimate.team.infra.jwt.JwtService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -16,7 +15,6 @@
@RequestMapping("/v1/admin/festivals")
@RequiredArgsConstructor
public class AdminController {
private final JwtService jwtService;
private final FestivalFacade festivalFacade;
private final FestivalHostFacade festivalHostFacade;
private final ParticipantFacade participantFacade;
Expand All @@ -25,85 +23,76 @@ public class AdminController {

@PostMapping()
public ResponseEntity<ApiResponse<FestivalResponse>> createFestival(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@RequestBody FestivalRequest request
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
FestivalResponse response = festivalFacade.createFestival(userId, request);
return ResponseBuilder.created(response);
}

@GetMapping()
public ResponseEntity<ApiResponse<List<AdminFestivalResponse>>> getAllFestivals(
@RequestHeader("Authorization") String accessToken
@RequestAttribute("userId") Long userId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
List<AdminFestivalResponse> response = festivalFacade.getAllFestivals(userId);
return ResponseBuilder.ok(response);
}

@GetMapping("/{festivalId}")
public ResponseEntity<ApiResponse<AdminFestivalDetailResponse>> getFestivalDetail(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable Long festivalId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
AdminFestivalDetailResponse response = festivalFacade.getFestivalDetail(userId, festivalId);
return ResponseBuilder.ok(response);
}

@GetMapping("/{festivalId}/participants/search")
public ResponseEntity<ApiResponse<List<SearchParticipantResponse>>> getParticipantByNickname(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId,
@RequestParam("nickname") String nickname
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);

List<SearchParticipantResponse> response = participantFacade.getParticipantByNickname(userId, festivalId, nickname);
return ResponseBuilder.ok(response);
}

@PostMapping("/{festivalId}/points")
public ResponseEntity<ApiResponse<Void>> rechargePoints(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId,
@RequestBody RechargePointRequest request
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
pointFacade.rechargePoints(userId, festivalId, request);
return ResponseBuilder.ok(null);
}

@PostMapping("/{festivalId}/hosts")
public ResponseEntity<ApiResponse<Void>> addHost(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId,
@RequestBody AddHostRequest request
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
festivalHostFacade.addHost(userId, festivalId, request);
return ResponseBuilder.created(null);
}

@GetMapping("/{festivalId}/participants/{participantId}/points")
public ResponseEntity<ApiResponse<PointHistoryResponse>> getParticipantPointHistory(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId,
@PathVariable("participantId") Long participantId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
PointHistoryResponse response = pointFacade.getParticipantPointHistory(userId, festivalId, participantId);
return ResponseBuilder.ok(response);
}

@GetMapping("/{festivalId}/participants/{participantId}/matchings")
public ResponseEntity<ApiResponse<AdminMatchingResponse>> getParticipantMatchingHistory(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId,
@PathVariable("participantId") Long participantId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
AdminMatchingResponse response = matchingFacade.getMatchingSize(userId, festivalId, participantId);
return ResponseBuilder.ok(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class AuthController {
public ResponseEntity<ApiResponse<TokenResponse>> login(
@RequestHeader("Authorization") String kakaoAccessToken
) {
log.info("social login - Code: {}", kakaoAccessToken);
log.info("social login - kakaoAccessToken: {}", kakaoAccessToken);

String platformId = loginFacade.getPlatformId(kakaoAccessToken);

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/festimate/team/api/facade/LoginFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.festimate.team.domain.auth.service.KakaoLoginService;
import org.festimate.team.domain.user.entity.Platform;
import org.festimate.team.domain.user.service.UserService;
import org.festimate.team.infra.jwt.JwtService;
import org.festimate.team.infra.jwt.JwtTokenProvider;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -15,7 +15,7 @@
@RequiredArgsConstructor
public class LoginFacade {

private final JwtService jwtService;
private final JwtTokenProvider jwtTokenProvider;
private final UserService userService;
private final KakaoLoginService kakaoLoginService;

Expand All @@ -28,18 +28,18 @@ public TokenResponse login(String platformId, Platform platform) {

private TokenResponse loginExistingUser(Long userId) {
log.info("기존 유저 로그인 성공 - userId: {}", userId);
String newRefreshToken = jwtService.createRefreshToken(userId);
String newRefreshToken = jwtTokenProvider.createRefreshToken(userId);

userService.updateRefreshToken(userId, newRefreshToken);
return new TokenResponse(userId, jwtService.createAccessToken(userId), newRefreshToken);
return new TokenResponse(userId, jwtTokenProvider.createAccessToken(userId), newRefreshToken);
}

public String getPlatformId(String authorization) {
return kakaoLoginService.getKakaoPlatformId(authorization);
}

private TokenResponse createTemporaryToken(String platformId) {
return new TokenResponse(null, jwtService.createTempAccessToken(platformId), jwtService.createTempRefreshToken(platformId));
return new TokenResponse(null, jwtTokenProvider.createTempAccessToken(platformId), jwtTokenProvider.createTempRefreshToken(platformId));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/festimate/team/api/facade/SignUpFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import org.festimate.team.domain.user.validator.NicknameValidator;
import org.festimate.team.global.exception.FestimateException;
import org.festimate.team.global.response.ResponseError;
import org.festimate.team.infra.jwt.JwtService;
import org.festimate.team.infra.jwt.JwtTokenProvider;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class SignUpFacade {
private final JwtService jwtService;
private final JwtTokenProvider jwtTokenProvider;
private final UserService userService;
private final NicknameValidator nicknameValidator;

Expand All @@ -36,8 +36,8 @@ public void validateNickname(String nickname) {

private TokenResponse createTokenResponse(User user) {
log.info("signup success - userId : {}, nickname : {}", user.getUserId(), user.getNickname());
String accessToken = jwtService.createAccessToken(user.getUserId());
String refreshToken = jwtService.createRefreshToken(user.getUserId());
String accessToken = jwtTokenProvider.createAccessToken(user.getUserId());
String refreshToken = jwtTokenProvider.createRefreshToken(user.getUserId());
userService.updateRefreshToken(user.getUserId(), refreshToken);
return TokenResponse.of(user.getUserId(), accessToken, refreshToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,29 @@
import org.festimate.team.api.festival.dto.FestivalVerifyResponse;
import org.festimate.team.global.response.ApiResponse;
import org.festimate.team.global.response.ResponseBuilder;
import org.festimate.team.infra.jwt.JwtService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/v1/festivals")
@RequiredArgsConstructor
public class FestivalController {
private final JwtService jwtService;
private final FestivalFacade festivalFacade;

@PostMapping("/verify")
public ResponseEntity<ApiResponse<FestivalVerifyResponse>> verifyFestival(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@RequestBody FestivalVerifyRequest request
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
FestivalVerifyResponse response = festivalFacade.verifyFestival(userId, request);
return ResponseBuilder.ok(response);
}

@GetMapping("/{festivalId}")
public ResponseEntity<ApiResponse<FestivalInfoResponse>> getFestivalInfo(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
FestivalInfoResponse response = festivalFacade.getFestivalInfo(userId, festivalId);
return ResponseBuilder.ok(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.festimate.team.api.matching.dto.MatchingStatusResponse;
import org.festimate.team.global.response.ApiResponse;
import org.festimate.team.global.response.ResponseBuilder;
import org.festimate.team.infra.jwt.JwtService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -16,38 +15,31 @@
@RequiredArgsConstructor
public class MatchingController {
private final MatchingFacade matchingFacade;
private final JwtService jwtService;

@PostMapping("/{festivalId}/matchings")
public ResponseEntity<ApiResponse<MatchingStatusResponse>> createMatching(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);

MatchingStatusResponse response = matchingFacade.createMatching(userId, festivalId);
return ResponseBuilder.created(response);
}

@GetMapping("/{festivalId}/matchings")
public ResponseEntity<ApiResponse<MatchingListResponse>> getMatching(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);

MatchingListResponse response = matchingFacade.getMatchingList(userId, festivalId);
return ResponseBuilder.ok(response);
}

@GetMapping("/{festivalId}/matchings/{matchingId}")
public ResponseEntity<ApiResponse<MatchingDetailInfo>> getMatchingDetail(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId,
@PathVariable("matchingId") Long matchingId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);

MatchingDetailInfo response = matchingFacade.getMatchingDetail(userId, festivalId, matchingId);
return ResponseBuilder.ok(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.festimate.team.domain.participant.service.ParticipantService;
import org.festimate.team.global.response.ApiResponse;
import org.festimate.team.global.response.ResponseBuilder;
import org.festimate.team.infra.jwt.JwtService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -15,82 +14,74 @@
@RequiredArgsConstructor
public class ParticipantController {

private final JwtService jwtService;
private final ParticipantService participantService;
private final ParticipantFacade participantFacade;

@PostMapping("/{festivalId}/participants/type")
public ResponseEntity<ApiResponse<TypeResponse>> getFestivalType(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable Long festivalId,
@RequestBody TypeRequest request
) {
jwtService.parseTokenAndGetUserId(accessToken);
TypeResponse response = participantService.getTypeResult(request);
return ResponseBuilder.ok(response);
}

@GetMapping("/{festivalId}/participants/me")
public ResponseEntity<ApiResponse<EntryResponse>> entryFestival(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
EntryResponse response = participantFacade.entryFestival(userId, festivalId);

return ResponseBuilder.ok(response);
}

@PostMapping("/{festivalId}/participants")
public ResponseEntity<ApiResponse<EntryResponse>> createParticipant(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId,
@RequestBody ProfileRequest request
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
EntryResponse response = participantFacade.createParticipant(userId, festivalId, request);
return ResponseBuilder.created(response);
}

@GetMapping("/{festivalId}/participants/me/profile")
public ResponseEntity<ApiResponse<ProfileResponse>> getMyProfile(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
ProfileResponse response = participantFacade.getParticipantProfile(userId, festivalId);
return ResponseBuilder.ok(response);
}

@GetMapping("/{festivalId}/participants/me/summary")
public ResponseEntity<ApiResponse<MainUserInfoResponse>> getParticipantAndPoint(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
MainUserInfoResponse response = participantFacade.getParticipantSummary(userId, festivalId);

return ResponseBuilder.ok(response);
}

@GetMapping("/{festivalId}/participants/me/type")
public ResponseEntity<ApiResponse<DetailProfileResponse>> getParticipantType(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
DetailProfileResponse response = participantFacade.getParticipantType(userId, festivalId);

return ResponseBuilder.ok(response);
}

@PatchMapping("/{festivalId}/participants/me/message")
public ResponseEntity<ApiResponse<Void>> modifyMyMessage(
@RequestHeader("Authorization") String accessToken,
@RequestAttribute("userId") Long userId,
@PathVariable("festivalId") Long festivalId,
@RequestBody MessageRequest request
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
participantFacade.modifyMessage(userId, festivalId, request);

return ResponseBuilder.created(null);
Expand Down
Loading
Loading