Skip to content

Commit

Permalink
支持生成 Mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo committed Jun 30, 2024
1 parent 4e68309 commit b91e6ba
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Command/GenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ public function createModel(string $model, string $index): int
$code = str_replace('__MODEL__', $modelName, $code);
$code = str_replace('__INDEX__', $index, $code);

$mapping = $mapping[$index]['mappings']['properties'];
$properties = '';
foreach ($mapping as $property => $item) {
$properties .= "'{$property}' => ['type' => '{$item['type']}']," . PHP_EOL;
}

$code = str_replace('__MAPPING__', $properties, $code);

file_put_contents($modelPath, $code);

return 0;
Expand All @@ -122,6 +130,13 @@ public function getIndex(): string
{
return "__INDEX__";
}
public function getMapping(): array
{
return [
__MAPPING__
];
}
}';
}
}

0 comments on commit b91e6ba

Please sign in to comment.