mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 20:27:23 +00:00
Fix UpdateResource
This commit is contained in:
@@ -57,9 +57,18 @@ func GetResourceList(page, pageSize int) ([]model.Resource, int, error) {
|
||||
|
||||
func UpdateResource(r model.Resource) error {
|
||||
// Update a resource in the database
|
||||
r1 := r
|
||||
r.Images = nil
|
||||
r.Tags = nil
|
||||
if err := db.Save(&r).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.Model(&r1).Association("Images").Replace(r.Images); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.Model(&r1).Association("Tags").Replace(r.Tags); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user