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
9d81dd42
Commit
9d81dd42
authored
Sep 27, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add remark to product & series & snapshot
parent
267b8da0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
22 deletions
+6
-22
carts_controller.rb
lib/shotengai/controller/customer/carts_controller.rb
+1
-1
product_snapshots_controller.rb
...engai/controller/customer/product_snapshots_controller.rb
+1
-1
products_controller.rb
lib/shotengai/controller/customer/products_controller.rb
+1
-1
series.rb
lib/shotengai/series.rb
+0
-17
snapshot.rb
lib/shotengai/snapshot.rb
+3
-2
No files found.
lib/shotengai/controller/customer/carts_controller.rb
View file @
9d81dd42
...
@@ -24,7 +24,7 @@ module Shotengai
...
@@ -24,7 +24,7 @@ module Shotengai
def
snapshot_params
def
snapshot_params
params
.
require
(
:snapshot
).
permit
(
params
.
require
(
:snapshot
).
permit
(
:shotengai_series_id
,
:count
:shotengai_series_id
,
:count
,
remark_input:
[
:key
,
:val
]
)
)
end
end
...
...
lib/shotengai/controller/customer/product_snapshots_controller.rb
View file @
9d81dd42
...
@@ -31,7 +31,7 @@ module Shotengai
...
@@ -31,7 +31,7 @@ module Shotengai
private
private
def
resource_params
def
resource_params
params
.
require
(
resource_key
).
permit
(
params
.
require
(
resource_key
).
permit
(
:count
,
:shotengai_series_id
:count
,
:shotengai_series_id
,
remark_input:
[
:key
,
:val
]
)
)
end
end
...
...
lib/shotengai/controller/customer/products_controller.rb
View file @
9d81dd42
...
@@ -9,7 +9,7 @@ module Shotengai
...
@@ -9,7 +9,7 @@ module Shotengai
skip_before_action
:buyer_auth
skip_before_action
:buyer_auth
def
default_query
resources
def
default_query
resources
resources
.
aliv
e
resources
.
on_sal
e
end
end
def
index_query
resources
def
index_query
resources
...
...
lib/shotengai/series.rb
View file @
9d81dd42
...
@@ -85,12 +85,6 @@ module Shotengai
...
@@ -85,12 +85,6 @@ module Shotengai
end
end
end
end
def
initialize
*
arg
super
(
*
arg
)
self
.
remark
=
Hash
[
product
.
remark
.
map
{
|
k
,
v
|
[
k
,
true
]
}]
self
end
def
cut_stock
count
def
cut_stock
count
self
.
stock
.
eql?
(
-
1
)
||
self
.
update!
(
stock:
self
.
stock
-
count
)
self
.
stock
.
eql?
(
-
1
)
||
self
.
update!
(
stock:
self
.
stock
-
count
)
end
end
...
@@ -102,15 +96,6 @@ module Shotengai
...
@@ -102,15 +96,6 @@ module Shotengai
def
meta
def
meta
super
||
{}
super
||
{}
end
end
def
spec_output
spec
.
map
{
|
key
,
val
|
{
key:
key
,
val:
val
,
}
}
end
private
private
# spec 字段
# spec 字段
...
@@ -127,8 +112,6 @@ module Shotengai
...
@@ -127,8 +112,6 @@ module Shotengai
# product.remark.keys 包含 remark.keys
# product.remark.keys 包含 remark.keys
illegal_key
=
(
remark
.
keys
-
product
.
remark
.
keys
)
illegal_key
=
(
remark
.
keys
-
product
.
remark
.
keys
)
errors
.
add
(
:remark
,
"非法的关键字,
#{
illegal_key
}
"
)
unless
illegal_key
.
empty?
errors
.
add
(
:remark
,
"非法的关键字,
#{
illegal_key
}
"
)
unless
illegal_key
.
empty?
# illegal_values = remark.reject { |k, v| !!v == v }.keys
# errors.add(:spec, "非法的值,仅允许布尔值。#{illegal_values}") unless illegal_values.empty?
end
end
def
uniq_spec
def
uniq_spec
...
...
lib/shotengai/snapshot.rb
View file @
9d81dd42
...
@@ -156,9 +156,10 @@ module Shotengai
...
@@ -156,9 +156,10 @@ module Shotengai
def
check_remark
def
check_remark
errors
.
add
(
:remark
,
'remark 必须是个 Hash'
)
unless
remark
.
is_a?
(
Hash
)
errors
.
add
(
:remark
,
'remark 必须是个 Hash'
)
unless
remark
.
is_a?
(
Hash
)
required_key
=
series
.
series
.
remark
.
select
{
|
k
,
v
|
v
}.
keys
nullable_key
=
series
.
remark
.
select
{
|
k
,
v
|
v
}.
keys
required_key
=
product
.
remark
.
keys
-
nullable_key
# remark 可添加多余字段
# remark 可添加多余字段
errors
.
add
(
:remark
,
'非法的关键字,或关键字缺失'
)
unless
(
required_key
-
remark
.
keys
).
empty?
errors
.
add
(
:remark
,
'非法的关键字,或关键字缺失'
)
unless
(
required_key
-
remark
.
keys
).
empty?
end
end
# NOTE: Shotengai::Snapshot.find_by_id(self.id) to get the self before changed
# NOTE: Shotengai::Snapshot.find_by_id(self.id) to get the self before changed
...
...
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