소스 검색

Merge branch 'oss_12_31_liu'

rkljw 3 달 전
부모
커밋
15ea43cb73
9개의 변경된 파일339개의 추가작업 그리고 6개의 파일을 삭제
  1. 0 1
      .env
  2. 58 0
      app/Controller/MinioController.php
  3. 18 0
      app/JsonRpc/PublicRpcService.php
  4. 12 0
      app/JsonRpc/PublicRpcServiceInterface.php
  5. 1 0
      composer.json
  6. 219 1
      composer.lock
  7. 5 0
      config/api/public.php
  8. 5 4
      config/autoload/server.php
  9. 21 0
      config/autoload/services.php

+ 0 - 1
.env

@@ -35,4 +35,3 @@ WECHAT = https://api.weixin.qq.com/
 APPID = wx830ada852dd1707f
 #小程序SECRET
 APP_SECRET = 09d1ac9287cb6f3c5e81aa27a6b7138e
-#12

+ 58 - 0
app/Controller/MinioController.php

@@ -0,0 +1,58 @@
+<?php
+declare (strict_types = 1);
+namespace App\Controller;
+
+use App\JsonRpc\PublicRpcServiceInterface;
+use App\Tools\Result;
+use Hyperf\Di\Annotation\Inject;
+use Hyperf\Validation\Contract\ValidatorFactoryInterface;
+
+class MinioController extends AbstractController
+{
+    #[Inject]
+    protected ValidatorFactoryInterface $validationFactory;
+    /**
+     * @var PublicRpcServiceInterface
+     */
+    #[Inject]
+    private $publicServiceClient;
+
+    /**
+     * 获取所有的buckets
+     * @return array
+     */
+    public function listBuckets()
+    {
+       $result = $this->publicServiceClient->getBuckets([]);
+        // 直接返回服务层生成的响应
+       return Result::success($result['data']);
+    }
+
+    /**
+     * 上传文件
+     * @return array
+     */
+    public function uploadFiles()
+    {
+        $uploadedFile  = $this->request->file('file');
+        if ($uploadedFile && $uploadedFile->isValid()) {
+            $filename = $uploadedFile->getClientFilename();
+            $fileContent = base64_encode(file_get_contents($uploadedFile->getRealPath()));
+            $mimeType = $uploadedFile->getMimeType();
+            $data['fileContent'] = $fileContent;
+            $data['fileName'] = $filename;
+            $data['contentType'] = $mimeType;
+            $data['ext'] = $uploadedFile->getExtension();
+            $data['size'] = $uploadedFile->getSize();
+            $result = $this->publicServiceClient->uploadFile($data);
+            if($result['code']==200){
+                return Result::success($result['data']);
+            }else{
+                return Result::error("上传失败了!");
+            }
+        }else{
+            return Result::error("请选择需要上传的文件");
+        }
+
+    }
+}

+ 18 - 0
app/JsonRpc/PublicRpcService.php

@@ -217,4 +217,22 @@ class PublicRpcService extends AbstractServiceClient implements PublicRpcService
     {
         return $this->__request(__FUNCTION__, $data);
     }
+
+    /**
+     * @param array $data
+     * @return array|mixed
+     */
+    public function getBuckets(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+
+    /**
+     * @param array $data
+     * @return array|mixed
+     */
+    public function uploadFile(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
 }

+ 12 - 0
app/JsonRpc/PublicRpcServiceInterface.php

@@ -129,4 +129,16 @@ interface PublicRpcServiceInterface
      * 
      */
     public function modZhinengbumen(array $data);
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getBuckets(array $data);
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function uploadFile(array $data);
 }

+ 1 - 0
composer.json

@@ -13,6 +13,7 @@
     "license": "Apache-2.0",
     "require": {
         "php": ">=8.1",
+        "aws/aws-sdk-php": "^3.336",
         "death_satan/hyperf-validate": "^3.71",
         "doctrine/annotations": "^2.0",
         "easyswoole/verifycode": "3.x",

+ 219 - 1
composer.lock

@@ -4,8 +4,160 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "52cb6d820556611bfba432f00741d784",
+    "content-hash": "1720e871d24f37be6d7a2842f61de2fc",
     "packages": [
+        {
+            "name": "aws/aws-crt-php",
+            "version": "v1.2.7",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/awslabs/aws-crt-php.git",
+                "reference": "d71d9906c7bb63a28295447ba12e74723bd3730e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/awslabs/aws-crt-php/zipball/d71d9906c7bb63a28295447ba12e74723bd3730e",
+                "reference": "d71d9906c7bb63a28295447ba12e74723bd3730e",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.5"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.8.35||^5.6.3||^9.5",
+                "yoast/phpunit-polyfills": "^1.0"
+            },
+            "suggest": {
+                "ext-awscrt": "Make sure you install awscrt native extension to use any of the functionality."
+            },
+            "type": "library",
+            "autoload": {
+                "classmap": [
+                    "src/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "AWS SDK Common Runtime Team",
+                    "email": "aws-sdk-common-runtime@amazon.com"
+                }
+            ],
+            "description": "AWS Common Runtime for PHP",
+            "homepage": "https://github.com/awslabs/aws-crt-php",
+            "keywords": [
+                "amazon",
+                "aws",
+                "crt",
+                "sdk"
+            ],
+            "support": {
+                "issues": "https://github.com/awslabs/aws-crt-php/issues",
+                "source": "https://github.com/awslabs/aws-crt-php/tree/v1.2.7"
+            },
+            "time": "2024-10-18T22:15:13+00:00"
+        },
+        {
+            "name": "aws/aws-sdk-php",
+            "version": "3.336.6",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/aws/aws-sdk-php.git",
+                "reference": "0a99dab427f0a1c082775301141aeac3558691ad"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/0a99dab427f0a1c082775301141aeac3558691ad",
+                "reference": "0a99dab427f0a1c082775301141aeac3558691ad",
+                "shasum": ""
+            },
+            "require": {
+                "aws/aws-crt-php": "^1.2.3",
+                "ext-json": "*",
+                "ext-pcre": "*",
+                "ext-simplexml": "*",
+                "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5",
+                "guzzlehttp/promises": "^1.4.0 || ^2.0",
+                "guzzlehttp/psr7": "^1.9.1 || ^2.4.5",
+                "mtdowling/jmespath.php": "^2.6",
+                "php": ">=7.2.5",
+                "psr/http-message": "^1.0 || ^2.0"
+            },
+            "require-dev": {
+                "andrewsville/php-token-reflection": "^1.4",
+                "aws/aws-php-sns-message-validator": "~1.0",
+                "behat/behat": "~3.0",
+                "composer/composer": "^1.10.22",
+                "dms/phpunit-arraysubset-asserts": "^0.4.0",
+                "doctrine/cache": "~1.4",
+                "ext-dom": "*",
+                "ext-openssl": "*",
+                "ext-pcntl": "*",
+                "ext-sockets": "*",
+                "nette/neon": "^2.3",
+                "paragonie/random_compat": ">= 2",
+                "phpunit/phpunit": "^5.6.3 || ^8.5 || ^9.5",
+                "psr/cache": "^1.0 || ^2.0 || ^3.0",
+                "psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
+                "sebastian/comparator": "^1.2.3 || ^4.0",
+                "yoast/phpunit-polyfills": "^1.0"
+            },
+            "suggest": {
+                "aws/aws-php-sns-message-validator": "To validate incoming SNS notifications",
+                "doctrine/cache": "To use the DoctrineCacheAdapter",
+                "ext-curl": "To send requests using cURL",
+                "ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",
+                "ext-sockets": "To use client-side monitoring"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "3.0-dev"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "src/functions.php"
+                ],
+                "psr-4": {
+                    "Aws\\": "src/"
+                },
+                "exclude-from-classmap": [
+                    "src/data/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "Amazon Web Services",
+                    "homepage": "http://aws.amazon.com"
+                }
+            ],
+            "description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project",
+            "homepage": "http://aws.amazon.com/sdkforphp",
+            "keywords": [
+                "amazon",
+                "aws",
+                "cloud",
+                "dynamodb",
+                "ec2",
+                "glacier",
+                "s3",
+                "sdk"
+            ],
+            "support": {
+                "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
+                "issues": "https://github.com/aws/aws-sdk-php/issues",
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.336.6"
+            },
+            "time": "2024-12-28T04:16:13+00:00"
+        },
         {
             "name": "carbonphp/carbon-doctrine-types",
             "version": "3.2.0",
@@ -5538,6 +5690,72 @@
             ],
             "time": "2024-12-05T17:15:07+00:00"
         },
+        {
+            "name": "mtdowling/jmespath.php",
+            "version": "2.8.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/jmespath/jmespath.php.git",
+                "reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/a2a865e05d5f420b50cc2f85bb78d565db12a6bc",
+                "reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2.5 || ^8.0",
+                "symfony/polyfill-mbstring": "^1.17"
+            },
+            "require-dev": {
+                "composer/xdebug-handler": "^3.0.3",
+                "phpunit/phpunit": "^8.5.33"
+            },
+            "bin": [
+                "bin/jp.php"
+            ],
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.8-dev"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "src/JmesPath.php"
+                ],
+                "psr-4": {
+                    "JmesPath\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Graham Campbell",
+                    "email": "hello@gjcampbell.co.uk",
+                    "homepage": "https://github.com/GrahamCampbell"
+                },
+                {
+                    "name": "Michael Dowling",
+                    "email": "mtdowling@gmail.com",
+                    "homepage": "https://github.com/mtdowling"
+                }
+            ],
+            "description": "Declaratively specify how to extract elements from a JSON document",
+            "keywords": [
+                "json",
+                "jsonpath"
+            ],
+            "support": {
+                "issues": "https://github.com/jmespath/jmespath.php/issues",
+                "source": "https://github.com/jmespath/jmespath.php/tree/2.8.0"
+            },
+            "time": "2024-09-04T18:46:31+00:00"
+        },
         {
             "name": "nesbot/carbon",
             "version": "2.72.5",

+ 5 - 0
config/api/public.php

@@ -4,6 +4,7 @@ declare (strict_types = 1);
 use App\Controller\PublicController;
 use App\Middleware\Auth\FooMiddleware;
 use Hyperf\HttpServer\Router\Router;
+use App\Controller\MinioController;
 
 Router::addRoute(['GET', 'POST'], '/verifyCode', 'App\Controller\IndexController@verifyCode');
 
@@ -57,5 +58,9 @@ Router::addGroup(
         Router::get('/getLetterType', [PublicController::class, 'getLetterType']);
         //获取子类型
         Router::get('/getLetterTypeChildren', [PublicController::class, 'getLetterTypeChildren']);
+
+        Router::post('/buckets', [MinioController::class, 'listBuckets']);
+
+        Router::post('/uploadFiles', [MinioController::class, 'uploadFiles']);
     }
 );

+ 5 - 4
config/autoload/server.php

@@ -47,11 +47,12 @@ return [
         Constant::OPTION_WORKER_NUM => swoole_cpu_num(),
         Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid',
         Constant::OPTION_OPEN_TCP_NODELAY => true,
-        Constant::OPTION_MAX_COROUTINE => 100000,
+        Constant::OPTION_MAX_COROUTINE => 10 * 1024 * 1024,
         Constant::OPTION_OPEN_HTTP2_PROTOCOL => true,
-        Constant::OPTION_MAX_REQUEST => 100000,
-        Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024,
-        Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024,
+        Constant::OPTION_MAX_REQUEST => 10 * 1024 * 1024,
+        Constant::OPTION_SOCKET_BUFFER_SIZE => 10 * 1024 * 1024,
+        Constant::OPTION_BUFFER_OUTPUT_SIZE => 10 * 1024 * 1024,
+        Constant::OPTION_UPLOAD_MAX_FILESIZE => 10 * 1024 * 1024,
     ],
     'callbacks' => [
         Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'],

+ 21 - 0
config/autoload/services.php

@@ -46,6 +46,27 @@ return [
             'nodes' => [
                 ['host' => '127.0.0.1', 'port' => 9502],
             ],
+            'settings' => [
+                'open_length_check' => true,
+                'package_max_length' => 1024 * 1024, // 最大包长度
+                'package_length_type' => 'N',
+                'package_body_offset' => 8,
+                'package_length_offset' => 4,
+                'package_length_field' => 'length',
+            ],
+            'options' => [
+                'connect_timeout' => 50.0, // 连接超时时间,单位为秒
+                'read_timeout' => 100.0,   // 读取超时时间,单位为秒
+                'write_timeout' => 100.0,  // 写入超时时间,单位为秒
+            ],
+            'pool' => [
+                'min_connections' => 1,
+                'max_connections' => 30,
+                'connect_timeout' => 100.0, // 连接池连接超时时间,单位为秒
+                'wait_timeout' => 30.0,     // 等待连接池可用连接的超时时间,单位为秒
+                'heartbeat' => -1,         // 心跳检测间隔,-1 表示禁用心跳检测
+                'max_idle_time' => 60.0,   // 连接的最大空闲时间,单位为秒
+            ],
         ],
         [
             //资讯-新闻