diff --git a/.gitignore b/.gitignore index 0021b38..9467dee 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,7 @@ out/ ### dev ### application-dev.yml +# local/dev only +.dev/ +docker-compose.yml +init-user.sql \ No newline at end of file diff --git a/src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveRequestDto.java b/src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveRequestDto.java index 8d87f00..532f3a0 100644 --- a/src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveRequestDto.java +++ b/src/main/java/dmu/dasom/api/domain/executive/dto/ExecutiveRequestDto.java @@ -15,8 +15,6 @@ @Schema(name = "ExecutiveRequestDto", description = "임원진 요청 DTO") public class ExecutiveRequestDto { - private Long id; - @NotBlank(message = "임원진 이름은 필수 입력 사항입니다.") @Size(max = 50, message = "임원진 이름은 최대 50자입니다.") @Schema(description = "임원진 이름", example = "김다솜") @@ -45,7 +43,7 @@ public ExecutiveEntity toEntity() { .role(this.role) .githubUsername(this.github_username) .team(this.team) - .sortOrder(this.sortOrder) + .sortOrder(sortOrder != null ? sortOrder : 9999) .build(); } } diff --git a/src/main/java/dmu/dasom/api/domain/executive/entity/ExecutiveEntity.java b/src/main/java/dmu/dasom/api/domain/executive/entity/ExecutiveEntity.java index 45b1a22..9d34442 100644 --- a/src/main/java/dmu/dasom/api/domain/executive/entity/ExecutiveEntity.java +++ b/src/main/java/dmu/dasom/api/domain/executive/entity/ExecutiveEntity.java @@ -58,6 +58,15 @@ public void update(ExecutiveUpdateRequestDto dto) { if (dto.getSortOrder() != null) this.sortOrder = dto.getSortOrder(); } + @PrePersist + public void prePersist() { + if (sortOrder == null) sortOrder = 9999; + } + @PreUpdate + public void preUpdate() { + if (sortOrder == null) sortOrder = 9999; + } + // 엔티티 -> DTO 변환 책임 public ExecutiveResponseDto toResponseDto() { return ExecutiveResponseDto.builder() diff --git a/src/main/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceImpl.java b/src/main/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceImpl.java index 42563d6..7070886 100644 --- a/src/main/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceImpl.java +++ b/src/main/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceImpl.java @@ -47,7 +47,8 @@ public List getAllExecutives() { // 임원진 멤버 생성 public ExecutiveCreationResponseDto createExecutive(ExecutiveRequestDto requestDto) { - return new ExecutiveCreationResponseDto(executiveRepository.save(requestDto.toEntity()).getId()); + ExecutiveEntity saved = executiveRepository.save(requestDto.toEntity()); + return new ExecutiveCreationResponseDto(saved.getId()); } // 임원진 멤버 삭제 diff --git a/src/test/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceTest.java b/src/test/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceTest.java index 93825df..884ef1b 100644 --- a/src/test/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceTest.java +++ b/src/test/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceTest.java @@ -88,7 +88,6 @@ void createExecutive_success() { // given Long id = 1L; ExecutiveRequestDto dto = new ExecutiveRequestDto( - id, "김다솜", "회장", "동아리 운영 총괄",