package com.zksy.screen.controller;

import com.zksy.common.core.domain.Result;
import com.zksy.service.MinioFileStorageService;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
public class FileController {
    @Autowired
    private MinioFileStorageService minioFileStorageService;
    @Value("${minio.readPath}")
    private String readPath;
    @Value("${minio.bucket}")
    private String bucket;
    @SneakyThrows
    @PostMapping("/upload")
    public Result<String> uploadFile(@RequestParam("file") MultipartFile file) {
        String s = minioFileStorageService.uploadFile(file, "大屏图片");
        return Result.ok(readPath+bucket+s);
    }
    @DeleteMapping("/delete")
    public Result<String> deleteFile(String path) {
        minioFileStorageService.deleteFile(path);
        return Result.ok("删除成功");
    }
}
