fix: 更新文档清理工具

This commit is contained in:
邹景立 2025-03-11 19:50:31 +08:00
parent 71c66ca7fe
commit f6b10b676d

View File

@ -109,10 +109,8 @@ class File extends Controller
public function distinct()
{
$map = ['issafe' => 0, 'uuid' => AdminService::getUserId()];
$db1 = SystemFile::mk()->fieldRaw('max(id) id')->where($map)->group('type,xkey');
$db2 = $this->app->db->table($db1->buildSql())->alias('dt')->field('id');
SystemFile::mk()->where($map)->whereRaw("id not in {$db2->buildSql()}")->delete();
SystemFile::mk()->where($map)->where(['status' => 1])->delete();
$subQuery = SystemFile::mk()->fieldRaw('MAX(id) AS id')->where($map)->group('type, xkey')->buildSql();
SystemFile::mk()->where($map)->whereRaw("id NOT IN ({$subQuery})")->delete();
$this->success('清理重复文件成功!');
}
}