line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Service; |
2
|
2
|
|
|
2
|
|
522
|
use Mojo::Base -base; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
3
|
2
|
|
|
2
|
|
299
|
use Carp 'croak'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
265
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has [qw/dbi models app/]; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub model{ |
8
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Check model existence |
11
|
0
|
0
|
0
|
|
|
|
croak qq{model "$name" is not yet created } unless($self->models && $self->models->{$name}); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Get model |
14
|
0
|
|
|
|
|
|
return $self->models->{$name}; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Mojolicious::Service - Mojolicious框架中所有Service的基类(具体的Service需要用户实现)! |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 VERSION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Version 0.01 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Mojolicious::Service |
32
|
|
|
|
|
|
|
my $service = Mojolicious::Service->new({ |
33
|
|
|
|
|
|
|
dbi=>DBIx::Custom->new(), |
34
|
|
|
|
|
|
|
models=>{} |
35
|
|
|
|
|
|
|
}); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $user->some_mothed(arg1,arg2,……); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Mojolicious框架中所有Service的基类(具体的Service需要用户实现)! |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 dbi |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
dbi 是为service提供数据库操作接口的对象。 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 models |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
models 是为service提供数据模型操作接口的对象。 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 app |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
当前应用程序的引用,通常是Mojolicious对象。 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 METHODS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 model |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
根据model的名称从 models 属性中获取model。 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
wfso, C<< <461663376 at qq.com> >> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 BUGS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
75
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
76
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SUPPORT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
perldoc Mojolicious::Service |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
You can also look for information at: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over 4 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
L |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * CPAN Ratings |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * Search CPAN |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; # End of Mojolicious::Service |