package com.sckw.file.controller;

import com.sckw.core.web.response.BaseResult;
import com.sckw.file.api.dto.FileInfoVO;
import com.sckw.file.service.FileInfoService;
import jakarta.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/common")
public class CommonController {
    @Resource
    private FileInfoService fileInfoService;

    /**
     * 通用上传请求（单个）
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public BaseResult<FileInfoVO> uploadFile(@RequestPart("file") MultipartFile file) {
        return BaseResult.success(fileInfoService.uploadFile(file));
    }


}
