@@ -23,52 +23,53 @@ import org.mybatis.dynamic.sql.insert.GeneralInsertDSL
23
23
import org.mybatis.dynamic.sql.insert.InsertDSL
24
24
import org.mybatis.dynamic.sql.insert.MultiRowInsertDSL
25
25
26
- fun count (column : BasicColumn , completer : CountColumnCompleter ) =
27
- completer(KotlinCountColumnBuilder (SqlBuilder .countColumn(column))).build()
26
+ object KotlinModelBuilderFunctions {
27
+ fun count (column : BasicColumn , completer : CountCompleter ) =
28
+ completer(KotlinCountBuilder (SqlBuilder .countColumn(column))).build()
28
29
29
- fun countDistinct (column : BasicColumn , completer : CountColumnCompleter ) =
30
- completer(KotlinCountColumnBuilder (SqlBuilder .countDistinctColumn(column))).build()
30
+ fun countDistinct (column : BasicColumn , completer : CountCompleter ) =
31
+ completer(KotlinCountBuilder (SqlBuilder .countDistinctColumn(column))).build()
31
32
32
- fun count (start : KotlinCountBuilder , completer : CountCompleter ) =
33
- completer(start).build()
33
+ fun countFrom (table : SqlTable , completer : CountCompleter ) =
34
+ with (KotlinCountBuilder (SqlBuilder .countColumn(SqlBuilder .constant<Long >(" *" )))) {
35
+ completer(from(table)).build()
36
+ }
34
37
35
- fun countFrom (table : SqlTable , completer : CountCompleter ) =
36
- count( KotlinCountBuilder (SqlBuilder .countFrom (table)), completer )
38
+ fun deleteFrom (table : SqlTable , completer : DeleteCompleter ) =
39
+ completer( KotlinDeleteBuilder (SqlBuilder .deleteFrom (table))).build( )
37
40
38
- fun deleteFrom (table : SqlTable , completer : DeleteCompleter ) =
39
- completer(KotlinDeleteBuilder ( SqlBuilder .deleteFrom (table) )).build()
41
+ fun insertInto (table : SqlTable , completer : GeneralInsertCompleter ) =
42
+ completer(GeneralInsertDSL .insertInto (table)).build()
40
43
41
- fun insertInto (table : SqlTable , completer : GeneralInsertCompleter ) =
42
- completer(GeneralInsertDSL .insertInto(table)).build()
44
+ fun insertSelect (table : SqlTable , completer : InsertSelectCompleter ) =
45
+ with (completer(KotlinInsertSelectSubQueryBuilder ())) {
46
+ SqlBuilder .insertInto(table)
47
+ .withColumnList(columnList)
48
+ .withSelectStatement(selectBuilder)
49
+ .build()
50
+ }
43
51
44
- fun insertSelect (table : SqlTable , completer : InsertSelectCompleter ) =
45
- with (completer(KotlinInsertSelectSubQueryBuilder ())) {
46
- SqlBuilder .insertInto(table)
47
- .withColumnList(columnList)
48
- .withSelectStatement(selectBuilder)
49
- .build()
50
- }
52
+ fun <T > BatchInsertDSL.IntoGatherer<T>.into (table : SqlTable , completer : BatchInsertCompleter <T >) =
53
+ completer(into(table)).build()
51
54
52
- fun <T > BatchInsertDSL .IntoGatherer<T>.into (table : SqlTable , completer : BatchInsertCompleter <T >) =
53
- completer(into(table)).build()
55
+ fun <T > InsertDSL .IntoGatherer<T>.into (table : SqlTable , completer : InsertCompleter <T >) =
56
+ completer(into(table)).build()
54
57
55
- fun <T > InsertDSL .IntoGatherer<T>.into (table : SqlTable , completer : InsertCompleter <T >) =
56
- completer(into(table)).build()
58
+ fun <T > MultiRowInsertDSL .IntoGatherer<T>.into (table : SqlTable , completer : MultiRowInsertCompleter <T >) =
59
+ completer(into(table)).build()
57
60
58
- fun < T > MultiRowInsertDSL.IntoGatherer<T>. into ( table : SqlTable , completer : MultiRowInsertCompleter < T > ) =
59
- completer(into(table)).build( )
61
+ fun select ( vararg columns : BasicColumn , completer : SelectCompleter ) =
62
+ select(columns.asList(), completer )
60
63
61
- fun select (vararg columns : BasicColumn , completer : SelectCompleter ) =
62
- select(columns.asList(), completer )
64
+ fun select (columns : List < BasicColumn > , completer : SelectCompleter ) =
65
+ completer( KotlinSelectBuilder ( SqlBuilder . select(columns))).build( )
63
66
64
- fun select ( columns : List < BasicColumn > , completer : SelectCompleter ) =
65
- completer( KotlinSelectBuilder ( SqlBuilder .select( columns))).build( )
67
+ fun selectDistinct ( vararg columns : BasicColumn , completer : SelectCompleter ) =
68
+ selectDistinct( columns.asList(), completer )
66
69
67
- fun selectDistinct (vararg columns : BasicColumn , completer : SelectCompleter ) =
68
- selectDistinct(columns.asList(), completer )
70
+ fun selectDistinct (columns : List < BasicColumn > , completer : SelectCompleter ) =
71
+ completer( KotlinSelectBuilder ( SqlBuilder . selectDistinct(columns))).build( )
69
72
70
- fun selectDistinct (columns : List <BasicColumn >, completer : SelectCompleter ) =
71
- completer(KotlinSelectBuilder (SqlBuilder .selectDistinct(columns))).build()
72
-
73
- fun update (table : SqlTable , completer : UpdateCompleter ) =
74
- completer(KotlinUpdateBuilder (SqlBuilder .update(table))).build()
73
+ fun update (table : SqlTable , completer : UpdateCompleter ) =
74
+ completer(KotlinUpdateBuilder (SqlBuilder .update(table))).build()
75
+ }
0 commit comments