package com.erp.controller;

import com.erp.dto.ApiResponse;
import com.erp.service.ScreenStandardService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/screen-standard")
@RequiredArgsConstructor
@Slf4j
public class ScreenStandardController {

    private final ScreenStandardService screenStandardService;

    /**
     * GET /api/screen-standard/web-types
     * 웹타입 목록 조회 (active / category / search 필터)
     */
    @GetMapping("/web-types")
    public ResponseEntity<ApiResponse<List<Map<String, Object>>>> getWebTypeList(
            @RequestParam Map<String, Object> params) {
        List<Map<String, Object>> data = screenStandardService.getWebTypeList(params);
        return ResponseEntity.ok(ApiResponse.success(data, "웹타입 목록을 성공적으로 조회했습니다."));
    }

    /**
     * GET /api/screen-standard/web-types/categories
     * 웹타입 카테고리 목록 조회
     * NOTE: /web-types/{webType} 경로가 없으므로 순서 무관하지만 명확성을 위해 먼저 선언
     */
    @GetMapping("/web-types/categories")
    public ResponseEntity<ApiResponse<List<Map<String, Object>>>> getWebTypeCategoryList() {
        List<Map<String, Object>> data = screenStandardService.getWebTypeCategoryList();
        return ResponseEntity.ok(ApiResponse.success(data, "웹타입 카테고리 목록을 성공적으로 조회했습니다."));
    }

    /**
     * GET /api/screen-standard/button-actions
     * 버튼 액션 목록 조회 (active / category / search 필터)
     */
    @GetMapping("/button-actions")
    public ResponseEntity<ApiResponse<List<Map<String, Object>>>> getButtonActionList(
            @RequestParam Map<String, Object> params) {
        List<Map<String, Object>> data = screenStandardService.getButtonActionList(params);
        return ResponseEntity.ok(ApiResponse.success(data, "버튼 액션 목록을 성공적으로 조회했습니다."));
    }

    /**
     * GET /api/screen-standard/button-actions/categories
     * 버튼 액션 카테고리 목록 조회
     */
    @GetMapping("/button-actions/categories")
    public ResponseEntity<ApiResponse<List<Map<String, Object>>>> getButtonActionCategoryList() {
        List<Map<String, Object>> data = screenStandardService.getButtonActionCategoryList();
        return ResponseEntity.ok(ApiResponse.success(data, "버튼 액션 카테고리 목록을 성공적으로 조회했습니다."));
    }
}
