ocdp v1
This commit is contained in:
82
backend/internal/adapter/input/http/dto/cluster_dto.go
Normal file
82
backend/internal/adapter/input/http/dto/cluster_dto.go
Normal file
@ -0,0 +1,82 @@
|
||||
package dto
|
||||
|
||||
// CreateClusterRequest 创建集群请求
|
||||
type CreateClusterRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Host string `json:"host" binding:"required"`
|
||||
CAData string `json:"caData"`
|
||||
CADataAlt string `json:"ca_data"`
|
||||
CertData string `json:"certData"`
|
||||
CertDataAlt string `json:"cert_data"`
|
||||
KeyData string `json:"keyData"`
|
||||
KeyDataAlt string `json:"key_data"`
|
||||
Token string `json:"token"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// UpdateClusterRequest 更新集群请求
|
||||
type UpdateClusterRequest struct {
|
||||
Name string `json:"name"`
|
||||
Host string `json:"host"`
|
||||
CAData string `json:"caData"`
|
||||
CADataAlt string `json:"ca_data"`
|
||||
CertData string `json:"certData"`
|
||||
CertDataAlt string `json:"cert_data"`
|
||||
KeyData string `json:"keyData"`
|
||||
KeyDataAlt string `json:"key_data"`
|
||||
Token string `json:"token"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// Normalize 将多种命名风格的字段合并到统一字段
|
||||
func (r *CreateClusterRequest) Normalize() {
|
||||
if r.CAData == "" {
|
||||
r.CAData = r.CADataAlt
|
||||
}
|
||||
if r.CertData == "" {
|
||||
r.CertData = r.CertDataAlt
|
||||
}
|
||||
if r.KeyData == "" {
|
||||
r.KeyData = r.KeyDataAlt
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize 将多种命名风格的字段合并到统一字段
|
||||
func (r *UpdateClusterRequest) Normalize() {
|
||||
if r.CAData == "" {
|
||||
r.CAData = r.CADataAlt
|
||||
}
|
||||
if r.CertData == "" {
|
||||
r.CertData = r.CertDataAlt
|
||||
}
|
||||
if r.KeyData == "" {
|
||||
r.KeyData = r.KeyDataAlt
|
||||
}
|
||||
}
|
||||
|
||||
// ClusterResponse 集群响应(敏感数据已脱敏)
|
||||
type ClusterResponse struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Host string `json:"host"`
|
||||
Description string `json:"description"`
|
||||
// 认证配置状态(不返回实际证书数据,仅返回是否已配置)
|
||||
HasCAData bool `json:"hasCaData"`
|
||||
HasCertData bool `json:"hasCertData"`
|
||||
HasKeyData bool `json:"hasKeyData"`
|
||||
HasToken bool `json:"hasToken"`
|
||||
// 脱敏数据(仅用于前端显示,实际值为掩码)
|
||||
CAData string `json:"caData,omitempty"` // 脱敏显示(••••••••)
|
||||
CertData string `json:"certData,omitempty"` // 脱敏显示(••••••••)
|
||||
KeyData string `json:"keyData,omitempty"` // 脱敏显示(••••••••)
|
||||
Token string `json:"token,omitempty"` // 脱敏显示(••••••••)
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// ClusterHealthResponse 集群健康状态响应
|
||||
type ClusterHealthResponse struct {
|
||||
Healthy bool `json:"healthy"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user