123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- {assign var="datetime" value=$file->GetFileCreateTime()}
- {assign var="namespace" value=$file->GetNamespace()}
- {assign var="classes" value=$file->GetClasses()}
- {assign var="uses" value=$file->GetUses()}
- <?php
- /**
- * Created by FFB.
- * Company: Shenzhen Zhixun Information Tec. Nanchang Com.
- * Copyright: ShenzhenZhixun
- * Email: eastbus@126.com
- * User: FFB
- * Date: {$datetime}
- * 文件不允许修改,自动生成
- */
- namespace {$namespace};
- {section name=index loop=$uses}
- use {{$uses[index]}};
- {/section}
- {section name=index loop=$classes}
- {assign var="className" value=$classes[index]->GetClassName()}
- {assign var="tableName" value=$classes[index]->GetTable()->GetName()}
- {assign var="tableNameHump" value=$classes[index]->GetTable()->GetNameForHump()}
- {assign var="attrs" value=$classes[index]->GetAttrs()}
- {assign var="extends" value=$classes[index]->GetExtends()}
- class {$className}{foreach item=e from=$extends key=i}{if $i == 0} extends {/if}{$e}{/foreach}{
- public function __construct($config = [])
- {
- parent::__construct({$tableNameHump}::class, $config);
- }
- /**
- * @param null $db
- * @return {$tableNameHump} | null | array
- */
- public function one($db = null)
- {
- return parent::one($db);
- }
- /**
- * @param null $db
- * @return array | {$tableNameHump}[]
- */
- public function all($db = null)
- {
- return parent::all($db);
- }
- public static function tableName()
- {
- return '{literal}{{{/literal}{{$tableName}}{literal}}}{/literal}';
- }
- {section name=index loop=$attrs}
- {assign var="fieldName" value=$attrs[index]->GetColumn()->GetName()}
- {assign var="fieldComment" value=$attrs[index]->GetColumn()->GetComment()}
- {assign var="attrName" value=$attrs[index]->GetName()}
- /**
- * ------------ 字段 {{$fieldName}}
- * ------------ 表字段注释: {{$fieldComment}}
- * 如果$val不是function,通过传入的值,直接组成['tableName' => $val]给到where方法
- * 如果是function,则闭包函数的类型为 function(string $tableName, ActiveQuery $activeQuery)
- * @param mixed | callable
- */
- public function filterBy{{$attrName}}($val): self
- {
- if(is_callable($val)){
- $val("{{$fieldName}}", $this);
- return $this;
- }
- $this->andWhere(["{{$fieldName}}" => $val]);
- return $this;
- }
- // ---------------------------------------------
- {/section}
- }
- {/section}
|