Files
medical-mall/doc_mall/consumer/sql/update_product_attributes.sql
2026-02-03 17:26:23 +08:00

59 lines
2.6 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =====================================================================================
-- 补充商品参数数据 (Update Product Attributes)
-- 对应前端 product-detail.uvue 中的药品相关字段
-- 字段存储在 ml_products 表的 attributes JSONB 列中
-- =====================================================================================
-- 1. 更新所有商品,设置默认的通用参数 (避免 NULL)
UPDATE public.ml_products
SET attributes = attributes || '{
"specification": "标准盒装",
"expiry_date": "24个月",
"storage_conditions": "密封,置阴凉干燥处",
"approval_number": "国药准字H20050000"
}'::jsonb
WHERE attributes IS NULL OR attributes = '{}'::jsonb;
-- 2. 针对特定类型的商品设置详细参数 (示例:感冒药/止痛药类)
-- 假设通过名称模糊匹配
UPDATE public.ml_products
SET attributes = attributes || '{
"specification": "0.3g*24粒/盒",
"usage": "口服。一次1-2粒一日3次。",
"side_effects": "偶见恶心、呕吐、皮疹等轻微反应。",
"precautions": "1. 忌烟、酒及辛辣、生冷、油腻食物。\n2. 不宜在服药期间同时服用滋补性中药。",
"expiry_date": "36个月",
"storage_conditions": "密封,防潮",
"approval_number": "国药准字Z44020000"
}'::jsonb
WHERE name LIKE '%胶囊%' OR name LIKE '%感冒%';
-- 3. 针对特定类型的商品设置详细参数 (示例:维生素/保健类)
UPDATE public.ml_products
SET attributes = attributes || '{
"specification": "100片/瓶",
"usage": "每日一次,每次一片,饭后服用。",
"side_effects": "本品耐受性良好,偶见胃肠道不适。",
"precautions": "1. 本品不能代替药物。\n2. 不宜超过推荐量或与同类营养补充剂同时食用。",
"expiry_date": "24个月",
"storage_conditions": "遮光,密闭保存",
"approval_number": "国食健字G20100000"
}'::jsonb
WHERE name LIKE '%维生素%' OR name LIKE '%片%';
-- 4. 针对特定类型的商品设置详细参数 (示例:外用药/口罩)
UPDATE public.ml_products
SET attributes = attributes || '{
"specification": "10片/包",
"usage": "外用,打开包装即可使用。",
"side_effects": "极少数患者可能出现皮肤过敏。",
"precautions": "1. 本品为一次性使用。\n2. 皮肤破损处禁用。",
"expiry_date": "2年",
"storage_conditions": "置于通风干燥处",
"approval_number": "浙械注准20200000"
}'::jsonb
WHERE name LIKE '%口罩%' OR name LIKE '%贴%';
-- 5. 验证更新结果
-- SELECT id, name, attributes FROM public.ml_products LIMIT 5;