function.ftl 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <#--获取查询数据类型-->
  2. <#function getDataType colType start>
  3. <#if (colType=="long") > <#return "L">
  4. <#elseif (colType=="int")><#return "N">
  5. <#elseif (colType=="double")><#return "BD">
  6. <#elseif (colType=="Short")><#return "SN">
  7. <#elseif (colType=="Date" && start=="1")><#return "DL">
  8. <#elseif (colType=="Date" && start=="0")><#return "DG">
  9. <#else><#return "SL"></#if>
  10. </#function>
  11. <#--将字符串 user_id 转换为 类似userId-->
  12. <#function convertUnderLine field>
  13. <#assign rtn><#list field?split("_") as x><#if (x_index==0)><#if x?length==1>${x?upper_case}<#else>${x?lower_case}</#if><#else>${x?lower_case?cap_first}</#if></#list></#assign>
  14. <#return rtn>
  15. </#function>
  16. <#function getPk table>
  17. <#assign rtn><#if (table.pkModel??) >${table.pkModel.columnName}<#else>id</#if></#assign>
  18. <#return rtn>
  19. </#function>
  20. <#--获取主键类型-->
  21. <#function getPkType table>
  22. <#list table.columnList as col>
  23. <#if col.isPK>
  24. <#if (col.colType=="Integer")><#assign rtn>"Long"</#assign><#return rtn>
  25. <#else><#assign pkType=col.colType ></#if>
  26. </#if>
  27. </#list>
  28. <#assign rtn>${pkType}</#assign>
  29. <#return rtn>
  30. </#function>
  31. <#--获取外键类型 没有则返回Long-->
  32. <#function getFkType table>
  33. <#assign fk=table.foreignKey>
  34. <#list table.fieldList as col>
  35. <#if (col.fieldName?lower_case)==(fk?lower_case)>
  36. <#if (col.fieldType=="Integer")><#assign rtn>Long</#assign><#return rtn><#else><#assign rtn>${col.fieldType}</#assign><#return rtn></#if>
  37. </#if>
  38. </#list>
  39. <#assign rtn>Long</#assign><#return rtn>
  40. </#function>
  41. <#function getPkVar table>
  42. <#assign pkField=table.pkField>
  43. <#assign rtn><#if (table.pkModel??) ><#noparse>${</#noparse>${table.pkModel.columnName}<#noparse>}</#noparse><#else>"id"</#if></#assign>
  44. <#return rtn>
  45. </#function>
  46. <#function getJdbcType dataType>
  47. <#assign dbtype=dataType?lower_case>
  48. <#assign rtn>
  49. <#if dbtype?ends_with("int") || (dbtype=="double") || (dbtype=="float") || (dbtype=="decimal") || dbtype?ends_with("number")||dbtype?starts_with("numeric") >
  50. NUMERIC
  51. <#elseif (dbtype?index_of("char")>-1) >
  52. VARCHAR
  53. <#elseif (dbtype=="date") || (dbtype=="datetime") >
  54. DATE
  55. <#elseif (dbtype?index_of("timestamp")>-1)>
  56. TIMESTAMP
  57. <#elseif (dbtype?ends_with("text") || dbtype?ends_with("clob")) >
  58. CLOB
  59. </#if></#assign>
  60. <#return rtn?trim>
  61. </#function>
  62. <#function isSubTableExist subtables>
  63. <#assign rtn=false>
  64. <#if subtables?exists && subtables?size!=0>
  65. <#assign rtn=true>
  66. </#if>
  67. <#return rtn>
  68. </#function>
  69. <#function supportFlow table>
  70. <#assign rtn=false>
  71. <#if table.variable.flowKey?exists>
  72. <#assign rtn=true>
  73. </#if>
  74. <#return rtn>
  75. </#function>
  76. <#function getComment table>
  77. <#assign comment=table.tabComment>
  78. <#if !comment?exists>
  79. <#assign comment=table.tableName>
  80. </#if>
  81. <#return comment>
  82. </#function>