roleAllow(UserRole::NORMAL_ADMIN); } protected function getParam(): IParam { return $this->param; } protected function run(Request $request): JsonResponse { $param = $this->param; try { $this->transaction->beginTransaction(); $currentContract = $this->loginUser()->getCurrentContract(); if (!$currentContract) { throw new AppCommonException("認証不正"); } $this->manager->initForModify($currentContract, $this->getTartgetUserId()); if (!$this->param->checkTimestamp($this->manager->getTimestamp())) { throw new ExclusiveException(); } $messages = $this->manager ->fill($param->toArray()) ->update(); if (count($messages) !== 0) { $this->transaction->rollBack(); return $this->validateErrorResponse($messages); } $this->transaction->commit(); } catch (Exception $e) { $this->transaction->rollBack(); throw $e; } return $this->successResponse(); } private function getTartgetUserId(): string { $loginUserRole = $this->loginUser()->user()->role; if ($this->param->id !== null) { if ($loginUserRole === UserRole::CONTRACT_ADMIN || $loginUserRole === UserRole::SUPER_ADMIN) { return $this->param->id; } else { throw new AppCommonException('認証不正'); } } return $this->loginUser()->user()->id; } }