|
@@ -126,7 +126,6 @@ class SwrpcServerCom extends Command |
|
@@ -126,7 +126,6 @@ class SwrpcServerCom extends Command |
126
|
$this->error('SWRPC_SERVER_PORT未设置');
|
126
|
$this->error('SWRPC_SERVER_PORT未设置');
|
127
|
return -1;
|
127
|
return -1;
|
128
|
}
|
128
|
}
|
129
|
-
|
|
|
130
|
$logger = new Logger('swrpc');
|
129
|
$logger = new Logger('swrpc');
|
131
|
$logger->pushHandler(new StreamHandler(STDOUT, Logger::INFO));
|
130
|
$logger->pushHandler(new StreamHandler(STDOUT, Logger::INFO));
|
132
|
$server = new Server($name, $host, $port, [
|
131
|
$server = new Server($name, $host, $port, [
|
|
@@ -140,21 +139,21 @@ class SwrpcServerCom extends Command |
|
@@ -140,21 +139,21 @@ class SwrpcServerCom extends Command |
140
|
|
139
|
|
141
|
$filters = [];
|
140
|
$filters = [];
|
142
|
$specifyModules = $this->option('module') ? explode(',', $this->option('module')) : [];
|
141
|
$specifyModules = $this->option('module') ? explode(',', $this->option('module')) : [];
|
143
|
- $modules = Module::all();
|
|
|
144
|
- /** @var \Nwidart\Modules\Laravel\Module $module */
|
|
|
145
|
- foreach ($modules as $module) {
|
|
|
146
|
- if ($module->getName() == 'Common') {
|
|
|
147
|
- continue;
|
|
|
148
|
- }
|
142
|
+ $loader = require base_path('vendor').'/autoload.php';
|
|
|
143
|
+ // 获取注册的命名空间前缀并筛选出 Composer 包的命名空间
|
|
|
144
|
+ $prefixes = $loader->getPrefixesPsr4();
|
|
|
145
|
+ foreach ($prefixes as $key => $prefix) {
|
149
|
//如果有指定moudle,则只有指定的moudle会生成,否则会生成全部
|
146
|
//如果有指定moudle,则只有指定的moudle会生成,否则会生成全部
|
150
|
- if (count($specifyModules) > 0 && !in_array($module->getName(), $specifyModules)) {
|
147
|
+ if (count($specifyModules) > 0 && !in_array($key, $specifyModules, true)) {
|
151
|
continue;
|
148
|
continue;
|
152
|
}
|
149
|
}
|
153
|
- $namespace = ltrim(str_replace([base_path(), '/'], ['', '\\'], $module->getPath()), '\\') . '\\Services\\';
|
|
|
154
|
- $servicePath = $module->getPath() . '/Services';
|
150
|
+ $namespace = $key . 'Http\Service';
|
|
|
151
|
+ //fetch file
|
|
|
152
|
+ $servicePath = $prefix[0] . '/Http/Service';
|
155
|
if (!is_dir($servicePath)) {
|
153
|
if (!is_dir($servicePath)) {
|
156
|
continue;
|
154
|
continue;
|
157
|
}
|
155
|
}
|
|
|
156
|
+
|
158
|
$queues = scandir($servicePath);
|
157
|
$queues = scandir($servicePath);
|
159
|
while (count($queues) > 0) {
|
158
|
while (count($queues) > 0) {
|
160
|
$file = array_shift($queues);
|
159
|
$file = array_shift($queues);
|
|
@@ -199,7 +198,7 @@ class SwrpcServerCom extends Command |
|
@@ -199,7 +198,7 @@ class SwrpcServerCom extends Command |
199
|
*/
|
198
|
*/
|
200
|
protected function build($namespace, $class): ?object
|
199
|
protected function build($namespace, $class): ?object
|
201
|
{
|
200
|
{
|
202
|
- $serviceClass = str_replace('/', '\\', $namespace . $class);
|
201
|
+ $serviceClass = str_replace('/', '\\', $namespace . '\\' . $class);
|
203
|
if (!class_exists($serviceClass)) {
|
202
|
if (!class_exists($serviceClass)) {
|
204
|
$this->error($serviceClass . '类不存在');
|
203
|
$this->error($serviceClass . '类不存在');
|
205
|
return null;
|
204
|
return null;
|