package com.bonus.sgzb.file.controller;

import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.file.service.FileUploadTencentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * Description: 腾讯云文件上传接口
 *
 * @Author 阮世耀
 * @Create 2023/12/3 16:33
 * @Version 1.0
 */
@Api(tags = "腾讯云文件上传接口")
@RestController
@RequestMapping("/tencent/cos")
public class FileUploadTencentController extends BaseController {

    @Resource
    private FileUploadTencentService fileUploadTencentService;

    @ApiOperation(value = "文件上传")
    @PostMapping("uploadFile")
    public AjaxResult uploadFile(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestParam("file") MultipartFile file) {
        String uploadUrl = fileUploadTencentService.uploadFile(file);
        return success(uploadUrl);
    }

}
