feat: update route ads
This commit is contained in:
@@ -12,6 +12,7 @@ type accessor struct {
|
||||
type Ads interface {
|
||||
Create(adsdomain.Ads) error
|
||||
GetAll() ([]adsdomain.Ads, error)
|
||||
Update(adsdomain.Ads) error
|
||||
Delete(string) error
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package adsrepository
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
adsdomain "legalgo-BE-go/internal/domain/ads"
|
||||
|
||||
"gorm.io/gorm/clause"
|
||||
)
|
||||
|
||||
func (a *accessor) Update(spec adsdomain.Ads) error {
|
||||
if err := a.db.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "id"}},
|
||||
DoUpdates: clause.AssignmentColumns([]string{
|
||||
"image_url",
|
||||
"url",
|
||||
"updated_at",
|
||||
"start_date",
|
||||
"end_date",
|
||||
}),
|
||||
}).Select(
|
||||
"image_url",
|
||||
"url",
|
||||
"updated_at",
|
||||
"start_date",
|
||||
"end_date",
|
||||
).Save(&spec).Error; err != nil {
|
||||
return fmt.Errorf("failed to update tag: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user