收紧数据保存检查

This commit is contained in:
2026-05-14 14:23:01 +08:00
parent 80f04c92ec
commit 8f89503c88
13 changed files with 174 additions and 42 deletions

View File

@@ -117,8 +117,14 @@ func (s *productService) UpdateProduct(update *UpdateProductData) error {
if update.Status != nil {
do = append(do, q.Product.Status.Value(*update.Status))
}
_, err := q.Product.Where(q.Product.ID.Eq(update.Id)).UpdateSimple(do...)
return err
r, err := q.Product.Where(q.Product.ID.Eq(update.Id)).UpdateSimple(do...)
if err != nil {
return err
}
if r.RowsAffected == 0 {
return core.NewBizErr("产品状态已过期")
}
return nil
}
type UpdateProductData struct {
@@ -132,6 +138,12 @@ type UpdateProductData struct {
// 删除产品
func (s *productService) DeleteProduct(id int32) error {
_, err := q.Product.Where(q.Product.ID.Eq(id)).UpdateColumn(q.Product.DeletedAt, time.Now())
return err
r, err := q.Product.Where(q.Product.ID.Eq(id)).UpdateColumn(q.Product.DeletedAt, time.Now())
if err != nil {
return err
}
if r.RowsAffected == 0 {
return core.NewBizErr("产品状态已过期")
}
return nil
}