package org.wcs.serve.controller.app;

import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.wcs.model.vo.serve.AppServeDataResponse;
import org.wcs.serve.service.intf.IFileService;

import java.util.List;

/**
 * 文件控制器
 */
@RestController
@RequestMapping("/app/wcsFile")
@ResponseBody
@RequiredArgsConstructor
public class FileController {

    private final IFileService fileService;


    /**
     * 获取文件列表
     * @return 文件列表
     */
    @RequestMapping("/getFilesName")
    public AppServeDataResponse<List<String>> getFilesName() {
        return fileService.getFilesName();
    }

    /**
     * 下载文件
     */
    @GetMapping("/downLoadFile")
    public void downLoadFile(@RequestParam("fileName") @NotBlank(message = "文件名不能为空") String fileName, HttpServletResponse response) {
        fileService.downLoadFile(fileName, response);
    }
}
