diff --git a/server/service/exa_breakpoint_continue.go b/server/service/exa_breakpoint_continue.go index 27164aab31534dc749dce9cc32a548dda808e373..cfc3b9889ce57a8be16d317f75ae8a54e6d9d2b2 100644 --- a/server/service/exa_breakpoint_continue.go +++ b/server/service/exa_breakpoint_continue.go @@ -22,16 +22,15 @@ func FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (err erro cfile.FileMd5 = fileMd5 cfile.FileName = fileName cfile.ChunkTotal = chunkTotal - notHaveSameMd5Finish := errors.Is(global.GVA_DB.Where("file_md5 = ? AND is_finish = ?", fileMd5, true).First(&file).Error, gorm.ErrRecordNotFound) - if notHaveSameMd5Finish { + + if errors.Is(global.GVA_DB.Where("file_md5 = ? AND is_finish = ?", fileMd5, true).First(&file).Error, gorm.ErrRecordNotFound) { err = global.GVA_DB.Where("file_md5 = ? AND file_name = ?", fileMd5, fileName).Preload("ExaFileChunk").FirstOrCreate(&file, cfile).Error return err, file - } else { - cfile.IsFinish = true - cfile.FilePath = file.FilePath - err = global.GVA_DB.Create(&cfile).Error - return err, cfile } + cfile.IsFinish = true + cfile.FilePath = file.FilePath + err = global.GVA_DB.Create(&cfile).Error + return err, cfile } // @title CreateFileChunk diff --git a/server/service/exa_simple_uploader.go b/server/service/exa_simple_uploader.go index f888bd9f4f2d41a049f8e1acbd7a7d34b927a8c5..25777c3d7234e5bd82a84a7c358a97cb89422429 100644 --- a/server/service/exa_simple_uploader.go +++ b/server/service/exa_simple_uploader.go @@ -28,8 +28,7 @@ func MergeFileMd5(md5 string, fileName string) (err error) { finishDir := "./finish/" dir := "./chunk/" + md5 //如果文件上传成功 不做后续操作 通知成功即可 - notFinish := errors.Is(global.GVA_DB.First(&model.ExaSimpleUploader{}, "identifier = ? AND is_done = ?", md5, true).Error, gorm.ErrRecordNotFound) - if !notFinish { + if !errors.Is(global.GVA_DB.First(&model.ExaSimpleUploader{}, "identifier = ? AND is_done = ?", md5, true).Error, gorm.ErrRecordNotFound) { return nil } diff --git a/server/service/sys_authority.go b/server/service/sys_authority.go index dc6b86df08e088434bde91529c4bc657a92ec85f..1ef4c92128af7530e6273ff3f2f7aafe2095b729 100644 --- a/server/service/sys_authority.go +++ b/server/service/sys_authority.go @@ -19,8 +19,7 @@ import ( func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAuthority) { var authorityBox model.SysAuthority - notHas := errors.Is(global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&authorityBox).Error, gorm.ErrRecordNotFound) - if !notHas { + if !errors.Is(global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&authorityBox).Error, gorm.ErrRecordNotFound) { return errors.New("存在相同角色id"), auth } err = global.GVA_DB.Create(&auth).Error @@ -36,8 +35,7 @@ func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAut func CopyAuthority(copyInfo response.SysAuthorityCopyResponse) (err error, authority model.SysAuthority) { var authorityBox model.SysAuthority - notHas := errors.Is(global.GVA_DB.Where("authority_id = ?", copyInfo.Authority.AuthorityId).First(&authorityBox).Error, gorm.ErrRecordNotFound) - if !notHas { + if !errors.Is(global.GVA_DB.Where("authority_id = ?", copyInfo.Authority.AuthorityId).First(&authorityBox).Error, gorm.ErrRecordNotFound) { return errors.New("存在相同角色id"), authority } copyInfo.Authority.Children = []model.SysAuthority{} @@ -79,12 +77,10 @@ func UpdateAuthority(auth model.SysAuthority) (err error, authority model.SysAut // 删除角色 func DeleteAuthority(auth *model.SysAuthority) (err error) { - notHas := errors.Is(global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&model.SysUser{}).Error, gorm.ErrRecordNotFound) - if !notHas { + if !errors.Is(global.GVA_DB.Where("authority_id = ?", auth.AuthorityId).First(&model.SysUser{}).Error, gorm.ErrRecordNotFound) { return errors.New("此角色有用户正在使用禁止删除") } - notHas = errors.Is(global.GVA_DB.Where("parent_id = ?", auth.AuthorityId).First(&model.SysAuthority{}).Error, gorm.ErrRecordNotFound) - if !notHas { + if !errors.Is(global.GVA_DB.Where("parent_id = ?", auth.AuthorityId).First(&model.SysAuthority{}).Error, gorm.ErrRecordNotFound) { return errors.New("此角色存在子角色不允许删除") } db := global.GVA_DB.Preload("SysBaseMenus").Where("authority_id = ?", auth.AuthorityId).First(auth) diff --git a/server/service/sys_base_menu.go b/server/service/sys_base_menu.go index eee9e525986e5ca741048bd9867b501c52dce6bd..787acc96cba5d625d5e6ff14ad5fb15e3e8cfca4 100644 --- a/server/service/sys_base_menu.go +++ b/server/service/sys_base_menu.go @@ -52,8 +52,7 @@ func UpdateBaseMenu(menu model.SysBaseMenu) (err error) { db := global.GVA_DB.Where("id = ?", menu.ID).Find(&oldMenu) if oldMenu.Name != menu.Name { - notSame := errors.Is(global.GVA_DB.Where("id <> ? AND name = ?", menu.ID, menu.Name).First(&model.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) - if !notSame { + if !errors.Is(global.GVA_DB.Where("id <> ? AND name = ?", menu.ID, menu.Name).First(&model.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) { global.GVA_LOG.Debug("存在相同name修改失败") return errors.New("存在相同name修改失败") } diff --git a/server/service/sys_dictionary.go b/server/service/sys_dictionary.go index b3992fe48b06c84557eecf5fd979d82f8fc25936..832ded6bd447cd486745889edba638baaee2831d 100644 --- a/server/service/sys_dictionary.go +++ b/server/service/sys_dictionary.go @@ -53,9 +53,9 @@ func UpdateSysDictionary(sysDictionary *model.SysDictionary) (err error) { } else { if (!errors.Is(global.GVA_DB.First(&model.SysDictionary{}, "type = ?", sysDictionary.Type).Error, gorm.ErrRecordNotFound)) { return errors.New("存在相同的type,不允许创建") - } else { - err = db.Updates(sysDictionaryMap).Error } + err = db.Updates(sysDictionaryMap).Error + } return err }