package com.fjhx.common.controller;

import com.alibaba.fastjson2.JSONObject;
import com.fjhx.common.service.file.FtpFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * FTP文件服务控制器
 */
@RestController
@RequestMapping("/fileService")
public class FileServiceController {

    @Autowired
    private FtpFileService ftpFileService;

    /**
     * 创建临时文件夹
     */
    @PostMapping("/createTempFolder")
    public JSONObject createTempFolder() {
        return ftpFileService.createTempFolder();
    }

    /**
     * 将临时文件移动到永久文件夹
     *
     * @return
     */
    @PostMapping("/moveTempFolderToPermanent")
    public JSONObject moveFolder(String sourceFolderPath, String targetFolderPath) {
        return ftpFileService.moveFolder(sourceFolderPath, targetFolderPath);
    }

    /**
     * 获取文件夹中的文件下载地址列表
     */
    @PostMapping("/getFileList")
    List<String> getFileList(String folderPath) {
        return ftpFileService.getFileList(folderPath);
    }

}
