package com.snack.server.module.category.controller;

import com.snack.server.common.Result;
import com.snack.server.module.category.service.CategoryService;
import com.snack.server.module.category.vo.CategoryTreeVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
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;

/**
 * 商品分类（用户端 / 公开接口）
 */
@Tag(name = "商品分类（公开）")
@RestController
@RequestMapping("/api/category")
@RequiredArgsConstructor
public class CategoryPublicController {

    private final CategoryService categoryService;

    @Operation(summary = "获取启用的分类树（用户端首页）")
    @GetMapping("/tree")
    public Result<List<CategoryTreeVO>> tree() {
        return Result.ok(categoryService.listTree(1));
    }
}
