@@ -250,7 +250,7 @@ func (s *Service) UpdateEndpoint(req UpdateEndpointRequest) (*Endpoint, error) {
250250 // 修改配置:更新名称、URL、API路径,可选的API密钥
251251 updates := make (map [string ]interface {})
252252 needUpdateCache := false
253-
253+
254254 if req .Name != "" {
255255 // 检查新名称是否已存在
256256 var count int64
@@ -262,7 +262,7 @@ func (s *Service) UpdateEndpoint(req UpdateEndpointRequest) (*Endpoint, error) {
262262 }
263263 updates ["name" ] = req .Name
264264 }
265-
265+
266266 if req .URL != "" && req .URL != endpoint .URL {
267267 // 检查URL是否重复
268268 var count int64
@@ -279,17 +279,17 @@ func (s *Service) UpdateEndpoint(req UpdateEndpointRequest) (*Endpoint, error) {
279279 }
280280 needUpdateCache = true
281281 }
282-
282+
283283 if req .APIPath != "" && req .APIPath != endpoint .APIPath {
284284 updates ["api_path" ] = req .APIPath
285285 needUpdateCache = true
286286 }
287-
287+
288288 if req .APIKey != "" && req .APIKey != endpoint .APIKey {
289289 updates ["api_key" ] = req .APIKey
290290 needUpdateCache = true
291291 }
292-
292+
293293 updates ["updated_at" ] = time .Now ()
294294
295295 if err := s .db .Model (& endpoint ).Updates (updates ).Error ; err != nil {
@@ -311,7 +311,7 @@ func (s *Service) UpdateEndpoint(req UpdateEndpointRequest) (*Endpoint, error) {
311311 if req .APIKey == "" {
312312 return nil , errors .New ("API密钥不能为空" )
313313 }
314-
314+
315315 updates := map [string ]interface {}{
316316 "api_key" : req .APIKey ,
317317 "updated_at" : time .Now (),
@@ -336,11 +336,11 @@ func (s *Service) UpdateEndpoint(req UpdateEndpointRequest) (*Endpoint, error) {
336336// DeleteEndpoint 删除端点
337337func (s * Service ) DeleteEndpoint (id int64 ) error {
338338 return s .db .Transaction (func (tx * gorm.DB ) error {
339- // 1) 删除隧道标签关联表记录 (通过隧道ID关联)
340- if err := tx .Exec ("DELETE FROM tunnel_tags WHERE tunnel_id IN (SELECT id FROM tunnels WHERE endpoint_id = ?)" , id ).Error ; err != nil {
339+ // 1) 删除隧道分组关联表记录 (通过隧道ID关联)
340+ if err := tx .Exec ("DELETE FROM tunnel_groups WHERE tunnel_id IN (SELECT id FROM tunnels WHERE endpoint_id = ?)" , id ).Error ; err != nil {
341341 // 忽略记录不存在的错误
342342 if ! errors .Is (err , gorm .ErrRecordNotFound ) {
343- return fmt .Errorf ("删除隧道标签关联失败 : %v" , err )
343+ return fmt .Errorf ("删除隧道分组关联失败 : %v" , err )
344344 }
345345 }
346346
0 commit comments