Pārlūkot izejas kodu

feat(webForwarding): 添加 HTTPS证书和密钥支持

- 在 WebForwarding 结构体中添加 HttpsCert 和 HttpsKey 字段
- 更新相关请求和响应结构体,支持 HTTPS 证书和密钥
- 修改服务层逻辑,处理 HTTPS 证书和密钥的更新
fusu 1 mēnesi atpakaļ
vecāks
revīzija
a1ae4cc7ba

+ 4 - 0
api/v1/webForwarding.go

@@ -26,6 +26,8 @@ type WebForwardingDataSend struct {
 	AccessRule         string `form:"access_rule" json:"access_rule"`
 	IsHttps            int    `form:"is_https" json:"is_https" default:"0"`
 	Comment            string `form:"comment" json:"comment"`
+	HttpsCert          string `form:"https_cert" json:"https_cert omitempty"`
+	HttpsKey           string `form:"https_key" json:"https_key omitempty"`
 }
 
 
@@ -56,6 +58,8 @@ type WebForwardingDataRequest struct {
 	AccessRule         string `form:"access_rule" json:"access_rule"`
 	IsHttps            int    `form:"is_https" json:"is_https" default:"0"`
 	Comment            string `form:"comment" json:"comment"`
+	HttpsCert          string `form:"https_cert" json:"https_cert"`
+	HttpsKey           string `form:"https_key" json:"https_key"`
 }
 
 type DeleteWebForwardingRequest struct {

+ 2 - 0
internal/model/webforwarding.go

@@ -30,6 +30,8 @@ type WebForwarding struct {
 	Cc5xxBlockDuration   string `gorm:"column:cc_5xx_block_duration;null"`
 	IsHttps              int `gorm:"null"`
 	Comment              string `gorm:"null"`
+	HttpsCert             string `gorm:"null"`
+	HttpsKey             string `gorm:"null"`
 	CreatedAt            time.Time
 	UpdatedAt            time.Time
 }

+ 8 - 0
internal/service/webforwarding.go

@@ -131,6 +131,8 @@ func (s *webForwardingService) GetWebForwarding(ctx context.Context, req v1.GetF
 		AllowIpList:         backend.AllowIpList,
 		DenyIpList:          backend.DenyIpList,
 		AccessRule:          backend.AccessRule,
+		HttpsKey: 			webForwarding.HttpsKey,
+		HttpsCert: 			webForwarding.HttpsCert,
 	}, nil
 }
 
@@ -173,6 +175,8 @@ func (s *webForwardingService) buildWafFormData(req *v1.WebForwardingDataSend, r
 		"access_rule":           req.AccessRule,
 		"is_https":              req.IsHttps,
 		"comment":               req.Comment,
+		"https_cert":            req.HttpsCert,
+		"https_key":             req.HttpsKey,
 	}
 }
 
@@ -202,6 +206,8 @@ func (s *webForwardingService) buildWebForwardingModel(req *v1.WebForwardingData
 		Cc5xxBlockDuration: req.Cc5xxBlockDuration,
 		IsHttps:            req.IsHttps,
 		Comment:            req.Comment,
+		HttpsCert:          req.HttpsCert,
+		HttpsKey:           req.HttpsKey,
 	}
 }
 
@@ -267,6 +273,8 @@ func (s *webForwardingService) prepareWafData(ctx context.Context, req *v1.WebFo
 		DenyIpList:          denyIpListStr,
 		AccessRule:          req.WebForwardingData.AccessRule,
 		Comment:             req.WebForwardingData.Comment,
+		HttpsCert:           req.WebForwardingData.HttpsCert,
+		HttpsKey:            req.WebForwardingData.HttpsKey,
 	}
 
 	// 4. 构建 WAF 表单数据映射