package cn.reghao.tnb.file.app.zdisk.controller;

import cn.reghao.tnb.common.web.WebResult;
import cn.reghao.tnb.common.auth.AuthUser;
import cn.reghao.tnb.file.app.zdisk.model.dto.SyncedFile;
import cn.reghao.tnb.file.app.zdisk.service.DiskSyncService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author reghao
 * @date 2025-09-01 11:42:46
 */
@Tag(name = "网盘同步接口")
@RestController
@RequestMapping("/api/disk/sync")
@AuthUser
public class DiskSyncController {
    private final DiskSyncService diskSyncService;

    public DiskSyncController(DiskSyncService diskSyncService) {
        this.diskSyncService = diskSyncService;
    }

    @Operation(summary = "获取文件树", description = "N")
    @GetMapping(value = "/check", produces = MediaType.APPLICATION_JSON_VALUE)
    public String checkFile(@RequestParam("path") String path) {
        return WebResult.success();
    }

    @Operation(summary = "获取文件树", description = "N")
    @GetMapping(value = "/get", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getFileTree() {
        return WebResult.success();
    }

    @Operation(summary = "同步磁盘上的文件(或文件夹)", description = "N")
    @PostMapping(value = "/put", produces = MediaType.APPLICATION_JSON_VALUE)
    public String putFile(@RequestBody @Validated SyncedFile syncedFile) {
        diskSyncService.putFile(syncedFile);
        return WebResult.success();
    }
}
