setGet.tpl 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {assign var="datetime" value=$file->GetFileCreateTime()}
  2. {assign var="namespace" value=$file->GetNamespace()}
  3. {assign var="classes" value=$file->GetClasses()}
  4. {assign var="uses" value=$file->GetUses()}
  5. <?php
  6. /**
  7. * Created by FFB.
  8. * Company: Shenzhen Zhixun Information Tec. Nanchang Com.
  9. * Copyright: ShenzhenZhixun
  10. * Email: eastbus@126.com
  11. * User: FFB
  12. * 文件不允许修改,自动生成
  13. */
  14. namespace {$namespace};
  15. {section name=index loop=$uses}
  16. use {{$uses[index]}};
  17. {/section}
  18. {section name=index loop=$classes}
  19. {assign var="className" value=$classes[index]->GetClassName()}
  20. {assign var="tableName" value=$classes[index]->GetTable()->GetName()}
  21. {assign var="attrs" value=$classes[index]->GetAttrs()}
  22. {assign var="extends" value=$classes[index]->GetExtends()}
  23. trait {$className}{foreach item=e from=$extends key=i}{if $i == 0} extends {/if}{$e}{/foreach}{
  24. {section name=index loop=$attrs}
  25. {assign var="fieldName" value=$attrs[index]->GetColumn()->GetName()}
  26. {assign var="fieldComment" value=$attrs[index]->GetColumn()->GetComment()}
  27. {assign var="attrName" value=$attrs[index]->GetName()}
  28. /**
  29. * ------------ 字段 {{$fieldName}}
  30. * ------------ 表字段注释: {{$fieldComment}}
  31. */
  32. public function set{{$attrName}}($val): self
  33. {
  34. $this->setAttr("{{$fieldName}}", $val);
  35. return $this;
  36. }
  37. public function get{{$attrName}}()
  38. {
  39. return $this->{{$fieldName}} ?? null;
  40. }
  41. // ---------------------------------------------
  42. {/section}
  43. }
  44. {/section}