Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix/98] 회원가입 로직 수정 #106

Merged
merged 5 commits into from
Aug 2, 2024
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
12 changes: 9 additions & 3 deletions src/main/generated/com/gamegoo/domain/QMatchingRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,29 @@ public class QMatchingRecord extends EntityPathBase<MatchingRecord> {

public final NumberPath<Long> id = createNumber("id", Long.class);

public final BooleanPath isComplete = createBoolean("isComplete");

public final NumberPath<Integer> mainPosition = createNumber("mainPosition", Integer.class);

public final StringPath matchingType = createString("matchingType");

public final QMember member;

public final BooleanPath mike = createBoolean("mike");

public final StringPath rank = createString("rank");

public final StringPath status = createString("status");

public final NumberPath<Integer> subPosition = createNumber("subPosition", Integer.class);

public final NumberPath<Integer> tier = createNumber("tier", Integer.class);
public final StringPath tier = createString("tier");

//inherited
public final DateTimePath<java.time.LocalDateTime> updatedAt = _super.updatedAt;

public final NumberPath<Integer> wantPosition = createNumber("wantPosition", Integer.class);

public final NumberPath<Double> winRate = createNumber("winRate", Double.class);

public QMatchingRecord(String variable) {
this(MatchingRecord.class, forVariable(variable), INITS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ public enum ErrorStatus implements BaseErrorCode {
MATCHING_STATUS_BAD_REQUEST(HttpStatus.BAD_REQUEST, "MATCH400", "status는 SUCCESS, QUIT 둘 중 하나로만 변경이 가능합니다."),
MATCHING_NOT_FOUND(HttpStatus.NOT_FOUND, "MATCH404", "해당 사용자의 매칭 정보가 없습니다."),


// Riot 관련 에러
RIOT_NOT_FOUND(HttpStatus.NOT_FOUND, "RIOT404", "해당 Riot 계정이 존재하지 않습니다."),
RIOT_MATCH_NOT_FOUND(HttpStatus.NOT_FOUND, "RIOTMATCH404", "해당 Riot 계정의 매칭을 불러오는 도중 에러가 발생했습니다."),
RIOT_MATCH_NOT_FOUND(HttpStatus.NOT_FOUND, "RIOTMATCH404", "해당 Riot 계정의 매칭을 불러오는 도중 에러가 발생했습니다. 최근 100판 이내 이벤트 매칭 제외, 일반 매칭(일반게임,랭크게임,칼바람)을 많이 한 계정으로 다시 시도하세요."),
RIOT_PREFER_CHAMPION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "RIOTCHAMPION500", "선호 챔피언을 연동하는 도중 에러가 발생했습니다"),
CHAMPION_NOT_FOUND(HttpStatus.NOT_FOUND, "CHAMPION404", "해당 챔피언이 존재하지 않습니다."),
RIOT_MEMBER_CONFLICT(HttpStatus.CONFLICT, "RIOT409", "해당 이메일 계정은 이미 다른 RIOT 계정과 연동되었습니다."),
RIOT_ACCOUNT_CONFLICT(HttpStatus.CONFLICT, "RIOT409", "해당 RIOT 계정은 이미 다른 이메일과 연동되어있습니다."),
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/gamegoo/controller/member/AuthController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.gamegoo.controller.member;

import com.gamegoo.apiPayload.ApiResponse;
import com.gamegoo.converter.MemberConverter;
import com.gamegoo.domain.Member;
import com.gamegoo.dto.member.MemberRequest;
import com.gamegoo.dto.member.MemberResponse;
import com.gamegoo.service.member.AuthService;
Expand All @@ -25,12 +27,16 @@ public class AuthController {

@PostMapping("/join")
@Operation(summary = "회원가입 API 입니다.", description = "API for join")
public ApiResponse<String> joinMember(
public ApiResponse<MemberResponse.myProfileMemberDTO> joinMember(
@RequestBody @Valid MemberRequest.JoinRequestDTO joinRequestDTO) {
String email = joinRequestDTO.getEmail();
String password = joinRequestDTO.getPassword();
authService.joinMember(email, password);
return ApiResponse.onSuccess("회원가입에 성공했습니다.");
String gameName = joinRequestDTO.getGameName();
String tag = joinRequestDTO.getTag();

Member member = authService.joinMember(email, password, gameName, tag);

return ApiResponse.onSuccess(MemberConverter.toMyProfileDTO(member));
}

@PostMapping("/email/send")
Expand Down Expand Up @@ -70,7 +76,7 @@ public ApiResponse<Object> refreshTokens(
public ApiResponse<String> logoutMember() {
Long memberId = JWTUtil.getCurrentUserId();
authService.logoutMember(memberId);

return ApiResponse.onSuccess("로그아웃에 성공했습니다");
}
}
34 changes: 15 additions & 19 deletions src/main/java/com/gamegoo/controller/member/ProfileController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
import com.gamegoo.service.member.ProfileService;
import com.gamegoo.util.JWTUtil;
import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import java.util.stream.Collectors;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequiredArgsConstructor
Expand All @@ -32,24 +28,24 @@ public class ProfileController {
@PutMapping("/gamestyle")
@Operation(summary = "gamestyle 추가 및 수정 API 입니다.", description = "API for Gamestyle addition and modification ")
public ApiResponse<List<MemberResponse.GameStyleResponseDTO>> addGameStyle(
@RequestBody MemberRequest.GameStyleRequestDTO gameStyleRequestDTO) {
@RequestBody MemberRequest.GameStyleRequestDTO gameStyleRequestDTO) {
Long memberId = JWTUtil.getCurrentUserId();
List<MemberGameStyle> memberGameStyles = profileService.addMemberGameStyles(
gameStyleRequestDTO, memberId);
gameStyleRequestDTO, memberId);

List<MemberResponse.GameStyleResponseDTO> dtoList = memberGameStyles.stream()
.map(memberGameStyle -> MemberResponse.GameStyleResponseDTO.builder()
.gameStyleId(memberGameStyle.getGameStyle().getId())
.gameStyleName(memberGameStyle.getGameStyle().getStyleName())
.build()).collect(Collectors.toList());
.map(memberGameStyle -> MemberResponse.GameStyleResponseDTO.builder()
.gameStyleId(memberGameStyle.getGameStyle().getId())
.gameStyleName(memberGameStyle.getGameStyle().getStyleName())
.build()).collect(Collectors.toList());

return ApiResponse.onSuccess(dtoList);
}

@PutMapping("/position")
@Operation(summary = "주/부 포지션 수정 API 입니다.", description = "API for Main/Sub Position Modification")
public ApiResponse<String> modifyPosition(
@RequestBody @Valid MemberRequest.PositionRequestDTO positionRequestDTO) {
@RequestBody @Valid MemberRequest.PositionRequestDTO positionRequestDTO) {
Long userId = JWTUtil.getCurrentUserId();
int mainP = positionRequestDTO.getMainP();
int subP = positionRequestDTO.getSubP();
Expand All @@ -62,7 +58,7 @@ public ApiResponse<String> modifyPosition(
@PutMapping("/profile_image")
@Operation(summary = "프로필 이미지 수정 API 입니다.", description = "API for Profile Image Modification")
public ApiResponse<String> modifyPosition(
@RequestBody MemberRequest.ProfileImageRequestDTO profileImageDTO) {
@RequestBody MemberRequest.ProfileImageRequestDTO profileImageDTO) {
Long userId = JWTUtil.getCurrentUserId();
String profileImage = profileImageDTO.getProfileImage();

Expand All @@ -72,7 +68,7 @@ public ApiResponse<String> modifyPosition(
}

@DeleteMapping("")
@Operation(summary = "회원 탈퇴 API 입니다.", description = "API for Member")
@Operation(summary = "회원 탈퇴 API 입니다.", description = "API for Blinding Member")
public ApiResponse<String> blindMember() {
Long userId = JWTUtil.getCurrentUserId();

Expand All @@ -81,7 +77,7 @@ public ApiResponse<String> blindMember() {

}

@Operation(summary = "마이페이지 조회 API", description = "나 -> 나 조회하는 마이페이지 API 입니다.")
@Operation(summary = "회원 조회하는 API 입니다.", description = "API for looking up member")
@GetMapping("/profile")
public ApiResponse<MemberResponse.myProfileMemberDTO> getBlockList() {
Long memberId = JWTUtil.getCurrentUserId();
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/gamegoo/controller/member/RiotController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import com.gamegoo.dto.member.MemberRequest;
import com.gamegoo.service.member.RiotService;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/member")
Expand All @@ -21,16 +22,16 @@ public class RiotController {
private final RiotService riotService;

@PostMapping("/riot")
@Operation(summary = "회원가입 시 riot API를 통해 소환사명을 인증하는 API", description = "API for verifying by riot API")
@Operation(summary = "실제 존재하는 Riot 계정인지 검증하는 API", description = "API for verifying account by riot API")
public ApiResponse<String> VerifyRiot(
@RequestBody @Valid MemberRequest.verifyRiotRequestDTO verifyRiotRequestDTO) {
@RequestBody @Valid MemberRequest.verifyRiotRequestDTO verifyRiotRequestDTO) {
String gameName = verifyRiotRequestDTO.getGameName();
String tag = verifyRiotRequestDTO.getTag();
String email = verifyRiotRequestDTO.getEmail();

riotService.updateMemberRiotInfo(gameName, tag, email);
riotService.verifyRiot(gameName, tag);

return ApiResponse.onSuccess("Riot 계정이 연동되었습니다.");
return ApiResponse.onSuccess("해당 Riot 계정은 존재합니다.");

}

}
69 changes: 42 additions & 27 deletions src/main/java/com/gamegoo/converter/MemberConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
import com.gamegoo.domain.Friend;
import com.gamegoo.domain.Member;
import com.gamegoo.dto.member.MemberResponse;
import org.springframework.data.domain.Page;

import java.util.List;
import java.util.stream.Collectors;
import org.springframework.data.domain.Page;

public class MemberConverter {

public static MemberResponse.blockListDTO toBlockListDTO(Page<Member> blockList) {
List<MemberResponse.blockedMemberDTO> blockedMemberDtoList = blockList.stream()
.map(MemberConverter::toBlockedMemberDTO)
.collect(Collectors.toList());
.map(MemberConverter::toBlockedMemberDTO)
.collect(Collectors.toList());

return MemberResponse.blockListDTO.builder()
.blockedMemberDTOList(blockedMemberDtoList)
Expand All @@ -25,42 +26,56 @@ public static MemberResponse.blockListDTO toBlockListDTO(Page<Member> blockList)

}

public static MemberResponse.blockedMemberDTO toBlockedMemberDTO(Member membr) {
public static MemberResponse.blockedMemberDTO toBlockedMemberDTO(Member member) {
return MemberResponse.blockedMemberDTO.builder()
.memberId(membr.getId())
.profileImg(membr.getProfileImage())
.email(membr.getEmail())
.name(membr.getGameName())
.memberId(member.getId())
.profileImg(member.getProfileImage())
.email(member.getEmail())
.name(member.getGameName())
.build();

}

public static MemberResponse.myProfileMemberDTO toMyProfileDTO(Member member) {
List<MemberResponse.GameStyleResponseDTO> dtoList = member.getMemberGameStyleList().stream()
.map(memberGameStyle -> MemberResponse.GameStyleResponseDTO.builder()
.gameStyleId(memberGameStyle.getGameStyle().getId())
.gameStyleName(memberGameStyle.getGameStyle().getStyleName())
.build()).collect(Collectors.toList());
List<MemberResponse.GameStyleResponseDTO> gameStyleResponseDTOList = null;
if (member.getMemberGameStyleList() != null) {
gameStyleResponseDTOList = member.getMemberGameStyleList().stream()
.map(memberGameStyle -> MemberResponse.GameStyleResponseDTO.builder()
.gameStyleId(memberGameStyle.getGameStyle().getId())
.gameStyleName(memberGameStyle.getGameStyle().getStyleName())
.build()).collect(Collectors.toList());
}

List<MemberResponse.ChampionResponseDTO> championResponseDTOList = null;
if (member.getMemberChampionList() != null) {
championResponseDTOList = member.getMemberChampionList().stream()
.map(memberChampion -> MemberResponse.ChampionResponseDTO.builder()
.championId(memberChampion.getMember().getId())
.championName(memberChampion.getChampion().getName())
.build()).collect(Collectors.toList());
}


return MemberResponse.myProfileMemberDTO.builder()
.email(member.getEmail())
.gameName(member.getGameName())
.tag(member.getTag())
.tier(member.getTier())
.rank(member.getRank())
.profileImg(member.getProfileImage())
.updatedAt(String.valueOf(member.getUpdatedAt()))
.gameStyleResponseDTOList(dtoList)
.build();
.email(member.getEmail())
.gameName(member.getGameName())
.tag(member.getTag())
.tier(member.getTier())
.rank(member.getRank())
.profileImg(member.getProfileImage())
.updatedAt(String.valueOf(member.getUpdatedAt()))
.gameStyleResponseDTOList(gameStyleResponseDTOList)
.championResponseDTOList(championResponseDTOList)
.build();
}

public static MemberResponse.friendInfoDTO toFriendInfoDto(Friend friend) {
return MemberResponse.friendInfoDTO.builder()
.memberId(friend.getToMember().getId())
.name(friend.getToMember().getGameName())
.memberProfileImg(friend.getToMember().getProfileImage())
.isLiked(friend.getIsLiked())
.build();
.memberId(friend.getToMember().getId())
.name(friend.getToMember().getGameName())
.memberProfileImg(friend.getToMember().getProfileImage())
.isLiked(friend.getIsLiked())
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.*;

import javax.persistence.*;
import java.util.ArrayList;

@Getter
@Entity
Expand Down Expand Up @@ -32,8 +33,10 @@ public void setMember(Member member) {
this.member.getMemberChampionList().remove(this);
}
this.member = member;
if (this.member.getMemberChampionList() == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 여기에서 이 조건을 추가하신 이유가 있으신가요?
@OneToMany(mappedBy = "member", cascade = CascadeType.ALL) private List<MemberChampion> memberChampionList = new ArrayList<>();
member 엔티티에서 이렇게 초기화를 해 주어서 저는 memberChampionList가 null인 경우가 없을 거라고 생각했었는데 혹시 이 조건+코드가 없으면 뭔가 오류가 나는건지 궁금합니다..!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네ㅠㅠ 이상하게 @onetomany를 했음에도 불구하고 이런 에러가 발생하더라구요..
Cannot invoke "java.util.List.add(Object)" because the return value of "com.gamegoo.domain.Member.getMemberChampionList()" is null
그래서 추가했습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 그렇군요...... ㅠㅠㅠㅠ 왜 그런건지 제가 나중에 따로 찾아보겠습니다.. 그럼 이대로 머지해주시면 될 것 같아요 !!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 감사합니다!

this.member.setMemberChampionList(new ArrayList<>());
}
this.member.getMemberChampionList().add(this);

}

public void removeMember(Member member) {
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/gamegoo/dto/member/MemberRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public static class JoinRequestDTO {
String email;
@NotBlank(message = "password는 비워둘 수 없습니다.")
String password;
@NotBlank(message = "gameName 값은 비워둘 수 없습니다.")
String gameName;
@NotBlank(message = "tag 값은 비워둘 수 없습니다.")
String tag;

}

Expand All @@ -60,11 +64,11 @@ public static class PasswordRequestDTO {

@Getter
public static class PositionRequestDTO {
@Min(value = 1, message = "메인 포지션의 값은 1이상이어야 합니다.")
@Min(value = 0, message = "메인 포지션의 값은 0이상이어야 합니다.")
@Max(value = 5, message = "메인 포지션의 값은 5이하이어야 합니다.")
int mainP;
@Min(value = 1, message = "서브 포지션의 값은 1이상이어야 합니다.")
@Max(value = 5, message = "서브 포지션의 값은 1이상이어야합니다.")
@Min(value = 0, message = "서브 포지션의 값은 0이상이어야 합니다.")
@Max(value = 5, message = "서브 포지션의 값은 5이하이어야합니다.")
int subP;
}

Expand All @@ -82,8 +86,6 @@ public static class RefreshTokenRequestDTO {

@Getter
public static class verifyRiotRequestDTO {
@NotBlank(message = "email 값은 비워둘 수 없습니다.")
String email;
@NotBlank(message = "gameName 값은 비워둘 수 없습니다.")
String gameName;
@NotBlank(message = "tag 값은 비워둘 수 없습니다.")
Expand Down
Loading
Loading