Skip to content

Commit

Permalink
fixed:修复更新api失败的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelmaxQm committed May 14, 2024
1 parent c515805 commit 136fb2f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions server/service/system/sys_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,16 @@ func (apiService *ApiService) UpdateApi(api system.SysApi) (err error) {
err = global.GVA_DB.First(&oldA, "id = ?", api.ID).Error
if oldA.Path != api.Path || oldA.Method != api.Method {
var duplicateApi system.SysApi
if err := global.GVA_DB.First(&duplicateApi, "path = ? AND method = ?", api.Path, api.Method).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
return err
if ferr := global.GVA_DB.First(&duplicateApi, "path = ? AND method = ?", api.Path, api.Method).Error; ferr != nil {
if !errors.Is(ferr, gorm.ErrRecordNotFound) {
return ferr
}
} else {
if duplicateApi.ID != api.ID {
return errors.New("存在相同api路径")
}
}
if duplicateApi.ID != api.ID {
return errors.New("存在相同api路径")
}

}
if err != nil {
return err
Expand Down

0 comments on commit 136fb2f

Please sign in to comment.