mirror of
https://gitee.com/ulthon/ul-file-share.git
synced 2026-07-09 14:12:49 +08:00
Compare commits
4 Commits
v1.0.0-bet
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f07719496 | ||
|
|
c66cd4f275 | ||
|
|
f7954291b1 | ||
|
|
2e35902e46 |
@@ -57,10 +57,12 @@ class UploadFiles
|
||||
return Filesystem::disk(self::$disk)->delete($model_file->getData('save_name'));
|
||||
}
|
||||
|
||||
public static function save(Request $request)
|
||||
public static function save(Request $request, $type = null)
|
||||
{
|
||||
|
||||
if (is_null($type)) {
|
||||
$type = $request->param('type');
|
||||
}
|
||||
if (empty($type)) {
|
||||
return json_message('缺少类型参数');
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class File extends Common
|
||||
|
||||
UploadFiles::setDisks('safe');
|
||||
|
||||
return UploadFiles::save($request);
|
||||
return UploadFiles::save($request, 'fileshare');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
46
app/tools/controller/ClearFile.php
Normal file
46
app/tools/controller/ClearFile.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\tools\controller;
|
||||
|
||||
use app\model\Share;
|
||||
use app\model\ShareFiles;
|
||||
use think\facade\Filesystem;
|
||||
use think\facade\Log;
|
||||
use think\Request;
|
||||
|
||||
class ClearFile
|
||||
{
|
||||
public function do()
|
||||
{
|
||||
|
||||
$now_time = time();
|
||||
|
||||
$list_share = Share::where('create_time', '<', $now_time - 86400 * 10)->where('clear_time', 0)->select();
|
||||
|
||||
foreach ($list_share as $model_share) {
|
||||
|
||||
Log::debug('清空数据:' . $model_share->build_download_save_name);
|
||||
|
||||
if (Filesystem::disk('safe')->fileExists($model_share->build_download_save_name)) {
|
||||
Filesystem::disk('safe')->delete($model_share->build_download_save_name);
|
||||
}
|
||||
|
||||
$list_files = ShareFiles::where('share_id', $model_share->id)->select();
|
||||
|
||||
|
||||
foreach ($list_files as $model_files) {
|
||||
if (Filesystem::disk('safe')->fileExists($model_files->save_name)) {
|
||||
Filesystem::disk('safe')->delete($model_files->save_name);
|
||||
}
|
||||
$model_files->clear_time = time();
|
||||
$model_files->save();
|
||||
}
|
||||
|
||||
$model_share->clear_time = time();
|
||||
$model_share->status = 1;
|
||||
$model_share->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,15 +19,16 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1.0",
|
||||
"topthink/framework": "6.0.*",
|
||||
"topthink/think-orm": "2.0.*",
|
||||
"topthink/framework": "^6.0",
|
||||
"topthink/think-orm": "^2.0",
|
||||
"topthink/think-view": "^1.0",
|
||||
"topthink/think-migration": "^3.0",
|
||||
"topthink/think-helper": "^3.1",
|
||||
"topthink/think-captcha": "^3.0",
|
||||
"topthink/think-multi-app": "^1.0",
|
||||
"ulthon/user_hub_client": "^1.0",
|
||||
"alchemy/zippy": "^1.0"
|
||||
"alchemy/zippy": "^1.0",
|
||||
"topthink/think-filesystem": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/var-dumper": "^4.2"
|
||||
|
||||
@@ -45,6 +45,7 @@ class CreateTableShare extends Migrator
|
||||
->addColumn(ColumnFormat::integerTypeStatus('status'))
|
||||
->addColumn(ColumnFormat::integer('times_download'))
|
||||
->addColumn(ColumnFormat::integer('visit'))
|
||||
->addColumn(ColumnFormat::integer('clear_time')->setComment('清空数据时间'))
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,6 @@
|
||||
|
||||
$('.file-list .file-item').each(function (index, elem) {
|
||||
var fileData = $(elem).data('success')
|
||||
|
||||
fileList.push(fileData)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user