Skip to content

Commit 10e7189

Browse files
authored
[hotfix] 조직도 API 코드 수정
1 parent 743a924 commit 10e7189

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ out/
4242
### dev ###
4343
application-dev.yml
4444

45+
# local/dev only
46+
.dev/
47+
docker-compose.yml
48+
init-user.sql

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
// 임원진 멤버 삭제

src/test/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ void createExecutive_success() {
8888
// given
8989
Long id = 1L;
9090
ExecutiveRequestDto dto = new ExecutiveRequestDto(
91-
id,
9291
"김다솜",
9392
"회장",
9493
"동아리 운영 총괄",

0 commit comments

Comments
 (0)