-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifier_edge.go
62 lines (50 loc) · 2 KB
/
notifier_edge.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
53
54
55
56
57
58
59
60
61
62
package v2
import (
"fmt"
"strings"
"github.com/jaehoonkim/synapse/pkg/manager/database/vanilla"
)
type NotifierEdge_essential struct {
// enums:"NaV(0), console(1), webhook(2), rabbitmq(3), slackhook(4)"
NotifierType NotifierType `column:"notifier_type,default(0)" json:"notifier_type,omitempty" swaggertype:"string" enums:"0,1,2,3,4"`
}
type NotifierEdge_property struct {
NotifierEdge_essential `json:",inline"`
Created vanilla.NullTime `column:"created" json:"created,omitempty" swaggertype:"string"`
Updated vanilla.NullTime `column:"updated" json:"updated,omitempty" swaggertype:"string"`
}
func (NotifierEdge_property) TableName() string {
return "managed_channel_notifier_edge"
}
type NotifierEdge struct {
NotifierEdge_property `json:",inline"`
Uuid string `column:"uuid" json:"uuid,omitempty"` // pk
}
type NotifierEdge_option struct {
NotifierEdge `alias:"EG," json:",inline"`
Console NotifierConsole_property `alias:"CS,console" json:"console,omitempty"`
Webhook NotifierWebhook_property `alias:"WH,webhook" json:"webhook,omitempty"`
RabbitMq NotifierRabbitMq_property `alias:"RQ,rabbitmq" json:"rabbitmq,omitempty"`
Slackhook NotifierSlackhook_property `alias:"SH,slackhook" json:"slackhook,omitempty"`
}
func (record NotifierEdge_option) TableName() string {
q := `(
SELECT %v /**columns**/
FROM %v EG /**managed_channel_notifier_edge**/
LEFT JOIN %v CS /**managed_channel_notifier_console**/
ON EG.uuid = CS.uuid
LEFT JOIN %v WH /**managed_channel_notifier_webhook**/
ON EG.uuid = WH.uuid
LEFT JOIN %v RQ /**managed_channel_notifier_rabbitmq**/
ON EG.uuid = RQ.uuid
LEFT JOIN %v SH /**managed_channel_notifier_slackhook**/
ON EG.uuid = SH.uuid
) X
`
EG := record.NotifierEdge_property.TableName()
CS := record.Console.TableName()
WH := record.Webhook.TableName()
RQ := record.RabbitMq.TableName()
SH := record.Slackhook.TableName()
return fmt.Sprintf(q, strings.Join(record.ColumnNamesWithAlias(), ", "), EG, CS, WH, RQ, SH)
}