fix: delete method

This commit is contained in:
2025-02-20 18:30:24 +07:00
parent e2a0ef628f
commit e108c922d7
6 changed files with 24 additions and 25 deletions

View File

@@ -35,9 +35,9 @@ func (service *AuthorService) Update(item Author) (Author, error) {
err := dal.Author.Preload(field.Associations).Save(&item)
return item, err
}
func (service *AuthorService) Delete(item Author) (Author, error) {
_, err := dal.Author.Unscoped().Preload(field.Associations).Delete(&item)
return item, err
func (service *AuthorService) Delete(id uint) error {
_, err := dal.Author.Unscoped().Where(dal.Author.Id.Eq(id)).Delete()
return err
}
func (service *AuthorService) Count() (int64, error) {
amount, err := dal.Author.Count()