sync: 同步 v1.0.4 并脱敏配置与镜像
This commit is contained in:
@@ -13,15 +13,20 @@ func applyContent(batch *Batch) {
|
||||
if batch == nil {
|
||||
return
|
||||
}
|
||||
batch.SMSContent = buildSMSContent(*batch)
|
||||
batch.EmailSubject = buildEmailSubject(*batch)
|
||||
batch.EmailBody = buildEmailBody(*batch)
|
||||
batch.PlatformTitle = buildPlatformTitle(*batch)
|
||||
batch.PlatformContent = buildPlatformContent(*batch)
|
||||
switch batch.Method {
|
||||
case MethodSMS:
|
||||
batch.SMSContent = buildSMSContent(*batch)
|
||||
case MethodEmail:
|
||||
batch.EmailSubject = buildEmailSubject(*batch)
|
||||
batch.EmailBody = buildEmailBody(*batch)
|
||||
case MethodPlatform:
|
||||
batch.PlatformTitle = buildPlatformTitle(*batch)
|
||||
batch.PlatformContent = buildPlatformContent(*batch)
|
||||
}
|
||||
}
|
||||
|
||||
func buildSMSContent(batch Batch) string {
|
||||
count := len(batch.Items)
|
||||
count := batchItemCount(batch)
|
||||
if count == 0 {
|
||||
return ""
|
||||
}
|
||||
@@ -29,7 +34,7 @@ func buildSMSContent(batch Batch) string {
|
||||
summary := batchObjectSummary(batch)
|
||||
title := warningTitle(batch)
|
||||
action := ""
|
||||
if hasAffectOperation(batch.Items) {
|
||||
if batchHasAffectOperation(batch) {
|
||||
action = ",涉及停机或断网操作"
|
||||
}
|
||||
|
||||
@@ -42,7 +47,7 @@ func buildSMSContent(batch Batch) string {
|
||||
}
|
||||
|
||||
func buildEmailSubject(batch Batch) string {
|
||||
count := len(batch.Items)
|
||||
count := batchItemCount(batch)
|
||||
if count == 0 {
|
||||
return "物联网预警提醒"
|
||||
}
|
||||
@@ -50,15 +55,15 @@ func buildEmailSubject(batch Batch) string {
|
||||
}
|
||||
|
||||
func buildEmailBody(batch Batch) string {
|
||||
count := len(batch.Items)
|
||||
count := batchItemCount(batch)
|
||||
if count == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
var builder strings.Builder
|
||||
builder.WriteString(`<div ` + warningEmailHTMLSignature + ` style="font-family:Arial,'Microsoft YaHei',sans-serif;font-size:14px;line-height:1.6;color:#1f2937;">`)
|
||||
fmt.Fprintf(&builder, `<p style="margin:0 0 12px;">%s,共 %d 条,最高级别:%s。</p>`, htmlEscape(warningTitle(batch)), count, htmlEscape(levelText(highestLevel(batch.Items))))
|
||||
if hasAffectOperation(batch.Items) {
|
||||
fmt.Fprintf(&builder, `<p style="margin:0 0 12px;">%s,共 %d 条,最高级别:%s。</p>`, htmlEscape(warningTitle(batch)), count, htmlEscape(levelText(batchHighestLevel(batch))))
|
||||
if batchHasAffectOperation(batch) {
|
||||
builder.WriteString(`<p style="margin:0 0 12px;color:#b42318;">本次预警包含停机或断网类操作,请重点确认。</p>`)
|
||||
}
|
||||
builder.WriteString(`<table style="width:100%;border-collapse:collapse;border:1px solid #d0d5dd;">`)
|
||||
@@ -92,13 +97,13 @@ func buildPlatformTitle(batch Batch) string {
|
||||
}
|
||||
|
||||
func buildPlatformContent(batch Batch) string {
|
||||
count := len(batch.Items)
|
||||
count := batchItemCount(batch)
|
||||
if count == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
content := buildPlatformSummaryContent(batch)
|
||||
if hasAffectOperation(batch.Items) {
|
||||
if batchHasAffectOperation(batch) {
|
||||
content += "本次提醒包含停机或断网类操作,请及时确认。"
|
||||
}
|
||||
|
||||
@@ -110,15 +115,15 @@ func buildPlatformSummaryContent(batch Batch) string {
|
||||
return fmt.Sprintf(
|
||||
"%s有%d张卡临近到期,最高档位:%s,请登录控制台查看。",
|
||||
firstObjectCode(batch),
|
||||
len(batch.Items),
|
||||
batchItemCount(batch),
|
||||
buildPlatformTitle(batch),
|
||||
)
|
||||
}
|
||||
return fmt.Sprintf(
|
||||
"%s触发%s,最高级别:%s,请登录控制台查看。",
|
||||
batchObjectSummary(batch),
|
||||
platformObjectSummary(batch),
|
||||
buildPlatformTitle(batch),
|
||||
levelText(highestLevel(batch.Items)),
|
||||
levelText(batchHighestLevel(batch)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -201,7 +206,7 @@ func itemDetailSummary(item Event) string {
|
||||
}
|
||||
|
||||
func batchObjectSummary(batch Batch) string {
|
||||
count := len(batch.Items)
|
||||
count := batchItemCount(batch)
|
||||
if count == 0 {
|
||||
return ""
|
||||
}
|
||||
@@ -427,3 +432,17 @@ func htmlEscape(value string) string {
|
||||
}
|
||||
return html.EscapeString(value)
|
||||
}
|
||||
|
||||
func platformObjectSummary(batch Batch) string {
|
||||
if len(batch.Items) == 0 {
|
||||
return ""
|
||||
}
|
||||
if batchItemCount(batch) > 5 {
|
||||
return fmt.Sprintf("\u5171%d%s", batchItemCount(batch), objectCountUnit(batch.Items[0]))
|
||||
}
|
||||
codes := make([]string, 0, len(batch.Items))
|
||||
for _, item := range batch.Items {
|
||||
codes = append(codes, displayObjectCode(item))
|
||||
}
|
||||
return strings.Join(codes, "\u3001")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user