diff --git a/internal/pkg/migrate/admin.go b/internal/pkg/migrate/admin.go index a2fc9a5..d924762 100644 --- a/internal/pkg/migrate/admin.go +++ b/internal/pkg/migrate/admin.go @@ -8,6 +8,7 @@ import ( api "github.com/begonia-org/go-sdk/api/user/v1" "github.com/spark-lence/tiga" "google.golang.org/protobuf/types/known/timestamppb" + "gorm.io/gorm" ) type UsersOperator struct { @@ -20,7 +21,7 @@ func NewUsersOperator(mysql *tiga.MySQLDao) *UsersOperator { func (m *UsersOperator) InitAdminUser(passwd string, aseKey, ivKey string, name, email, phone string) (string,error) { userExist:=&api.Users{} err := m.mysql.First(userExist,"role = ? and is_deleted=0 and status=?",api.Role_ADMIN,api.USER_STATUS_ACTIVE) - if err != nil { + if err != nil && err!=gorm.ErrRecordNotFound { return "", err } if userExist.Uid == ""{ diff --git a/internal/pkg/migrate/app.go b/internal/pkg/migrate/app.go index 596acf2..d57bc03 100644 --- a/internal/pkg/migrate/app.go +++ b/internal/pkg/migrate/app.go @@ -9,6 +9,7 @@ import ( api "github.com/begonia-org/go-sdk/api/app/v1" "github.com/spark-lence/tiga" "google.golang.org/protobuf/types/known/timestamppb" + "gorm.io/gorm" ) type APPOperator struct { @@ -21,7 +22,7 @@ func NewAPPOperator(mysql *tiga.MySQLDao) *APPOperator { func (m *APPOperator) InitAdminAPP(owner string) error { app := &api.Apps{} err := m.mysql.First(app, "name = ?", "admin-app") - if err != nil { + if err != nil && err != gorm.ErrRecordNotFound { return err } if app.Appid == "" { @@ -55,9 +56,9 @@ func (m *APPOperator) InitAdminAPP(owner string) error { return err } log.Print("########################################admin-app###############################") - log.Printf("Init appid:%s",app.Appid) - log.Printf("Init accessKey:%s",app.AccessKey) - log.Printf("Init secret:%s",app.Secret) + log.Printf("Init appid:%s", app.Appid) + log.Printf("Init accessKey:%s", app.AccessKey) + log.Printf("Init secret:%s", app.Secret) log.Print("#################################################################################") return nil }