package com.ruoyi.web.controller.tool;

import com.ruoyi.common.utils.FileUtil;
import com.ruoyi.framework.config.FileConfig;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.annotation.Post;
import org.noear.solon.core.handle.Result;
import org.noear.solon.core.handle.UploadedFile;

/**
 * 文件 操作处理
 * @author ruoyi
 */
@Controller
@Mapping("tool/file")
public class FileController {

    @Inject
    FileConfig fileConfig;

    /**
     * 单文件上传
     */
    @Post
    @Mapping("upload")
    public Result<String> upload(UploadedFile file) {
        return Result.succeed(FileUtil.upload(file, fileConfig.getMaxSize(), fileConfig.getFileType(), fileConfig.getSavePath(), fileConfig.getRequestPrefix()));
    }

}
