feat: update and delete tags and categories

This commit is contained in:
ericprd
2025-03-05 23:13:24 +08:00
parent 5c699dfa53
commit 299fcf949b
22 changed files with 283 additions and 32 deletions
+14
View File
@@ -0,0 +1,14 @@
package categoryrepository
import (
"fmt"
categorydomain "legalgo-BE-go/internal/domain/category"
)
func (a *accessor) Delete(id string) error {
if err := a.DB.Delete(&categorydomain.Category{}, "id = ?", id).Error; err != nil {
return fmt.Errorf("failed to delete category %s : %v", id, err)
}
return nil
}
+3 -3
View File
@@ -10,11 +10,11 @@ type accessor struct {
}
type Category interface {
CreateModel(categorydomain.CategoryReq) error
Update(categorydomain.Category) error
GetAllModel() ([]categorydomain.Category, error)
GetByIDs([]string) ([]categorydomain.Category, error)
CreateModel(categorydomain.CategoryReq) error
Update(categorydomain.Category) error
Delete(string) error
}
func New(
+1 -1
View File
@@ -11,7 +11,7 @@ func (a *accessor) Update(spec categorydomain.Category) error {
if err := a.DB.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "id"}},
DoUpdates: clause.AssignmentColumns([]string{"name", "code", "updated_at"}),
}).Save(&spec).Error; err != nil {
}).Select("name", "code", "updated_at").Save(&spec).Error; err != nil {
return fmt.Errorf("failed to update category: %v", err)
}