Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
shotengai
Commits
52c76607
Commit
52c76607
authored
Sep 30, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add info to product, series and snapshot
parent
1675501c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
6 deletions
+19
-6
1_create_shotengai_products_and_orders.rb
db/migrate/1_create_shotengai_products_and_orders.rb
+2
-0
product_series_controller.rb
...hotengai/controller/merchant/product_series_controller.rb
+2
-1
products_controller.rb
lib/shotengai/controller/merchant/products_controller.rb
+5
-1
json_column.rb
lib/shotengai/json_column.rb
+5
-0
product.rb
lib/shotengai/product.rb
+2
-2
series.rb
lib/shotengai/series.rb
+1
-1
snapshot.rb
lib/shotengai/snapshot.rb
+2
-1
No files found.
db/migrate/1_create_shotengai_products_and_orders.rb
View file @
52c76607
...
...
@@ -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
...
...
lib/shotengai/controller/merchant/product_series_controller.rb
View file @
52c76607
...
...
@@ -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
...
...
lib/shotengai/controller/merchant/products_controller.rb
View file @
52c76607
...
...
@@ -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
...
...
lib/shotengai/json_column.rb
View file @
52c76607
...
...
@@ -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
lib/shotengai/product.rb
View file @
52c76607
...
...
@@ -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
...
...
lib/shotengai/series.rb
View file @
52c76607
...
...
@@ -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
...
...
lib/shotengai/snapshot.rb
View file @
52c76607
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment