Skip to content

Commit

Permalink
Merge pull request #72 from TRIP-Side-Project/dev
Browse files Browse the repository at this point in the history
회원 가입 로직 수정 merge
  • Loading branch information
don9m1n authored Dec 15, 2023
2 parents a4b2b2c + cfbfbc9 commit 36f57ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class MemberController {
private final MemberService memberService;
private final EmailService emailService;

@PostMapping(value = "/join", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE})
public ResponseEntity<Void> join(@RequestPart JoinRequest joinRequest, @RequestPart(required = false) MultipartFile profileImg) throws IOException {
@PostMapping(value = "/join")
public ResponseEntity<Void> join(@ModelAttribute JoinRequest joinRequest) throws IOException {

memberService.join(joinRequest, profileImg);
memberService.join(joinRequest);
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package com.api.trip.domain.member.controller.dto;

import com.api.trip.domain.member.model.Member;
import lombok.Getter;
import lombok.*;
import org.springframework.web.multipart.MultipartFile;

@Getter
@Setter
@ToString
public class JoinRequest {

private String email;
private String password;
private String nickname;
private MultipartFile profileImg;

public static Member of(JoinRequest joinRequest, String password){
return Member.builder()
.email(joinRequest.getEmail())
.nickname(joinRequest.getNickname())
.password(password)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class MemberService {
private final AuthenticationManagerBuilder authenticationManagerBuilder;
private final JwtTokenProvider jwtTokenProvider;

public void join(JoinRequest joinRequest, MultipartFile profileImg) throws IOException {
public void join(JoinRequest joinRequest) throws IOException {

// 중복된 회원이 있는지 검사
memberRepository.findByEmail(joinRequest.getEmail()).ifPresent(it -> {
Expand All @@ -46,6 +46,8 @@ public void join(JoinRequest joinRequest, MultipartFile profileImg) throws IOExc
EmailAuth emailAuth = emailAuthRepository.findTop1ByEmailAndExpiredIsTrueOrderByCreatedAtDesc(joinRequest.getEmail())
.orElseThrow(() -> new RuntimeException("이메일 인증 토큰 정보가 없습니다!"));

MultipartFile profileImg = joinRequest.getProfileImg();

String profileImgUrl = "";
if (profileImg == null || profileImg.isEmpty()) {
// 프로필 사진 데이터가 없으면 기본 이미지 세팅
Expand Down

0 comments on commit 36f57ac

Please sign in to comment.