2023-10-14 15:14:05 +08:00
|
|
|
// Package abstract ...
|
|
|
|
//
|
|
|
|
// Description : abstract ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2023-10-14 15:06
|
|
|
|
package abstract
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.zhangdeman.cn/zhangdeman/database"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Base 定义base约束
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 15:06 2023/10/14
|
|
|
|
type Base interface {
|
|
|
|
// Create 创建数据
|
|
|
|
Create(dbInstance *gorm.DB, data interface{}, optionList ...database.SetOption) error
|
|
|
|
// Update 更新数据
|
|
|
|
Update(dbInstance *gorm.DB, updateData interface{}, optionFuncList ...database.SetOption) (int64, error)
|
2024-01-13 17:08:47 +08:00
|
|
|
// UpdateOne 更新一条数据
|
|
|
|
UpdateOne(dbInstance *gorm.DB, updateData interface{}, optionFuncList ...database.SetOption) (int64, error)
|
2023-10-14 15:14:05 +08:00
|
|
|
// List 查询数据列表
|
|
|
|
List(dbInstance *gorm.DB, result interface{}, optionFuncList ...database.SetOption) error
|
|
|
|
// Delete 删除数据
|
|
|
|
Delete(dbInstance *gorm.DB, dataModel interface{}, optionFuncList ...database.SetOption) (int64, error)
|
|
|
|
// Detail 数据详情
|
|
|
|
Detail(dbInstance *gorm.DB, result interface{}, optionFuncList ...database.SetOption) error
|
|
|
|
// IsNotFound 错误是否为数据不存在
|
|
|
|
IsNotFound(err error) bool
|
|
|
|
// Count 查询数据数量
|
|
|
|
Count(dbInstance *gorm.DB, optionFuncList ...database.SetOption) (int64, error)
|
|
|
|
// Tx 执行事务
|
|
|
|
Tx(dbInstance *gorm.DB, txFunc func(dbInstance *gorm.DB) error) error
|
|
|
|
// Begin 开启事务
|
|
|
|
Begin(dbInstance *gorm.DB) *gorm.DB
|
|
|
|
// Commit 提交事务
|
|
|
|
Commit(db *gorm.DB) error
|
|
|
|
// Rollback 回滚事务
|
|
|
|
Rollback(db *gorm.DB) error
|
|
|
|
}
|