删除冗余代码&修复bug
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace catchAdmin\permissions\model;
|
namespace catchAdmin\permissions\model;
|
||||||
|
|
||||||
|
use catchAdmin\permissions\model\search\JobsSearch;
|
||||||
use catcher\base\CatchModel;
|
use catcher\base\CatchModel;
|
||||||
|
|
||||||
class Job extends CatchModel
|
class Job extends CatchModel
|
||||||
{
|
{
|
||||||
|
use JobsSearch;
|
||||||
|
|
||||||
protected $name = 'jobs';
|
protected $name = 'jobs';
|
||||||
|
|
||||||
protected $field = [
|
protected $field = [
|
||||||
|
@@ -54,7 +54,7 @@ class CatchAdmin
|
|||||||
*/
|
*/
|
||||||
public static function cacheDirectory(): string
|
public static function cacheDirectory(): string
|
||||||
{
|
{
|
||||||
return self::makeDirectory(app()->getRuntimePath() . self::NAME . DIRECTORY_SEPARATOR);
|
return self::makeDirectory(app()->getRuntimePath() . self::$root . DIRECTORY_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,6 +139,7 @@ class CatchAdmin
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @time 2019年12月12日
|
* @time 2019年12月12日
|
||||||
|
* @param bool $select
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getModulesInfo($select = true): array
|
public static function getModulesInfo($select = true): array
|
||||||
|
@@ -1,53 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace catcher\base;
|
namespace catcher\base;
|
||||||
|
|
||||||
use catcher\CatchAdmin;
|
|
||||||
|
|
||||||
abstract class CatchController
|
abstract class CatchController
|
||||||
{
|
{
|
||||||
/**public function __construct()
|
|
||||||
{
|
|
||||||
$this->loadConfig();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @time 2019年12月15日
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function loadConfig(): void
|
|
||||||
{
|
|
||||||
$module = explode('\\', get_class($this))[1];
|
|
||||||
|
|
||||||
$moduleConfig = CatchAdmin::moduleDirectory($module) . 'config.php';
|
|
||||||
|
|
||||||
if (file_exists(CatchAdmin::moduleDirectory($module) . 'config.php')) {
|
|
||||||
app()->config->load($moduleConfig);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @time 2019年12月13日
|
|
||||||
* @param $name
|
|
||||||
* @param $value
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __set($name, $value)
|
|
||||||
{
|
|
||||||
// TODO: Implement __set() method.
|
|
||||||
$this->{$name} = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __get($name)
|
|
||||||
{
|
|
||||||
// TODO: Implement __get() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __isset($name)
|
|
||||||
{
|
|
||||||
// TODO: Implement __isset() method.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,8 @@ namespace catcher\generate\factory;
|
|||||||
|
|
||||||
use catcher\exceptions\FailedException;
|
use catcher\exceptions\FailedException;
|
||||||
use catcher\generate\template\Model as Template;
|
use catcher\generate\template\Model as Template;
|
||||||
|
use catcher\Utils;
|
||||||
|
use Phinx\Util\Util;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\helper\Str;
|
use think\helper\Str;
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ class Model extends Factory
|
|||||||
}
|
}
|
||||||
|
|
||||||
$content = $template->useTrait($extra['soft_delete']) .
|
$content = $template->useTrait($extra['soft_delete']) .
|
||||||
$template->name($table) .
|
$template->name(str_replace(Utils::tablePrefix(), '', $table)) .
|
||||||
$template->field($this->parseField($table));
|
$template->field($this->parseField($table));
|
||||||
|
|
||||||
$class = $template->header() .
|
$class = $template->header() .
|
||||||
|
@@ -4,9 +4,11 @@ namespace catcher\library;
|
|||||||
use catcher\CatchAdmin;
|
use catcher\CatchAdmin;
|
||||||
use catcher\exceptions\FailedException;
|
use catcher\exceptions\FailedException;
|
||||||
use catcher\facade\Http;
|
use catcher\facade\Http;
|
||||||
|
use Doctrine\DBAL\Types\DateImmutableType;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\TransferStats;
|
use GuzzleHttp\TransferStats;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use function GuzzleHttp\Psr7\str;
|
||||||
use function GuzzleHttp\Psr7\stream_for;
|
use function GuzzleHttp\Psr7\stream_for;
|
||||||
|
|
||||||
class Compress
|
class Compress
|
||||||
@@ -34,19 +36,41 @@ class Compress
|
|||||||
throw new FailedException(sprintf('module 【%s】not found~', $moduleName));
|
throw new FailedException(sprintf('module 【%s】not found~', $moduleName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取模块内的所有文件
|
|
||||||
$files = $this->getFilesFromDir(CatchAdmin::directory() . $moduleName);
|
|
||||||
|
|
||||||
$packageZip = new \ZipArchive();
|
|
||||||
// zip 打包位置 默认打包在 catch 目录下
|
// zip 打包位置 默认打包在 catch 目录下
|
||||||
$zipPath = $zipPath ? : CatchAdmin::directory() . $moduleName . '.zip';
|
$zipPath = $zipPath ? : CatchAdmin::directory() . $moduleName . '.zip';
|
||||||
|
|
||||||
|
$this->dirToZip(CatchAdmin::directory() . $moduleName, $zipPath);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打包 dir
|
||||||
|
*
|
||||||
|
* @time 2020年07月13日
|
||||||
|
* @param $dir
|
||||||
|
* @param $zipPath
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function dirToZip($dir, $zipPath)
|
||||||
|
{
|
||||||
|
$packageZip = new \ZipArchive();
|
||||||
|
|
||||||
|
$files = $this->getFilesFromDir($dir);
|
||||||
|
|
||||||
$packageZip->open($zipPath, \ZipArchive::CREATE);
|
$packageZip->open($zipPath, \ZipArchive::CREATE);
|
||||||
$packageZip->addEmptyDir($moduleName);
|
|
||||||
|
// 获取 dir 目录作为 zip 的根目录
|
||||||
|
$d = explode(DIRECTORY_SEPARATOR, rtrim($dir, DIRECTORY_SEPARATOR));
|
||||||
|
|
||||||
|
$packageZip->addEmptyDir(array_pop($d));
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$baseName = basename($file);
|
$baseName = basename($file);
|
||||||
$localName = str_replace([CatchAdmin::directory(), $baseName], ['', ''], $file);
|
$localName = str_replace([implode(DIRECTORY_SEPARATOR, $d), $baseName], ['', ''], $file);
|
||||||
$packageZip->addFile($file, $localName . $baseName);
|
$packageZip->addFile($file, $localName . $baseName);
|
||||||
}
|
}
|
||||||
|
|
||||||
$packageZip->close();
|
$packageZip->close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user