feat: upgrade IDatabase

This commit is contained in:
2025-10-18 21:34:35 +08:00
parent ad300277f8
commit 4c3f6f2a43

View File

@ -17,7 +17,7 @@ import (
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:06 2023/10/14
type IDatabase interface {
type IDatabase[DatabaseDataType any, DatabaseTableColumns any] interface {
// Create 创建数据
Create(dbInstance *gorm.DB, data any, optionList ...define.SetOption) error
// Update 更新数据
@ -25,13 +25,13 @@ type IDatabase interface {
// UpdateOne 更新一条数据
UpdateOne(dbInstance *gorm.DB, updateData any, optionFuncList ...define.SetOption) (int64, error)
// List 查询数据列表
List(dbInstance *gorm.DB, result any, optionFuncList ...define.SetOption) error
List(dbInstance *gorm.DB, result *[]DatabaseDataType, optionFuncList ...define.SetOption) error
// ListAndTotal 查询列表并返回满足条件数据总数
ListAndTotal(dbInstance *gorm.DB, listRes any, totalRes *int64, disableTotal bool, optionFuncList ...define.SetOption) error
ListAndTotal(dbInstance *gorm.DB, listRes *[]DatabaseDataType, totalRes *int64, disableTotal bool, optionFuncList ...define.SetOption) error
// Delete 删除数据
Delete(dbInstance *gorm.DB, dataModel any, optionFuncList ...define.SetOption) (int64, error)
Delete(dbInstance *gorm.DB, dataModel *DatabaseDataType, optionFuncList ...define.SetOption) (int64, error)
// Detail 数据详情
Detail(dbInstance *gorm.DB, result any, optionFuncList ...define.SetOption) error
Detail(dbInstance *gorm.DB, result *DatabaseDataType, optionFuncList ...define.SetOption) error
// IsNotFound 错误是否为数据不存在
IsNotFound(err error) bool
// Count 查询数据数量
@ -45,5 +45,5 @@ type IDatabase interface {
// Rollback 回滚事务
Rollback(db *gorm.DB) error
// DetailByPrimaryID 根据主键ID, 查询任意表的数据详情
DetailByPrimaryID(dbInstance *gorm.DB, result any, primaryID any, primaryKey ...string) error
DetailByPrimaryID(dbInstance *gorm.DB, result *DatabaseDataType, primaryID any, primaryKey ...string) error
}