rails_ship 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +32 -0
  4. data/Rakefile +32 -0
  5. data/app/controllers/ship/admin/addresses_controller.rb +48 -0
  6. data/app/controllers/ship/admin/base_controller.rb +5 -0
  7. data/app/controllers/ship/admin/home_controller.rb +8 -0
  8. data/app/controllers/ship/admin/packages_controller.rb +43 -0
  9. data/app/controllers/ship/admin/trade_items_controller.rb +72 -0
  10. data/app/controllers/ship/driver/base_controller.rb +9 -0
  11. data/app/controllers/ship/driver/favorites_controller.rb +39 -0
  12. data/app/controllers/ship/my/addresses_controller.rb +58 -0
  13. data/app/controllers/ship/my/base_controller.rb +5 -0
  14. data/app/controllers/ship/my/cars_controller.rb +54 -0
  15. data/app/controllers/ship/my/drivers_controller.rb +38 -0
  16. data/app/controllers/ship/my/favorites_controller.rb +40 -0
  17. data/app/controllers/ship/my/lines_controller.rb +71 -0
  18. data/app/controllers/ship/my/locations_controller.rb +60 -0
  19. data/app/controllers/ship/my/packages_controller.rb +53 -0
  20. data/app/controllers/ship/my/principal_addresses_controller.rb +26 -0
  21. data/app/controllers/ship/panel/base_controller.rb +5 -0
  22. data/app/controllers/ship/panel/lines_controller.rb +53 -0
  23. data/app/controllers/ship/panel/similars_controller.rb +61 -0
  24. data/app/jobs/ship/car_ocr_job.rb +11 -0
  25. data/app/jobs/ship/driver_ocr_job.rb +11 -0
  26. data/app/jobs/ship/location_geo_job.rb +10 -0
  27. data/app/models/ship/address.rb +7 -0
  28. data/app/models/ship/car.rb +5 -0
  29. data/app/models/ship/driver.rb +5 -0
  30. data/app/models/ship/ext/order.rb +7 -0
  31. data/app/models/ship/ext/trade_item.rb +11 -0
  32. data/app/models/ship/ext/user.rb +15 -0
  33. data/app/models/ship/favorite.rb +5 -0
  34. data/app/models/ship/line.rb +5 -0
  35. data/app/models/ship/line_similar.rb +5 -0
  36. data/app/models/ship/location.rb +5 -0
  37. data/app/models/ship/model/address.rb +10 -0
  38. data/app/models/ship/model/car.rb +34 -0
  39. data/app/models/ship/model/driver.rb +45 -0
  40. data/app/models/ship/model/favorite.rb +14 -0
  41. data/app/models/ship/model/line.rb +28 -0
  42. data/app/models/ship/model/line_similar.rb +16 -0
  43. data/app/models/ship/model/location.rb +53 -0
  44. data/app/models/ship/model/package.rb +28 -0
  45. data/app/models/ship/model/packaged.rb +29 -0
  46. data/app/models/ship/model/shipment.rb +22 -0
  47. data/app/models/ship/model/shipping.rb +9 -0
  48. data/app/models/ship/package.rb +6 -0
  49. data/app/models/ship/packaged.rb +5 -0
  50. data/app/models/ship/shipment.rb +5 -0
  51. data/app/models/ship.rb +11 -0
  52. data/app/views/admin/_ship_nav.html.erb +11 -0
  53. data/app/views/panel/_ship_nav.html.erb +10 -0
  54. data/app/views/ship/admin/addresses/_address.html.erb +24 -0
  55. data/app/views/ship/admin/addresses/_edit_form.html.erb +3 -0
  56. data/app/views/ship/admin/addresses/_form.html.erb +9 -0
  57. data/app/views/ship/admin/addresses/index.html.erb +36 -0
  58. data/app/views/ship/admin/base/_nav.html.erb +3 -0
  59. data/app/views/ship/admin/home/index.html.erb +0 -0
  60. data/app/views/ship/admin/packages/_button.html.erb +0 -0
  61. data/app/views/ship/admin/packages/_edit_form.html.erb +4 -0
  62. data/app/views/ship/admin/packages/_filter_form.html.erb +9 -0
  63. data/app/views/ship/admin/packages/_form.html.erb +5 -0
  64. data/app/views/ship/admin/packages/_index_tbody.html.erb +8 -0
  65. data/app/views/ship/admin/packages/_index_thead.html.erb +5 -0
  66. data/app/views/ship/admin/packages/_new_form.html.erb +4 -0
  67. data/app/views/ship/admin/packages/_show_table.html.erb +16 -0
  68. data/app/views/ship/admin/packages/index.html.erb +5 -0
  69. data/app/views/ship/admin/rallies/_filter.html.erb +7 -0
  70. data/app/views/ship/admin/rallies/_form.html+phone.erb +17 -0
  71. data/app/views/ship/admin/rallies/_show_table.html+phone.erb +24 -0
  72. data/app/views/ship/admin/rallies/_show_table.html.erb +12 -0
  73. data/app/views/ship/admin/rallies/index.html+phone.erb +26 -0
  74. data/app/views/ship/admin/rallies/show.html.erb +26 -0
  75. data/app/views/ship/admin/trade_items/_filter.html.erb +9 -0
  76. data/app/views/ship/admin/trade_items/_form.html.erb +7 -0
  77. data/app/views/ship/admin/trade_items/_show_table.html.erb +24 -0
  78. data/app/views/ship/admin/trade_items/index.html.erb +51 -0
  79. data/app/views/ship/driver/favorites/_button.html+phone.erb +4 -0
  80. data/app/views/ship/driver/favorites/_edit_form.html.erb +4 -0
  81. data/app/views/ship/driver/favorites/_filter_form.html+phone.erb +14 -0
  82. data/app/views/ship/driver/favorites/_filter_form.html.erb +9 -0
  83. data/app/views/ship/driver/favorites/_form.html.erb +3 -0
  84. data/app/views/ship/driver/favorites/_index_tbody.html.erb +6 -0
  85. data/app/views/ship/driver/favorites/_index_thead.html.erb +3 -0
  86. data/app/views/ship/driver/favorites/_index_tr.html.erb +4 -0
  87. data/app/views/ship/driver/favorites/_new_form.html.erb +4 -0
  88. data/app/views/ship/driver/favorites/_show_table.html.erb +8 -0
  89. data/app/views/ship/driver/favorites/index.html.erb +5 -0
  90. data/app/views/ship/my/addresses/_edit_form.html.erb +21 -0
  91. data/app/views/ship/my/addresses/_form.html.erb +23 -0
  92. data/app/views/ship/my/addresses/index.html.erb +44 -0
  93. data/app/views/ship/my/cars/_edit_form.html.erb +6 -0
  94. data/app/views/ship/my/cars/_filter_form.html.erb +9 -0
  95. data/app/views/ship/my/cars/_index_tbody.html.erb +3 -0
  96. data/app/views/ship/my/cars/_index_thead.html.erb +4 -0
  97. data/app/views/ship/my/cars/_new_form.html.erb +4 -0
  98. data/app/views/ship/my/cars/_show_table.html.erb +16 -0
  99. data/app/views/ship/my/cars/create.turbo_stream.erb +1 -0
  100. data/app/views/ship/my/cars/index.html+phone.erb +19 -0
  101. data/app/views/ship/my/cars/index.html.erb +5 -0
  102. data/app/views/ship/my/cars/new.html.erb +25 -0
  103. data/app/views/ship/my/drivers/_edit_form.html.erb +6 -0
  104. data/app/views/ship/my/drivers/_form.html.erb +4 -0
  105. data/app/views/ship/my/drivers/_index_tbody.html.erb +3 -0
  106. data/app/views/ship/my/drivers/_index_thead.html.erb +4 -0
  107. data/app/views/ship/my/drivers/_new_form.html.erb +4 -0
  108. data/app/views/ship/my/drivers/_show_table.html.erb +12 -0
  109. data/app/views/ship/my/drivers/_uploader.html.erb +22 -0
  110. data/app/views/ship/my/drivers/edit.html.erb +20 -0
  111. data/app/views/ship/my/drivers/show.html.erb +33 -0
  112. data/app/views/ship/my/favorites/_button.html+phone.erb +4 -0
  113. data/app/views/ship/my/favorites/_edit_form.html.erb +4 -0
  114. data/app/views/ship/my/favorites/_filter_form.html+phone.erb +14 -0
  115. data/app/views/ship/my/favorites/_filter_form.html.erb +9 -0
  116. data/app/views/ship/my/favorites/_form.html.erb +3 -0
  117. data/app/views/ship/my/favorites/_index_tbody.html.erb +6 -0
  118. data/app/views/ship/my/favorites/_index_thead.html.erb +3 -0
  119. data/app/views/ship/my/favorites/_new_form.html.erb +4 -0
  120. data/app/views/ship/my/favorites/_show_table.html.erb +8 -0
  121. data/app/views/ship/my/favorites/index.html.erb +5 -0
  122. data/app/views/ship/my/lines/_edit_form.html.erb +4 -0
  123. data/app/views/ship/my/lines/_filter_form.html.erb +1 -0
  124. data/app/views/ship/my/lines/_form.html.erb +3 -0
  125. data/app/views/ship/my/lines/_index_tbody.html.erb +6 -0
  126. data/app/views/ship/my/lines/_index_tr.html.erb +4 -0
  127. data/app/views/ship/my/lines/_item_field.html.erb +8 -0
  128. data/app/views/ship/my/lines/_item_location.html.erb +13 -0
  129. data/app/views/ship/my/lines/_new_form.html.erb +15 -0
  130. data/app/views/ship/my/lines/_select/_tab_bar.html.erb +10 -0
  131. data/app/views/ship/my/lines/_select.html.erb +10 -0
  132. data/app/views/ship/my/lines/_show/_index_tbody.html.erb +6 -0
  133. data/app/views/ship/my/lines/_show/_index_tr.html+phone.erb +6 -0
  134. data/app/views/ship/my/lines/_show_table.html.erb +9 -0
  135. data/app/views/ship/my/lines/add.turbo_stream.erb +1 -0
  136. data/app/views/ship/my/lines/index.html.erb +5 -0
  137. data/app/views/ship/my/lines/new.html.erb +1 -0
  138. data/app/views/ship/my/lines/requirement.html.erb +5 -0
  139. data/app/views/ship/my/lines/select.turbo_stream.erb +1 -0
  140. data/app/views/ship/my/lines/show.html+phone.erb +30 -0
  141. data/app/views/ship/my/locations/_edit_form.html.erb +4 -0
  142. data/app/views/ship/my/locations/_filter_form.html.erb +9 -0
  143. data/app/views/ship/my/locations/_form.html.erb +6 -0
  144. data/app/views/ship/my/locations/_index_tbody.html.erb +5 -0
  145. data/app/views/ship/my/locations/_index_thead.html.erb +6 -0
  146. data/app/views/ship/my/locations/_new_form.html.erb +4 -0
  147. data/app/views/ship/my/locations/_show_table.html.erb +20 -0
  148. data/app/views/ship/my/locations/index.html.erb +5 -0
  149. data/app/views/ship/my/packages/index.html.erb +31 -0
  150. data/app/views/ship/my/principal_addresses/index.html+phone.erb +32 -0
  151. data/app/views/ship/my/principal_addresses/plans.html+phone.erb +23 -0
  152. data/app/views/ship/my/principal_addresses/show.html+phone.erb +27 -0
  153. data/app/views/ship/panel/base/_nav.html.erb +3 -0
  154. data/app/views/ship/panel/lines/_edit_form.html.erb +4 -0
  155. data/app/views/ship/panel/lines/_filter_form.html.erb +9 -0
  156. data/app/views/ship/panel/lines/_form.html.erb +4 -0
  157. data/app/views/ship/panel/lines/_index_tbody.html.erb +4 -0
  158. data/app/views/ship/panel/lines/_index_thead.html.erb +5 -0
  159. data/app/views/ship/panel/lines/_index_tr.html.erb +19 -0
  160. data/app/views/ship/panel/lines/_new_form.html.erb +4 -0
  161. data/app/views/ship/panel/lines/_show_table.html.erb +12 -0
  162. data/app/views/ship/panel/lines/index.html.erb +5 -0
  163. data/app/views/ship/panel/similars/_breadcrumb.html.erb +7 -0
  164. data/app/views/ship/panel/similars/_button.html.erb +3 -0
  165. data/app/views/ship/panel/similars/_edit_form.html.erb +4 -0
  166. data/app/views/ship/panel/similars/_filter_form.html.erb +9 -0
  167. data/app/views/ship/panel/similars/_form.html.erb +4 -0
  168. data/app/views/ship/panel/similars/_index_tbody.html.erb +3 -0
  169. data/app/views/ship/panel/similars/_index_thead.html.erb +4 -0
  170. data/app/views/ship/panel/similars/_new/_button.html.erb +0 -0
  171. data/app/views/ship/panel/similars/_new/_index_tr.html.erb +10 -0
  172. data/app/views/ship/panel/similars/_new/_index_tr_remove.html.erb +10 -0
  173. data/app/views/ship/panel/similars/_new_form.html.erb +4 -0
  174. data/app/views/ship/panel/similars/_show_table.html.erb +12 -0
  175. data/app/views/ship/panel/similars/create.turbo_stream.erb +3 -0
  176. data/app/views/ship/panel/similars/destroy.turbo_stream.erb +3 -0
  177. data/app/views/ship/panel/similars/index.html.erb +5 -0
  178. data/app/views/ship/panel/similars/new.html.erb +16 -0
  179. data/config/locales/zh.attributes.yml +15 -0
  180. data/config/locales/zh.yml +51 -0
  181. data/config/routes.rb +66 -0
  182. data/lib/rails_ship/config.rb +11 -0
  183. data/lib/rails_ship/engine.rb +21 -0
  184. data/lib/rails_ship.rb +2 -0
  185. metadata +240 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ed2c568e3f960e452267781613935c718b0717ed1634bf30e327260f576b51a3
4
+ data.tar.gz: d8e5e7e205539ad4f0c2b95dcd277f15b15a4ca71cfd1b8c556b6e61a39be1ce
5
+ SHA512:
6
+ metadata.gz: 53174a30f7f5ada7250eef14c528d8b53b80934f88f4782f6cb153989bc6e1d0259a0d994af1c51bf0dcc6af897bb26ac20166f591906d1417a64d84e593b25c
7
+ data.tar.gz: 9cd1a62d72180c722a3f34a146a20f9e4046f688bffacf56351cf65b9361fe27301c018dde5dbbb3fb38f6a7148db4282e449626bac8831248175998533aef11
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2018-Present Mingyuan Qin <mingyuan0715@foxmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # RailsShip
2
+
3
+ [![测试](https://github.com/work-design/rails_ship/actions/workflows/test.yml/badge.svg)](https://github.com/work-design/rails_ship/actions/workflows/test.yml)
4
+ [![Docker构建](https://github.com/work-design/rails_ship/actions/workflows/cd.yml/badge.svg)](https://github.com/work-design/rails_ship/actions/workflows/cd.yml)
5
+ [![Gem](https://github.com/work-design/rails_ship/actions/workflows/gempush.yml/badge.svg)](https://github.com/work-design/rails_ship/actions/workflows/gempush.yml)
6
+ Short description and motivation.
7
+
8
+ ## Usage
9
+ How to use my plugin.
10
+
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'rails_ship'
16
+ ```
17
+
18
+ And then execute:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+ ```bash
25
+ $ gem install rails_ship
26
+ ```
27
+
28
+ ## 依赖
29
+ * [rails_trade](https://github.com/work-design/rails_trade)
30
+
31
+ ## 许可证
32
+ 遵循 [MIT](https://opensource.org/licenses/MIT) 协议
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'RailsShip'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1,48 @@
1
+ module Ship
2
+ class Admin::AddressesController < Admin::BaseController
3
+ before_action :set_address, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ q_params = {}
7
+ q_params.merge! params.permit('address_users.user_id')
8
+
9
+ @addresses = Address.default_where(q_params).page(params[:page])
10
+ end
11
+
12
+ def show
13
+ end
14
+
15
+ def edit
16
+ end
17
+
18
+ def update
19
+ respond_to do |format|
20
+ if @address.update(address_params)
21
+ format.html { redirect_to admin_addresses_url(user_id: @address.user_id), notice: 'Address was successfully updated.' }
22
+ format.js
23
+ else
24
+ format.html { render :edit }
25
+ format.js
26
+ end
27
+ end
28
+ end
29
+
30
+ def destroy
31
+ @address.destroy
32
+ respond_to do |format|
33
+ format.html { redirect_to admin_addresses_url(user_id: @address.user_id), notice: 'Address was successfully destroyed.' }
34
+ format.js
35
+ end
36
+ end
37
+
38
+ private
39
+ def set_address
40
+ @address = Address.find(params[:id])
41
+ end
42
+
43
+ def address_params
44
+ params.fetch(:address, {}).permit! #(:user_id, :buyer_id, :area_id, :kind, :contact_person, :tel, :address)
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,5 @@
1
+ module Ship
2
+ class Admin::BaseController < AdminController
3
+
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module Ship
2
+ class Admin::HomeController < Admin::BaseController
3
+
4
+ def index
5
+ end
6
+
7
+ end
8
+ end
@@ -0,0 +1,43 @@
1
+ module Ship
2
+ class Admin::PackagesController < Admin::BaseController
3
+ before_action :set_package, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ q_params = {}
7
+ q_params.merge! params.permit(:address_id)
8
+
9
+ @packages = Package.includes(:packageds, :address).default_where(q_params).page(params[:page])
10
+ end
11
+
12
+ def show
13
+ end
14
+
15
+ def edit
16
+ end
17
+
18
+ def update
19
+ @package.assign_attributes(package_params)
20
+
21
+ unless @package.save
22
+ render :edit, locals: { model: @package }, status: :unprocessable_entity
23
+ end
24
+ end
25
+
26
+ def destroy
27
+ @package.destroy
28
+ end
29
+
30
+ private
31
+ def set_package
32
+ @package = Package.find(params[:id])
33
+ end
34
+
35
+ def package_params
36
+ params.fetch(:package, {}).permit(
37
+ :state,
38
+ :expected_on,
39
+ )
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,72 @@
1
+ module Ship
2
+ class Admin::TradeItemsController < Admin::BaseController
3
+ before_action :set_address
4
+ before_action :set_trade_item, only: [:show, :edit, :update, :destroy]
5
+
6
+ def index
7
+ q_params = {
8
+ status: 'paid'
9
+ }
10
+ @trade_items = @address.trade_items.includes(:trade, :produce_plan).default_where(q_params).page(params[:page])
11
+ end
12
+
13
+ def package
14
+ pack = @address.packages.build
15
+ trade_items = @address.trade_items.paid.find params[:add_ids].split(',')
16
+ user_ids = trade_items.pluck(:user_id).uniq
17
+ if user_ids.size > 1
18
+ render 'edit', locals: { message: 'user 不一致,不能打包' } and return
19
+ end
20
+ produce_plan_ids = trade_items.pluck(:produce_plan_id).uniq
21
+ if produce_plan_ids.size > 1
22
+ render 'edit', locals: { message: 'produce plan 不一致,不能打包' } and return
23
+ end
24
+
25
+ pack.user_id = user_ids[0]
26
+ pack.produce_plan_id = produce_plan_ids[0]
27
+ trade_items.each do |trade_item|
28
+ p = trade_item.packageds.build
29
+ p.package = pack
30
+ p.save
31
+ end
32
+
33
+ render 'create'
34
+ end
35
+
36
+ def show
37
+ end
38
+
39
+ def edit
40
+ end
41
+
42
+ def update
43
+ @trade_item.assign_attributes(trade_item_params)
44
+
45
+ unless @trade_item.save
46
+ render :edit, locals: { model: @trade_item }, status: :unprocessable_entity
47
+ end
48
+ end
49
+
50
+ def destroy
51
+ @trade_item.destroy
52
+ end
53
+
54
+ private
55
+ def set_address
56
+ @address = Address.find params[:address_id]
57
+ end
58
+
59
+ def set_trade_item
60
+ @trade_item = TradeItem.find(params[:id])
61
+ end
62
+
63
+ def trade_item_params
64
+ params.fetch(:trade_item, {}).permit(
65
+ :good_id,
66
+ :number,
67
+ :status
68
+ )
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,9 @@
1
+ module Ship
2
+ class Driver::BaseController < MyController
3
+
4
+ def current_driver
5
+ current_user.driver
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ module Ship
2
+ class Driver::FavoritesController < Driver::BaseController
3
+ before_action :set_favorite, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ @favorites = current_driver.favorites.includes(:user).page(params[:page])
7
+ end
8
+
9
+ def show
10
+ end
11
+
12
+ def edit
13
+ end
14
+
15
+ def update
16
+ @favorite.assign_attributes(favorite_params)
17
+
18
+ unless @favorite.save
19
+ render :edit, locals: { model: @favorite }, status: :unprocessable_entity
20
+ end
21
+ end
22
+
23
+ def destroy
24
+ @favorite.destroy
25
+ end
26
+
27
+ private
28
+ def set_favorite
29
+ @favorite = Favorite.find(params[:id])
30
+ end
31
+
32
+ def favorite_params
33
+ params.fetch(:favorite, {}).permit(
34
+ :remark
35
+ )
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,58 @@
1
+ module Ship
2
+ class My::AddressesController < My::BaseController
3
+ before_action :set_address, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ @addresses = current_cart.addresses.includes(:area).page(params[:page])
7
+ end
8
+
9
+ def new
10
+ @address = current_cart.addresses.build
11
+ end
12
+
13
+ def create
14
+ @address = current_cart.addresses.build(address_params)
15
+
16
+ if @address.save
17
+ render 'create'
18
+ else
19
+ render :new, locals: { model: @address }, status: :unprocessable_entity
20
+ end
21
+ end
22
+
23
+ def show
24
+ end
25
+
26
+ def edit
27
+ end
28
+
29
+ def update
30
+ @address.assign_attributes address_params
31
+
32
+ if @address.save
33
+ render 'update'
34
+ else
35
+ render :edit, locals: { model: @address }, status: :unprocessable_entity
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ @address.destroy
41
+ end
42
+
43
+ private
44
+ def set_address
45
+ @address = Address.find(params[:id])
46
+ end
47
+
48
+ def address_params
49
+ params.fetch(:address, {}).permit(
50
+ :area_id,
51
+ :contact_person,
52
+ :tel,
53
+ :address
54
+ )
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ module Ship
2
+ class My::BaseController < MyController
3
+
4
+ end
5
+ end
@@ -0,0 +1,54 @@
1
+ module Ship
2
+ class My::CarsController < My::BaseController
3
+ before_action :set_car, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ @cars = current_user.cars.page(params[:page])
7
+ end
8
+
9
+ def new
10
+ @car = current_user.cars.build
11
+ end
12
+
13
+ def create
14
+ @car = current_user.cars.build(car_params)
15
+
16
+ unless @car.save
17
+ render :new, locals: { model: @car }, status: :unprocessable_entity
18
+ end
19
+ end
20
+
21
+ def show
22
+ end
23
+
24
+ def edit
25
+ end
26
+
27
+ def update
28
+ @car.assign_attributes(car_params)
29
+
30
+ unless @car.save
31
+ render :edit, locals: { model: @car }, status: :unprocessable_entity
32
+ end
33
+ end
34
+
35
+ def destroy
36
+ @car.destroy
37
+ end
38
+
39
+ private
40
+ def set_car
41
+ @car = current_user.cars.find(params[:id])
42
+ end
43
+
44
+ def car_params
45
+ params.fetch(:car, {}).permit(
46
+ :location,
47
+ :number,
48
+ :media_id,
49
+ :registration
50
+ )
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,38 @@
1
+ module Ship
2
+ class My::DriversController < My::BaseController
3
+ before_action :set_driver, only: [:show, :edit, :update, :destroy]
4
+
5
+ def show
6
+ end
7
+
8
+ def edit
9
+ end
10
+
11
+ def update
12
+ @driver.assign_attributes(driver_params)
13
+
14
+ unless @driver.save
15
+ render :edit, locals: { model: @driver }, status: :unprocessable_entity
16
+ end
17
+ end
18
+
19
+ def destroy
20
+ @driver.destroy
21
+ end
22
+
23
+ private
24
+ def set_driver
25
+ @driver = current_user.driver || current_user.build_driver
26
+ end
27
+
28
+ def driver_params
29
+ params.fetch(:driver, {}).permit(
30
+ :name,
31
+ :number,
32
+ :media_id,
33
+ :license
34
+ )
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,40 @@
1
+ module Ship
2
+ class My::FavoritesController < My::BaseController
3
+ before_action :set_favorite, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ @favorites = current_user.favorites.page(params[:page])
7
+ end
8
+
9
+ def show
10
+ end
11
+
12
+ def edit
13
+ end
14
+
15
+ def update
16
+ @favorite.assign_attributes(favorite_params)
17
+
18
+ unless @favorite.save
19
+ render :edit, locals: { model: @favorite }, status: :unprocessable_entity
20
+ end
21
+ end
22
+
23
+ def destroy
24
+ @favorite.destroy
25
+ end
26
+
27
+ private
28
+ def set_favorite
29
+ @favorite = current_user.favorites.find(params[:id])
30
+ end
31
+
32
+ def favorite_params
33
+ params.fetch(:favorite, {}).permit(
34
+ :driver_avatar,
35
+ :driver_name
36
+ )
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,71 @@
1
+ module Ship
2
+ class My::LinesController < My::BaseController
3
+ before_action :set_line, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ @lines = current_user.lines.order(id: :asc).page(params[:page])
7
+ end
8
+
9
+ def requirement
10
+ @lines = current_user.lines.order(id: :asc).page(params[:page])
11
+ end
12
+
13
+ def new
14
+ @line = current_user.lines.build
15
+ @line.locations.build(position: 1)
16
+ end
17
+
18
+ def add
19
+ @line = current_user.lines.build(line_params)
20
+ @line.locations.select(&->(i){ i.position > params[:position].to_i }).each do |i|
21
+ i.position += 1
22
+ end
23
+ @line.locations.build(position: params[:position].to_i + 1)
24
+ end
25
+
26
+ def select
27
+ @line = current_user.lines.build
28
+ end
29
+
30
+ def create
31
+ @line = current_user.lines.build(line_params)
32
+
33
+ unless @line.save
34
+ render :new, locals: { model: @line }, status: :unprocessable_entity
35
+ end
36
+ end
37
+
38
+ def show
39
+ @similars = @line.similars
40
+ end
41
+
42
+ def edit
43
+ end
44
+
45
+ def update
46
+ @line.assign_attributes(line_params)
47
+
48
+ unless @line.save
49
+ render :edit, locals: { model: @line }, status: :unprocessable_entity
50
+ end
51
+ end
52
+
53
+ def destroy
54
+ @line.destroy
55
+ end
56
+
57
+ private
58
+ def set_line
59
+ @line = current_user.lines.find(params[:id])
60
+ end
61
+
62
+ def line_params
63
+ params.fetch(:line, {}).permit(
64
+ :start_name,
65
+ :finish_name,
66
+ locations_attributes: {}
67
+ )
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,60 @@
1
+ module Ship
2
+ class My::LocationsController < My::BaseController
3
+ before_action :set_line
4
+ before_action :set_location, only: [:show, :edit, :update, :destroy]
5
+
6
+ def index
7
+ @locations = Location.page(params[:page])
8
+ end
9
+
10
+ def new
11
+ @location = Location.new
12
+ end
13
+
14
+ def create
15
+ @location = Location.new(location_params)
16
+
17
+ unless @location.save
18
+ render :new, locals: { model: @location }, status: :unprocessable_entity
19
+ end
20
+ end
21
+
22
+ def show
23
+ end
24
+
25
+ def edit
26
+ end
27
+
28
+ def update
29
+ @location.assign_attributes(location_params)
30
+
31
+ unless @location.save
32
+ render :edit, locals: { model: @location }, status: :unprocessable_entity
33
+ end
34
+ end
35
+
36
+ def destroy
37
+ @location.destroy
38
+ end
39
+
40
+ private
41
+ def set_line
42
+ @line = Line.find params[:line_id]
43
+ end
44
+
45
+ def set_location
46
+ @location = Location.find(params[:id])
47
+ end
48
+
49
+ def location_params
50
+ params.fetch(:location, {}).permit(
51
+ :poiname,
52
+ :poiaddress,
53
+ :cityname,
54
+ :lat,
55
+ :lng
56
+ )
57
+ end
58
+
59
+ end
60
+ end