feat(goctl):Add ignore-columns flag (#2407)
* fix #2074,#2100 * format code * fix #2397 * format code * Support comma spliter * format code
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package gen
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/collection"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/model/sql/template"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/util"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
||||
@@ -32,6 +34,17 @@ func genVars(table Table, withCache, postgreSql bool) (string, error) {
|
||||
"withCache": withCache,
|
||||
"postgreSql": postgreSql,
|
||||
"data": table,
|
||||
"ignoreColumns": func() string {
|
||||
var set = collection.NewSet()
|
||||
for _, c := range table.ignoreColumns {
|
||||
if postgreSql {
|
||||
set.AddStr(fmt.Sprintf(`"%s"`, c))
|
||||
} else {
|
||||
set.AddStr(fmt.Sprintf("\"`%s`\"", c))
|
||||
}
|
||||
}
|
||||
return strings.Join(set.KeysStr(), ", ")
|
||||
}(),
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user