feature 1.1.5 (#411)
This commit is contained in:
@@ -12,12 +12,9 @@ import (
|
||||
func genInsert(table Table, withCache bool) (string, string, error) {
|
||||
keySet := collection.NewSet()
|
||||
keyVariableSet := collection.NewSet()
|
||||
for fieldName, key := range table.CacheKey {
|
||||
if fieldName == table.PrimaryKey.Name.Source() {
|
||||
continue
|
||||
}
|
||||
for _, key := range table.UniqueCacheKey {
|
||||
keySet.AddStr(key.DataKeyExpression)
|
||||
keyVariableSet.AddStr(key.Variable)
|
||||
keyVariableSet.AddStr(key.KeyLeft)
|
||||
}
|
||||
|
||||
expressions := make([]string, 0)
|
||||
@@ -27,12 +24,17 @@ func genInsert(table Table, withCache bool) (string, string, error) {
|
||||
if camel == "CreateTime" || camel == "UpdateTime" {
|
||||
continue
|
||||
}
|
||||
if field.IsPrimaryKey && table.PrimaryKey.AutoIncrement {
|
||||
continue
|
||||
|
||||
if field.Name.Source() == table.PrimaryKey.Name.Source() {
|
||||
if table.PrimaryKey.AutoIncrement {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
expressions = append(expressions, "?")
|
||||
expressionValues = append(expressionValues, "data."+camel)
|
||||
}
|
||||
|
||||
camel := table.Name.ToCamel()
|
||||
text, err := util.LoadTemplate(category, insertTemplateFile, template.Insert)
|
||||
if err != nil {
|
||||
@@ -43,7 +45,7 @@ func genInsert(table Table, withCache bool) (string, string, error) {
|
||||
Parse(text).
|
||||
Execute(map[string]interface{}{
|
||||
"withCache": withCache,
|
||||
"containsIndexCache": table.ContainsUniqueKey,
|
||||
"containsIndexCache": table.ContainsUniqueCacheKey,
|
||||
"upperStartCamelObject": camel,
|
||||
"lowerStartCamelObject": stringx.From(camel).Untitle(),
|
||||
"expression": strings.Join(expressions, ", "),
|
||||
@@ -61,11 +63,9 @@ func genInsert(table Table, withCache bool) (string, string, error) {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
insertMethodOutput, err := util.With("insertMethod").
|
||||
Parse(text).
|
||||
Execute(map[string]interface{}{
|
||||
"upperStartCamelObject": camel,
|
||||
})
|
||||
insertMethodOutput, err := util.With("insertMethod").Parse(text).Execute(map[string]interface{}{
|
||||
"upperStartCamelObject": camel,
|
||||
})
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user