File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed
src/main/java/dmu/dasom/api/domain/executive Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 33import dmu .dasom .api .domain .executive .dto .ExecutiveCreationResponseDto ;
44import dmu .dasom .api .domain .executive .dto .ExecutiveRequestDto ;
55import dmu .dasom .api .domain .executive .dto .ExecutiveResponseDto ;
6+ import dmu .dasom .api .domain .executive .dto .ExecutiveUpdateRequestDto ;
67import dmu .dasom .api .domain .executive .service .ExecutiveService ;
8+ import dmu .dasom .api .domain .news .dto .NewsUpdateRequestDto ;
79import io .swagger .v3 .oas .annotations .Operation ;
810import io .swagger .v3 .oas .annotations .tags .Tag ;
911import jakarta .validation .Valid ;
@@ -31,4 +33,11 @@ public ResponseEntity<ExecutiveResponseDto> getExecutiveById(@PathVariable @Min(
3133 public ResponseEntity <ExecutiveCreationResponseDto > createExecutive (@ Valid @ RequestBody ExecutiveRequestDto requestDto ) {
3234 return ResponseEntity .status (201 ).body (executiveService .createExecutive (requestDto ));
3335 }
36+
37+ @ Operation (summary = "임원진 수정" )
38+ @ PutMapping ("/{id}" )
39+ public ResponseEntity <ExecutiveResponseDto > updateExecutive (@ PathVariable @ Min (1 ) Long id ,
40+ @ Valid @ RequestBody ExecutiveUpdateRequestDto requestDto ) {
41+ return ResponseEntity .ok (executiveService .updateExecutive (id , requestDto ));
42+ }
3443}
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ public class ExecutiveEntity extends BaseEntity {
3131 @ Column (nullable =false , length = 255 )
3232 private String githubUrl ;
3333
34+ // 엔티티 업데이트 메소드
35+ public void update (String name , String position , String githubUrl ) {
36+ this .name = name ;
37+ this .position = position ;
38+ this .githubUrl = githubUrl ;
39+ }
40+
3441 // 엔티티 -> DTO 변환 책임
3542 public ExecutiveResponseDto toResponseDto () {
3643 return ExecutiveResponseDto .builder ()
Original file line number Diff line number Diff line change 33import dmu .dasom .api .domain .executive .dto .ExecutiveCreationResponseDto ;
44import dmu .dasom .api .domain .executive .dto .ExecutiveRequestDto ;
55import dmu .dasom .api .domain .executive .dto .ExecutiveResponseDto ;
6+ import dmu .dasom .api .domain .executive .dto .ExecutiveUpdateRequestDto ;
67import dmu .dasom .api .domain .executive .entity .ExecutiveEntity ;
78import dmu .dasom .api .domain .executive .repository .ExecutiveRepository ;
89import lombok .RequiredArgsConstructor ;
@@ -31,8 +32,13 @@ public ExecutiveCreationResponseDto createExecutive(ExecutiveRequestDto requestD
3132 }
3233
3334 // 임원진 멤버 수정
34- /*@Transactional
35- public ExecutiveResponseDto updateExecutive(ExecutiveRequestDto requestDto) {
36- return
37- }*/
35+ @ Transactional
36+ public ExecutiveResponseDto updateExecutive (Long id , ExecutiveUpdateRequestDto requestDto ) {
37+ ExecutiveEntity executive = executiveRepository .findById (id )
38+ .orElseThrow (() -> new IllegalArgumentException ("Executive not found" )); // 임시 에러 코드 출력 나중에 커스텀 에러코드로 수정
39+
40+ executive .update (requestDto .getName (), requestDto .getPosition (), requestDto .getGithubUrl ());
41+
42+ return executive .toResponseDto ();
43+ }
3844}
You can’t perform that action at this time.
0 commit comments