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
df42df0a
Commit
df42df0a
authored
Aug 29, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish Merchant Order Controller
parent
21ab10da
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
9 deletions
+39
-9
index.json.jbuilder
...ators/templates/views/merchant/orders/index.json.jbuilder
+3
-2
show.json.jbuilder
...rators/templates/views/merchant/orders/show.json.jbuilder
+1
-1
_order.json.jbuilder
lib/generators/templates/views/share/_order.json.jbuilder
+2
-2
base.rb
lib/shotengai/controllers/base.rb
+14
-3
orders_controller.rb
lib/shotengai/controllers/merchant/orders_controller.rb
+19
-0
product_snapshots_controller.rb
...ngai/controllers/merchant/product_snapshots_controller.rb
+0
-1
No files found.
lib/generators/templates/views/merchant/orders/index.json.jbuilder
View file @
df42df0a
json.current_page @
order
s.current_page
json.total_pages @
order
s.total_pages
json.current_page @
resource
s.current_page
json.total_pages @
resource
s.total_pages
json.set! @resources.klass.model_name.collection do
json.array! @resources, partial: 'shotengai/share/order_simple', as: :order
end
\ No newline at end of file
lib/generators/templates/views/merchant/orders/show.json.jbuilder
View file @
df42df0a
json.partial! "shotengai/share/order
_simple
", order: @resource
json.partial! "shotengai/share/order", order: @resource
lib/generators/templates/views/share/_order.json.jbuilder
View file @
df42df0a
...
...
@@ -3,4 +3,4 @@ json.extract! order, :id, :seq, :status_zh, :address,
:delivery_way, :delivery_cost,
:merchant_remark, :mark, :customer_remark,
:status, :status_zh, :meta
json.snapshots, partial: 'shotengai/share/snapshot_simple', as: :series
\ No newline at end of file
json.snapshots order.snapshots, partial: 'shotengai/share/snapshot_simple', as: :snapshot
\ No newline at end of file
lib/shotengai/controllers/base.rb
View file @
df42df0a
...
...
@@ -59,9 +59,20 @@ module Shotengai
respond_to
:json
# TODO: could not catch the exception
# rescue_from Shotengai::WebError do |e|
# render json: { error: e.message }, status: e.status
# end
respond_to
:json
rescue_from
::
Shotengai
::
WebError
do
|
e
|
render
json:
{
error:
e
.
message
},
status:
e
.
status
end
rescue_from
ActiveRecord
::
RecordInvalid
do
|
e
|
render
json:
{
error:
e
.
message
},
status:
400
end
rescue_from
AASM
::
InvalidTransition
do
|
e
|
render
json:
{
error:
e
.
message
},
status:
400
end
def
index
page
=
params
[
:page
]
||
1
...
...
lib/shotengai/controllers/merchant/orders_controller.rb
View file @
df42df0a
...
...
@@ -2,7 +2,26 @@ module Shotengai
module
Controller
module
Merchant
class
OrdersController
<
Shotengai
::
Controller
::
Base
self
.
resources
=
Order
self
.
template_dir
=
'shotengai/merchant/orders/'
remove_actions
:create
,
:destroy
index_query
do
|
resource
,
params
|
resource
.
status_is
(
params
[
:status
])
end
def
send_out
@resource
.
send_out!
respond_with
@resource
,
template:
"
#{
@@template_dir
}
/show"
end
private
def
resource_params
params
.
require
(
resource_key
).
permit
(
:merchant_remark
,
:mark
)
end
end
end
end
...
...
lib/shotengai/controllers/merchant/product_snapshots_controller.rb
View file @
df42df0a
...
...
@@ -12,7 +12,6 @@ module Shotengai
end
index_query
do
|
resource
,
params
|
# where(nil) will skip the where
resource
.
where
(
params
[
:order_id
]
&&
{
shotengai_order_id:
params
[
:order_id
]
}
).
where
(
...
...
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