mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
943818f7d4
将 OpenFlare 与平台业务的数据访问从 model 与 apps 直连迁入 repository, model 仅保留实体与无 IO 规则;补充 code-check 架构守卫与开发规范。
46 lines
1.7 KiB
Go
46 lines
1.7 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package model
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// OpenFlareApplyLogQuery filters apply logs for list queries.
|
|
type OpenFlareApplyLogQuery struct {
|
|
NodeID string
|
|
PageNo int
|
|
PageSize int
|
|
}
|
|
|
|
// OpenFlareApplyLog stores node configuration apply results.
|
|
type OpenFlareApplyLog struct {
|
|
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
|
|
NodeID string `json:"node_id" gorm:"index;size:64;not null"`
|
|
Version string `json:"version" gorm:"size:32;not null"`
|
|
Result string `json:"result" gorm:"size:32;not null"`
|
|
Message string `json:"message" gorm:"type:text"`
|
|
Checksum string `json:"checksum" gorm:"size:64;not null;default:''"`
|
|
MainConfigChecksum string `json:"main_config_checksum" gorm:"size:64;not null;default:''"`
|
|
RouteConfigChecksum string `json:"route_config_checksum" gorm:"size:64;not null;default:''"`
|
|
SupportFileCount int `json:"support_file_count" gorm:"not null;default:0"`
|
|
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
|
|
}
|
|
|
|
// TableName returns the GORM table name.
|
|
func (OpenFlareApplyLog) TableName() string {
|
|
return "of_apply_logs"
|
|
}
|
|
|
|
// IsRepeatSuccessApplyLog reports whether the payload repeats an already-recorded success entry.
|
|
func IsRepeatSuccessApplyLog(latest *OpenFlareApplyLog, version, checksum, result string) bool {
|
|
if latest == nil || result != "success" {
|
|
return false
|
|
}
|
|
return latest.Result == "success" &&
|
|
strings.TrimSpace(latest.Version) == strings.TrimSpace(version) &&
|
|
strings.TrimSpace(latest.Checksum) == strings.TrimSpace(checksum)
|
|
}
|