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

feat: onboarding API #51

Merged
merged 1 commit into from
Feb 5, 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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.fullcar.member.application.member;

import com.fullcar.member.domain.member.Company;
import com.fullcar.member.infra.EmailMessage;
import com.fullcar.member.domain.member.Member;
import com.fullcar.member.presentation.member.dto.request.EmailRequestDto;
import com.fullcar.member.presentation.member.dto.request.OnboardingRequestDto;
import com.fullcar.member.presentation.member.dto.response.MemberGetResponseDto;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
Expand All @@ -28,4 +30,19 @@ public EmailMessage toEntity(EmailRequestDto emailRequestDto) {
.subject("[FullCar] νšŒμ‚¬ 이메일 인증")
.build();
}

public Member toEntity(OnboardingRequestDto onboardingRequestDto) {
return Member.builder()
.company(
Company.builder()
.companyName(onboardingRequestDto.getCompanyName())
.latitude(onboardingRequestDto.getLatitude())
.longitude(onboardingRequestDto.getLongitude())
.build()
)
.email(onboardingRequestDto.getEmail())
.nickname(onboardingRequestDto.getNickname())
.gender(onboardingRequestDto.getGender())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fullcar.core.exception.NotFoundException;
import com.fullcar.core.response.ErrorCode;
import com.fullcar.member.domain.member.*;
import com.fullcar.member.presentation.member.dto.request.CompanyRequestDto;
import com.fullcar.member.presentation.member.dto.request.OnboardingRequestDto;
import com.fullcar.member.presentation.member.dto.response.MemberGetResponseDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -15,7 +15,6 @@
@RequiredArgsConstructor
public class MemberService {
private final MemberRepository memberRepository;
private final CompanyMapper companyMapper;
private final MemberMapper memberMapper;

/**
Expand All @@ -31,9 +30,8 @@ public Member findByMemberId(MemberId memberId) {
}

@Transactional
public void registerCompany(Member member, CompanyRequestDto companyRequestDto) {
Company company = companyMapper.toEntity(companyRequestDto);
findByMemberId(member.getId()).updateCompany(company);
public void registerOnboarding(Member member, OnboardingRequestDto onboardingRequestDto) {
findByMemberId(member.getId()).saveOnBoardingInfo(memberMapper.toEntity(onboardingRequestDto));
}

@Transactional(readOnly = true)
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/fullcar/member/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class Member {

private String email;

@Enumerated(EnumType.STRING)
private Gender gender;

@Builder.Default
Expand Down Expand Up @@ -76,7 +77,10 @@ public void updateCarInformation(CarId carId) {
this.carId = carId;
}

public void updateCompany(Company company) {
this.company = new Company(company.getCompanyName(), company.getLatitude(), company.getLongitude());
public void saveOnBoardingInfo(Member member) {
this.email = member.getEmail();
this.nickname = member.getNickname();
this.gender = member.getGender();
this.company = new Company(member.getCompany().getCompanyName(), member.getCompany().getLatitude(), member.getCompany().getLongitude());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.fullcar.member.application.member.MemberService;
import com.fullcar.member.domain.member.Member;
import com.fullcar.member.domain.member.service.MailService;
import com.fullcar.member.presentation.member.dto.request.CompanyRequestDto;
import com.fullcar.member.presentation.member.dto.request.OnboardingRequestDto;
import com.fullcar.member.presentation.member.dto.request.EmailRequestDto;
import com.fullcar.member.presentation.member.dto.response.MemberGetResponseDto;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -26,14 +26,14 @@ public class MemberController {
private final MemberService memberService;
private final MailService mailService;

@Operation(summary = "νšŒμ‚¬ 선택 API")
@Operation(summary = "μ˜¨λ³΄λ”© API")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "201", description = "등둝 성곡"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "500", description = "μ„œλ²„ λ‚΄λΆ€ 였λ₯˜", content = @Content)
})
@PostMapping("/onboarding/company")
public ApiResponse<Object> postCompany(@CurrentMember Member member, @RequestBody @Valid CompanyRequestDto companyRequestDto) {
memberService.registerCompany(member, companyRequestDto);
@PostMapping("/onboarding")
public ApiResponse<Object> postOnboarding(@CurrentMember Member member, @RequestBody @Valid OnboardingRequestDto onboardingRequestDto) {
memberService.registerOnboarding(member, onboardingRequestDto);
return ApiResponse.success(SuccessCode.REGISTER_SUCCESS);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fullcar.member.presentation.member.dto.request;

import com.fullcar.member.domain.member.Gender;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
Expand All @@ -10,8 +11,9 @@
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class CompanyRequestDto {
@Schema(description = "νšŒμ‚¬ 이름", example = "넀이버")
public class OnboardingRequestDto {

@Schema(description = "νšŒμ‚¬λͺ…", example = "ꡬ글 코리아")
@NotBlank
private String companyName;

Expand All @@ -20,4 +22,13 @@ public class CompanyRequestDto {

@Schema(description = "경도", example = "71.530045")
private BigDecimal longitude;

@Schema(description = "νšŒμ‚¬ 이메일", example = "[email protected]")
private String email;

@Schema(description = "λ‹‰λ„€μž„", example = "ν”Όκ³€ν•œ 물개")
private String nickname;

@Schema(description = "성별", example = "NONE")
private Gender gender;
}
Loading