84 lines
1.6 KiB
Go
84 lines
1.6 KiB
Go
// Package dto 定义通知模块的服务边界对象(入参/出参)。
|
|
package dto
|
|
|
|
import "strings"
|
|
|
|
// NoticeChannelVO 渠道出参。
|
|
type NoticeChannelVO struct {
|
|
Id uint64
|
|
Code string
|
|
Name string
|
|
Enabled int
|
|
Config string
|
|
Remark string
|
|
}
|
|
|
|
// NoticeChannelInput 渠道入参。
|
|
type NoticeChannelInput struct {
|
|
Id uint64
|
|
Code string
|
|
Name string
|
|
Enabled int
|
|
Config string
|
|
Remark string
|
|
}
|
|
|
|
// NoticeRuleVO 规则出参。
|
|
type NoticeRuleVO struct {
|
|
Id uint64
|
|
Name string
|
|
EventType string
|
|
ChannelCodes []string
|
|
UserIds []uint64
|
|
TitleTemplate string
|
|
BodyTemplate string
|
|
Enabled int
|
|
}
|
|
|
|
// NoticeRuleInput 规则入参。
|
|
type NoticeRuleInput struct {
|
|
Id uint64
|
|
Name string
|
|
EventType string
|
|
ChannelCodes []string
|
|
UserIds []uint64
|
|
TitleTemplate string
|
|
BodyTemplate string
|
|
Enabled int
|
|
}
|
|
|
|
// NoticeLogVO 通知记录出参。
|
|
type NoticeLogVO struct {
|
|
Id uint64
|
|
RuleId uint64
|
|
EventType string
|
|
ChannelCode string
|
|
UserId uint64
|
|
Target string
|
|
Title string
|
|
Body string
|
|
Result int
|
|
Error string
|
|
CreatedAt string
|
|
}
|
|
|
|
// NoticeLogFilter 通知记录筛选。
|
|
type NoticeLogFilter struct {
|
|
Page int
|
|
Size int
|
|
EventType string
|
|
ChannelCode string
|
|
Result int // 0全部 1成功 2失败
|
|
DateFrom string
|
|
DateTo string
|
|
}
|
|
|
|
// RenderTemplate 简单模板渲染:将 {{key}} 替换为 vars 中对应值。
|
|
func RenderTemplate(tpl string, vars map[string]string) string {
|
|
out := tpl
|
|
for k, v := range vars {
|
|
out = strings.ReplaceAll(out, "{{"+k+"}}", v)
|
|
}
|
|
return out
|
|
}
|