Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ out/
### dev ###
application-dev.yml

# local/dev only
.dev/
docker-compose.yml
init-user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "김다솜")
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public List<ExecutiveListResponseDto> 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());
}

// 임원진 멤버 삭제
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ void createExecutive_success() {
// given
Long id = 1L;
ExecutiveRequestDto dto = new ExecutiveRequestDto(
id,
"김다솜",
"회장",
"동아리 운영 총괄",
Expand Down
Loading