收紧数据保存检查

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

@@ -43,8 +43,14 @@ func (s *productDiscountService) Update(data UpdateProductDiscountData) (err err
do = append(do, q.ProductDiscount.Discount.Value(*data.Discount))
}
_, err = q.ProductDiscount.Where(q.ProductDiscount.ID.Eq(data.ID)).UpdateSimple(do...)
return err
r, err := q.ProductDiscount.Where(q.ProductDiscount.ID.Eq(data.ID)).UpdateSimple(do...)
if err != nil {
return err
}
if r.RowsAffected == 0 {
return core.NewServErr("产品折扣状态已过期")
}
return nil
}
type UpdateProductDiscountData struct {
@@ -54,6 +60,12 @@ type UpdateProductDiscountData struct {
}
func (s *productDiscountService) Delete(id int32) (err error) {
_, err = q.ProductDiscount.Where(q.ProductDiscount.ID.Eq(id)).UpdateColumn(q.ProductDiscount.DeletedAt, time.Now())
return
r, err := q.ProductDiscount.Where(q.ProductDiscount.ID.Eq(id)).UpdateColumn(q.ProductDiscount.DeletedAt, time.Now())
if err != nil {
return err
}
if r.RowsAffected == 0 {
return core.NewServErr("产品折扣状态已过期")
}
return nil
}