diff --git a/internal/api/client_init/init_config.go b/internal/api/client_init/init_config.go index f36a22065..de08fc90c 100644 --- a/internal/api/client_init/init_config.go +++ b/internal/api/client_init/init_config.go @@ -9,6 +9,7 @@ import ( "net/http" "github.com/gin-gonic/gin" + "github.com/jinzhu/gorm" ) func SetClientInitConfig(c *gin.Context) { @@ -61,8 +62,11 @@ func GetClientInitConfig(c *gin.Context) { } config, err := imdb.GetClientInitConfig() if err != nil { - log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) + if !gorm.IsRecordNotFoundError(err) { + log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) + return + } } resp.Data.DiscoverPageURL = config.DiscoverPageURL log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp ", resp) diff --git a/pkg/common/db/mysql_model/im_mysql_model/client_config.go b/pkg/common/db/mysql_model/im_mysql_model/client_config.go index 9e508ef3e..ae932ed92 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/client_config.go +++ b/pkg/common/db/mysql_model/im_mysql_model/client_config.go @@ -7,7 +7,7 @@ func SetClientInitConfig(m map[string]interface{}) error { if result.Error != nil { return result.Error } - if result.RowsAffected == 1 { + if result.RowsAffected == 0 { err := db.DB.MysqlDB.DefaultGormDB().Model(&db.ClientInitConfig{}).Create(m).Error return err }