package com.sz.admin.monitor.controller;

import com.sz.admin.monitor.pojo.vo.tree.TreeNodeVO;
import com.sz.admin.monitor.service.TreeService;
import com.sz.core.common.entity.ApiResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName: TreeController
 * Package: com.sz.admin.monitor.controller
 * Description:
 */
@Tag(name = "树结构")
@RestController
@RequestMapping("tree")
@RequiredArgsConstructor
@Profile({"dev", "local", "preview"})
public class TreeController {
    @Resource
    private TreeService treeService;

    @Operation(summary = "获取设备管理的树型结构数据")
    @GetMapping("/structure")
    public ApiResult<List<TreeNodeVO>> getTreeStructure() {
        return ApiResult.success(treeService.buildTree());
    }

    @Operation(summary = "获取视频预览的树型结构数据")
    @GetMapping("/preview")
    public ApiResult<List<TreeNodeVO>> getTreePreview() {
        return ApiResult.success(treeService.buildTreePreview());
    }
}
