php
userRepository = $userRepository;
}
public function getUserById($userId) {
return $this->userRepository->findUserById($userId);
}
}
class UserRepository {
public function findUserById($userId) {
// 从数据库中查找用户信息
return "User" . $userId;
}
}
$userRepository = new UserRepository();
$userService = new UserService($userRepository);
$user = $userService->getUserById(1);
echo $user;
?>
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-