feat: add book admin display fields
This commit is contained in:
@@ -11,3 +11,15 @@ func paginate(info commonReq.PageInfo) func(db *gorm.DB) *gorm.DB { return (&inf
|
||||
func deleteByIDs[T any](ids []int) error {
|
||||
return global.GVA_DB.Where("id in ?", ids).Delete(new(T)).Error
|
||||
}
|
||||
|
||||
func createWithExplicitIsEnabled[T any](item *T, isEnabled bool) error {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if err := tx.Create(item).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if isEnabled {
|
||||
return nil
|
||||
}
|
||||
return tx.Model(item).Update("is_enabled", false).Error
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user