package com.sqx.modules.file;

import com.sqx.common.utils.Result;
import com.sqx.modules.file.service.NewFileService;
import icu.xuyijie.secureapi.annotation.DecryptParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author codingliang
 * @date 2025-10-21
 */
@Api(value = "文件上传(管理员端)")
@RestController
@RequestMapping(value = "admin/new-file")
@RequiredArgsConstructor
public class NewFileController {

    private final NewFileService newFileService;

    @ApiOperation("文件上传")
    @RequestMapping(value = "upload", method = RequestMethod.POST)
    public Result upload(@DecryptParam("file") MultipartFile file){
        String src = newFileService.upload(file);
        return Result.success().put("data",src);
    }
}
