package com.yida.data.school.transaction.controller;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.apply.EduProductCategory;
import com.yida.data.school.transaction.service.EduProductCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "交易-商品类别")
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/transaction/category")
public class EduProductCategoryController {

    private final EduProductCategoryService eduProductCategoryService;

    @ApiOperation("构建类别树")
    @GetMapping("/getCategoryTree")
    public ResultBean<List<EduProductCategory>> getCategoryTree() {
        return ResultBean.buildSuccess(eduProductCategoryService.getCategoryTree());
    }

    @ApiOperation("保存类别")
    @PostMapping("/saveCategory")
    public ResultBean saveCategory(@RequestBody EduProductCategory category) {
        eduProductCategoryService.saveCategory(category);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("批量删除类别")
    @PostMapping("/delCategoryBatch")
    public ResultBean delCategoryBBatch(@RequestBody List<Long> ids) {
        eduProductCategoryService.delCategoryBatch(ids);
        return ResultBean.buildSuccess();
    }
}
