fix: zero value failed to update

This commit is contained in:
zchengo
2022-12-23 20:21:36 +08:00
parent 8de3ccdebd
commit 7fecd6ba7f
5 changed files with 55 additions and 18 deletions
+2 -2
View File
@@ -42,8 +42,8 @@ func (p *ProductService) Update(param *models.ProductUpdateParam) int {
Status: param.Status,
Updated: time.Now().Unix(),
}
err := global.Db.Model(&product).Updates(&product).Error
if err != nil {
db := global.Db.Model(&product).Select("*").Omit("id", "creator", "created")
if err := db.Updates(&product).Error; err != nil {
return response.ErrCodeFailed
}
return response.ErrCodeSuccess