MARK_DOWN.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package main
  2. var MARK_DOWN = `###项目介绍
  3. ####特性:
  4. - xml配置RESTfull API、业务涉及的结构体(Bean)、数据库表结构。自动生成项目结构,形成开发规范
  5. - 自动化生成RESTfull API,绑定相关参数,不需要关心网络参数及返回相关的编码。
  6. - Bean生成通过配置形成生成,支持类型继承,自动将继承参数复制到新的结构体
  7. - 支持SqlMap,自动根据数据库结构生成。
  8. - 技术栈使用gin+xormplus
  9. ###开发准备
  10. - 1 请将以上go代码复制到: {!}{!}{!}$GOPATH/{project_name}/main.go{!}{!}{!}
  11. - 2 下载依赖包:
  12. - git clone https://git.qianqiusoft.com/qianqiusoft/light-apiengine.git $GOPATH/src/git.qianqiusoft.com/qianqiusoft/light-apiengine
  13. git clone https://git.qianqiusoft.com/qianqiusoft/light-apiengine-client.git $GOPATH/src/git.qianqiusoft.com/qianqiusoft/light-apiengine-client
  14. - 3 {!}{!}{!}cd $GOPATH/light-hello; go get && go build[code]{!}{!}{!}
  15. - 4 执行light-hello文件 {!}{!}{!}./{project_name}{!}{!}{!}
  16. - 5 程序自动生成相关项目文件,取消main.go两处注释即可
  17. {!}{!}{!}
  18. package main
  19. import (
  20. //生成代码后请手动取消此处注释
  21. //"{project_name}/routers"
  22. _ "github.com/go-sql-driver/mysql"
  23. "git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
  24. sysrouters "git.qianqiusoft.com/qianqiusoft/light-apiengine/routers"
  25. "git.qianqiusoft.com/qianqiusoft/light-apiengine-client/client"
  26. "git.qianqiusoft.com/qianqiusoft/light-apiengine/config"
  27. )
  28. func main() {
  29. if config.AppConfig.RunMode != "release" {
  30. go client.NewEngineClient("{project_name}").GenerateCurrentProject()
  31. }
  32. if config.AppConfig.RunMode != "gen" {
  33. apiengine := engine.Default()
  34. sysrouters.InitRouter(apiengine)
  35. //生成代码后请手动取消此处注释
  36. routers.InitRouter(apiengine)
  37. apiengine.Run()
  38. }
  39. }
  40. {!}{!}{!}
  41. ###开发项目
  42. 配置文件: {!}{!}{!}{project_name}.xml{!}{!}{!}
  43. 生成文件当中,以{!}{!}{!}_gen.go{!}{!}{!}结尾的文件都会被覆盖,请不要手动更改文件,如果开发过程中发现必须改这个文件的,可以提出来修改代码生成框架。
  44. ###RESTful API配置
  45. {!}{!}{!}
  46. <controllers>
  47. <controller name="busniess" desc="开发平台">
  48. <api name="generate" desc="生成数据" method="post">
  49. <!--参数ref表示接受Bean结点定义的类型,以$符号开头,如果是一般数据类型,请个别现象用type参数,如:type="string"-->
  50. <param name="hello" desc="配置文件" ref="$hello_bean"></param>
  51. <return>
  52. <!--此处定义返回值类型,建议用以下固定方式-->
  53. <success ref="$sys_return"></success>
  54. <failure ref="$sys_return"></failure>
  55. </return>
  56. </api>
  57. </controller>
  58. </controllers>
  59. {!}{!}{!}
  60. ###数据库表格配置
  61. {!}{!}{!}
  62. <tables>
  63. <table name="hello" desc="hellworld">
  64. <column isNull="false" isPK="true" name="id" caption="主键" dbtype="varchar(36)" type="string" size="36" />
  65. <column isNull="false" name="user_id" caption="用户ID" type="string" size="36" dbtype="varchar(36)"/>
  66. <column isNull="false" name="domain" caption="域" type="string" size="50" dbtype="varchar(50)"/>
  67. <column isNull="false" name="create_by" caption="创建人" type="string" size="36" dbtype="varchar(36)"/>
  68. <column isNull="false" name="create_time" caption="创建时间" type="datetime" />
  69. <column isNull="false" name="last_update_by" caption="最后更新人" type="string" size="36" dbtype="varchar(36)"/>
  70. <column isNull="false" name="last_update_date" caption="最后更新时间" type="datetime" />
  71. <column isNull="false" name="del_flag" caption="是否删除 0:删除 1:正常" type="int32"/>
  72. </table>
  73. </tables>
  74. {!}{!}{!}
  75. 代码生成器将会生成以下结构体代码:
  76. {!}{!}{!}
  77. type Hello struct {
  78. //主键
  79. Id string {!}xorm:"'id' varchar(36) pk notnull "json:"id"{!}
  80. //用户ID
  81. UserId string {!}xorm:"'user_id' varchar(36) notnull "json:"user_id"{!}
  82. //域
  83. Domain string {!}xorm:"'domain' varchar(50) notnull "json:"domain"{!}
  84. //创建人
  85. CreateBy string {!}xorm:"'create_by' varchar(36) notnull "json:"create_by"{!}
  86. //创建时间
  87. CreateTime time.Time {!}xorm:"'create_time' notnull "json:"create_time"{!}
  88. //最后更新人
  89. LastUpdateBy string {!}xorm:"'last_update_by' varchar(36) notnull "json:"last_update_by"{!}
  90. //最后更新时间
  91. LastUpdateDate time.Time {!}xorm:"'last_update_date' notnull "json:"last_update_date"{!}
  92. //是否删除 0:删除 1:正常
  93. DelFlag int32 {!}xorm:"'del_flag' notnull "json:"del_flag"{!}
  94. }
  95. {!}{!}{!}
  96. ###业务Bean配置
  97. {!}{!}{!}
  98. <beans>
  99. <bean name="hello_bean" desc="helloworld">
  100. <prop name="id" type="string" caption="id"></prop>
  101. <prop name="name" type="string" caption="name"></prop>
  102. </bean>
  103. </beans>
  104. {!}{!}{!}
  105. - 支持继承功能,如:
  106. {!}{!}{!}
  107. <beans>
  108. <bean name="my_bean" desc="helloworld" inher="$hello_bean">
  109. <prop name="prpo1" type="string" caption="id"></prop>
  110. <prop name="children" type="string array" caption="name"></prop>
  111. </bean>
  112. </beans>
  113. {!}{!}{!}
  114. 其中:{!}{!}{!}inher="$hello"{!}{!}{!}表示继承自Hello这个结构体,属性{!}{!}{!}children{!}{!}{!}的{!}{!}{!}type="string array"{!}{!}{!}表示string数组{!}{!}{!}[]string{!}{!}{!}将会生成以下代码:
  115. {!}{!}{!}
  116. type MyBean struct {
  117. //helloworld
  118. Id string {!}json:"id"{!}
  119. //helloworld
  120. Name string {!}json:"name"{!}
  121. //id
  122. Prpo1 string {!}json:"prpo1"{!}
  123. //name
  124. Children []MyBean {!}json:"children"{!}
  125. }
  126. {!}{!}{!}
  127. ###内置功能
  128. ###数据库配置
  129. - 1.打开config/app.conf
  130. - 2.配置数据源datasource结点
  131. - 注意:运行程序,程序会自动根据连接串连接到数据库并创建相关的表结构
  132. ###Docker发布镜像
  133. - 更改app.conf字段 runmode = release
  134. - 运行./build_docker.sh
  135. `