-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from sakuraovq/master
add entity gen
- Loading branch information
Showing
20 changed files
with
417 additions
and
295 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace {= namespace}; | ||
|
||
use Swoft\Db\Model; | ||
use Swoft\Db\Bean\Annotation\Column; | ||
use Swoft\Db\Bean\Annotation\Entity; | ||
use Swoft\Db\Bean\Annotation\Id; | ||
use Swoft\Db\Bean\Annotation\Table; | ||
use Swoft\Db\Annotation\Mapping\Column; | ||
use Swoft\Db\Annotation\Mapping\Entity; | ||
use Swoft\Db\Annotation\Mapping\Id; | ||
use Swoft\Db\Eloquent\Model; | ||
{= usespace} | ||
|
||
/** | ||
* @Entity() | ||
* @Table(name="{= tableName}") | ||
* {= tableComment} | ||
* Class {= entityName} | ||
* | ||
* @since 2.0 | ||
* | ||
* @Entity(table="{= tableName}"{= dbPool | raw}) | ||
*/ | ||
class {= entityName} extends Model | ||
{ | ||
{= properties | raw } | ||
|
||
{= methods | raw } | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
public function {= methodName}() | ||
{ | ||
return $this->{= property}; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* @var {= type} {= propertyName} | ||
* {= comment | raw} | ||
{= id} | ||
* @Column(name="{= column}", type="{= columnType}"{= default | raw }) | ||
{= required} | ||
* @Column({= columnDetail | raw}) | ||
* @var {= type} | ||
*/ | ||
private {= propertyName}; | ||
private {= propertyName}; |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/** | ||
* @param {= type} {= paramName} | ||
* @param {= paramType} {= paramName} | ||
* @return self | ||
*/ | ||
public function {= methodName}({= type} {= paramName}): self | ||
{ | ||
$this->{= property} = {= paramName}; | ||
|
||
return $this; | ||
} | ||
} |
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
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
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,54 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace Swoft\Devtool\Helper; | ||
|
||
|
||
/** | ||
* Class ConsoleHelper | ||
* | ||
* @since 2.0 | ||
*/ | ||
class ConsoleHelper | ||
{ | ||
|
||
|
||
/** | ||
* Send confirm question | ||
* | ||
* @param string $question question | ||
* @param bool $default Default value | ||
* | ||
* @return bool | ||
*/ | ||
public static function confirm(string $question, $default = true): bool | ||
{ | ||
if (!$question = trim($question)) { | ||
\output()->writeln('Please provide a question message!', true); | ||
} | ||
|
||
$question = ucfirst(trim($question, '?')); | ||
$default = (bool)$default; | ||
$defaultText = $default ? 'yes' : 'no'; | ||
$message = "<comment>$question ?</comment>\nPlease confirm (yes|no)[default:<info>$defaultText</info>]: "; | ||
|
||
while (true) { | ||
\output()->writeln($message, false); | ||
$answer = \input()->read(); | ||
|
||
if (empty($answer)) { | ||
return $default; | ||
} | ||
|
||
if (0 === stripos($answer, 'y')) { | ||
return true; | ||
} | ||
|
||
if (0 === stripos($answer, 'n')) { | ||
return false; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
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
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
Oops, something went wrong.