Commit 98f4cee7 by ivan Lan

Separate the snapshot own meta from the meta come from its product and series

parent 2c35a499
...@@ -211,6 +211,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta ...@@ -211,6 +211,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
meta: { type: :object }, meta: { type: :object },
incr_snapshot_ids: { type: :array }, incr_snapshot_ids: { type: :array },
}, },
}
snapshot: { snapshot: {
type: :object, properties: { type: :object, properties: {
shotengai_series_id: { type: :integer }, shotengai_series_id: { type: :integer },
...@@ -219,7 +220,6 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta ...@@ -219,7 +220,6 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
} }
} }
} }
}
response(201, description: 'successful') do response(201, description: 'successful') do
let(:order_and_snapshot_params) { let(:order_and_snapshot_params) {
......
...@@ -16,8 +16,6 @@ module Shotengai ...@@ -16,8 +16,6 @@ module Shotengai
define_method("#{column}_input=") do |val| define_method("#{column}_input=") do |val|
parsed_val = val && val.map{ |h| { (h[:key] || h['key']) => (h[:val] || h['val']) } }.reduce(&:merge) parsed_val = val && val.map{ |h| { (h[:key] || h['key']) => (h[:val] || h['val']) } }.reduce(&:merge)
self.#{column} = parsed_val self.#{column} = parsed_val
# self.assign_attributes('#{column}' => parsed_val)
end end
define_method("#{column}_output") do define_method("#{column}_output") do
......
...@@ -80,8 +80,21 @@ module Shotengai ...@@ -80,8 +80,21 @@ module Shotengai
define_method(column) { read_attribute(column) || self.series.send(column) } define_method(column) { read_attribute(column) || self.series.send(column) }
end end
def full_meta
read_attribute(:meta) || {}
end
def full_meta= val
write_attribute(:meta, val)
end
def meta def meta
read_attribute(:meta) || (series.product.meta || {} ).merge(series.meta || {}) full_meta['snapshot'] || {}
end
def meta= val
self.full_meta = full_meta.merge('snapshot' => val)
end end
def already_disable def already_disable
...@@ -111,7 +124,11 @@ module Shotengai ...@@ -111,7 +124,11 @@ module Shotengai
banners: series.banners, banners: series.banners,
cover_image: series.cover_image, cover_image: series.cover_image,
detail: series.detail, detail: series.detail,
meta: (product.meta || {} ).merge(series.meta || {}) full_meta: {
product: product.meta,
series: series.meta,
snapshot: meta,
}
) )
end end
...@@ -138,12 +155,6 @@ module Shotengai ...@@ -138,12 +155,6 @@ module Shotengai
def order_status; shotengai_order&.status end def order_status; shotengai_order&.status end
def order_status_zh; shotengai_order&.status_zh end def order_status_zh; shotengai_order&.status_zh end
######
def meta
super || {}
end
private private
# spec 字段 # spec 字段
def check_spec def check_spec
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment