Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
import com.back.catchmate.domain.game.dto.GameResponse.GameInfo;
import com.back.catchmate.domain.game.entity.Game;
import com.back.catchmate.domain.user.converter.UserConverter;
import com.back.catchmate.domain.user.dto.UserResponse;
import com.back.catchmate.domain.user.dto.UserResponse.UserInfo;
import com.back.catchmate.domain.user.entity.User;
import lombok.RequiredArgsConstructor;
import org.springframework.cglib.core.Local;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.back.catchmate.domain.board.dto;

import com.back.catchmate.domain.game.dto.GameResponse.GameInfo;
import com.back.catchmate.domain.user.dto.UserResponse;
import com.back.catchmate.domain.user.dto.UserResponse.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.back.catchmate.domain.board.service;

import com.back.catchmate.domain.board.dto.BoardRequest;
import com.back.catchmate.domain.board.dto.BoardResponse.BoardDeleteInfo;
import com.back.catchmate.domain.board.dto.BoardResponse.BoardInfo;
import com.back.catchmate.domain.board.dto.BoardResponse.PagedBoardInfo;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.back.catchmate.domain.club.converter;

import com.back.catchmate.domain.club.dto.ClubResponse;
import com.back.catchmate.domain.club.dto.ClubResponse.ClubInfo;
import com.back.catchmate.domain.club.dto.ClubResponse.ClubInfoList;
import com.back.catchmate.domain.club.entity.Club;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
public class ClubConverter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.back.catchmate.domain.club.converter.ClubConverter;
import com.back.catchmate.domain.club.dto.ClubResponse;
import com.back.catchmate.domain.club.dto.ClubResponse.ClubInfoList;
import com.back.catchmate.domain.club.entity.Club;
import com.back.catchmate.domain.club.repository.ClubRepository;
import lombok.RequiredArgsConstructor;
Expand All @@ -18,7 +19,7 @@ public class ClubServiceImpl implements ClubService {

@Override
@Transactional(readOnly = true)
public ClubResponse.ClubInfoList getClubInfoList() {
public ClubInfoList getClubInfoList() {
List<Club> clubList = clubRepository.findAll();
return clubConverter.toClubInfoList(clubList);
}
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/com/back/catchmate/domain/game/entity/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@
import com.back.catchmate.domain.board.entity.Board;
import com.back.catchmate.domain.club.entity.Club;
import com.back.catchmate.global.entity.BaseTimeEntity;
import jakarta.persistence.*;
import lombok.*;
import jakarta.persistence.Column;
import jakarta.persistence.Id;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.time.LocalDateTime;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.back.catchmate.domain.game.repository;

import com.back.catchmate.domain.board.entity.Board;
import com.back.catchmate.domain.club.entity.Club;
import com.back.catchmate.domain.game.entity.Game;
import org.springframework.data.jpa.repository.JpaRepository;
Expand All @@ -9,5 +8,4 @@

public interface GameRepository extends JpaRepository<Game, Long> {
Game findByHomeClubAndAwayClubAndGameStartDate(Club homeClub, Club awayClub, LocalDateTime gameStartDate);

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ public static class NotificationInfo {
private boolean isRead;
}

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class CreateNotificationInfo {
private Long notificationId;
private LocalDateTime createdAt;
}

@Getter
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.back.catchmate.domain.user.controller;

import com.back.catchmate.domain.user.dto.UserRequest;
import com.back.catchmate.domain.user.dto.UserResponse.LoginInfo;
import com.back.catchmate.domain.user.dto.UserResponse.UpdateAlarmInfo;
import com.back.catchmate.domain.user.dto.UserResponse.UserInfo;
import com.back.catchmate.domain.user.entity.AlarmType;
import com.back.catchmate.domain.user.service.UserService;
import com.back.catchmate.global.dto.StateResponse;
Expand All @@ -22,8 +25,6 @@

import java.io.IOException;

import static com.back.catchmate.domain.user.dto.UserResponse.*;

@Tag(name = "사용자 관련 API")
@RestController
@RequestMapping("/user")
Expand Down Expand Up @@ -61,8 +62,8 @@ public StateResponse updateProfile(@RequestPart("request") @Valid UserRequest.Us
@Operation(summary = "알림 설정", description = "유저의 알람 수신 여부를 변경하는 API 입니다.")
@PatchMapping("/alarm")
public UpdateAlarmInfo updateAlarm(@JwtValidation Long userId,
@RequestParam("alarmType") AlarmType alarmType,
@RequestParam("isEnabled") char isEnabled) {
@RequestParam("alarmType") AlarmType alarmType,
@RequestParam("isEnabled") char isEnabled) {
return userService.updateAlarm(userId, alarmType, isEnabled);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.UUID;

import static com.back.catchmate.global.auth.service.AuthServiceImpl.PROVIDER_ID_SEPARATOR;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.back.catchmate.global.auth.controller;

import com.back.catchmate.global.auth.dto.request.AuthRequest;
import com.back.catchmate.global.auth.dto.response.AuthResponse.LoginInfo;
import com.back.catchmate.global.auth.dto.response.AuthResponse.NicknameCheckInfo;
import com.back.catchmate.global.auth.dto.response.AuthResponse.ReissueInfo;
import com.back.catchmate.global.auth.dto.AuthRequest.LoginRequest;
import com.back.catchmate.global.auth.dto.AuthResponse.AuthInfo;
import com.back.catchmate.global.auth.dto.AuthResponse.NicknameCheckInfo;
import com.back.catchmate.global.auth.dto.AuthResponse.ReissueInfo;
import com.back.catchmate.global.auth.service.AuthServiceImpl;
import com.back.catchmate.global.dto.StateResponse;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -28,7 +28,7 @@ public class AuthController {

@PostMapping("/login")
@Operation(summary = "로그인 & 회원가입 API", description = "회원가입/로그인을 통해 토큰을 발급하는 API 입니다.")
public LoginInfo login(@Valid @RequestBody AuthRequest.LoginRequest loginRequest) {
public AuthInfo login(@Valid @RequestBody LoginRequest loginRequest) {
return authService.login(loginRequest);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.back.catchmate.global.auth.converter;

import com.back.catchmate.global.auth.dto.response.AuthResponse.LoginInfo;
import com.back.catchmate.global.auth.dto.AuthResponse.AuthInfo;
import org.springframework.stereotype.Component;

@Component
public class AuthConverter {

public LoginInfo toLoginInfo(String accessToken, String refreshToken, Boolean isFirstLogin) {
return LoginInfo.builder()
public AuthInfo toLoginInfo(String accessToken, String refreshToken, Boolean isFirstLogin) {
return AuthInfo.builder()
.accessToken(accessToken)
.refreshToken(refreshToken)
.isFirstLogin(isFirstLogin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.back.catchmate.global.auth.dto.request;
package com.back.catchmate.global.auth.dto;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.back.catchmate.global.auth.dto.response;
package com.back.catchmate.global.auth.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -10,7 +10,7 @@ public abstract class AuthResponse {
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class LoginInfo {
public static class AuthInfo {
private String accessToken;
private String refreshToken;
private Boolean isFirstLogin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.back.catchmate.global.auth.service;

import com.back.catchmate.global.auth.dto.request.AuthRequest;
import com.back.catchmate.global.auth.dto.response.AuthResponse.LoginInfo;
import com.back.catchmate.global.auth.dto.response.AuthResponse.NicknameCheckInfo;
import com.back.catchmate.global.auth.dto.response.AuthResponse.ReissueInfo;
import com.back.catchmate.global.auth.dto.AuthRequest;
import com.back.catchmate.global.auth.dto.AuthResponse.AuthInfo;
import com.back.catchmate.global.auth.dto.AuthResponse.NicknameCheckInfo;
import com.back.catchmate.global.auth.dto.AuthResponse.ReissueInfo;
import com.back.catchmate.global.dto.StateResponse;

public interface AuthService {
LoginInfo login(AuthRequest.LoginRequest loginRequest);
AuthInfo login(AuthRequest.LoginRequest loginRequest);

NicknameCheckInfo checkNickname(String nickName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.back.catchmate.domain.user.entity.User;
import com.back.catchmate.domain.user.repository.UserRepository;
import com.back.catchmate.global.auth.converter.AuthConverter;
import com.back.catchmate.global.auth.dto.request.AuthRequest;
import com.back.catchmate.global.auth.dto.response.AuthResponse.LoginInfo;
import com.back.catchmate.global.auth.dto.response.AuthResponse.NicknameCheckInfo;
import com.back.catchmate.global.auth.dto.response.AuthResponse.ReissueInfo;
import com.back.catchmate.global.auth.dto.AuthRequest;
import com.back.catchmate.global.auth.dto.AuthResponse.AuthInfo;
import com.back.catchmate.global.auth.dto.AuthResponse.NicknameCheckInfo;
import com.back.catchmate.global.auth.dto.AuthResponse.ReissueInfo;
import com.back.catchmate.global.auth.entity.RefreshToken;
import com.back.catchmate.global.auth.repository.RefreshTokenRepository;
import com.back.catchmate.global.dto.StateResponse;
Expand All @@ -21,7 +21,6 @@

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class AuthServiceImpl implements AuthService {
private final JwtService jwtService;
private final UserRepository userRepository;
Expand All @@ -34,19 +33,19 @@ public class AuthServiceImpl implements AuthService {
// 로그인 메서드
@Override
@Transactional
public LoginInfo login(AuthRequest.LoginRequest loginRequest) {
public AuthInfo login(AuthRequest.LoginRequest loginRequest) {
// Provider ID와 Provider를 결합한 문자열 생성
String providerIdWithProvider = loginRequest.getProviderId() + PROVIDER_ID_SEPARATOR + loginRequest.getProvider();

// 결합한 문자열로 사용자 조회
Optional<User> findUserOptional = userRepository.findByProviderId(providerIdWithProvider);
boolean isFirstLogin = false;
LoginInfo loginInfo;
AuthInfo authInfo;

if (findUserOptional.isEmpty()) {
// 사용자가 없으면 최초 회원가입 여부를 true 반환
isFirstLogin = true;
loginInfo = authConverter.toLoginInfo(null, null, isFirstLogin);
authInfo = authConverter.toLoginInfo(null, null, isFirstLogin);
} else {
// 회원가입된 사용자가 있으면 AccessToken과 RefreshToken 반환
User user = findUserOptional.get();
Expand All @@ -61,10 +60,10 @@ public LoginInfo login(AuthRequest.LoginRequest loginRequest) {

// RefreshToken을 Redis에 저장
refreshTokenRepository.save(RefreshToken.of(refreshToken, userId));
loginInfo = authConverter.toLoginInfo(accessToken, refreshToken, isFirstLogin);
authInfo = authConverter.toLoginInfo(accessToken, refreshToken, isFirstLogin);
}

return loginInfo;
return authInfo;
}

private void checkFcmToken(AuthRequest.LoginRequest loginRequest, User user) {
Expand All @@ -74,13 +73,15 @@ private void checkFcmToken(AuthRequest.LoginRequest loginRequest, User user) {
}

// 닉네임 중복여부를 확인하는 메서드
@Override
@Transactional(readOnly = true)
public NicknameCheckInfo checkNickname(String nickName) {
boolean isAvailable = !userRepository.existsByNickName(nickName);
return new NicknameCheckInfo(isAvailable);
}

// 토큰 재발급 메서드
@Override
@Transactional
public ReissueInfo reissue(String refreshToken) {
// RefreshToken을 파싱하여 사용자 ID를 가져옴
Expand All @@ -95,6 +96,7 @@ public ReissueInfo reissue(String refreshToken) {
}

// 로그아웃 메서드
@Override
@Transactional
public StateResponse logout(String refreshToken) {
// RefreshToken을 파싱하여 사용자 ID를 가져옴
Expand Down
Loading