diff --git a/console/commands/orm/mysql.go b/console/commands/orm/mysql.go index 727f956..5df23e5 100644 --- a/console/commands/orm/mysql.go +++ b/console/commands/orm/mysql.go @@ -74,7 +74,6 @@ func GenMysql(name string, conf Conf, out string) { str += baseFunStr str += genFieldFunc(table, columns) str += genListFunc(table, columns) - str += genWithFunc(table, columns, conf) err := os.WriteFile(file+"_gen.go", []byte(str), 0766) if err != nil { log.Fatal(err) @@ -110,36 +109,6 @@ func genListFunc(table string, columns []tableColumn) string { return str } -func genWithFunc(table string, columns []tableColumn, conf Conf) string { - TableName := parser.StringToHump(table) - str := "" - if helper, ok := conf["helper"]; ok { - helperConf := helper.(map[interface{}]interface{}) - tableConfig, ok := helperConf[table].([]interface{}) - if ok { - for _, c := range tableConfig { - cf := c.(map[interface{}]interface{}) - with := cf["with"] - tbName := parser.StringToHump(cf["table"].(string)) - switch with { - case "many2many": - - default: - str += "\nfunc (orm *Orm" + TableName + ") Joins" + tbName + "(args ...interface{}) *Orm" + TableName + " {" + - "\n\torm.db.Joins(\"" + cf["alias"].(string) + "\", args...)" + - "\n\treturn orm" + - "\n}" - str += "\nfunc (orm *Orm" + TableName + ") Preload" + tbName + "(args ...interface{}) *Orm" + TableName + " {" + - "\n\torm.db.Preload(\"" + cf["alias"].(string) + "\", args...)" + - "\n\treturn orm" + - "\n}" - } - } - } - } - return str -} - func genFieldFunc(table string, columns []tableColumn) string { TableName := parser.StringToHump(table) diff --git a/console/commands/pgorm/pgsql.go b/console/commands/pgorm/pgsql.go index db3b644..a93e02f 100644 --- a/console/commands/pgorm/pgsql.go +++ b/console/commands/pgorm/pgsql.go @@ -64,7 +64,6 @@ func GenSql(name string, conf Conf, out string) { str += baseFunStr str += genFieldFunc(table, columns) str += genListFunc(table, columns) - str += genWithFunc(table, columns, conf) err := os.WriteFile(file+"_gen.go", []byte(str), 0766) if err != nil { log.Fatal(err) @@ -100,36 +99,6 @@ func genListFunc(table string, columns []tableColumn) string { return str } -func genWithFunc(table string, columns []tableColumn, conf Conf) string { - TableName := parser.StringToHump(table) - str := "" - if helper, ok := conf["helper"]; ok { - helperConf := helper.(map[interface{}]interface{}) - tableConfig, ok := helperConf[table].([]interface{}) - if ok { - for _, c := range tableConfig { - cf := c.(map[interface{}]interface{}) - with := cf["with"] - tbName := parser.StringToHump(cf["table"].(string)) - switch with { - case "many2many": - - default: - str += "\nfunc (orm *Orm" + TableName + ") Joins" + tbName + "(args ...interface{}) *Orm" + TableName + " {" + - "\n\torm.db.Joins(\"" + cf["alias"].(string) + "\", args...)" + - "\n\treturn orm" + - "\n}" - str += "\nfunc (orm *Orm" + TableName + ") Preload" + tbName + "(args ...interface{}) *Orm" + TableName + " {" + - "\n\torm.db.Preload(\"" + cf["alias"].(string) + "\", args...)" + - "\n\treturn orm" + - "\n}" - } - } - } - } - return str -} - func genFieldFunc(table string, columns []tableColumn) string { TableName := parser.StringToHump(table)