Skip to content

Commit dfd8960

Browse files
committed
fix: id 요청 및 null 값 변경
1 parent 80007d5 commit dfd8960

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveRequestDto.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
@Schema(name = "ExecutiveRequestDto", description = "임원진 요청 DTO")
1616
public class ExecutiveRequestDto {
1717

18-
private Long id;
19-
2018
@NotBlank(message = "임원진 이름은 필수 입력 사항입니다.")
2119
@Size(max = 50, message = "임원진 이름은 최대 50자입니다.")
2220
@Schema(description = "임원진 이름", example = "김다솜")
@@ -45,7 +43,7 @@ public ExecutiveEntity toEntity() {
4543
.role(this.role)
4644
.githubUsername(this.github_username)
4745
.team(this.team)
48-
.sortOrder(this.sortOrder)
46+
.sortOrder(sortOrder != null ? sortOrder : 9999)
4947
.build();
5048
}
5149
}

src/main/java/dmu/dasom/api/domain/executive/entity/ExecutiveEntity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ public void update(ExecutiveUpdateRequestDto dto) {
5858
if (dto.getSortOrder() != null) this.sortOrder = dto.getSortOrder();
5959
}
6060

61+
@PrePersist
62+
public void prePersist() {
63+
if (sortOrder == null) sortOrder = 9999;
64+
}
65+
@PreUpdate
66+
public void preUpdate() {
67+
if (sortOrder == null) sortOrder = 9999;
68+
}
69+
6170
// 엔티티 -> DTO 변환 책임
6271
public ExecutiveResponseDto toResponseDto() {
6372
return ExecutiveResponseDto.builder()

src/main/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public List<ExecutiveListResponseDto> getAllExecutives() {
4747

4848
// 임원진 멤버 생성
4949
public ExecutiveCreationResponseDto createExecutive(ExecutiveRequestDto requestDto) {
50-
return new ExecutiveCreationResponseDto(executiveRepository.save(requestDto.toEntity()).getId());
50+
ExecutiveEntity saved = executiveRepository.save(requestDto.toEntity());
51+
return new ExecutiveCreationResponseDto(saved.getId());
5152
}
5253

5354
// 임원진 멤버 삭제

0 commit comments

Comments
 (0)