All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s
33 lines
1020 B
Go
33 lines
1020 B
Go
package gateway
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
|
)
|
|
|
|
// ParseCardNetworkStatus 将 Gateway 卡状态转换为系统网络状态。
|
|
// 只有网关明确返回“正常”才视为开机;“准备”或“待激活”不能按正常卡展示。
|
|
func ParseCardNetworkStatus(cardStatus, extend string) (int, bool) {
|
|
status := strings.TrimSpace(cardStatus)
|
|
ext := strings.TrimSpace(extend)
|
|
|
|
switch status {
|
|
case constants.GatewayCardStatusNormal:
|
|
return constants.NetworkStatusOnline, true
|
|
case constants.GatewayCardStatusStopped, constants.GatewayCardStatusReady:
|
|
return constants.NetworkStatusOffline, true
|
|
}
|
|
|
|
if ext == constants.GatewayCardExtendPendingActivation {
|
|
return constants.NetworkStatusOffline, true
|
|
}
|
|
|
|
return constants.NetworkStatusOffline, false
|
|
}
|
|
|
|
// IsGatewayCardStopped 判断 Gateway 是否明确返回停机状态。
|
|
func IsGatewayCardStopped(cardStatus string) bool {
|
|
return strings.TrimSpace(cardStatus) == constants.GatewayCardStatusStopped
|
|
}
|