-
Notifications
You must be signed in to change notification settings - Fork 34
/
config_models.go
52 lines (44 loc) · 1.02 KB
/
config_models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package config
import (
"fmt"
"github.com/machinefi/w3bstream/pkg/depends/kit/sqlx/builder"
"github.com/machinefi/w3bstream/pkg/enums"
"github.com/machinefi/w3bstream/pkg/models"
"github.com/machinefi/w3bstream/pkg/types"
"github.com/machinefi/w3bstream/pkg/types/wasm"
)
type CondArgs struct {
ConfigIDs []types.SFID
RelIDs []types.SFID
Types []enums.ConfigType
}
func (r *CondArgs) Condition() builder.SqlCondition {
var (
m = &models.Config{}
c []builder.SqlCondition
)
if len(r.ConfigIDs) > 0 {
c = append(c, m.ColConfigID().In(r.ConfigIDs))
}
if len(r.RelIDs) > 0 {
c = append(c, m.ColRelID().In(r.RelIDs))
}
if len(r.Types) > 0 {
c = append(c, m.ColType().In(r.Types))
}
return builder.And(c...)
}
type Detail struct {
RelID types.SFID
wasm.Configuration
}
func (d *Detail) String() string {
return fmt.Sprintf("[rel: %v][type: %v]", d.RelID, d.ConfigType())
}
func (d *Detail) Log(err error) string {
s := d.String()
if err == nil {
return s
}
return fmt.Sprintf("%s: %v", s, err)
}