mirror of
https://github.com/ledccn/IYUUPlus.git
synced 2024-09-20 15:15:29 +00:00
fix:变更任务配置解析类的目录
This commit is contained in:
parent
9727629bd1
commit
13f28d4317
|
@ -45,7 +45,10 @@ class Handler extends ExceptionHandler
|
|||
'data' => [],
|
||||
'msg' => $error
|
||||
];
|
||||
$this->_debug && $rs['traces'] = (string)$exception;
|
||||
|
||||
if ($this->_debug) {
|
||||
$rs['traces'] = (string)$exception;
|
||||
}
|
||||
return new Response(200, $header, json_encode($rs, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use app\common\exception\BusinessException;
|
|||
use app\common\Config;
|
||||
use app\common\Constant;
|
||||
use app\domain\Config as domainConfig;
|
||||
use app\domain\Rss as domainRss;
|
||||
use app\domain\ConfigParser\Rss as domainRss;
|
||||
use app\domain\Users as domainUsers;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace app\controller;
|
|||
use support\Request;
|
||||
use support\Response;
|
||||
use app\domain\Crontab;
|
||||
use app\domain\Move as domainMove;
|
||||
use app\domain\Reseed as domainReseed;
|
||||
use app\domain\Rss as domainRss;
|
||||
use app\domain\ConfigParser\Move as domainMove;
|
||||
use app\domain\ConfigParser\Reseed as domainReseed;
|
||||
use app\domain\ConfigParser\Rss as domainRss;
|
||||
|
||||
/**
|
||||
* Class Task
|
||||
|
@ -24,7 +24,7 @@ class Task extends BaseController
|
|||
{
|
||||
$rs = self::RS;
|
||||
$uuid = $request->get('uuid');
|
||||
$rs['data'] = domainMove::configParser($uuid);
|
||||
$rs['data'] = domainMove::parser($uuid);
|
||||
return json($rs);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class Task extends BaseController
|
|||
{
|
||||
$rs = self::RS;
|
||||
$uuid = $request->get('uuid');
|
||||
$rs['data'] = domainReseed::configParser($uuid);
|
||||
$rs['data'] = domainReseed::parser($uuid);
|
||||
return json($rs);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class Task extends BaseController
|
|||
{
|
||||
$rs = self::RS;
|
||||
$uuid = $request->get('uuid');
|
||||
$rs['data'] = domainRss::configParser($uuid);
|
||||
$rs['data'] = domainRss::parser($uuid);
|
||||
return json($rs);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class Task extends BaseController
|
|||
$uuid = $request->get('uuid');
|
||||
$switch = $request->get('switch');
|
||||
//TODO...
|
||||
return json(domainReseed::configParser($uuid));
|
||||
return json(domainReseed::parser($uuid));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +93,7 @@ class Task extends BaseController
|
|||
$rs = self::RS;
|
||||
$uuid = $request->get('uuid');
|
||||
//TODO...
|
||||
return json(domainReseed::configParser($uuid));
|
||||
return json(domainReseed::parser($uuid));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
namespace app\domain;
|
||||
namespace app\domain\ConfigParser;
|
||||
|
||||
use app\domain\ConfigParserInterface;
|
||||
use app\domain\Config;
|
||||
|
||||
class Move implements ConfigParserInterface
|
||||
{
|
||||
|
@ -12,7 +15,7 @@ class Move implements ConfigParserInterface
|
|||
* @param string $uuid
|
||||
* @return array
|
||||
*/
|
||||
public static function configParser($uuid = ''):array
|
||||
public static function parser($uuid = ''):array
|
||||
{
|
||||
$rs = [
|
||||
'clients' => [],
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
namespace app\domain;
|
||||
namespace app\domain\ConfigParser;
|
||||
|
||||
use app\common\Config as Conf;
|
||||
use app\common\Constant;
|
||||
use app\domain\ConfigParserInterface;
|
||||
use app\domain\Config;
|
||||
use IYUU\Library\IFile;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ class Reseed implements ConfigParserInterface
|
|||
* @param string $uuid
|
||||
* @return array
|
||||
*/
|
||||
public static function configParser($uuid = ''):array
|
||||
public static function parser($uuid = ''):array
|
||||
{
|
||||
$rs = [
|
||||
'sites' => [],
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
namespace app\domain;
|
||||
namespace app\domain\ConfigParser;
|
||||
|
||||
use app\domain\ConfigParserInterface;
|
||||
use app\domain\Config;
|
||||
|
||||
class Rss implements ConfigParserInterface
|
||||
{
|
||||
|
@ -8,7 +11,7 @@ class Rss implements ConfigParserInterface
|
|||
* @param string $uuid
|
||||
* @return array
|
||||
*/
|
||||
public static function configParser($uuid = ''):array
|
||||
public static function parser($uuid = ''):array
|
||||
{
|
||||
$rs = [
|
||||
'site' => [],
|
|
@ -8,5 +8,5 @@ namespace app\domain;
|
|||
*/
|
||||
interface ConfigParserInterface
|
||||
{
|
||||
public static function configParser(array $uuid):array;
|
||||
public static function parser(string $uuid):array;
|
||||
}
|
|
@ -89,7 +89,6 @@ class Crontab
|
|||
$param['startTime'] = $param['startTime'] ?? time();
|
||||
$param['crontab'] = $param['crontab'] ?? self::parseCron($param);
|
||||
$param['command'] = self::parseCommand($param);
|
||||
//$param['command'] = $param['command'] ?? self::parseCommand($param);
|
||||
if (isset($param['switch']) && booleanParse($param['switch'])) {
|
||||
$filename = self::getFilePath($param['uuid'], self::cron_dir, self::cron_suffix);
|
||||
self::writeCronFile($filename, $param);
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
<?php
|
||||
namespace app\domain;
|
||||
|
||||
use IYUU\Library\IFile;
|
||||
use support\Request;
|
||||
use app\common\exception\BusinessException;
|
||||
use app\common\components\Curl;
|
||||
use app\common\Constant;
|
||||
use app\common\Config;
|
||||
use app\common\Config as Conf;
|
||||
|
||||
/**
|
||||
* 用户逻辑操作类 [无状态静态类]
|
||||
* 用户逻辑操作 [无状态静态类]
|
||||
* @access private 常驻内存运行,禁止执行器调用
|
||||
*/
|
||||
class Users
|
||||
|
@ -28,6 +27,9 @@ class Users
|
|||
|
||||
/**
|
||||
* 检查token及绑定状态
|
||||
* - 接口api.iyuu.cn返回的信息,原样返回给前端
|
||||
* @descr 接口地址 https://api.iyuu.cn/index.php?s=App.Api.Sites
|
||||
* 接口文档 https://api.iyuu.cn/docs.php?service=App.Api.Sites&detail=1&type=fold
|
||||
* @param string $token
|
||||
* @param Request $request
|
||||
* @return array
|
||||
|
@ -42,17 +44,20 @@ class Users
|
|||
$rs = json_decode($res->response, true);
|
||||
if (isset($rs['ret']) && ($rs['ret'] === 200) && isset($rs['data']['sites']) && is_array($rs['data']['sites'])) {
|
||||
$sites = array_column($rs['data']['sites'], null, 'site');
|
||||
Config::set('sites', $sites, Constant::config_format);
|
||||
Config::set('iyuu', ['iyuu.cn' => $token], Constant::config_format);
|
||||
Conf::set('sites', $sites, Constant::config_format);
|
||||
Conf::set('iyuu', ['iyuu.cn' => $token], Constant::config_format);
|
||||
// 验证通过,写入Session
|
||||
$session = $request->session();
|
||||
$session->set(Constant::Session_Token_Key, $token);
|
||||
} else {
|
||||
/**
|
||||
* 接口api.iyuu.cn在用户的token未激活时,会返回403状态码 和 推荐站点列表,供用户填写绑定信息
|
||||
*/
|
||||
if (isset($rs['ret']) && ($rs['ret'] === 403) && isset($rs['data']['recommend']) && is_array($rs['data']['recommend'])) {
|
||||
//用户未绑定合作站点
|
||||
$recommend = $rs['data']['recommend'];
|
||||
Config::set('recommend', $recommend, Constant::config_format);
|
||||
Config::set('iyuu', ['iyuu.cn' => $token], Constant::config_format);
|
||||
Conf::set('recommend', $recommend, Constant::config_format);
|
||||
Conf::set('iyuu', ['iyuu.cn' => $token], Constant::config_format);
|
||||
}
|
||||
}
|
||||
return $rs;
|
||||
|
@ -103,7 +108,7 @@ class Users
|
|||
if (empty($password)) {
|
||||
throw new BusinessException('密码不能为空', 250);
|
||||
}
|
||||
$userProfile = Config::get(self::getUserProfileName(), 'json');
|
||||
$userProfile = Conf::get(self::getUserProfileName(), 'json');
|
||||
if (is_null($userProfile)) {
|
||||
//初次使用,设置用户密码
|
||||
return self::setPassword($password);
|
||||
|
@ -140,7 +145,7 @@ class Users
|
|||
'created_at' => time()
|
||||
];
|
||||
|
||||
return Config::set(self::getUserProfileName(), $userProfile, 'json');
|
||||
return Conf::set(self::getUserProfileName(), $userProfile, 'json');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@ use IYUU\Client\AbstractClient;
|
|||
use IYUU\Library\IFile;
|
||||
use IYUU\Library\Table;
|
||||
use app\common\Constant;
|
||||
use app\domain\Reseed as domainReseed;
|
||||
use app\domain\ConfigParser\Reseed as domainReseed;
|
||||
use app\domain\Crontab as domainCrontab;
|
||||
|
||||
/**
|
||||
|
@ -144,7 +144,7 @@ class AutoReseed
|
|||
global $argv;
|
||||
$cron_name = isset($argv[1]) ? $argv[1] : null;
|
||||
is_null($cron_name) and die('缺少命令行参数。');
|
||||
self::$conf = domainReseed::configParser($cron_name);
|
||||
self::$conf = domainReseed::parser($cron_name);
|
||||
if (empty(self::$conf['sites']) || empty(self::$conf['clients'])) {
|
||||
die('解析计划任务失败:站点或客户端为空!可能当前任务已被停止或删除!'.PHP_EOL);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
namespace IYUU\Reseed;
|
||||
|
||||
use app\domain\Move as domainMove;
|
||||
use app\domain\ConfigParser\Move as domainMove;
|
||||
use app\domain\Crontab as domainCrontab;
|
||||
|
||||
class MoveTorrent extends AutoReseed
|
||||
|
@ -48,7 +48,7 @@ class MoveTorrent extends AutoReseed
|
|||
global $argv;
|
||||
$cron_name = isset($argv[1]) ? $argv[1] : null;
|
||||
is_null($cron_name) and die('缺少命令行参数。');
|
||||
self::$conf = domainMove::configParser($cron_name);
|
||||
self::$conf = domainMove::parser($cron_name);
|
||||
// 用户选择的下载器
|
||||
self::$clients = self::$conf['clients'];
|
||||
echo microtime(true).' 命令行参数解析完成!'.PHP_EOL;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace IYUU\Rss;
|
|||
use DOMDocument;
|
||||
use Curl\Curl;
|
||||
use IYUU\Library\Rpc;
|
||||
use app\domain\Rss as domainRss;
|
||||
use app\domain\ConfigParser\Rss as domainRss;
|
||||
|
||||
abstract class AbstractRss
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ abstract class AbstractRss
|
|||
*/
|
||||
protected static function getCliInput($uuid)
|
||||
{
|
||||
self::$conf = domainRss::configParser($uuid);
|
||||
self::$conf = domainRss::parser($uuid);
|
||||
if (empty(self::$conf['site'])) {
|
||||
die('解析计划任务失败:用户未配置的站点。'.PHP_EOL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user