unidom-product 0.2 → 0.3
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.
- checksums.yaml +4 -4
- data/README.md +16 -1
- data/app/assets/javascripts/unidom/product/application.js +1 -1
- data/app/assets/stylesheets/unidom/product/application.css +0 -1
- data/app/models/unidom/product/product.rb +7 -1
- data/app/models/unidom/product/product_associating.rb +22 -0
- data/app/views/layouts/unidom/product/application.html.erb +3 -2
- data/db/migrate/20020201000000_create_unidom_products.rb +1 -1
- data/db/migrate/20020211000000_create_unidom_product_associatings.rb +33 -0
- data/lib/unidom/product/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 388edde88bb09434d63ff9a0bd6e1473ade4f16c
|
|
4
|
+
data.tar.gz: 3b2eb0a046a4b04de46cb28e108e63e225dc9a78
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f2bc5b3bad27833224eef03a1542a2001a3363ad4b8647855b0148137b330ec8bda5087d64d3992bba0ae66ad7761aaa4992728a4b7eb7d4deb8d49006c013b
|
|
7
|
+
data.tar.gz: 69b7c736b9ab7d7a6deb36eaa6eba1fd47db6d6490005f3acdb147eacd0e16bf46d36170b29a10279743925c094adf12f0ceacab8cdbc26977b77d58424d03b7
|
data/README.md
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Product domain model engine includes Product and its relative models.
|
|
7
7
|
Unidom (统一领域对象模型)是一系列的领域模型引擎。产品领域模型引擎包括产品及其相关的模型。
|
|
8
8
|
|
|
9
|
+
## Recent Update
|
|
10
|
+
Check out the [Road Map](ROADMAP.md) to find out what's the next.
|
|
11
|
+
Check out the [Change Log](CHANGELOG.md) to find out what's new.
|
|
12
|
+
|
|
9
13
|
## Usage in Gemfile
|
|
10
14
|
```ruby
|
|
11
15
|
gem 'unidom-product'
|
|
@@ -15,8 +19,19 @@ gem 'unidom-product'
|
|
|
15
19
|
```shell
|
|
16
20
|
rake db:migrate
|
|
17
21
|
```
|
|
22
|
+
The migration versions start with 200202.
|
|
18
23
|
|
|
19
24
|
## Call the Model
|
|
20
25
|
```ruby
|
|
21
|
-
|
|
26
|
+
# Create a Product
|
|
27
|
+
product = Unidom::Product::Product.create(name: 'Apple iPhone 6S Plus 64G',
|
|
28
|
+
abbreviation: 'iPhone 6S+ 64G',
|
|
29
|
+
measurement_unit: 'unit',
|
|
30
|
+
packing_norm: '1 unit per pack',
|
|
31
|
+
formset_code: 'WARE',
|
|
32
|
+
description: 'the latest iPhone model',
|
|
33
|
+
instruction: 'It is almost sold out.')
|
|
34
|
+
|
|
35
|
+
# Find the Product per Formset Code
|
|
36
|
+
Product.formset_coded_as('SRVC').valid_at.alive.first
|
|
22
37
|
```
|
|
@@ -4,11 +4,17 @@ class Unidom::Product::Product < ActiveRecord::Base
|
|
|
4
4
|
|
|
5
5
|
self.table_name = 'unidom_products'
|
|
6
6
|
|
|
7
|
+
include Unidom::Common::Concerns::ModelExtension
|
|
8
|
+
|
|
7
9
|
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
|
8
10
|
validates :abbreviation, presence: true, length: { in: 1..self.columns_hash['abbreviation'].limit }
|
|
9
11
|
validates :measurement_unit, presence: true, length: { in: 1..self.columns_hash['measurement_unit'].limit }
|
|
10
12
|
validates :packing_norm, presence: true, length: { in: 1..self.columns_hash['packing_norm'].limit }
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
has_many :source_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :target_id #, as: :target
|
|
15
|
+
has_many :source_products, through: :source_product_associatings, source: :source
|
|
16
|
+
|
|
17
|
+
has_many :target_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :source_id #, as: :source
|
|
18
|
+
has_many :target_products, through: :target_product_associatings, source: :target
|
|
13
19
|
|
|
14
20
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Product Associating 表示产品之间的关联。常见的关联包括销售包装、产品换代等。
|
|
2
|
+
# source 是来源产品。如组合后的产品、被换代的产品、不兼容产品中的主产品。
|
|
3
|
+
# target 是目标产品。如参与组合的产品、替换其它产品的新产品、不兼容产品中的次要产品。
|
|
4
|
+
# product_association_code 是产品关联:
|
|
5
|
+
# CPLM 是产品补充 complement
|
|
6
|
+
# ICPT 是产品不兼容 incompatibility
|
|
7
|
+
# OBSL 是产品废弃 obsolescence
|
|
8
|
+
# PCKG 是销售包装 package
|
|
9
|
+
# SBST 是产品替代 substitute
|
|
10
|
+
|
|
11
|
+
class Unidom::Product::ProductAssociating < ActiveRecord::Base
|
|
12
|
+
|
|
13
|
+
self.table_name = 'unidom_product_associatings'
|
|
14
|
+
|
|
15
|
+
include Unidom::Common::Concerns::ModelExtension
|
|
16
|
+
|
|
17
|
+
validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
|
18
|
+
|
|
19
|
+
belongs_to :source, class_name: 'Unidom::Product::Product'
|
|
20
|
+
belongs_to :target, class_name: 'Unidom::Product::Product'
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<title>Product</title>
|
|
5
|
-
<%= stylesheet_link_tag
|
|
6
|
-
<%= javascript_include_tag "product/application" %>
|
|
5
|
+
<%= stylesheet_link_tag "product/application", media: "all" %>
|
|
7
6
|
<%= csrf_meta_tags %>
|
|
8
7
|
</head>
|
|
9
8
|
<body>
|
|
10
9
|
|
|
11
10
|
<%= yield %>
|
|
12
11
|
|
|
12
|
+
<%= javascript_include_tag 'unidom/product/application' %>
|
|
13
|
+
|
|
13
14
|
</body>
|
|
14
15
|
</html>
|
|
@@ -25,9 +25,9 @@ class CreateUnidomProducts < ActiveRecord::Migration
|
|
|
25
25
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
add_index :unidom_products, :slug, unique: true
|
|
29
28
|
add_index :unidom_products, :name
|
|
30
29
|
add_index :unidom_products, :abbreviation
|
|
30
|
+
add_index :unidom_products, :slug, unique: true
|
|
31
31
|
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class CreateUnidomProductAssociatings < ActiveRecord::Migration
|
|
2
|
+
|
|
3
|
+
def change
|
|
4
|
+
|
|
5
|
+
create_table :unidom_product_associatings, id: :uuid do |t|
|
|
6
|
+
|
|
7
|
+
t.references :source, type: :uuid, null: false, default: nil
|
|
8
|
+
t.references :target, type: :uuid, null: false, default: nil
|
|
9
|
+
|
|
10
|
+
t.column :product_association_code, 'char(4)', null: false, default: 'ZZZZ'
|
|
11
|
+
|
|
12
|
+
t.integer :ordinal, null: false, default: 0
|
|
13
|
+
t.decimal :quantity, null: false, default: 0.0, precision: 12, scale: 2
|
|
14
|
+
|
|
15
|
+
t.text :description
|
|
16
|
+
t.text :instruction
|
|
17
|
+
|
|
18
|
+
t.column :state, 'char(1)', null: false, default: 'C'
|
|
19
|
+
t.datetime :opened_at, null: false, default: Time.utc(1970)
|
|
20
|
+
t.datetime :closed_at, null: false, default: Time.utc(3000)
|
|
21
|
+
t.boolean :defunct, null: false, default: false
|
|
22
|
+
t.jsonb :notation, null: false, default: {}
|
|
23
|
+
|
|
24
|
+
t.timestamps null: false
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
add_index :unidom_product_associatings, :source_id
|
|
29
|
+
add_index :unidom_product_associatings, :target_id
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unidom-product
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.3'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Topbit Du
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: unidom-common
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0
|
|
19
|
+
version: '1.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0
|
|
26
|
+
version: '1.0'
|
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
|
28
28
|
The Product domain model engine includes Product and its relative models. Unidom
|
|
29
29
|
(统一领域对象模型)是一系列的领域模型引擎。产品领域模型引擎包括产品及其相关的模型。
|
|
@@ -41,9 +41,11 @@ files:
|
|
|
41
41
|
- app/controllers/unidom/product/application_controller.rb
|
|
42
42
|
- app/helpers/unidom/product/application_helper.rb
|
|
43
43
|
- app/models/unidom/product/product.rb
|
|
44
|
+
- app/models/unidom/product/product_associating.rb
|
|
44
45
|
- app/views/layouts/unidom/product/application.html.erb
|
|
45
46
|
- config/routes.rb
|
|
46
47
|
- db/migrate/20020201000000_create_unidom_products.rb
|
|
48
|
+
- db/migrate/20020211000000_create_unidom_product_associatings.rb
|
|
47
49
|
- lib/tasks/product_tasks.rake
|
|
48
50
|
- lib/unidom/product.rb
|
|
49
51
|
- lib/unidom/product/engine.rb
|
|
@@ -68,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
68
70
|
version: '0'
|
|
69
71
|
requirements: []
|
|
70
72
|
rubyforge_project:
|
|
71
|
-
rubygems_version: 2.4
|
|
73
|
+
rubygems_version: 2.6.4
|
|
72
74
|
signing_key:
|
|
73
75
|
specification_version: 4
|
|
74
76
|
summary: Unidom Product Domain Model Engine 产品领域模型引擎
|