代码生成记录
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled

This commit is contained in:
2025-11-28 14:21:43 +08:00
parent 9720e1a9e0
commit ba073d6187

View File

@@ -9,6 +9,8 @@ use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class CodeGenerationService
@@ -72,6 +74,45 @@ class CodeGenerationService
$this->utils = UtilsService::getInstance();
}
/**
* 获取代码生成记录列表
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function list(): array
{
// ds(json_encode());
$page = request()->get('page', 1);
$pageSize = request()->get('pageSize', 20);
$title = request()->get('title', '');
$query = CodeGenerationModel::where('deleted_at', 0);
// 如果有标题搜索条件
if (!empty($title)) {
$query->where('title', 'like', '%' . $title . '%');
}
$result = $query->orderBy('id', 'desc')
->paginate($pageSize, ['id', 'title', 'file_name', 'params', 'created_at', 'updated_at'], 'page', $page)
->toArray();
foreach ($result['data'] as &$item) {
$item['params'] = json_decode($item['params'], true);
}
// /www/sites/nl-admin-api/index/nl-admin-api/storage/app/public/zip/code-generation/企业信息-69290eaaac899.zip
// www\sites\nl-admin-api\index\nl-admin-api\storage\app\public\zip\code-generation\企业信息-69290eaaac899.zip
return [
'page' => $result['current_page'],
'size' => $result['per_page'],
'page_count' => $result['last_page'],
'total' => $result['total'],
'items' => $result['data'],
];
}
/**
* 获取实例
* @return null|static