Skip to content

Commit

Permalink
fix:init op skip not record found error
Browse files Browse the repository at this point in the history
  • Loading branch information
geebytes committed May 7, 2024
1 parent aa692f6 commit 9c921ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/pkg/migrate/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 == ""{
Expand Down
9 changes: 5 additions & 4 deletions internal/pkg/migrate/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 == "" {
Expand Down Expand Up @@ -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
}

0 comments on commit 9c921ef

Please sign in to comment.