package com.youlai.boot.system.controller;

import com.youlai.boot.common.result.Result;
import com.youlai.boot.system.model.entity.DirectoryNode;
import com.youlai.boot.system.model.form.DirForm;
import com.youlai.boot.system.service.FolderNodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/folder")
@RequiredArgsConstructor
public class FolderNodeController {


    private final FolderNodeService folderNodeService;



    @GetMapping("/get/{pageType}")
    public Result<DirectoryNode> getRoot(@PathVariable String pageType) {
        DirectoryNode folderNode = folderNodeService.getFolderNode(pageType);
        return Result.success(folderNode);
    }

    @PostMapping("/mkdir")
    public Result<Void> mkdir(@RequestBody DirForm dirForm) {

        folderNodeService.mkDir(dirForm);
        return Result.success();
    }

    @PostMapping("/rmdir")
    public Result<Void> rmdir(@RequestBody DirForm dirForm) {
        folderNodeService.rmDir(dirForm);
        return Result.success();

    }

    @PostMapping("/rename")
    public Result<Void> rename(@RequestBody DirForm dirForm) {
        folderNodeService.renameDir(dirForm);
        return Result.success();
    }





}
