feat: add book admin display fields

This commit is contained in:
2026-04-27 13:53:37 +08:00
parent 67c33d06be
commit 2fa15625b0
20 changed files with 472 additions and 70 deletions

View File

@@ -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
})
}