Skip to content

Commit 9078b43

Browse files
committed
feat: 임원진 전체 조회 기능 추가 (DASOMBE-14)
1 parent eff42a1 commit 9078b43

File tree

5 files changed

+71
-12
lines changed

5 files changed

+71
-12
lines changed

src/main/java/dmu/dasom/api/domain/executive/controller/ExecutiveController.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package dmu.dasom.api.domain.executive.controller;
22

3-
import dmu.dasom.api.domain.executive.dto.ExecutiveCreationResponseDto;
4-
import dmu.dasom.api.domain.executive.dto.ExecutiveRequestDto;
5-
import dmu.dasom.api.domain.executive.dto.ExecutiveResponseDto;
6-
import dmu.dasom.api.domain.executive.dto.ExecutiveUpdateRequestDto;
3+
import dmu.dasom.api.domain.executive.dto.*;
74
import dmu.dasom.api.domain.executive.service.ExecutiveServiceImpl;
85
import io.swagger.v3.oas.annotations.Operation;
96
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -13,6 +10,8 @@
1310
import org.springframework.http.ResponseEntity;
1411
import org.springframework.web.bind.annotation.*;
1512

13+
import java.util.List;
14+
1615
@Tag(name = "EXECUTIVE API", description = "임원진 API")
1716
@RestController
1817
@RequiredArgsConstructor
@@ -27,6 +26,12 @@ public ResponseEntity<ExecutiveResponseDto> getExecutiveById(@PathVariable @Min(
2726
return ResponseEntity.ok(executiveService.getExecutiveById(id));
2827
}
2928

29+
@Operation(summary = "임원진 전체 조회")
30+
@GetMapping
31+
public ResponseEntity<List<ExecutiveListResponseDto>> getAllExecutives() {
32+
return ResponseEntity.ok(executiveService.getAllExecutives());
33+
}
34+
3035
@Operation(summary = "임원진 생성")
3136
@PostMapping
3237
public ResponseEntity<ExecutiveCreationResponseDto> createExecutive(@Valid @RequestBody ExecutiveRequestDto requestDto) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package dmu.dasom.api.domain.executive.dto;
2+
3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
9+
@Getter
10+
@NoArgsConstructor
11+
@AllArgsConstructor
12+
@Builder
13+
@Schema(name = "ExecutiveListResponseDto", description = "임원진 목록 응답 Dto")
14+
public class ExecutiveListResponseDto {
15+
16+
@Schema(description = "임원진 ID", example = "1")
17+
private Long id;
18+
19+
@Schema(description = "임원진 이름", example = "김다솜")
20+
private String name;
21+
22+
@Schema(description = "임원진 직책", example = "회장")
23+
private String position;
24+
25+
@Schema(description = "임원진 깃허브 주소", example = "https://github.com/dasom")
26+
private String githubUrl;
27+
28+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dmu.dasom.api.domain.executive.entity;
22

33
import dmu.dasom.api.domain.common.BaseEntity; // BaseEntity 상속 받음
4+
import dmu.dasom.api.domain.executive.dto.ExecutiveListResponseDto;
45
import dmu.dasom.api.domain.executive.dto.ExecutiveResponseDto;
56
import io.swagger.v3.oas.annotations.media.Schema;
67
import jakarta.persistence.*; // JPA 어노테이션 패키지 ( DB 매핑 관련 )
@@ -47,4 +48,14 @@ public ExecutiveResponseDto toResponseDto() {
4748
.githubUrl(this.githubUrl)
4849
.build();
4950
}
51+
52+
// 임원진 전체 목록 조회
53+
public ExecutiveListResponseDto toListResponseDto() {
54+
return ExecutiveListResponseDto.builder()
55+
.id(this.id)
56+
.name(this.name)
57+
.position(this.position)
58+
.githubUrl(this.githubUrl)
59+
.build();
60+
}
5061
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package dmu.dasom.api.domain.executive.service;
22

3-
import dmu.dasom.api.domain.executive.dto.ExecutiveCreationResponseDto;
4-
import dmu.dasom.api.domain.executive.dto.ExecutiveRequestDto;
5-
import dmu.dasom.api.domain.executive.dto.ExecutiveResponseDto;
6-
import dmu.dasom.api.domain.executive.dto.ExecutiveUpdateRequestDto;
3+
import dmu.dasom.api.domain.executive.dto.*;
4+
5+
import java.util.List;
76

87
public interface ExecutiveService {
98

109
ExecutiveResponseDto getExecutiveById(Long id);
1110

11+
List<ExecutiveListResponseDto> getAllExecutives();
12+
1213
ExecutiveCreationResponseDto createExecutive(ExecutiveRequestDto requestDto);
1314

1415
void deleteExective(Long id);

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
import dmu.dasom.api.domain.common.exception.CustomException;
44
import dmu.dasom.api.domain.common.exception.ErrorCode;
5-
import dmu.dasom.api.domain.executive.dto.ExecutiveCreationResponseDto;
6-
import dmu.dasom.api.domain.executive.dto.ExecutiveRequestDto;
7-
import dmu.dasom.api.domain.executive.dto.ExecutiveResponseDto;
8-
import dmu.dasom.api.domain.executive.dto.ExecutiveUpdateRequestDto;
5+
import dmu.dasom.api.domain.executive.dto.*;
96
import dmu.dasom.api.domain.executive.entity.ExecutiveEntity;
107
import dmu.dasom.api.domain.executive.repository.ExecutiveRepository;
118
import lombok.RequiredArgsConstructor;
129
import org.springframework.stereotype.Service;
1310
import org.springframework.transaction.annotation.Transactional;
1411

12+
import java.util.List;
13+
import java.util.stream.Collectors;
14+
1515
@Service
1616
@RequiredArgsConstructor
1717
@Transactional(readOnly = true) // 기본값 : 읽기 전용
@@ -28,6 +28,20 @@ public ExecutiveResponseDto getExecutiveById(Long id) {
2828
return executive.toResponseDto();
2929
}
3030

31+
// 임원진 전체 조회
32+
// 이름, 직책, 깃허브 주소 출력
33+
public List<ExecutiveListResponseDto> getAllExecutives() {
34+
List<ExecutiveEntity> executives = executiveRepository.findAll();
35+
36+
List<Long> executiveIds = executives.stream()
37+
.map(ExecutiveEntity::getId)
38+
.toList();
39+
40+
return executives.stream()
41+
.map(executiveEntity -> executiveEntity.toListResponseDto())
42+
.toList();
43+
}
44+
3145
// 임원진 멤버 생성
3246
public ExecutiveCreationResponseDto createExecutive(ExecutiveRequestDto requestDto) {
3347
return new ExecutiveCreationResponseDto(executiveRepository.save(requestDto.toEntity()).getId());

0 commit comments

Comments
 (0)