success($this->tableService->getPageList($this->request->All())); } /** * 获取业务表字段信息 * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ #[GetMapping("getTableColumns")] public function getTableColumns(): ResponseInterface { return $this->success($this->columnService->getList($this->request->all())); } /** * 预览代码 * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface * @throws \Exception */ #[GetMapping("preview"), Permission("setting:code:preview")] public function preview(): ResponseInterface { return $this->success($this->tableService->preview((int) $this->request->input('id', 0))); } /** * 读取表数据 * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ #[GetMapping("readTable")] public function readTable(): ResponseInterface { return $this->success($this->tableService->read((int) $this->request->input('id'))); } /** * 更新业务表信息 * @param GenerateRequest $request * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ #[PostMapping("update"), Permission("setting:code:update")] public function update(GenerateRequest $request): ResponseInterface { return $this->tableService->updateTableAndColumns($request->validated()) ? $this->success() : $this->error(); } /** * 生成代码 * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ #[PostMapping("generate"), Permission("setting:code:generate"), OperationLog] public function generate(): ResponseInterface { return $this->_download( $this->tableService->generate((array) $this->request->input('ids', [])), 'mineadmin.zip' ); } /** * 加载数据表 * @param GenerateRequest $request * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ #[PostMapping("loadTable"), Permission("setting:code:loadTable"), OperationLog] public function loadTable(GenerateRequest $request): ResponseInterface { return $this->tableService->loadTable($request->input('names')) ? $this->success() : $this->error(); } /** * 删除代码生成表 * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ #[DeleteMapping("delete"), Permission("setting:code:delete"), OperationLog] public function delete(): ResponseInterface { return $this->tableService->delete((array) $this->request->input('ids', [])) ? $this->success() : $this->error(); } /** * 同步数据库中的表信息跟字段 * @param int $id * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ #[PutMapping("sync/{id}"), Permission("setting:code:sync"), OperationLog] public function sync(int $id): ResponseInterface { return $this->tableService->sync($id) ? $this->success() : $this->error(); } /** * 获取所有启用状态模块下的所有模型 * @return ResponseInterface * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ #[GetMapping("getModels")] public function getModels(): ResponseInterface { return $this->success($this->tableService->getModels()); } }