Commit 52c76607 by ivan Lan

Add info to product, series and snapshot

parent 1675501c
......@@ -39,6 +39,7 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
t.string :type
t.json :meta
t.json :remark
t.json :info
t.references :shotengai_product, foreign_key: true
t.timestamps
......@@ -88,6 +89,7 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
t.string :type
t.json :meta
t.json :remark
t.json :info
t.references :shotengai_series, foreign_key: true
t.references :shotengai_order, foreign_key: true
......
......@@ -40,13 +40,14 @@ module Shotengai
private
def resource_params
spec_input = params.require(resource_key).fetch(:spec_input, nil)&.map(&:permit!)
info_input = params.require(resource_key).fetch(:info_input, nil)&.map(&:permit!)
meta = params.require(resource_key).fetch(:meta, nil).try(:permit!)
# ????????!!!!!, spec_input: [:key, :val] 一样的输出值 却在test报错???
# QUESTION: WARNING: 文档bug吧?????
params.require(resource_key).permit(
:original_price, :price, :stock#, spec_input: [:key, :val]
).merge(
{ spec_input: spec_input, meta: meta }
{ spec_input: spec_input, info_input: info_input, meta: meta }
)
end
......
......@@ -65,6 +65,7 @@ module Shotengai
# spec = params.require(resource_key).fetch(:spec, nil).try(:permit!)
spec_input = params.require(resource_key).fetch(:spec_input, nil)&.map(&:permit!)
remark_input = params.require(resource_key).fetch(:remark_input, nil)&.map(&:permit!)
info_input = params.require(resource_key).fetch(:info_input, nil)&.map(&:permit!)
detail = params.require(resource_key).fetch(:detail, nil).try(:permit!)
meta = params.require(resource_key).fetch(:meta, nil).try(:permit!)
# NOTE: :catalog_list is a default catalog list for template example, maybe should move it to the template controller, but it need add controller template for every controller
......@@ -75,7 +76,10 @@ module Shotengai
# spec_input: [:key, val: []],
# remark_input: [:key, :val],
).merge(
{ spec_input: spec_input, remark_input: remark_input, detail: detail, meta: meta }
{
spec_input: spec_input, remark_input: remark_input, info_input: info_input,
detail: detail, meta: meta
}
)
end
end
......
......@@ -24,6 +24,10 @@ module Shotengai
}
end
end
def hash_column
# like meta, detail these json using for code development
end
end
end
end
\ No newline at end of file
......@@ -31,8 +31,8 @@ module Shotengai
require 'acts-as-taggable-on'
self.table_name = 'shotengai_products'
custom_hash_columns :spec, :remark
custom_hash_columns :spec, :remark, :info
belongs_to :manager, polymorphic: true, optional: true#, touch: true
validate :check_spec, if: :spec
......
......@@ -29,7 +29,7 @@ module Shotengai
# Using validates_uniqueness_of do not work if the order of Hash is diff
validate :uniq_spec
custom_hash_columns :spec, :remark
custom_hash_columns :spec, :remark, :info
delegate :title, :detail, :banners, :cover_image, :status, :status_zh, :manager, to: :product
......
......@@ -36,7 +36,7 @@ module Shotengai
validate :check_remark
validates :count, numericality: { only_integer: true, greater_than: 0 }
custom_hash_columns :spec, :remark
custom_hash_columns :spec, :info, :remark
validate :cannot_edit, if: :order_was_paid
before_destroy :cannot_edit, if: :order_was_paid
......@@ -129,6 +129,7 @@ module Shotengai
original_price: series.original_price,
price: series.price,
spec: series.spec,
info: series.info,
banners: series.banners,
cover_image: series.cover_image,
detail: series.detail,
......
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