feat:delete

master
howell 3 years ago
parent 0f72671aae
commit e9de4983d9

@ -372,11 +372,20 @@ func (g *goodsLogic) SearchCategory(req *ArgsSearchList) (result []*SearchListRe
func (g *goodsLogic) DeleteBox(user uint, req *strict.ArgsDelete) error {
var o goods2.GysGoodsInfoModel
if err := dbc.DB.Table(o.TableName()).
Delete(&o, "user_id = ? AND id = ? AND publish_status = ?",
user, req.GoodsID, goods2.GysGoodsInfoPublishStatusDraft).Error; err != nil {
if err := dbc.DB.Transaction(func(tx *gorm.DB) error {
if err := tx.Table(o.TableName()).
Delete(&o, "user_id = ? AND id = ? AND publish_status = ?",
user, req.GoodsID, goods2.GysGoodsInfoPublishStatusDraft).Error; err != nil {
return err
}
if err := tx.Delete(&goods2.GysGoodsSkuModel{}, "goods_id = ?", req.GoodsID).Error; err != nil {
return err
}
return nil
}); err != nil {
return err
}
return nil
}

Loading…
Cancel
Save