Skip to content

Commit

Permalink
♻️ Controller 세분화 리펙터링
Browse files Browse the repository at this point in the history
  • Loading branch information
jun108059 committed Jul 13, 2022
1 parent 530952b commit 8c3ad35
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package hexagonal.api.member.adapter.in.web;

import hexagonal.api.member.adapter.in.web.request.RegisterMemberReq;
import hexagonal.api.member.adapter.in.web.request.UpdateMemberReq;
import hexagonal.api.member.adapter.in.web.response.RegisterMemberResponse;
import hexagonal.api.member.adapter.in.web.response.UpdateMemberResponse;
import hexagonal.api.member.application.port.in.RegisterMemberCommand;
import hexagonal.api.member.application.port.in.RegisterMemberUseCase;
import hexagonal.api.member.application.port.in.UpdateMemberCommand;
import hexagonal.api.member.application.port.in.UpdateMemberUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class MemberController {
public class RegisterMemberController {

private final RegisterMemberUseCase registerMemberUseCase;
private final UpdateMemberUseCase updateMemberUseCase;


@PostMapping("/v1/member")
ResponseEntity<RegisterMemberResponse> registerMember(@RequestBody RegisterMemberReq memberInfo) {
Expand All @@ -34,17 +30,4 @@ ResponseEntity<RegisterMemberResponse> registerMember(@RequestBody RegisterMembe
return ResponseEntity.ok(response);
}

@PutMapping("/v1/member")
ResponseEntity<UpdateMemberResponse> updateMember(@RequestBody UpdateMemberReq memberInfo) {
// ToDo 입력모델 Valid Check 예외 처리
UpdateMemberCommand command = new UpdateMemberCommand(
memberInfo.getId(),
memberInfo.getName(),
memberInfo.getEmail(),
memberInfo.getType());

Long memId = updateMemberUseCase.updateMember(command);
UpdateMemberResponse response = new UpdateMemberResponse(memId, memberInfo.getName());
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package hexagonal.api.member.adapter.in.web;

import hexagonal.api.member.adapter.in.web.request.UpdateMemberReq;
import hexagonal.api.member.adapter.in.web.response.UpdateMemberResponse;
import hexagonal.api.member.application.port.in.UpdateMemberCommand;
import hexagonal.api.member.application.port.in.UpdateMemberUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
public class UpdateMemberController {

private final UpdateMemberUseCase updateMemberUseCase;

@PutMapping("/v1/member/{id}")
ResponseEntity<UpdateMemberResponse> updateMember(@RequestBody UpdateMemberReq memberInfo,
@PathVariable("id") Long id) {
// ToDo 입력모델 Valid Check 예외 처리
UpdateMemberCommand command = new UpdateMemberCommand(
id,
memberInfo.getName(),
memberInfo.getType());

Long memId = updateMemberUseCase.updateMember(command);
UpdateMemberResponse response = new UpdateMemberResponse(memId, memberInfo.getName());
return ResponseEntity.ok(response);
}
}

0 comments on commit 8c3ad35

Please sign in to comment.