feat: 更新 ProxyRoute 更新逻辑,优化 TLS 证书字段隐私,增强测试用例以验证 HTTPS 路由更新

This commit is contained in:
ryan
2026-03-11 11:09:59 +08:00
parent e895c91ab7
commit efcc6b5337
4 changed files with 63 additions and 4 deletions
+10 -1
View File
@@ -37,7 +37,16 @@ func (route *ProxyRoute) Insert() error {
}
func (route *ProxyRoute) Update() error {
return DB.Model(route).Select("domain", "origin_url", "enabled", "enable_https", "cert_id", "redirect_http", "custom_headers", "remark").Updates(route).Error
return DB.Model(&ProxyRoute{}).Where("id = ?", route.ID).Updates(map[string]any{
"domain": route.Domain,
"origin_url": route.OriginURL,
"enabled": route.Enabled,
"enable_https": route.EnableHTTPS,
"cert_id": route.CertID,
"redirect_http": route.RedirectHTTP,
"custom_headers": route.CustomHeaders,
"remark": route.Remark,
}).Error
}
func (route *ProxyRoute) Delete() error {
+2 -2
View File
@@ -5,8 +5,8 @@ import "time"
type TLSCertificate struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"uniqueIndex;size:255;not null"`
CertPEM string `json:"cert_pem" gorm:"type:text;not null"`
KeyPEM string `json:"key_pem" gorm:"type:text;not null"`
CertPEM string `json:"-" gorm:"type:text;not null"`
KeyPEM string `json:"-" gorm:"type:text;not null"`
NotBefore time.Time `json:"not_before"`
NotAfter time.Time `json:"not_after"`
Remark string `json:"remark" gorm:"size:255"`