package com.ruoyi.project.business.controller.train;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.business.domain.train.TtFileDirectory;
import com.ruoyi.project.business.service.train.ITtFileDirectoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 资料库 目录 Controller
 *
 * @author ruoyi
 * @date 2024-05-20
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/train/directory")
public class TtFileDirectoryController extends BaseController {
    private final ITtFileDirectoryService ttFileDirectoryService;

    /**
     * 获取目录树
     */
    @GetMapping("/tree")
    public AjaxResult getDirectoryTree() {
        return AjaxResult.success(ttFileDirectoryService.getDirectoryTree());
    }

    
    /**
     * 创建目录
     */
    @PostMapping
    public AjaxResult add(@RequestBody TtFileDirectory fileDirectory) {
        return AjaxResult.success(ttFileDirectoryService.save(fileDirectory));
    }
    
}
