Commit 770ece9a authored by 周智鹏's avatar 周智鹏
Browse files

更新micro-api-flow专用上传rpc 其余模块的申请rpc

parent 5bea017d
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -118,6 +118,50 @@ class UploadManager
        }
    }

    /**
     * 文件上传方法(micro-api-flow)
     * @param UploadedFile $file 上传的文件
     * @param array $options 配置参数
     * @param bool $realPath
     * @return string
     * @throws HttpResponseException
     */
    public static function uploadFileGetName($file, $options = [], $realPath = false)
    {
        $documentRoot = config('server.settings.document_root');
        if (!$documentRoot) {
            throw new \RuntimeException('未配置静态资源');
        }
        $options = self::parseOptions($options);
        if ($file->isValid()) {
            $extension = strtolower($file->getExtension());
            // 通过扩展名判断类型
            if (!in_array($extension, $options['mime'])) {
                throw new HttpResponseException('文件类型不支持,目前只支持' . implode(',', $options['mime']));
            }
            // 判断文件大小
            if ($file->getSize() > $options['maxSize']) {
                throw new HttpResponseException('文件超出系统规定的大小,最大不能超过' . num_2_file_size($options['maxSize']));
            }
            // 文件重命名,由当前日期时间 + 唯一ID + 扩展名
            $fileName = date('YmdHis') . uniqid() . '.' . $extension;
            $name = $file->toArray()['name'];
            $savePath = self::parsePath($options, $documentRoot) . $fileName.'_'.$name;
            $file->moveTo($savePath);
            if ($file->isMoved()) {
                if ($realPath) {
                    return $savePath;
                } else {
                    return str_replace($documentRoot, '', $savePath);
                }
            } else {
                throw new HttpResponseException('文件保存失败');
            }
        } else {
            throw new HttpResponseException('文件无效');
        }
    }

    /**
     * 生成头像
     * @return string|string[]
+17 −0
Original line number Diff line number Diff line
<?php


namespace Meibuyu\Micro\Service\Interfaces\Flow;


interface ProcessFormServiceInterface
{
    /**
     * 创建流程申请
     * @param $processId  流程id
     * @param $url        表单图片地址
     * @param $data       表单详细内容
     * @return mixed
     */
    public function createProcessForm($processId,$url,$data);
}
 No newline at end of file