🐛 Fix link external realm

This commit is contained in:
LittleSheep 2024-05-05 16:36:56 +08:00
parent 3a6b51da97
commit e443448a94

View File

@ -10,6 +10,7 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/grpc/proto" "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
"github.com/samber/lo" "github.com/samber/lo"
"gorm.io/gorm" "gorm.io/gorm"
"reflect"
) )
func GetRealm(id uint) (models.Realm, error) { func GetRealm(id uint) (models.Realm, error) {
@ -78,5 +79,18 @@ func LinkRealm(info *proto.RealmResponse) (models.Realm, error) {
} }
return realm, err return realm, err
} }
return realm, nil
prev := realm
realm.Alias = info.Alias
realm.Name = info.Name
realm.Description = info.Description
realm.IsPublic = info.IsPublic
realm.IsCommunity = info.IsCommunity
var err error
if !reflect.DeepEqual(prev, realm) {
err = database.C.Save(&realm).Error
}
return realm, err
} }