From ae4f99668d71239435a9027c923982da46e739c6 Mon Sep 17 00:00:00 2001 From: forge-bot Date: Tue, 14 Jul 2026 06:26:03 +0000 Subject: [PATCH] =?UTF-8?q?TA=20=EC=97=AD=ED=95=A0=20Spring=20=EA=B2=BD?= =?UTF-8?q?=EA=B3=84=20smoke=20(role-ta-live-1522-001)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RoleController.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main/java/com/runtimematrix/controller/RoleController.java diff --git a/src/main/java/com/runtimematrix/controller/RoleController.java b/src/main/java/com/runtimematrix/controller/RoleController.java new file mode 100644 index 0000000..ea78029 --- /dev/null +++ b/src/main/java/com/runtimematrix/controller/RoleController.java @@ -0,0 +1,61 @@ +package com.runtimematrix.controller; + +import com.runtimematrix.controller.dto.RoleResponse; +import com.runtimematrix.domain.model.Role; +import com.runtimematrix.service.RoleService; +import com.runtimematrix.service.command.CreateRoleCommand; +import com.runtimematrix.service.command.UpdateRoleCommand; +import jakarta.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.util.List; + +/** + * 역할 관리 REST 컨트롤러. + * ADR-001 Controller 경계: HTTP 처리, 검증, DTO 변환만 수행. 비즈니스 로직 없음. + */ +@RestController +@RequestMapping("/api/v1/roles") +public class RoleController { + + private final RoleService roleService; + + public RoleController(RoleService roleService) { + this.roleService = roleService; + } + + @PostMapping + public ResponseEntity createRole(@Valid @RequestBody CreateRoleRequest request) { + CreateRoleCommand command = new CreateRoleCommand(request.name(), request.description()); + Role created = roleService.createRole(command); + return ResponseEntity.created(URI.create("/api/v1/roles/" + created.getId())) + .body(RoleResponse.from(created)); + } + + @GetMapping("/{roleId}") + public ResponseEntity getRole(@PathVariable String roleId) { + return ResponseEntity.ok(RoleResponse.from(roleService.getRole(roleId))); + } + + @GetMapping + public ResponseEntity> getAllRoles() { + return ResponseEntity.ok(roleService.getAllRoles().stream() + .map(RoleResponse::from).toList()); + } + + @PutMapping("/{roleId}") + public ResponseEntity updateRole( + @PathVariable String roleId, + @Valid @RequestBody UpdateRoleRequest request) { + UpdateRoleCommand command = new UpdateRoleCommand(request.name(), request.description()); + return ResponseEntity.ok(RoleResponse.from(roleService.updateRole(roleId, command))); + } + + @DeleteMapping("/{roleId}") + public ResponseEntity deleteRole(@PathVariable String roleId) { + roleService.deleteRole(roleId); + return ResponseEntity.noContent().build(); + } +}