项目初始化

This commit is contained in:
2026-03-18 17:19:03 +08:00
commit ac6079b9ff
602 changed files with 58291 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace app\admin\controller\routine;
use app\common\controller\Backend;
use app\common\model\Attachment as AttachmentModel;
use Webman\Http\Request;
use support\Response;
class Attachment extends Backend
{
protected ?object $model = null;
protected array|string $quickSearchField = 'name';
protected array $withJoinTable = ['admin', 'user'];
protected array|string $defaultSortField = ['last_upload_time' => 'desc'];
protected function initController(Request $request): ?Response
{
$this->model = new AttachmentModel();
return null;
}
public function del(Request $request): Response
{
$response = $this->initializeBackend($request);
if ($response !== null) return $response;
$where = [];
$dataLimitAdminIds = $this->getDataLimitAdminIds();
if ($dataLimitAdminIds) {
$where[] = [$this->dataLimitField, 'in', $dataLimitAdminIds];
}
$ids = $request->post('ids', $request->get('ids', []));
$ids = is_array($ids) ? $ids : [];
$where[] = [$this->model->getPk(), 'in', $ids];
$data = $this->model->where($where)->select();
$count = 0;
try {
foreach ($data as $v) {
$count += $v->delete();
}
} catch (\Throwable $e) {
return $this->error(__('%d records and files have been deleted', [$count]) . $e->getMessage());
}
return $count ? $this->success(__('%d records and files have been deleted', [$count])) : $this->error(__('No rows were deleted'));
}
}