Ver Fonte

ComposerUpdate

Anyon há 4 anos atrás
pai
commit
335c528999

+ 4 - 4
composer.lock

@@ -929,12 +929,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/zoujingli/ThinkLibrary.git",
-                "reference": "3f1bb860cc95d7c15bb561b14ef21d295f5a8b7b"
+                "reference": "8626798197fcdef636619e59b7151ca9f2952f63"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/3f1bb860cc95d7c15bb561b14ef21d295f5a8b7b",
-                "reference": "3f1bb860cc95d7c15bb561b14ef21d295f5a8b7b",
+                "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/8626798197fcdef636619e59b7151ca9f2952f63",
+                "reference": "8626798197fcdef636619e59b7151ca9f2952f63",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -978,7 +978,7 @@
             ],
             "description": "ThinkPHP v6.0 Development Library",
             "homepage": "http://framework.thinkadmin.top",
-            "time": "2020-06-19T03:39:45+00:00"
+            "time": "2020-06-20T09:56:03+00:00"
         },
         {
             "name": "zoujingli/wechat-developer",

+ 2 - 0
vendor/composer/autoload_classmap.php

@@ -278,7 +278,9 @@ return array(
     'think\\admin\\service\\InstallService' => $vendorDir . '/zoujingli/think-library/src/service/InstallService.php',
     'think\\admin\\service\\MenuService' => $vendorDir . '/zoujingli/think-library/src/service/MenuService.php',
     'think\\admin\\service\\MessageService' => $vendorDir . '/zoujingli/think-library/src/service/MessageService.php',
+    'think\\admin\\service\\ModuleService' => $vendorDir . '/zoujingli/think-library/src/service/ModuleService.php',
     'think\\admin\\service\\NodeService' => $vendorDir . '/zoujingli/think-library/src/service/NodeService.php',
+    'think\\admin\\service\\OpenService' => $vendorDir . '/zoujingli/think-library/src/service/OpenService.php',
     'think\\admin\\service\\ProcessService' => $vendorDir . '/zoujingli/think-library/src/service/ProcessService.php',
     'think\\admin\\service\\QueueService' => $vendorDir . '/zoujingli/think-library/src/service/QueueService.php',
     'think\\admin\\service\\SystemService' => $vendorDir . '/zoujingli/think-library/src/service/SystemService.php',

+ 2 - 0
vendor/composer/autoload_static.php

@@ -411,7 +411,9 @@ class ComposerStaticInitb911c14a0826c73d9f097343fd33a252
         'think\\admin\\service\\InstallService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/InstallService.php',
         'think\\admin\\service\\MenuService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/MenuService.php',
         'think\\admin\\service\\MessageService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/MessageService.php',
+        'think\\admin\\service\\ModuleService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/ModuleService.php',
         'think\\admin\\service\\NodeService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/NodeService.php',
+        'think\\admin\\service\\OpenService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/OpenService.php',
         'think\\admin\\service\\ProcessService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/ProcessService.php',
         'think\\admin\\service\\QueueService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/QueueService.php',
         'think\\admin\\service\\SystemService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/SystemService.php',

+ 4 - 4
vendor/composer/installed.json

@@ -955,12 +955,12 @@
         "source": {
             "type": "git",
             "url": "https://github.com/zoujingli/ThinkLibrary.git",
-            "reference": "3f1bb860cc95d7c15bb561b14ef21d295f5a8b7b"
+            "reference": "8626798197fcdef636619e59b7151ca9f2952f63"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/3f1bb860cc95d7c15bb561b14ef21d295f5a8b7b",
-            "reference": "3f1bb860cc95d7c15bb561b14ef21d295f5a8b7b",
+            "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/8626798197fcdef636619e59b7151ca9f2952f63",
+            "reference": "8626798197fcdef636619e59b7151ca9f2952f63",
             "shasum": "",
             "mirrors": [
                 {
@@ -976,7 +976,7 @@
             "ext-json": "*",
             "topthink/framework": "^6.0"
         },
-        "time": "2020-06-19T03:39:45+00:00",
+        "time": "2020-06-20T09:56:03+00:00",
         "type": "library",
         "extra": {
             "think": {

+ 1 - 1
vendor/services.php

@@ -1,5 +1,5 @@
 <?php 
-// This file is automatically generated at:2020-06-19 11:47:46
+// This file is automatically generated at:2020-06-20 18:06:40
 declare (strict_types = 1);
 return array (
   0 => 'think\\app\\Service',

+ 97 - 0
vendor/zoujingli/think-library/src/service/ModuleService.php

@@ -0,0 +1,97 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: https://gitee.com/zoujingli/ThinkLibrary
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkLibrary
+// | github 代码仓库:https://github.com/zoujingli/ThinkLibrary
+// +----------------------------------------------------------------------
+
+namespace think\admin\service;
+
+use think\admin\Service;
+use ZipArchive;
+
+/**
+ * 应用模块安装服务
+ * Class ModuleService
+ * @package think\admin\service
+ */
+class ModuleService extends Service
+{
+
+    /**
+     * 安装应用模块
+     * @param string $name 模块名称
+     * @param ZipArchive $file 安装包
+     * @return array
+     */
+    public function install($name, ZipArchive $file)
+    {
+        // 安装包检查
+        list($state, $message) = $this->checkInstall($name, $file);
+        if (empty($state)) return [$state, $message];
+        // 执行文件安装
+        if ($file->extractTo($this->app->getBasePath() . $name)) {
+            return [1, '应用模块安装成功'];
+        } else {
+            return [0, '应用模块安装失败'];
+        }
+    }
+
+    /**
+     * 移除应用模块
+     * @param string $name
+     */
+    public function remove($name)
+    {
+        $directory = $this->app->getBasePath() . $name;
+        $this->forceRemove($directory);
+    }
+
+    /**
+     * 检测安装包是否正常
+     * @param string $name 模块名称
+     * @param ZipArchive $file 安装包
+     * @return array
+     */
+    private function checkInstall($name, ZipArchive $file)
+    {
+        $directory = "{$file->filename}.files";
+        file_exists($directory) || mkdir($directory, 0755, true);
+        // 尝试解压应用安装包
+        if ($file->extractTo($directory) === false) {
+            return [0, '应用模块压缩文件解压失败'];
+        }
+        // 检测应用模块配置文件
+        $info = @include($directory . DIRECTORY_SEPARATOR . 'app.php');
+        $this->forceRemove($directory);
+        // 返回应用模块检查结果
+        if (empty($info)) return [0, '未获取到应用模块配置信息'];
+        if ($info['name'] !== $name) return [0, '应用模块名称与注册名称不一致'];
+        return [1, '应用模块基础检查通过'];
+    }
+
+    /**
+     * 强制删除指定的目录
+     * @param string $directory
+     */
+    private function forceRemove($directory)
+    {
+        if (file_exists($directory) && is_dir($directory) && $handle = opendir($directory)) {
+            while (false !== ($item = readdir($handle))) if (!in_array($item, ['.', '..'])) {
+                $this->forceRemove("{$directory}/{$item}");
+            }
+            [closedir($handle), rmdir($directory)];
+        } else {
+            file_exists($directory) && is_file($directory) && @unlink($directory);
+        }
+    }
+
+}

+ 75 - 0
vendor/zoujingli/think-library/src/service/OpenService.php

@@ -0,0 +1,75 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: https://gitee.com/zoujingli/ThinkLibrary
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkLibrary
+// | github 代码仓库:https://github.com/zoujingli/ThinkLibrary
+// +----------------------------------------------------------------------
+
+namespace think\admin\service;
+
+use think\admin\extend\HttpExtend;
+use think\admin\Service;
+use think\App;
+
+/**
+ * 楚才开放平台服务
+ * Class OpenService
+ * @package think\admin\service
+ */
+class OpenService extends Service
+{
+    /**
+     * 接口账号
+     * @var string
+     */
+    protected $appid;
+
+    /**
+     * 接口密钥
+     * @var string
+     */
+    protected $appkey;
+
+    /**
+     * 楚才开放平台初始化
+     * OpenService constructor.
+     * @param App $app
+     * @param string $appid 接口账号
+     * @param string $appkey 接口密钥
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function __construct(App $app, $appid = '', $appkey = '')
+    {
+        parent::__construct($app);
+        $this->appid = $appid ?: sysconf('data.cuci_open_appid');
+        $this->appkey = $appkey ?: sysconf('data.cuci_open_appkey');
+    }
+
+    /**
+     * 接口数据请求
+     * @param string $uri 接口地址
+     * @param array $data 请求数据
+     * @return array
+     * @throws \think\admin\Exception
+     */
+    public function doRequest(string $uri, array $data = [])
+    {
+        [$time, $nostr, $json] = [time(), uniqid(), json_encode($data)];
+        $sign = md5($this->appid . '#' . $json . '#' . $time . '#' . $this->appkey . '#' . $nostr);
+        $data = ['appid' => $this->appid, 'time' => $time, 'nostr' => $nostr, 'sign' => $sign, 'data' => $json];
+        $result = json_decode(HttpExtend::post("https://open.cuci.cc/{$uri}", $data), true);
+        if (empty($result)) throw new \think\admin\Exception('接口响应异常');
+        if (empty($result['code'])) throw new \think\admin\Exception($result['info']);
+        return $result['data'] ?? [];
+    }
+}