fix gocyclo support
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/xxjwxc/public/tools"
|
||||
)
|
||||
|
||||
// Execute
|
||||
// Execute exe the cmd
|
||||
func Execute() {
|
||||
|
||||
// var tt oauth_db.UserInfoTbl
|
||||
|
||||
@@ -46,3 +46,11 @@ func getTypeName(name string) string {
|
||||
|
||||
panic(fmt.Sprintf("type (%v) not match in any way.maybe need to add on (https://github.com/xxjwxc/gormt/blob/master/data/view/cnf/def.go)", name))
|
||||
}
|
||||
|
||||
func getUninStr(left, middle, right string) string {
|
||||
re := left
|
||||
if len(right) > 0 {
|
||||
re = left + middle + right
|
||||
}
|
||||
return re
|
||||
}
|
||||
|
||||
@@ -64,46 +64,39 @@ func (m *_Model) genTableElement(cols []ColumusInfo) (el []genstruct.GenElement)
|
||||
case ColumusKeyUnique: // unique key.唯一索引
|
||||
tmp.AddTag(_tagGorm, "unique")
|
||||
case ColumusKeyIndex: // index key.复合索引
|
||||
if len(v1.KeyName) > 0 {
|
||||
tmp.AddTag(_tagGorm, "index:"+v1.KeyName)
|
||||
} else {
|
||||
tmp.AddTag(_tagGorm, "index")
|
||||
}
|
||||
tmp.AddTag(_tagGorm, getUninStr("index", ":", v1.KeyName))
|
||||
case ColumusKeyUniqueIndex: // unique index key.唯一复合索引
|
||||
if len(v1.KeyName) > 0 {
|
||||
tmp.AddTag(_tagGorm, "unique_index:"+v1.KeyName)
|
||||
} else {
|
||||
tmp.AddTag(_tagGorm, "unique_index")
|
||||
}
|
||||
tmp.AddTag(_tagGorm, getUninStr("unique_index", ":", v1.KeyName))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not simple output
|
||||
if !config.GetSimple() && len(v.Name) > 0 {
|
||||
tmp.AddTag(_tagGorm, "column:"+v.Name)
|
||||
tmp.AddTag(_tagGorm, "type:"+v.Type)
|
||||
if !v.IsNull {
|
||||
tmp.AddTag(_tagGorm, "not null")
|
||||
if len(v.Name) > 0 {
|
||||
// not simple output
|
||||
if !config.GetSimple() {
|
||||
tmp.AddTag(_tagGorm, "column:"+v.Name)
|
||||
tmp.AddTag(_tagGorm, "type:"+v.Type)
|
||||
if !v.IsNull {
|
||||
tmp.AddTag(_tagGorm, "not null")
|
||||
}
|
||||
}
|
||||
|
||||
// json tag
|
||||
if config.GetIsJSONTag() {
|
||||
if strings.EqualFold(v.Name, "id") {
|
||||
tmp.AddTag(_tagJSON, "-")
|
||||
} else {
|
||||
tmp.AddTag(_tagJSON, mybigcamel.UnMarshal(v.Name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// json tag
|
||||
if config.GetIsJSONTag() {
|
||||
if strings.EqualFold(v.Name, "id") {
|
||||
tmp.AddTag(_tagJSON, "-")
|
||||
} else if len(v.Name) > 0 {
|
||||
tmp.AddTag(_tagJSON, mybigcamel.UnMarshal(v.Name))
|
||||
}
|
||||
}
|
||||
el = append(el, tmp)
|
||||
|
||||
// ForeignKey
|
||||
if config.GetIsForeignKey() && len(v.ForeignKeyList) > 0 {
|
||||
fklist := m.genForeignKey(v)
|
||||
if len(fklist) > 0 {
|
||||
el = append(el, fklist...)
|
||||
}
|
||||
el = append(el, fklist...)
|
||||
}
|
||||
// -----------end
|
||||
}
|
||||
@@ -185,3 +178,8 @@ func (m *_Model) getColumusKeyMulti(tableName, col string) (isMulti bool, isFind
|
||||
return false, false, ""
|
||||
// -----------------end
|
||||
}
|
||||
|
||||
// ///////////////////////// func
|
||||
func (m *_Model) generateFunc() {
|
||||
|
||||
}
|
||||
|
||||
1
go.mod
1
go.mod
@@ -3,6 +3,7 @@ module github.com/xxjwxc/gormt
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835 // indirect
|
||||
github.com/go-playground/universal-translator v0.17.0 // indirect
|
||||
github.com/jinzhu/gorm v1.9.11
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@@ -31,6 +31,8 @@ github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DP
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/ezbuy/tgen v0.0.0-20180109020500-95ef13895032/go.mod h1:OeW1N0acAlRaGTlOG8jRZZUKEtyiGa0qvD+lWNWb9vs=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835 h1:roDmqJ4Qes7hrDOsWsMCce0vQHz3xiMPjJ9m4c2eeNs=
|
||||
github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835/go.mod h1:BjL/N0+C+j9uNX+1xcNuM9vdSIcXCZrQZUYbXOFbgN8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
|
||||
Reference in New Issue
Block a user