Class AdminApiController

java.lang.Object
com.easydesk.web.controller.AdminApiController

@Screen("Admin") @RestController @RequestMapping("/admin/api") public class AdminApiController extends Object
AdminController(Thymeleaf 화면)와 같은 기능(그룹별 role 조회 / grant / revokeAll)을 JSON으로 제공하는 API. 화면은 계속 Thymeleaf로 그리되, 나중에 드래그앤드롭(DnD) 같은 화면 새로고침 없는 인터랙션을 얹을 때는 이 API를 fetch()로 호출하는 방식으로 확장하기 위해 만들었다. ModelManager가 (user, group) 단위로만 grant/revokeAll을 지원하기 때문에(개별 role revoke는 없음), DnD로 그린다면 "role 카드를 group 박스로 드래그 = grant", "role 카드를 group 박스 밖(휴지통 등)으로 드래그 = 그 group의 revokeAll" 정도의 인터랙션이 자연스럽다. board() 엔드포인트가 한 번에 특정 user의 전체 group x role 매트릭스를 내려주므로, 화면 최초 렌더링(보드 그리기)에 바로 쓸 수 있다. AdminController와 마찬가지로 로그인 여부만 확인한다 (세션 속성 LOGIN_USER).
  • Constructor Details

    • AdminApiController

      public AdminApiController(@Qualifier("moduleSecurityService") SecurityService moduleSecurityService)
  • Method Details

    • meta

      @GetMapping("/meta") public AdminApiController.MetaResponse meta(HttpSession session)
      화면(특히 나중에 만들 DnD 보드)을 그리는 데 필요한 고정 목록 (User/Group/Role). 실제 DB를 조회하는 대신 UserEnum/GroupEnum/RoleEnum 값을 그대로 노출한다.
    • board

      @GetMapping("/board") public AdminApiController.BoardResponse board(@RequestParam("user") String userName, HttpSession session)
      특정 user에 대해, 모든 group x 모든 role 조합의 부여 여부를 한 번에 내려준다. DnD 보드를 최초로 그릴 때 이 응답 하나로 "어떤 role 카드가 어떤 group 박스 안에 이미 들어가 있는지"를 결정할 수 있다.
    • boardGroup

      @GetMapping("/board/group") public AdminApiController.GroupRoles boardGroup(@RequestParam("user") String userName, @RequestParam("group") String groupName, HttpSession session)
      특정 user/group 하나의 role 부여 현황만 조회. grant/revokeAll 이후 그 group 박스 하나만 갱신하고 싶을 때 board() 대신 이걸 써도 된다.
    • grant

      @PostMapping("/grant") public org.springframework.http.ResponseEntity<?> grant(@RequestBody AdminApiController.GrantRequest request, HttpSession session)
      role 카드를 group 박스에 드롭했을 때 호출될 엔드포인트. 성공하면 그 group의 갱신된 role 현황을 그대로 돌려주므로, 프론트는 응답을 받아 해당 박스만 다시 그리면 된다.
    • revokeAll

      @PostMapping("/revoke-all") public org.springframework.http.ResponseEntity<?> revokeAll(@RequestBody AdminApiController.RevokeAllRequest request, HttpSession session)
      role 카드를 group 박스 밖으로 드래그(또는 휴지통에 드롭)했을 때 호출될 엔드포인트. ModelManager API 특성상 "이 group에 대한 모든 role"이 한 번에 회수된다 (개별 role만 빼는 API는 없음).
    • updateItemTypeAttributeProperty

      @Screen("AdminItemTypeAttributes") @PostMapping("/item-types/{typeId}/attributes/{attributeId}/property") public org.springframework.http.ResponseEntity<?> updateItemTypeAttributeProperty(@PathVariable("typeId") Integer typeId, @PathVariable("attributeId") Integer attributeId, @RequestBody AdminApiController.AttributePropertyRequest request, HttpSession session)
      admin-item-type-attribute-groups 화면(ItemTypeAttribute)에서 필수/기본텍스트/중복체크/빠른검색 checkbox 를 클릭했을 때 곧바로 서버에 반영하기 위한 endpoint. 화면 새로고침 없이 fetch() 로 호출된다.
    • updateModuleAttributeProperty

      @Screen("AdminModuleAttributes") @PostMapping("/modules/{moduleId}/item-types/{typeId}/attributes/{attributeId}/property") public org.springframework.http.ResponseEntity<?> updateModuleAttributeProperty(@PathVariable("moduleId") Long moduleId, @PathVariable("typeId") Integer typeId, @PathVariable("attributeId") Integer attributeId, @RequestBody AdminApiController.AttributePropertyRequest request, HttpSession session)
      admin-module-attribute-groups 화면(ModuleAttribute)의 같은 기능. 이 Module 에 ItemType 이 실제로 등록되어 있으면(ModuleItemType 존재) ModuleAttribute 를, 아니면(Module 미등록 - ItemType 소유 Group) ItemTypeAttribute 를 갱신한다 (ModuleAdminController#toAttributeGroupRow() 와 동일한 판단 방식).
    • updateModuleAttributeRegistration

      @Screen("AdminModuleAttributes") @PostMapping("/modules/{moduleId}/item-types/{typeId}/attributes/{attributeId}/registration") public org.springframework.http.ResponseEntity<?> updateModuleAttributeRegistration(@PathVariable("moduleId") Long moduleId, @PathVariable("typeId") Integer typeId, @PathVariable("attributeId") Integer attributeId, @RequestBody AdminApiController.AttributeRegistrationRequest request, HttpSession session)
      admin-module-attribute-groups 화면에서, ModuleAttribute 로 아직 등록되지 않은 Attribute 의 '활성' checkbox 를 클릭했을 때 호출된다 (mit != null 인 화면에서만 렌더링되는 checkbox - ModuleAdminController#toAttributeGroupRow() 참고). value=true 면 core 의 ModuleAttributeFactory.getFactory(mit).add(attribute) 로 등록하고, value=false 면 이미 등록된 ModuleAttribute#delete(user) 로 제거한다. 이 Module 에 typeId 가 등록되어 있지 않으면 (ModuleItemType 없음) 등록/제거 자체가 불가능하므로 400 을 돌려준다.
    • updateModuleItemTypeProperty

      @Screen("AdminModuleItemTypes") @PostMapping("/modules/{moduleId}/item-types/{typeId}/property") public org.springframework.http.ResponseEntity<?> updateModuleItemTypeProperty(@PathVariable("moduleId") Long moduleId, @PathVariable("typeId") Integer typeId, @RequestBody AdminApiController.ModuleItemTypePropertyRequest request, HttpSession session)
      admin-module-item-types 화면(기본 편집 모드)에서 ModuleItemType 의 active/display/dedupe/moderation checkbox 나 order/comments/maxVotes 숫자 dropdown 값이 바뀌면 곧바로 서버에 반영하기 위한 endpoint. 화면 새로고침 없이 fetch() 로 호출된다. 이 Module 에 등록되지 않은 ItemType(ModuleItemType 없음) 이나 잠긴(locked) ItemType 은 화면에서도 편집 component 를 그리지 않으며, 여기서도 400 을 돌려준다.