package com.tofly.gpsboot.controller.common;

import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.gpsboot.service.comm.IFileInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;

import java.util.List;

/**
 * @author wujianjun
 * @date 2023/12/8 16:32
 */
@RestController
@RequestMapping("/common")
@Api(tags = "公共文件上传")
public class CommonController {

    @Value("${xrty.ftp.commonFilePath}")
    private String commonFilePath;

    @Autowired
    private IFileInfoService iFileInfoService;

    @ApiOperation(value = "上传文件")
    @PostMapping(value = "/fileUpload")
    @ToFlyAppLog(title = "上传文件")
    public ResultRespone<Object> saveTrouble(@RequestParam(value = "fileList", required = false) List<MultipartFile> fileList) {
        return ResultRespone.success(iFileInfoService.saveFileList(fileList, commonFilePath));
    }
}
