Commit 38bbbe81 authored by liupei's avatar liupei

parent 52ec5b8f
...@@ -34,7 +34,7 @@ require ( ...@@ -34,7 +34,7 @@ require (
go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/sdk v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect
golang.org/x/net v0.40.0 // indirect golang.org/x/net v0.40.0 // indirect
golang.org/x/sys v0.35.0 // indirect golang.org/x/sys v0.35.0 // indirect; indirect
golang.org/x/text v0.25.0 // indirect golang.org/x/text v0.25.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
...@@ -8,6 +8,7 @@ var ( ...@@ -8,6 +8,7 @@ var (
type DataInsert struct { type DataInsert struct {
groupId string groupId string
update int
rows map[string][]interface{} rows map[string][]interface{}
arg map[string]interface{} arg map[string]interface{}
} }
...@@ -23,6 +24,13 @@ func (i *DataInsert) SetGroupId(groupId string) *DataInsert { ...@@ -23,6 +24,13 @@ func (i *DataInsert) SetGroupId(groupId string) *DataInsert {
return i return i
} }
// SetUpdate 设置更新
// 0: 插入,1: 更新
func (i *DataInsert) SetUpdate(update int) *DataInsert {
i.update = update
return i
}
func (i *DataInsert) SetFormRows(formId string, rows []interface{}) *DataInsert { func (i *DataInsert) SetFormRows(formId string, rows []interface{}) *DataInsert {
if _, ok := i.rows[formId]; ok { if _, ok := i.rows[formId]; ok {
i.rows[formId] = nil i.rows[formId] = nil
...@@ -45,5 +53,6 @@ func (i *DataInsert) Do(ctx context.Context) Response { ...@@ -45,5 +53,6 @@ func (i *DataInsert) Do(ctx context.Context) Response {
return request(ctx, dataInsertPath, map[string]interface{}{ return request(ctx, dataInsertPath, map[string]interface{}{
"group_id": i.groupId, "group_id": i.groupId,
"rows": i.rows, "rows": i.rows,
"update": i.update,
}) })
} }
...@@ -10,6 +10,7 @@ type SqlBuilder interface { ...@@ -10,6 +10,7 @@ type SqlBuilder interface {
GroupBy(groupBy string) SqlBuilder GroupBy(groupBy string) SqlBuilder
OrderBy(orderBy string) SqlBuilder OrderBy(orderBy string) SqlBuilder
Build() (string, []interface{}) Build() (string, []interface{})
Clone() SqlBuilder
} }
type Where struct { type Where struct {
......
...@@ -155,3 +155,17 @@ func (d *DuckDBSqlBuilder) Build() (string, []interface{}) { ...@@ -155,3 +155,17 @@ func (d *DuckDBSqlBuilder) Build() (string, []interface{}) {
return sql, d.whereArgs return sql, d.whereArgs
} }
// Clone 实现 Clone 方法
func (d *DuckDBSqlBuilder) Clone() SqlBuilder {
return &DuckDBSqlBuilder{
fields: d.fields,
where: d.where,
formId: d.formId,
limitPage: d.limitPage,
limitSize: d.limitSize,
groupBy: d.groupBy,
orderBy: d.orderBy,
whereArgs: make([]interface{}, 0),
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment