|
@@ -52,6 +52,8 @@ type CdnService interface {
|
|
|
EditWebSockets(ctx context.Context, req v1.WebSocket) error
|
|
|
// 启用webSocket
|
|
|
EditHTTPWebWebsocket(ctx context.Context,websocketId int64,websocketJSON []byte) error
|
|
|
+ // 启用/禁用网站
|
|
|
+ EditWebIsOn(ctx context.Context,serverId int64,isOn bool) error
|
|
|
}
|
|
|
|
|
|
func NewCdnService(
|
|
@@ -928,4 +930,25 @@ func (s *cdnService) EditHTTPWebWebsocket(ctx context.Context,websocketId int64,
|
|
|
return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Message)
|
|
|
}
|
|
|
return nil
|
|
|
+}
|
|
|
+
|
|
|
+// 启用/禁用网站
|
|
|
+func (s *cdnService) EditWebIsOn(ctx context.Context,serverId int64,isOn bool) error {
|
|
|
+ formData := map[string]interface{}{
|
|
|
+ "serverId": serverId,
|
|
|
+ "isOn": isOn,
|
|
|
+ }
|
|
|
+ apiUrl := s.Url + "ServerService/updateServerIsOn"
|
|
|
+ resBody, err := s.sendDataWithTokenRetry(ctx, formData, apiUrl)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var res v1.GeneralResponse[any]
|
|
|
+ if err := json.Unmarshal(resBody, &res); err != nil {
|
|
|
+ return fmt.Errorf("反序列化响应 JSON 失败 (内容: %s): %w", string(resBody), err)
|
|
|
+ }
|
|
|
+ if res.Code != 200 {
|
|
|
+ return fmt.Errorf("API 错误: code %d, msg '%s'", res.Code, res.Message)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
}
|