Skip to content

Commit

Permalink
fix: gormfind (#370)
Browse files Browse the repository at this point in the history
Co-authored-by: fusikai <fusikai@douyu.tv>
  • Loading branch information
linthan and fusikai committed Feb 13, 2023
1 parent 6d0e164 commit 83429f5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/install/mock_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func mockGrafanaSetting(url string, e *echo.Echo) {

func mockAdminUser() {
var user db.User
invoker.JunoMysql.Where("uid = ?", 1).Find(&user)
invoker.JunoMysql.Where("uid = ?", 1).First(&user)
if user.Uid == 0 {
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/service/confgo/tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (r *confu) GetTplList(where db.CmcTpl, currentPage, pageSize int, keyType,
}

func (r *confu) GetTpl(v int) (resp db.CmcTpl, err error) {
err = r.DB.Where("id = ?", v).Find(&resp).Error
err = r.DB.Where("id = ?", v).First(&resp).Error
return
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/service/confgov2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func Instances(param view.ReqConfigInstanceList) (resp view.RespConfigInstanceLi
instanceNotPublished = make(view.RespConfigInstanceList, 0)
)
// get configuration info
query := mysql.Where("id=?", param.ConfigurationID).Find(&configuration)
query := mysql.Where("id=?", param.ConfigurationID).First(&configuration)
if query.Error != nil {
err = query.Error
return
Expand Down Expand Up @@ -772,7 +772,7 @@ func Publish(param view.ReqPublishConfig, c echo.Context) (err error) {

// get publish version
var confHistory db.ConfigurationHistory
query = mysql.Where("configuration_id=? and version =?", param.ID, param.Version).Find(&confHistory)
query = mysql.Where("configuration_id=? and version =?", param.ID, param.Version).First(&confHistory)
if query.Error != nil {
return query.Error
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/service/confgov2/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func getUsedStatus(env, zoneCode, filePath string, ipPort string) int {
}

func getConfigurationStatus(configurationID uint, hostName string) (res db.ConfigurationStatus, err error) {
query := mysql.Preload("ConfigurationPublish").Where("configuration_id=? and host_name=?", configurationID, hostName).Order("id desc").Find(&res)
query := mysql.Preload("ConfigurationPublish").Where("configuration_id=? and host_name=?", configurationID, hostName).Order("id desc").First(&res)
if query.Error != nil {
err = query.Error
return
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/service/resource/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
func (r *resource) GetApp(identify interface{}) (resp db.AppInfo, err error) {
switch v := identify.(type) {
case string:
err = r.DB.Where("app_name = ?", v).Find(&resp).Error
err = r.DB.Where("app_name = ?", v).First(&resp).Error
case int, uint:
err = r.DB.Where("aid=?", v).Find(&resp).Error
err = r.DB.Where("aid=?", v).First(&resp).Error
default:
err = errors.New("identify type error")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/service/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (t *tool) List(currentPage int, pageSize int, queryObj string) *view.RespTo
func (t *tool) Detail(id int) *db.ToolInfo {
resp := new(db.ToolInfo)
invoker.JunoMysql.Table("tool").Select("id, name, url, pic_url, create_time, `desc`").
Where("id = ?", id).Find(&resp)
Where("id = ?", id).First(&resp)
return resp
}

Expand Down

0 comments on commit 83429f5

Please sign in to comment.