-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修改了表结构重新生成模型,也不用担心会覆盖掉模型类中自己写的方法
- Loading branch information
Showing
3 changed files
with
91 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?= '<?php' ?> | ||
|
||
namespace <?= $namespace ?>\Base; | ||
|
||
use Imi\Model\Model; | ||
use Imi\Model\Annotation\Column; | ||
|
||
/** | ||
* <?= $className ?>Base | ||
|
||
<?php foreach($fields as $field):?> | ||
* @property <?= $field['phpType'] ?> $<?= $field['varName'] ?> | ||
|
||
<?php endforeach;?> | ||
*/ | ||
abstract class <?= $className ?>Base extends Model | ||
{ | ||
<?php | ||
foreach($fields as $field): | ||
?> | ||
/** | ||
* <?= $field['name'] ?><?= '' === $field['comment'] ? '' : (' - ' . $field['comment']) ?> | ||
* @Column(name="<?= $field['name'] ?>", type="<?= $field['type'] ?>", length=<?= $field['length'] ?>, accuracy=<?= $field['accuracy'] ?>, nullable=<?= json_encode($field['nullable']) ?>, default="<?= $field['default'] ?>", isPrimaryKey=<?= json_encode($field['isPrimaryKey']) ?>, primaryKeyIndex=<?= $field['primaryKeyIndex'] ?>, isAutoIncrement=<?= json_encode($field['isAutoIncrement']) ?>) | ||
* @var <?= $field['phpType'] ?> | ||
*/ | ||
protected $<?= $field['varName'] ?>; | ||
/** | ||
* 获取 <?= $field['varName'] ?><?= '' === $field['comment'] ? '' : (' - ' . $field['comment']) ?> | ||
* | ||
* @return <?= $field['phpType'] ?> | ||
*/ | ||
public function get<?= ucfirst($field['varName']) ?>() | ||
{ | ||
return $this-><?= $field['varName'] ?>; | ||
} | ||
|
||
/** | ||
* 赋值 <?= $field['varName'] ?><?= '' === $field['comment'] ? '' : (' - ' . $field['comment']) ?> | ||
|
||
* @param <?= $field['phpType'] ?> $<?= $field['varName'] ?> <?= $field['name'] ?> | ||
|
||
* @return static | ||
*/ | ||
public function set<?= ucfirst($field['varName']) ?>($<?= $field['varName'] ?>) | ||
{ | ||
$this-><?= $field['varName'] ?> = $<?= $field['varName'] ?>; | ||
return $this; | ||
} | ||
|
||
<?php | ||
endforeach; | ||
?> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters