feat(ReverseEngine):初始化工程

This commit is contained in:
huangzj
2020-04-26 11:01:26 +08:00
commit a84341447a
22 changed files with 1199 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
package entity
import "database/sql"
type ColumnMessage struct {
Field string //字段名称
Type string //字段类型
Collation sql.NullString //编码信息
Null sql.NullString //是否允许为空
Key sql.NullString //是否是主键
Default sql.NullString //默认值
Extra sql.NullString //不懂
Privileges sql.NullString //执行权限
Comment sql.NullString //注释信息
}
/*
返回结果判断是不是主键
*/
func (c *ColumnMessage) IsKey() bool {
if c.Key.Valid && c.Key.String == "PRI" {
return true
}
return false
}
/*
返回结果是否为空信息
*/
func (c *ColumnMessage) CanNull() bool {
if c.Null.Valid && c.Null.String == "NO" {
return false
}
return true
}
/*
返回注释信息,没有注释信息返回空字符串
*/
func (c *ColumnMessage) GetComment() string {
if c.Comment.Valid {
return c.Comment.String
}
return ""
}
/*
返回默认值信息
*/
func (c *ColumnMessage) GetDefault() string {
if c.Default.Valid {
return c.Default.String
}
return ""
}
+15
View File
@@ -0,0 +1,15 @@
package entity
type FieldMessage struct {
FiledName string //类型名称
FieldType string //类型
OriginType string //数据库原始类型
/*
正常情况下tag的组合是 `TagKey:"pk/ not null/ FieldType"`
*/
TagKey string //tag的key
IsKey bool //是否主键
Comment string //注释内容
Default string //默认值信息
CanNull bool //是否可以为空
}
+5
View File
@@ -0,0 +1,5 @@
package entity
type TableMessage struct {
TableName string //数据库表名
}