From e89760f374750dc359da733094a83ad9cd61071f Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Sun, 8 May 2022 16:04:20 +0800 Subject: [PATCH] code refactor --- src/models/target.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/models/target.go b/src/models/target.go index 5d02aad2..c94b1539 100644 --- a/src/models/target.go +++ b/src/models/target.go @@ -36,10 +36,14 @@ func (t *Target) Add() error { return Insert(t) } - return DB().Model(&Target{}).Where("ident = ?", t.Ident).Updates(map[string]interface{}{ - "cluster": t.Cluster, - "update_at": t.UpdateAt, - }).Error + if obj.Cluster != t.Cluster { + return DB().Model(&Target{}).Where("ident = ?", t.Ident).Updates(map[string]interface{}{ + "cluster": t.Cluster, + "update_at": t.UpdateAt, + }).Error + } + + return nil } func (t *Target) FillGroup(cache map[int64]*BusiGroup) error {