unidom-certificate 3.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/controllers/unidom/certificate/application_controller.rb +8 -2
- data/app/helpers/unidom/certificate/application_helper.rb +7 -1
- data/app/jobs/unidom/certificate/application_job.rb +7 -1
- data/app/mailers/unidom/certificate/application_mailer.rb +9 -3
- data/app/models/unidom/certificate/application_record.rb +8 -2
- data/app/models/unidom/certificate/certificating.rb +37 -31
- data/app/models/unidom/certificate/concerns/as_certificated.rb +33 -25
- data/app/models/unidom/certificate/concerns/as_certification.rb +33 -25
- data/db/migrate/20010201000000_create_unidom_certificatings.rb +4 -4
- data/lib/unidom/certificate/version.rb +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ace38c6993c47828a11094f9db7c0b2e1ff0f2a6fec99957557fb9a8bf1652a
|
4
|
+
data.tar.gz: 3c7cc35a01cc4ae967f516f459f1c86f355bcafb56a34fb47ecede72148f7cdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d64e1c619a1b2cea5183a7917d23f4634f7c598fa5b32b80fd736a29fa1ca258fae4a46b89bb0aa461ac0c81644ab47451c2df4248f8f90514d73ead59d14511
|
7
|
+
data.tar.gz: 71df4b7f664652f53819f0e5b6f818a0c804ca177617644a7ed23d1c9429b46c646e4e921fedef6aa53c73dfc0bf07096ff252ef5939698eb1699c058f71ba77
|
data/README.md
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/unidom-certificate.svg)](https://badge.fury.io/rb/unidom-certificate)
|
7
7
|
[![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-certificate.svg)](https://gemnasium.com/github.com/topbitdu/unidom-certificate)
|
8
8
|
|
9
|
-
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Certificate domain model engine includes
|
10
|
-
Unidom (统一领域对象模型)
|
9
|
+
Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Certificate domain model engine includes the Certificating model.
|
10
|
+
Unidom (统一领域对象模型)是一系列的领域模型引擎。证书领域模型引擎包括认证的模型。
|
11
11
|
|
12
12
|
|
13
13
|
|
@@ -1,6 +1,12 @@
|
|
1
1
|
##
|
2
2
|
# Application controller 是模块内所有控制器的基类。
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
module Unidom
|
5
|
+
module Certificate
|
6
|
+
|
7
|
+
class ApplicationController < ActionController::Base
|
8
|
+
protect_from_forgery with: :exception
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
6
12
|
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
##
|
2
2
|
# Application mailer 是模块内所有电子邮件发送类的基类。
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module Unidom
|
5
|
+
module Certificate
|
6
|
+
|
7
|
+
class ApplicationMailer < ActionMailer::Base
|
8
|
+
default from: 'from@example.com'
|
9
|
+
layout 'mailer'
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
7
13
|
end
|
@@ -1,6 +1,12 @@
|
|
1
1
|
##
|
2
2
|
# Application record 是模块内所有模型的抽象基类。
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
module Unidom
|
5
|
+
module Certificate
|
6
|
+
|
7
|
+
class ApplicationRecord < ActiveRecord::Base
|
8
|
+
self.abstract_class = true
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
6
12
|
end
|
@@ -1,35 +1,41 @@
|
|
1
1
|
##
|
2
2
|
# Certificating 是参与者和证书之间的认证关系。
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
scope :certification_is, ->(certification) { where certification: certification }
|
17
|
-
|
18
|
-
##
|
19
|
-
# 由认证者 certificator 用证书 certification 去认证的人或者机构 certificated ,认证时间是: opened_at。
|
20
|
-
def self.certificate!(certification: nil, certificated: nil, certificator: nil, opened_at: Time.now)
|
21
|
-
assert_present! :certification, certification
|
22
|
-
assert_present! :certificated, certificated
|
23
|
-
assert_present! :opened_at, opened_at
|
24
|
-
|
25
|
-
attributes = { opened_at: opened_at }
|
26
|
-
if certificator.present?
|
27
|
-
attributes[:certificator] = certificator
|
28
|
-
else
|
29
|
-
attributes[:certificator_id] = Unidom::Common::NULL_UUID
|
30
|
-
attributes[:certificator_type] = ''
|
31
|
-
end
|
32
|
-
self.certification_is(certification).certificated_is(certificated).valid_at(now: opened_at).alive.first_or_create! attributes
|
33
|
-
end
|
4
|
+
module Unidom
|
5
|
+
module Certificate
|
6
|
+
|
7
|
+
class Certificating < ApplicationRecord
|
8
|
+
|
9
|
+
self.table_name = 'unidom_certificatings'
|
10
|
+
|
11
|
+
include Unidom::Common::Concerns::ModelExtension
|
12
|
+
|
13
|
+
belongs_to :certificator, polymorphic: true
|
14
|
+
belongs_to :certificated, polymorphic: true
|
15
|
+
belongs_to :certification, polymorphic: true
|
34
16
|
|
35
|
-
|
17
|
+
scope :certificated_by, ->(certificator) { where certificator: certificator }
|
18
|
+
scope :certificated_is, ->(certificated) { where certificated: certificated }
|
19
|
+
scope :certification_is, ->(certification) { where certification: certification }
|
20
|
+
|
21
|
+
##
|
22
|
+
# 由认证者 certificator 用证书 certification 去认证的人或者机构 certificated ,认证时间是: opened_at。
|
23
|
+
def self.certificate!(certification: nil, certificated: nil, certificator: nil, opened_at: Time.now)
|
24
|
+
assert_present! :certification, certification
|
25
|
+
assert_present! :certificated, certificated
|
26
|
+
assert_present! :opened_at, opened_at
|
27
|
+
|
28
|
+
attributes = { opened_at: opened_at }
|
29
|
+
if certificator.present?
|
30
|
+
attributes[:certificator] = certificator
|
31
|
+
else
|
32
|
+
attributes[:certificator_id] = Unidom::Common::NULL_UUID
|
33
|
+
attributes[:certificator_type] = ''
|
34
|
+
end
|
35
|
+
self.certification_is(certification).certificated_is(certificated).valid_at(now: opened_at).alive.first_or_create! attributes
|
36
|
+
end
|
37
|
+
|
38
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Certificate::Certificating'
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -1,43 +1,51 @@
|
|
1
1
|
##
|
2
2
|
# As Certificated 是被认证参与者的领域关注点。
|
3
3
|
|
4
|
-
module Unidom
|
4
|
+
module Unidom
|
5
|
+
module Certificate
|
6
|
+
module Concerns
|
5
7
|
|
6
|
-
|
7
|
-
include Unidom::Common::Concerns::ArgumentValidation
|
8
|
+
module AsCertificated
|
8
9
|
|
9
|
-
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
include Unidom::Common::Concerns::ArgumentValidation
|
10
12
|
|
11
|
-
|
13
|
+
included do |includer|
|
12
14
|
|
13
|
-
|
14
|
-
# 被认证者被证书 certification 认证,认证者为 by ,认证时间是 at (缺省为当前时间)。
|
15
|
-
# 如: person.is_certificated! mcse, by: bill_gates, at: Time.now
|
16
|
-
def is_certificated!(certification, by: nil, at: Time.now)
|
15
|
+
has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certificated
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
##
|
18
|
+
# 被认证者被证书 certification 认证,认证者为 by ,认证时间是 at (缺省为当前时间)。
|
19
|
+
# 如: person.is_certificated! mcse, by: bill_gates, at: Time.now
|
20
|
+
def is_certificated!(certification, by: nil, at: Time.now)
|
21
21
|
|
22
|
-
|
22
|
+
assert_present! :certification, certification
|
23
|
+
assert_present! :by, by
|
24
|
+
assert_present! :at, at
|
23
25
|
|
24
|
-
|
26
|
+
certificatings.certification_is(certification).valid_at(now: at).alive.first_or_create! certificator: by, opened_at: at
|
25
27
|
|
26
|
-
|
27
|
-
# 判断当前被认证者在指定的时间 at (缺省为当前时间)是否有指定的证书 certification 。如:
|
28
|
-
# person.is_certificated? mcse, at: Time.now
|
29
|
-
def is_certificated?(certification, at: Time.now)
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
##
|
31
|
+
# 判断当前被认证者在指定的时间 at (缺省为当前时间)是否有指定的证书 certification 。如:
|
32
|
+
# person.is_certificated? mcse, at: Time.now
|
33
|
+
def is_certificated?(certification, at: Time.now)
|
33
34
|
|
34
|
-
|
35
|
+
assert_present! :certification, certification
|
36
|
+
assert_present! :at, at
|
35
37
|
|
36
|
-
|
38
|
+
certificatings.certification_is(certification).valid_at(now: at).alive.exists?
|
37
39
|
|
38
|
-
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
end
|
42
|
+
end
|
42
43
|
|
44
|
+
module ClassMethods
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
43
51
|
end
|
@@ -1,43 +1,51 @@
|
|
1
1
|
##
|
2
2
|
# As Certification 是证书的领域关注点。
|
3
3
|
|
4
|
-
module Unidom
|
4
|
+
module Unidom
|
5
|
+
module Certificate
|
6
|
+
module Concerns
|
5
7
|
|
6
|
-
|
7
|
-
include Unidom::Common::Concerns::ArgumentValidation
|
8
|
+
module AsCertification
|
8
9
|
|
9
|
-
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
include Unidom::Common::Concerns::ArgumentValidation
|
10
12
|
|
11
|
-
|
13
|
+
included do |includer|
|
12
14
|
|
13
|
-
|
14
|
-
# 用证书去认证参与者(被认证者)。 by 是认证者, at 是认证时间(缺省为当前时间)。
|
15
|
-
# 如:mcse.certificate! person, by: bill_gates, at: Time.now
|
16
|
-
def certificate!(certificated, by: nil, at: Time.now)
|
15
|
+
has_many :certificatings, class_name: 'Unidom::Certificate::Certificating', as: :certification
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
##
|
18
|
+
# 用证书去认证参与者(被认证者)。 by 是认证者, at 是认证时间(缺省为当前时间)。
|
19
|
+
# 如:mcse.certificate! person, by: bill_gates, at: Time.now
|
20
|
+
def certificate!(certificated, by: nil, at: Time.now)
|
21
21
|
|
22
|
-
|
22
|
+
assert_present! :certificated, certificated
|
23
|
+
assert_present! :by, by
|
24
|
+
assert_present! :at, at
|
23
25
|
|
24
|
-
|
26
|
+
certificatings.certificated_is(certificated).valid_at(now: at).alive.first_or_create! certificator: by, opened_at: at
|
25
27
|
|
26
|
-
|
27
|
-
# 判断当前认证书在指定的时间 at (缺省为当前时间)是否对被认证者 certificated 生效。如:
|
28
|
-
# mcse.certificated? person, at: Time.now
|
29
|
-
def certificate?(certificated, at: Time.now)
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
##
|
31
|
+
# 判断当前认证书在指定的时间 at (缺省为当前时间)是否对被认证者 certificated 生效。如:
|
32
|
+
# mcse.certificated? person, at: Time.now
|
33
|
+
def certificate?(certificated, at: Time.now)
|
33
34
|
|
34
|
-
|
35
|
+
assert_present! :certificated, certificated
|
36
|
+
assert_present! :at, at
|
35
37
|
|
36
|
-
|
38
|
+
certificatings.certificated_is(certificated).valid_at(now: at).alive.exists?
|
37
39
|
|
38
|
-
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
end
|
42
|
+
end
|
42
43
|
|
44
|
+
module ClassMethods
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
43
51
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateUnidomCertificatings < ActiveRecord::Migration
|
1
|
+
class CreateUnidomCertificatings < ActiveRecord::Migration[6.0]
|
2
2
|
|
3
3
|
def change
|
4
4
|
|
@@ -11,9 +11,9 @@ class CreateUnidomCertificatings < ActiveRecord::Migration
|
|
11
11
|
t.references :certification, type: :uuid, null: false,
|
12
12
|
polymorphic: { null: false, default: '', limit: 200 }
|
13
13
|
|
14
|
-
t.column :state, 'char(1)', null: false, default:
|
15
|
-
t.datetime :opened_at, null: false, default: ::
|
16
|
-
t.datetime :closed_at, null: false, default: ::
|
14
|
+
t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
|
15
|
+
t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
|
16
|
+
t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
|
17
17
|
t.boolean :defunct, null: false, default: false
|
18
18
|
t.jsonb :notation, null: false, default: {}
|
19
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-certificate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -25,8 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
28
|
-
The Certificate domain model engine includes
|
29
|
-
models. Unidom (统一领域对象模型)是一系列的领域模型引擎。证书领域模型引擎包括身份证和营业执照的模型。
|
28
|
+
The Certificate domain model engine includes Certificating model. Unidom (统一领域对象模型)是一系列的领域模型引擎。证书领域模型引擎包括认证的模型。
|
30
29
|
email:
|
31
30
|
- topbit.du@gmail.com
|
32
31
|
executables: []
|
@@ -61,11 +60,11 @@ files:
|
|
61
60
|
- lib/unidom/certificate/types_rspec.rb
|
62
61
|
- lib/unidom/certificate/validators_rspec.rb
|
63
62
|
- lib/unidom/certificate/version.rb
|
64
|
-
homepage: https://
|
63
|
+
homepage: https://gitee.com/Unidom/unidom-certificate
|
65
64
|
licenses:
|
66
65
|
- MIT
|
67
66
|
metadata: {}
|
68
|
-
post_install_message:
|
67
|
+
post_install_message:
|
69
68
|
rdoc_options: []
|
70
69
|
require_paths:
|
71
70
|
- lib
|
@@ -80,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
79
|
- !ruby/object:Gem::Version
|
81
80
|
version: '0'
|
82
81
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
84
|
-
signing_key:
|
82
|
+
rubygems_version: 3.2.3
|
83
|
+
signing_key:
|
85
84
|
specification_version: 4
|
86
85
|
summary: Unidom Certificate Domain Model Engine 证书领域模型引擎
|
87
86
|
test_files: []
|