增加数据库异常是否为数据不存在

This commit is contained in:
2023-02-23 15:59:09 +08:00
parent 9f569069d5
commit 0dd215a1b9
3 changed files with 48 additions and 5 deletions

View File

@ -70,6 +70,15 @@ func (b *BaseDao) Detail(dbInstance *gorm.DB, result interface{}, optionFuncList
return dbInstance.Table(b.TableName).First(result).Error
}
// IsNotFound 增加结果是否为数据不存在的判断
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:57 2023/2/23
func (b *BaseDao) IsNotFound(err error) bool {
return err == gorm.ErrRecordNotFound
}
// Count 查询数量
//
// Author : go_developer@163.com<白茶清欢>