增加文件清理操作

This commit is contained in:
Anyon 2022-07-12 11:22:16 +08:00
parent 7526721b4a
commit 525834a40d
2 changed files with 17 additions and 0 deletions

View File

@ -80,4 +80,18 @@ class File extends Controller
{
SystemFile::mDelete();
}
/**
* 清理重复文件
* @auth true
* @return void
*/
public function distinct()
{
$map = ['uuid' => AdminService::getUserId()];
$db1 = SystemFile::mk()->fieldRaw('max(id) id')->where($map)->group('hash');
$db2 = $this->app->db->table($db1->buildSql())->alias('dt')->field('id');
SystemFile::mk()->whereRaw("id not in {$db2->buildSql()}")->delete();
$this->success('清理重复文件记录');
}
}

View File

@ -1,6 +1,9 @@
{extend name='table'}
{block name="button"}
<!--{if auth("distinct")}-->
<a data-table-id="FileTable" data-load='{:url("distinct")}' class='layui-btn layui-btn-sm layui-btn-primary'>清理重复</a>
<!--{/if}-->
<!--{if auth("remove")}-->
<a data-confirm="确定永久删除这些账号吗?" data-table-id="FileTable" data-action='{:url("remove")}' data-rule="id#{id}" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</a>
<!--{/if}-->