fix: DetailForAny
This commit is contained in:
12
base.go
12
base.go
@ -289,12 +289,20 @@ func (b *BaseDao[DatabaseDataType, DatabaseTableColumns]) Columns() DatabaseTabl
|
||||
func (b *BaseDao[DatabaseDataType, DatabaseTableColumns]) DetailForAny(tx *gorm.DB, tableName string, result any, optionList ...define.SetOption) error {
|
||||
tx = tx.Model(&gorm.Model{}).Table(tableName)
|
||||
tx = b.setTxCondition(tx, optionList...)
|
||||
return tx.Model(result).First(result).Error
|
||||
return tx.Model(&IgnoreData{}).First(result).Error
|
||||
}
|
||||
|
||||
// ListForAny 查询任意表数据列表
|
||||
func (b *BaseDao[DatabaseDataType, DatabaseTableColumns]) ListForAny(tx *gorm.DB, tableName string, data any, optionList ...define.SetOption) error {
|
||||
tx = tx.Model(&gorm.Model{}).Table(tableName)
|
||||
tx = b.setTxCondition(tx, optionList...)
|
||||
return tx.Model(data).Find(data).Error
|
||||
return tx.Model(&IgnoreData{}).Find(data).Error
|
||||
}
|
||||
|
||||
type IgnoreData struct {
|
||||
gorm.DB
|
||||
}
|
||||
|
||||
func (id IgnoreData) TableName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user