CountLog 도메인의 구현에 대하여 논의하고자 하는 문제 #30
Closed
kimdotcom2
started this conversation in
General
Replies: 3 comments 11 replies
-
|
@kimdotcom2 님 안녕하세요!
|
Beta Was this translation helpful? Give feedback.
3 replies
-
|
현재 제가 구상하고 있는 interaction interface의 코드 형태는 이렇습니다. public interface ChangeLogService {
...
//직원 생성 시 로그 생성
ChangeLogDto addCreateEmployeeLog(EmployeeLogDto.CreateLogRequest request);
//직원 정보 수정 시 로그 생성
ChangeLogDto addUpdateEmployeeLog(EmployeeLogDto.CreateUpdateLogRequest request);
//직원 퇴사 시 로그 생성
ChangeLogDto addDeleteEmployeeLog(EmployeeLogDto.CreateDeleteLogRequest request);
}
public class EmployeeLogDto {
private EmployeeLogDto() {
}
@Builder
public record EmployeeBaseInfo(
LocalDateTime hireDate,
String name,
String position,
String department,
String email,
String employeeNumber,
String status
) {}
public record LogMetadata(
@Nullable
String memo,
String ipAddress
) {
public static LogMetadata withMemo(String ipAddress, String memo) {
return new LogMetadata(memo, ipAddress);
}
public static LogMetadata withoutMemo(String ipAddress) {
return new LogMetadata(null, ipAddress);
}
}
@Builder
public record CreateLogRequest(
EmployeeBaseInfo employeeInfo,
LogMetadata metadata
) {}
@Builder
public record CreateUpdateLogRequest(
EmployeeBaseInfo before,
EmployeeBaseInfo after,
LogMetadata metadata
) {}
@Builder
public record CreateDeleteLogRequest(
EmployeeBaseInfo employeeInfo,
LogMetadata metadata
) {}
}새 직원이 들어오거나 직원이 퇴사하였을 때 인자로 주어질 Dto의 형태는 비슷합니다. 직원 정보를 수정할 때 생성하는 로그는 기존의 직원 정보와 수정할 새로운 정보가 모두 필요합니다. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
#36 이슈 생성 완료. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
1. 도메인 설계 문제
프로토타입에서는 수정 내역의 상세에서 이전 직원 정보와 수정된 직원 정보를 함께 보여줄 것을 요구한다.
그렇다면 변경이 발생했을 때 수정 전 직원 정보도 같이 저장하도록 엔티티를 설계해야 하는 것인가?
어떻게 구현할 것인가?
등등등
2. 수정 이력 메소드 동작 방식 문제
직원 정보 수정 이력은 직원이 추가되거나 직원 정보가 수정되었을 때 같이 생성되어야 한다.
아마도 직원 모듈의 서비스에서 직원 정보 수정 이력 모듈의 서비스를 주입받아 호출하도록 구현할 것이다.
그런데 수정 이력을 저장하는 로직이 완료될 때까지 클라이언트가 기다려야 한다면 지연이 발생해 UX가 저하될 가능성이 있다.
그리고 부가 작업인 로그 저장이 실패했다고 전체 작업을 실패로 간주해 클라이언트에게 에러를 반환하는 것은 합리적이지 못하다.
그렇다면 주입할 직원 정보 수정 이력 모듈의 메소드는 비동기로 작동하도록 구현할 것인가?
3. 순환 참조 문제
2에서 말했듯이 직원 모듈은 직원 정보 수정 이력 모듈의 서비스를 인터페이스를 통해 참조하게 된다.
하지만 1을 구현하려면 직원 정보 수정 이력 모듈은 직원 모듈의 서비스를 참조해 현재 직원 정보를 DTO로 가져와야 할 것이다.
순환 참조 문제를 우려해야 할까?
Beta Was this translation helpful? Give feedback.
All reactions