Skip to content

Commit

Permalink
๐Ÿ”ฅ[FEAT]-#4-Member ์˜ ๊ฒฐ๊ณผ ์กฐํšŒ
Browse files Browse the repository at this point in the history
## ๊ฐœ์š”
/my/result
  • Loading branch information
daehwan2yo committed Dec 28, 2021
1 parent 36baa71 commit 388808e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import com.codingwasabi.trti.domain.member.model.entity.Member;
import com.codingwasabi.trti.domain.member.model.request.RequestExistMemberDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseExistMemberDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseMemberResultDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto;

public interface MemberService {
ResponseMyInfoDto getMemberInfo(Member member);

ResponseExistMemberDto existMember(RequestExistMemberDto requestDto);

ResponseMemberResultDto getResult(Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.codingwasabi.trti.domain.member.MemberService;
import com.codingwasabi.trti.domain.member.model.request.RequestExistMemberDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseExistMemberDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseMemberResultDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -29,5 +30,9 @@ public ResponseEntity<ResponseExistMemberDto> existMember(@RequestBody RequestEx
return ResponseEntity.ok(memberService.existMember(requestDto));
}


@GetMapping("/my/result")
public ResponseEntity<ResponseMemberResultDto>
getMemberResult(@AuthenticationPrincipal MemberAdaptor memberAdaptor) {
return ResponseEntity.ok(memberService.getResult(memberAdaptor.getMember()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.codingwasabi.trti.domain.member.model.entity.Member;
import com.codingwasabi.trti.domain.member.model.request.RequestExistMemberDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseExistMemberDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseMemberResultDto;
import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto;
import com.codingwasabi.trti.domain.member.repository.MemberRepository;
import lombok.RequiredArgsConstructor;
Expand All @@ -30,4 +31,9 @@ public ResponseExistMemberDto existMember(RequestExistMemberDto requestDto) {

return ResponseExistMemberDto.from(member);
}

@Override
public ResponseMemberResultDto getResult(Member member) {
return ResponseMemberResultDto.from(member);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.codingwasabi.trti.domain.member.model.response;

import com.codingwasabi.trti.domain.result.model.values.AnswerType;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class ResponseMemberDetailResultDto {
private Long id;
private Integer selected;

public static ResponseMemberDetailResultDto from(AnswerType answerType) {
return new ResponseMemberDetailResultDto(answerType.getId(), answerType.getSelected());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.codingwasabi.trti.domain.member.model.response;

import com.codingwasabi.trti.domain.member.model.entity.Member;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
@AllArgsConstructor
public class ResponseMemberResultDto {
private String name;
private List<ResponseMemberDetailResultDto> answer;

public static ResponseMemberResultDto from(Member member) {
return new ResponseMemberResultDto(member.getNickname(), getDetailResult(member));
}

private static List<ResponseMemberDetailResultDto> getDetailResult(Member member) {
List<ResponseMemberDetailResultDto> resultList = new ArrayList<>();
resultList.add(ResponseMemberDetailResultDto.from(member.getResult().getToMove()));
resultList.add(ResponseMemberDetailResultDto.from(member.getResult().getToEat_1()));
resultList.add(ResponseMemberDetailResultDto.from(member.getResult().getToEat_2()));
resultList.add(ResponseMemberDetailResultDto.from(member.getResult().getToStay_1()));
resultList.add(ResponseMemberDetailResultDto.from(member.getResult().getToStay_2()));
resultList.add(ResponseMemberDetailResultDto.from(member.getResult().getToStay_3()));
resultList.add(ResponseMemberDetailResultDto.from(member.getResult().getToActive()));

return resultList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import com.codingwasabi.trti.domain.common.Period;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Getter
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@NoArgsConstructor
Expand Down

0 comments on commit 388808e

Please sign in to comment.