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

GETP-196 refactor: member 컴포넌트 포트-어댑터 아키텍처 적용 #128

Merged
merged 4 commits into from
Aug 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import es.princip.getp.api.controller.ApiResponse.ApiSuccessResult;
import es.princip.getp.domain.auth.application.SignUpService;
import es.princip.getp.domain.auth.application.command.SignUpCommand;
import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.model.Email;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.princip.getp.api.controller.auth.dto.request;

import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand;
import es.princip.getp.domain.member.command.ServiceTermAgreementCommand;
import es.princip.getp.domain.serviceTerm.domain.ServiceTermTag;
import jakarta.validation.constraints.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package es.princip.getp.api.controller.auth.dto.request;

import es.princip.getp.domain.auth.application.command.SignUpCommand;
import es.princip.getp.domain.member.command.annotation.UserMemberType;
import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand;
import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.command.domain.model.MemberType;
import es.princip.getp.domain.member.command.domain.model.Password;
import es.princip.getp.api.validation.UserMemberType;
import es.princip.getp.domain.member.command.ServiceTermAgreementCommand;
import es.princip.getp.domain.member.model.Email;
import es.princip.getp.domain.member.model.MemberType;
import es.princip.getp.domain.member.model.Password;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import es.princip.getp.domain.client.command.application.command.EditClientCommand;
import es.princip.getp.domain.client.command.domain.Address;
import es.princip.getp.domain.client.command.domain.BankAccount;
import es.princip.getp.domain.member.command.annotation.EmailPattern;
import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern;
import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.command.domain.model.Nickname;
import es.princip.getp.domain.member.command.domain.model.PhoneNumber;
import es.princip.getp.api.validation.EmailPattern;
import es.princip.getp.api.validation.PhoneNumberPattern;
import es.princip.getp.domain.member.model.Email;
import es.princip.getp.domain.member.model.Nickname;
import es.princip.getp.domain.member.model.PhoneNumber;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import es.princip.getp.domain.client.command.application.command.RegisterClientCommand;
import es.princip.getp.domain.client.command.domain.Address;
import es.princip.getp.domain.client.command.domain.BankAccount;
import es.princip.getp.domain.member.command.annotation.EmailPattern;
import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern;
import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.command.domain.model.Nickname;
import es.princip.getp.domain.member.command.domain.model.PhoneNumber;
import es.princip.getp.api.validation.EmailPattern;
import es.princip.getp.api.validation.PhoneNumberPattern;
import es.princip.getp.domain.member.model.Email;
import es.princip.getp.domain.member.model.Nickname;
import es.princip.getp.domain.member.model.PhoneNumber;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import es.princip.getp.domain.client.command.domain.Address;
import es.princip.getp.domain.client.command.domain.BankAccount;
import es.princip.getp.domain.client.command.domain.Client;
import es.princip.getp.domain.member.command.domain.model.Member;
import es.princip.getp.domain.member.model.Member;

import java.time.LocalDateTime;

Expand All @@ -25,7 +25,7 @@ public static ClientResponse of(final Client client, final Member member) {
member.getNickname().getValue(),
client.getEmail().getValue(),
member.getPhoneNumber().getValue(),
member.getProfileImage().getUri(),
member.getProfileImage().getUrl(),
client.getAddress(),
client.getBankAccount(),
client.getCreatedAt(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import es.princip.getp.api.controller.ApiResponse;
import es.princip.getp.api.controller.ApiResponse.ApiSuccessResult;
import es.princip.getp.api.security.details.PrincipalDetails;
import es.princip.getp.api.controller.member.command.dto.response.ProfileImageResponse;
import es.princip.getp.domain.member.command.application.MemberService;
import es.princip.getp.api.security.details.PrincipalDetails;
import es.princip.getp.application.member.command.ChangeProfileImageCommand;
import es.princip.getp.application.member.port.in.ChangeProfileImageUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -17,11 +18,11 @@
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/member/me")
@RequiredArgsConstructor
@RequestMapping("/member/me")
public class MyMemberController {

private final MemberService memberService;
private final ChangeProfileImageUseCase changeProfileImageUseCase;

/**
* 내 프로필 이미지 등록
Expand All @@ -37,7 +38,8 @@ public ResponseEntity<ApiSuccessResult<ProfileImageResponse>> uploadProfileImage
@RequestPart final MultipartFile image
) {
final Long memberId = principalDetails.getMember().getMemberId();
final String profileImageUri = memberService.changeProfileImage(memberId, image);
final ChangeProfileImageCommand command = new ChangeProfileImageCommand(memberId, image);
final String profileImageUri = changeProfileImageUseCase.changeProfileImage(command);
final ProfileImageResponse response = new ProfileImageResponse(profileImageUri);
return ApiResponse.success(HttpStatus.CREATED, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import es.princip.getp.api.controller.ApiResponse;
import es.princip.getp.api.security.details.PrincipalDetails;
import es.princip.getp.api.controller.member.query.dto.response.MemberResponse;
import es.princip.getp.domain.member.command.domain.model.Member;
import es.princip.getp.domain.member.model.Member;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package es.princip.getp.api.controller.member.query.dto.response;

import es.princip.getp.domain.member.command.domain.model.Member;
import es.princip.getp.domain.member.command.domain.model.MemberType;
import es.princip.getp.domain.member.command.domain.model.Nickname;
import es.princip.getp.domain.member.command.domain.model.ProfileImage;
import es.princip.getp.domain.member.model.Member;
import es.princip.getp.domain.member.model.MemberType;
import es.princip.getp.domain.member.model.Nickname;
import es.princip.getp.domain.member.model.ProfileImage;

import java.time.LocalDateTime;
import java.util.Optional;
Expand All @@ -25,7 +25,7 @@ public static MemberResponse from(final Member member) {
.map(Nickname::getValue)
.orElse(null),
Optional.ofNullable(member.getProfileImage())
.map(ProfileImage::getUri)
.map(ProfileImage::getUrl)
.orElse(null),
member.getMemberType(),
member.getCreatedAt(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package es.princip.getp.api.controller.people.command.dto.request;

import es.princip.getp.common.annotation.Enum;
import es.princip.getp.domain.member.command.annotation.EmailPattern;
import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern;
import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.command.domain.model.Nickname;
import es.princip.getp.domain.member.command.domain.model.PhoneNumber;
import es.princip.getp.api.validation.EmailPattern;
import es.princip.getp.api.validation.PhoneNumberPattern;
import es.princip.getp.domain.member.model.Email;
import es.princip.getp.domain.member.model.Nickname;
import es.princip.getp.domain.member.model.PhoneNumber;
import es.princip.getp.domain.people.command.application.command.CreatePeopleCommand;
import es.princip.getp.domain.people.command.domain.PeopleType;
import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package es.princip.getp.api.controller.people.command.dto.request;

import es.princip.getp.common.annotation.Enum;
import es.princip.getp.domain.member.command.annotation.EmailPattern;
import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern;
import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.command.domain.model.Nickname;
import es.princip.getp.domain.member.command.domain.model.PhoneNumber;
import es.princip.getp.api.validation.EmailPattern;
import es.princip.getp.api.validation.PhoneNumberPattern;
import es.princip.getp.domain.member.model.Email;
import es.princip.getp.domain.member.model.Nickname;
import es.princip.getp.domain.member.model.PhoneNumber;
import es.princip.getp.domain.people.command.application.command.UpdatePeopleCommand;
import es.princip.getp.domain.people.command.domain.PeopleType;
import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package es.princip.getp.api.controller.project.command.dto.request;

import es.princip.getp.common.domain.MeetingSchedule;
import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern;
import es.princip.getp.api.validation.PhoneNumberPattern;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import es.princip.getp.api.controller.PageResponse;
import es.princip.getp.api.security.details.PrincipalDetails;
import es.princip.getp.api.controller.people.query.dto.people.DetailPeopleResponse;
import es.princip.getp.domain.member.command.domain.model.Member;
import es.princip.getp.domain.member.model.Member;
import es.princip.getp.domain.project.query.application.ProjectApplicantService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.princip.getp.api.security.details;

import es.princip.getp.domain.member.command.domain.model.Member;
import es.princip.getp.domain.member.model.Member;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package es.princip.getp.api.security.details;

import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.command.domain.model.Member;
import es.princip.getp.domain.member.command.domain.model.MemberRepository;
import es.princip.getp.application.member.port.out.LoadMemberPort;
import es.princip.getp.domain.member.model.Email;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
Expand All @@ -12,12 +11,11 @@
@Service
@RequiredArgsConstructor
public class PrincipalDetailsService implements UserDetailsService {
private final MemberRepository memberRepository;

private final LoadMemberPort loadMemberPort;

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
Member member = memberRepository.findByEmail(Email.of(username))
.orElseThrow(() -> new UsernameNotFoundException("User not found"));
return new PrincipalDetails(member);
public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException {
return new PrincipalDetails(loadMemberPort.loadBy(Email.of(username)));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.princip.getp.domain.member.command.annotation;
package es.princip.getp.api.validation;

import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.model.Email;
import jakarta.validation.Constraint;
import jakarta.validation.constraints.Pattern;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.princip.getp.domain.member.command.annotation;
package es.princip.getp.api.validation;

import es.princip.getp.domain.member.command.domain.model.PhoneNumber;
import es.princip.getp.domain.member.model.PhoneNumber;
import jakarta.validation.Constraint;
import jakarta.validation.constraints.Pattern;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.princip.getp.domain.member.command.annotation;
package es.princip.getp.api.validation;

import jakarta.validation.Constraint;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.princip.getp.domain.member.command.annotation;
package es.princip.getp.api.validation;

import es.princip.getp.domain.member.command.domain.model.MemberType;
import es.princip.getp.domain.member.model.MemberType;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package es.princip.getp.application.member.command;

import org.springframework.web.multipart.MultipartFile;

public record ChangeProfileImageCommand(
Long memberId,
MultipartFile image
) {
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
package es.princip.getp.domain.member.command.application.command;
package es.princip.getp.application.member.command;

import es.princip.getp.domain.client.command.application.command.EditClientCommand;
import es.princip.getp.domain.client.command.application.command.RegisterClientCommand;
import es.princip.getp.domain.member.command.domain.model.Nickname;
import es.princip.getp.domain.member.command.domain.model.PhoneNumber;
import es.princip.getp.domain.member.model.Nickname;
import es.princip.getp.domain.member.model.PhoneNumber;
import es.princip.getp.domain.people.command.application.command.CreatePeopleCommand;
import es.princip.getp.domain.people.command.application.command.UpdatePeopleCommand;

public record UpdateMemberCommand(
public record EditMemberCommand(
Long memberId,
Nickname nickname,
PhoneNumber phoneNumber
) {
public static UpdateMemberCommand from(final CreatePeopleCommand command) {
return new UpdateMemberCommand(
public static EditMemberCommand from(final CreatePeopleCommand command) {
return new EditMemberCommand(
command.memberId(),
command.nickname(),
command.phoneNumber()
);
}

public static UpdateMemberCommand from(final UpdatePeopleCommand command) {
return new UpdateMemberCommand(
public static EditMemberCommand from(final UpdatePeopleCommand command) {
return new EditMemberCommand(
command.memberId(),
command.nickname(),
command.phoneNumber()
);
}

public static UpdateMemberCommand from(final RegisterClientCommand command) {
return new UpdateMemberCommand(
public static EditMemberCommand from(final RegisterClientCommand command) {
return new EditMemberCommand(
command.memberId(),
command.nickname(),
command.phoneNumber()
);
}

public static UpdateMemberCommand from(final EditClientCommand command) {
return new UpdateMemberCommand(
public static EditMemberCommand from(final EditClientCommand command) {
return new EditMemberCommand(
command.memberId(),
command.nickname(),
command.phoneNumber()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package es.princip.getp.application.member.port.in;

import es.princip.getp.application.member.command.ChangeProfileImageCommand;

public interface ChangeProfileImageUseCase {

String changeProfileImage(ChangeProfileImageCommand command);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package es.princip.getp.application.member.port.in;

import es.princip.getp.application.member.command.EditMemberCommand;

public interface EditMemberUseCase {

void editMember(EditMemberCommand command);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package es.princip.getp.application.member.port.out;

import es.princip.getp.domain.member.model.Email;

public interface CheckMemberPort {

boolean existsByEmail(Email email);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package es.princip.getp.application.member.port.out;

import es.princip.getp.domain.member.model.Email;
import es.princip.getp.domain.member.model.Member;

public interface LoadMemberPort {

Member loadBy(Email email);

Member loadBy(Long id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package es.princip.getp.application.member.port.out;

import es.princip.getp.domain.member.model.Member;

public interface SaveMemberPort {

Long save(Member member);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package es.princip.getp.application.member.port.out;

import es.princip.getp.domain.member.model.Member;

public interface UpdateMemberPort {

void update(Member member);
}
Loading