Skip to content

Commit

Permalink
๐Ÿ‘” ํšŒ์› ์ •๋ณด ๋ณ€๊ฒฝ(Adapter & Service)(#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
jun108059 committed Jul 25, 2022
1 parent 5e1237e commit bcdbe3a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

@Getter
public class UpdateMemberReq {

Long id;
String name;
String email;
String type;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Long saveMember(MemberJpaEntity memberJpaEntity) {

@Override
public Long updateMember(MemberJpaEntity memberJpaEntity) {
memberRepository.save(memberJpaEntity);
return null;
MemberJpaEntity saveEntity = memberRepository.save(memberJpaEntity);
return saveEntity.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@ public class UpdateMemberService implements UpdateMemberUseCase {

@Override
public Long updateMember(UpdateMemberCommand command) {
// ID ์กด์žฌ ์—ฌ๋ถ€ ๊ฒ€์‚ฌ
if (checkMemberExistsById(command.getId())) {
MemberJpaEntity memberJpaEntity = command.toJpaEntity();
return updateMemberPort.updateMember(memberJpaEntity);
MemberJpaEntity jpaEntity = checkMemberExistsById(command.getId());
if (jpaEntity != null) {
jpaEntity.setName(command.getName());
jpaEntity.setType(command.getMemberType());
return updateMemberPort.updateMember(jpaEntity);
} else {
// FixMe Custom Exception ์ฒ˜๋ฆฌํ•˜๊ธฐ
return null;
return 0L;
}
}

private boolean checkMemberExistsById(Long id) {
private MemberJpaEntity checkMemberExistsById(Long id) {
try {
findMemberPort.findMemberById(id);
return findMemberPort.findMemberById(id);
} catch (EntityNotFoundException e) {
return false;
return null;
}

return true;
}
}

0 comments on commit bcdbe3a

Please sign in to comment.