- 优化代码质量

v6
Chaim 4 years ago
parent 7694f7b24f
commit da38bbca15

@ -1,3 +1,6 @@
## v6.0.81 / 2020-07-12
- 优化代码质量
## v6.0.80 / 2020-07-12
- 优化描述

@ -73,7 +73,8 @@ class Mysql
'cache_value' => $cache_value,
'cache_expire' => Times::dateRear("Y-m-d H:i:s", $this->cache_expire)
]);
return $result ? true : false;
if (empty($result)) return false;
return true;
}
/**
@ -107,7 +108,8 @@ class Mysql
$result = Db::table($this->table)
->where('cache_name', $this->cache_name)
->delete();
return $result ? true : false;
if (empty($result)) return false;
return true;
}
/**
@ -126,7 +128,8 @@ class Mysql
'cache_value' => $cache_value,
'cache_expire' => Times::dateRear("Y-m-d H:i:s", $this->cache_expire)
]);
return $result ? true : false;
if (empty($result)) return false;
return true;
}
/**
@ -146,7 +149,8 @@ class Mysql
->update([
'cache_value' => $cache_value + $int
]);
return $result ? true : false;
if (empty($result)) return false;
return true;
}
/**
@ -166,6 +170,7 @@ class Mysql
->update([
'cache_value' => $cache_value - $int
]);
return $result ? true : false;
if (empty($result)) return false;
return true;
}
}

@ -28,7 +28,7 @@ use think\db\exception\ModelNotFoundException;
/**
* 定义当前版本
*/
const VERSION = '6.0.80';
const VERSION = '6.0.81';
if (!function_exists('get_ip_info')) {
/**

@ -36,6 +36,8 @@ use think\Facade;
* @method static bool folderZip(string $name, string $suffix_name = '.png', string $file_name = '*') 把文件夹里面的文件打包成zip文件
* @method static string getFiles(string $path) 获取目录下的所有文件和目录
* @method static bool rmFiles(string $path) 删除目录下的文件
* @method static bool judgeFile(string $path) 判断文件是否存在
* @method static bool judgeContents(string $path) 判断目录是否存在
*/
class Files extends Facade
{

@ -147,4 +147,26 @@ class Files
}
return true;
}
/**
* 判断文件是否存在
* @param string $path
* @return bool
*/
public function judgeFile(string $path): bool
{
if (file_exists($path)) return true;
return false;
}
/**
* 判断目录是否存在
* @param string $path
* @return bool
*/
public function judgeContents(string $path): bool
{
if (is_dir($path)) return true;
return false;
}
}

@ -20,6 +20,7 @@
namespace DtApp\ThinkLibrary\service\bt;
use DtApp\ThinkLibrary\exception\DtaException;
use DtApp\ThinkLibrary\facade\Files;
use DtApp\ThinkLibrary\Service;
use DtApp\ThinkLibrary\service\curl\BtService;
@ -346,14 +347,8 @@ class ApiService extends Service
public function toArray()
{
$this->getHttp();
switch ($this->where['type']) {
case 'sites':
$this->getDataWithOrderOpt();
break;
default:
$this->getDataWithCount();
break;
}
if ($this->where['type'] == 'sites') $this->getDataWithOrderOpt();
else $this->getDataWithCount();
if (empty($this->backtrack)) return [];
if (is_array($this->backtrack)) return $this->backtrack;
return json_decode($this->backtrack, true);
@ -386,7 +381,7 @@ class ApiService extends Service
//定义cookie保存位置
$file = app()->getRootPath() . 'runtime/dtapp/bt/cookie/';
$cookie_file = $file . md5($this->panel) . '.cookie';
is_dir($file) or mkdir($file, 0777, true);
if (empty(Files::judgeContents($file))) mkdir($file, 0777, true);
if (!file_exists($cookie_file)) {
$fp = fopen($cookie_file, 'w+');
fclose($fp);

Loading…
Cancel
Save