This commit is contained in:
likun 2025-07-14 09:22:49 +08:00
parent 037950a599
commit 5c2af96ac2
3 changed files with 9 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"sort" "sort"
"strconv"
"strings" "strings"
"text/template" "text/template"
"time" "time"
@ -32,6 +33,7 @@ type CdnServerNoticeInfo struct {
NoticeList []*CdnNoticeInfo NoticeList []*CdnNoticeInfo
} }
// todo 根据项目获取不同的cdn推送内容
func genCdnServerListContent(projectEt *entity.Project, serverList, noticeList []*entity.CommonResource) (string, error) { func genCdnServerListContent(projectEt *entity.Project, serverList, noticeList []*entity.CommonResource) (string, error) {
info := &CdnServerNoticeInfo{} info := &CdnServerNoticeInfo{}
hook, _ := projects.GetProjectResourceHook(projectEt, consts.ResourcesName_Server).(projects.IServerInfoHook) hook, _ := projects.GetProjectResourceHook(projectEt, consts.ResourcesName_Server).(projects.IServerInfoHook)
@ -71,7 +73,8 @@ func genCdnServerListContent(projectEt *entity.Project, serverList, noticeList [
serverInfo.Properties[5].Value = fmt.Sprintf("%v", getCdnServerStatus(serverDbInfo)) serverInfo.Properties[5].Value = fmt.Sprintf("%v", getCdnServerStatus(serverDbInfo))
serverInfo.Properties[6].Key = "area" serverInfo.Properties[6].Key = "area"
serverInfo.Properties[6].Value = "1区" serverId, _ := strconv.Atoi(serverDbInfo.ServerConfID)
serverInfo.Properties[6].Value = getCdnServerArea(serverId)
serverInfo.Properties[7].Key = "type" serverInfo.Properties[7].Key = "type"
serverInfo.Properties[7].Value = "1" serverInfo.Properties[7].Value = "1"
@ -109,6 +112,11 @@ func genCdnServerListContent(projectEt *entity.Project, serverList, noticeList [
return bytesBuffer.String(), nil return bytesBuffer.String(), nil
} }
func getCdnServerArea(serverId int) string {
// 神魔大陆每4个服对应一个区从20001开始
return fmt.Sprintf("%v区", (serverId-20001)/4+1)
}
func getCdnServerStatus(server *model.Server) int { func getCdnServerStatus(server *model.Server) int {
if server.IsServerDown { if server.IsServerDown {
return consts.CdnServerStatus_Maintain return consts.CdnServerStatus_Maintain

Binary file not shown.

Binary file not shown.