123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- package main
- var MARK_DOWN = `###项目介绍
- ####特性:
- - xml配置RESTfull API、业务涉及的结构体(Bean)、数据库表结构。自动生成项目结构,形成开发规范
- - 自动化生成RESTfull API,绑定相关参数,不需要关心网络参数及返回相关的编码。
- - Bean生成通过配置形成生成,支持类型继承,自动将继承参数复制到新的结构体
- - 支持SqlMap,自动根据数据库结构生成。
- - 技术栈使用gin+xormplus
- ###开发准备
- - 1 请将以上go代码复制到: {!}{!}{!}$GOPATH/{project_name}/main.go{!}{!}{!}
- - 2 下载依赖包:
- - git clone https://git.qianqiusoft.com/qianqiusoft/light-apiengine.git $GOPATH/src/git.qianqiusoft.com/qianqiusoft/light-apiengine
- git clone https://git.qianqiusoft.com/qianqiusoft/light-apiengine-client.git $GOPATH/src/git.qianqiusoft.com/qianqiusoft/light-apiengine-client
- - 3 {!}{!}{!}cd $GOPATH/light-hello; go get && go build[code]{!}{!}{!}
- - 4 执行light-hello文件 {!}{!}{!}./{project_name}{!}{!}{!}
- - 5 程序自动生成相关项目文件,取消main.go两处注释即可
- {!}{!}{!}
- package main
- import (
- //生成代码后请手动取消此处注释
- //"{project_name}/routers"
- _ "github.com/go-sql-driver/mysql"
- "git.qianqiusoft.com/qianqiusoft/light-apiengine/engine"
- sysrouters "git.qianqiusoft.com/qianqiusoft/light-apiengine/routers"
- "git.qianqiusoft.com/qianqiusoft/light-apiengine-client/client"
- "git.qianqiusoft.com/qianqiusoft/light-apiengine/config"
- )
- func main() {
- if config.AppConfig.RunMode != "release" {
- go client.NewEngineClient("{project_name}").GenerateCurrentProject()
- }
- if config.AppConfig.RunMode != "gen" {
- apiengine := engine.Default()
- sysrouters.InitRouter(apiengine)
- //生成代码后请手动取消此处注释
- routers.InitRouter(apiengine)
- apiengine.Run()
- }
- }
- {!}{!}{!}
- ###开发项目
- 配置文件: {!}{!}{!}{project_name}.xml{!}{!}{!}
- 生成文件当中,以{!}{!}{!}_gen.go{!}{!}{!}结尾的文件都会被覆盖,请不要手动更改文件,如果开发过程中发现必须改这个文件的,可以提出来修改代码生成框架。
- ###RESTful API配置
- {!}{!}{!}
- <controllers>
- <controller name="busniess" desc="开发平台">
- <api name="generate" desc="生成数据" method="post">
- <!--参数ref表示接受Bean结点定义的类型,以$符号开头,如果是一般数据类型,请个别现象用type参数,如:type="string"-->
- <param name="hello" desc="配置文件" ref="$hello_bean"></param>
- <return>
- <!--此处定义返回值类型,建议用以下固定方式-->
- <success ref="$sys_return"></success>
- <failure ref="$sys_return"></failure>
- </return>
- </api>
- </controller>
- </controllers>
- {!}{!}{!}
- ###数据库表格配置
- {!}{!}{!}
- <tables>
- <table name="hello" desc="hellworld">
- <column isNull="false" isPK="true" name="id" caption="主键" dbtype="varchar(36)" type="string" size="36" />
- <column isNull="false" name="user_id" caption="用户ID" type="string" size="36" dbtype="varchar(36)"/>
- <column isNull="false" name="domain" caption="域" type="string" size="50" dbtype="varchar(50)"/>
- <column isNull="false" name="create_by" caption="创建人" type="string" size="36" dbtype="varchar(36)"/>
- <column isNull="false" name="create_time" caption="创建时间" type="datetime" />
- <column isNull="false" name="last_update_by" caption="最后更新人" type="string" size="36" dbtype="varchar(36)"/>
- <column isNull="false" name="last_update_date" caption="最后更新时间" type="datetime" />
- <column isNull="false" name="del_flag" caption="是否删除 0:删除 1:正常" type="int32"/>
- </table>
- </tables>
- {!}{!}{!}
- 代码生成器将会生成以下结构体代码:
- {!}{!}{!}
- type Hello struct {
- //主键
- Id string {!}xorm:"'id' varchar(36) pk notnull "json:"id"{!}
- //用户ID
- UserId string {!}xorm:"'user_id' varchar(36) notnull "json:"user_id"{!}
- //域
- Domain string {!}xorm:"'domain' varchar(50) notnull "json:"domain"{!}
- //创建人
- CreateBy string {!}xorm:"'create_by' varchar(36) notnull "json:"create_by"{!}
- //创建时间
- CreateTime time.Time {!}xorm:"'create_time' notnull "json:"create_time"{!}
- //最后更新人
- LastUpdateBy string {!}xorm:"'last_update_by' varchar(36) notnull "json:"last_update_by"{!}
- //最后更新时间
- LastUpdateDate time.Time {!}xorm:"'last_update_date' notnull "json:"last_update_date"{!}
- //是否删除 0:删除 1:正常
- DelFlag int32 {!}xorm:"'del_flag' notnull "json:"del_flag"{!}
- }
- {!}{!}{!}
- ###业务Bean配置
- {!}{!}{!}
- <beans>
- <bean name="hello_bean" desc="helloworld">
- <prop name="id" type="string" caption="id"></prop>
- <prop name="name" type="string" caption="name"></prop>
- </bean>
- </beans>
- {!}{!}{!}
- - 支持继承功能,如:
- {!}{!}{!}
- <beans>
- <bean name="my_bean" desc="helloworld" inher="$hello_bean">
- <prop name="prpo1" type="string" caption="id"></prop>
- <prop name="children" type="string array" caption="name"></prop>
- </bean>
- </beans>
- {!}{!}{!}
- 其中:{!}{!}{!}inher="$hello"{!}{!}{!}表示继承自Hello这个结构体,属性{!}{!}{!}children{!}{!}{!}的{!}{!}{!}type="string array"{!}{!}{!}表示string数组{!}{!}{!}[]string{!}{!}{!}将会生成以下代码:
- {!}{!}{!}
- type MyBean struct {
- //helloworld
- Id string {!}json:"id"{!}
- //helloworld
- Name string {!}json:"name"{!}
- //id
- Prpo1 string {!}json:"prpo1"{!}
- //name
- Children []MyBean {!}json:"children"{!}
- }
- {!}{!}{!}
- ###内置功能
- ###数据库配置
- - 1.打开config/app.conf
- - 2.配置数据源datasource结点
- - 注意:运行程序,程序会自动根据连接串连接到数据库并创建相关的表结构
- ###Docker发布镜像
- - 更改app.conf字段 runmode = release
- - 运行./build_docker.sh
- `
|