Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateAppcode(driver, connStr, level, tables, currpath string)
- func GenerateController(cname, currpath string)
- func GenerateHproseAppcode(driver, connStr, level, tables, currpath string)
- func GenerateMigration(mname, upsql, downsql, curpath string)
- func GenerateModel(mname, fields, currpath string)
- func GenerateScaffold(sname, fields, currpath, driver, conn string)
- func GenerateView(viewpath, currpath string)
- type Column
- type DBDriver
- type DbTransformer
- type ForeignKey
- type MvcPath
- type MysqlDB
- type OrmTag
- type PostgresDB
- func (postgresDB *PostgresDB) GetColumns(db *sql.DB, table *Table, blackList map[string]bool)
- func (*PostgresDB) GetConstraints(db *sql.DB, table *Table, blackList map[string]bool)
- func (*PostgresDB) GetGoDataType(sqlType string) (string, error)
- func (*PostgresDB) GetTableNames(db *sql.DB) (tables []string)
- type Table
Constants ¶
const ( OModel byte = 1 << iota OController ORouter )
const ( StructModelTPL = `package models {{importTimePkg}} {{modelStruct}} ` ModelTPL = `` /* 701-byte string literal not displayed */ PoTPL = `package po {{importTimePkg}} {{poStruct}} ` CtrlTPL = `` /* 535-byte string literal not displayed */ VoTPL = `package vo {{importTimePkg}} type {{voName}}SingleVo struct { ApiResponse Data {{voName}}Vo ` + "`json:\"data\"`" + ` } type {{voName}}ListVo struct { ApiResponse Data []{{voName}}Vo ` + "`json:\"data\"`" + ` } type {{voName}}PageListVo struct { ApiResponse Data {{voName}}PageList ` + "`json:\"data\"`" + ` } type {{voName}}PageList struct { Pagination List []{{voName}}Vo ` + "`json:\"list\"`" + ` } {{voStruct}} ` RouterTPL = `` /* 462-byte string literal not displayed */ NamespaceTPL = ` beego.NSNamespace("/{{nameSpace}}", beego.NSInclude( &controllers.{{ctrlName}}Controller{}, ), ), ` )
const ( HproseAddFunction = `` /* 407-byte string literal not displayed */ HproseStructModelTPL = `package models {{importTimePkg}} {{modelStruct}} ` HproseModelTPL = `` /* 3738-byte string literal not displayed */ )
const ( MPath = "migrations" MDateFormat = "20060102_150405" DBPath = "database" )
const ( MigrationHeader = `` /* 364-byte string literal not displayed */ DDLSpecCreate = `` /* 244-byte string literal not displayed */ DDLSpecAlter = `` /* 132-byte string literal not displayed */ MigrationUp = `` /* 143-byte string literal not displayed */ MigrationDown = `` /* 157-byte string literal not displayed */ )
Variables ¶
var DDL utils.DocValue
var Fields utils.DocValue
var HproseAddFunctions = []string{}
var HproseMainconngo = `` /* 844-byte string literal not displayed */
var HproseMaingo = `` /* 803-byte string literal not displayed */
var HproseModels = `` /* 997-byte string literal not displayed */
var HproseModels2 = `` /* 1572-byte string literal not displayed */
var Hproseconf = `appname = {{.Appname}}
httpport = 8080
runmode = dev
autorender = false
copyrequestbody = true
EnableDocs = true
`
var Level utils.DocValue
var SQLConn utils.DocValue
var SQLDriver utils.DocValue
var Tables utils.DocValue
Functions ¶
func GenerateAppcode ¶
func GenerateAppcode(driver, connStr, level, tables, currpath string)
func GenerateController ¶
func GenerateController(cname, currpath string)
func GenerateHproseAppcode ¶
func GenerateHproseAppcode(driver, connStr, level, tables, currpath string)
func GenerateMigration ¶
func GenerateMigration(mname, upsql, downsql, curpath string)
generateMigration generates migration file template for database schema update. The generated file template consists of an up() method for updating schema and a down() method for reverting the update.
func GenerateModel ¶
func GenerateModel(mname, fields, currpath string)
func GenerateScaffold ¶
func GenerateScaffold(sname, fields, currpath, driver, conn string)
Types ¶
type Column ¶
Column reprsents a column for a table
func (*Column) String ¶
String returns the source code string of a field in Table struct It maps to a column in database table. e.g. Id int `orm:"column(id);auto"`
func (*Column) StringWithoutOrmTag ¶
type DBDriver ¶
type DBDriver interface { GenerateCreateUp(tableName string) string GenerateCreateDown(tableName string) string }
func NewDBDriver ¶
func NewDBDriver() DBDriver
type DbTransformer ¶
type DbTransformer interface { GetTableNames(conn *sql.DB) []string GetConstraints(conn *sql.DB, table *Table, blackList map[string]bool) GetColumns(conn *sql.DB, table *Table, blackList map[string]bool) GetGoDataType(sqlType string) (string, error) }
DbTransformer has method to reverse engineer a database schema to restful api code
type ForeignKey ¶
ForeignKey represents a foreign key column for a table
type MysqlDB ¶
type MysqlDB struct { }
MysqlDB is the MySQL version of DbTransformer
func (*MysqlDB) GetColumns ¶
GetColumns retrieves columns details from information_schema and fill in the Column struct
func (*MysqlDB) GetConstraints ¶
GetConstraints gets primary key, unique key and foreign keys of a table from information_schema and fill in the Table struct
func (*MysqlDB) GetGoDataType ¶
GetGoDataType maps an SQL data type to Golang data type
type OrmTag ¶
type OrmTag struct { Auto bool Pk bool Null bool Index bool Unique bool Column string Size string Decimals string Digits string AutoNow bool AutoNowAdd bool Type string Default string RelOne bool ReverseOne bool RelFk bool ReverseMany bool RelM2M bool Comment string // column comment }
OrmTag contains Beego ORM tag information for a column
func (*OrmTag) StringWithoutOrm ¶
StringWithoutOrm returns the tag string for a column without orm
type PostgresDB ¶
type PostgresDB struct { }
PostgresDB is the PostgreSQL version of DbTransformer
func (*PostgresDB) GetColumns ¶
GetColumns for PostgreSQL
func (*PostgresDB) GetConstraints ¶
GetConstraints for PostgreSQL
func (*PostgresDB) GetGoDataType ¶
func (*PostgresDB) GetGoDataType(sqlType string) (string, error)
GetGoDataType returns the Go type from the mapped Postgres type
func (*PostgresDB) GetTableNames ¶
func (*PostgresDB) GetTableNames(db *sql.DB) (tables []string)
GetTableNames for PostgreSQL
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
@Time : 2019/9/3 10:37 @Author : duanqiangwen @File : config @Software: GoLand @Time : 2019/9/3 10:26 @Author : duanqiangwen @File : client @Software: GoLand @Time : 2019/9/3 11:40 @Author : duanqiangwen @File : doc_model @Software: GoLand
|
@Time : 2019/9/3 10:37 @Author : duanqiangwen @File : config @Software: GoLand @Time : 2019/9/3 10:26 @Author : duanqiangwen @File : client @Software: GoLand @Time : 2019/9/3 11:40 @Author : duanqiangwen @File : doc_model @Software: GoLand |
@Time : 2019/9/11 18:29 @Author : duanqiangwen @File : g_validation @Software: GoLand
|
@Time : 2019/9/11 18:29 @Author : duanqiangwen @File : g_validation @Software: GoLand |