Compare commits
797 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dcbe82f398 | ||
![]() |
afe70d39b9 | ||
![]() |
9118e07d7b | ||
![]() |
c0f05fcf8f | ||
![]() |
35445f37e1 | ||
![]() |
94c430f491 | ||
![]() |
97efb82971 | ||
![]() |
5f49a22a5e | ||
![]() |
85f4fc0df8 | ||
![]() |
04a7818608 | ||
![]() |
21c1df4f69 | ||
![]() |
0dfe4fb5c6 | ||
![]() |
9ca1fd42ae | ||
![]() |
5713d12ce1 | ||
![]() |
e01790aa23 | ||
![]() |
ecf0970ca4 | ||
![]() |
78e782dd01 | ||
![]() |
e4a5ae0c37 | ||
![]() |
c8e9e6361c | ||
![]() |
7c4fa5c516 | ||
![]() |
97b7f73ff2 | ||
![]() |
0b5c883012 | ||
![]() |
a9671b6227 | ||
![]() |
9ab22b1a1c | ||
![]() |
a931b7597c | ||
![]() |
4506219fb2 | ||
![]() |
91a1d253c5 | ||
![]() |
3d58942844 | ||
![]() |
e0b2aafd2c | ||
![]() |
7278be4e49 | ||
![]() |
a62020650c | ||
![]() |
9baadccfbb | ||
![]() |
538006c3c6 | ||
![]() |
e2399b6aa6 | ||
![]() |
c5aee52667 | ||
![]() |
8991315888 | ||
![]() |
9754a23360 | ||
![]() |
753f6b9dcf | ||
![]() |
bcb96cd3c4 | ||
![]() |
3908c26e2c | ||
![]() |
f17570deef | ||
![]() |
390fc8ccd5 | ||
![]() |
4d9f57a8c7 | ||
![]() |
b8e08eac96 | ||
![]() |
bece4dac86 | ||
![]() |
4b8d5aa507 | ||
![]() |
5ec24ae9c9 | ||
![]() |
25c5faf440 | ||
![]() |
097b0e1ee5 | ||
![]() |
09b20c255b | ||
![]() |
a3db671328 | ||
![]() |
33177f26cb | ||
![]() |
45712076d2 | ||
![]() |
5979088144 | ||
![]() |
42e6cd36aa | ||
![]() |
08b3e472a9 | ||
![]() |
42b99dd64c | ||
![]() |
e412fd3b60 | ||
![]() |
4f0c37d281 | ||
![]() |
bae186d82a | ||
![]() |
5223997031 | ||
![]() |
5fa20a4f28 | ||
![]() |
0cd799dce3 | ||
![]() |
72a878ed30 | ||
![]() |
5f65e3d25f | ||
![]() |
66ec4f174d | ||
![]() |
64ab5439a6 | ||
![]() |
0558764093 | ||
![]() |
4216a48907 | ||
![]() |
8b65690450 | ||
![]() |
4f461bb673 | ||
![]() |
e30de13d35 | ||
![]() |
c72943da58 | ||
![]() |
a98fbdc7a1 | ||
![]() |
42ffcb75c7 | ||
![]() |
c74c3c23d4 | ||
![]() |
5211d29c5e | ||
![]() |
82dc1ebd05 | ||
![]() |
e35532850d | ||
![]() |
0da4627217 | ||
![]() |
5fd218d26a | ||
![]() |
ee624300b6 | ||
![]() |
dc4855f5c1 | ||
![]() |
9e13a9c937 | ||
![]() |
90990f8782 | ||
![]() |
40276babfb | ||
![]() |
818ffb2ce6 | ||
![]() |
763a05fa80 | ||
![]() |
8c153cce60 | ||
![]() |
93b6f1e2f1 | ||
![]() |
61b9a07d99 | ||
![]() |
d75c455bdc | ||
![]() |
04e2b1ffe5 | ||
![]() |
14b5b3ce3a | ||
![]() |
a4e84ffa75 | ||
![]() |
bd7f62b9ed | ||
![]() |
3a2689db18 | ||
![]() |
3fb55deaaf | ||
![]() |
b07defb0e9 | ||
![]() |
377b72ae19 | ||
![]() |
dd023caf36 | ||
![]() |
163d1c4bee | ||
![]() |
2c2b7f8723 | ||
![]() |
d533aeaa9e | ||
![]() |
a6cebc3750 | ||
![]() |
214ca68b44 | ||
![]() |
e712f824f5 | ||
![]() |
f301f149fb | ||
![]() |
96751d6974 | ||
![]() |
da9aa45036 | ||
![]() |
9ec1285cb9 | ||
![]() |
3947ba7386 | ||
![]() |
d0a9a41c68 | ||
![]() |
7fbee46c73 | ||
![]() |
c8a7d0291c | ||
![]() |
d0044ee019 | ||
![]() |
3466c8ec1f | ||
![]() |
b3be31750a | ||
![]() |
ca7a3df823 | ||
![]() |
9a5e7010b1 | ||
![]() |
2e67214032 | ||
![]() |
c5fb6f9409 | ||
![]() |
8f73948223 | ||
![]() |
2941eeac1e | ||
![]() |
e0007d4150 | ||
![]() |
0e3656c7cc | ||
![]() |
44ed0b9788 | ||
![]() |
1d660ba648 | ||
![]() |
202f7f1dea | ||
![]() |
b1f5c22c9d | ||
![]() |
a7609d9c77 | ||
![]() |
cb9deeb7ce | ||
![]() |
b62cf987d1 | ||
![]() |
c6e235ca6c | ||
![]() |
03bb91cd9e | ||
![]() |
e15838386f | ||
![]() |
bcf37924d3 | ||
![]() |
1a965ff4f5 | ||
![]() |
bbfb206210 | ||
![]() |
2f76d0da38 | ||
![]() |
ea6e45450c | ||
![]() |
4bfa907191 | ||
![]() |
6c9f1cface | ||
![]() |
8776849d98 | ||
![]() |
b5a589d4da | ||
![]() |
c529d36f03 | ||
![]() |
de97a1319e | ||
![]() |
d410434979 | ||
![]() |
29732738dc | ||
![]() |
230ea26a1b | ||
![]() |
d1a42637fe | ||
![]() |
fae47bf246 | ||
![]() |
cba66dfe58 | ||
![]() |
cc34e058f0 | ||
![]() |
3ab7e207c9 | ||
![]() |
e232062ba6 | ||
![]() |
3a0c537ce0 | ||
![]() |
d9faa42905 | ||
![]() |
99727f1c7d | ||
![]() |
7fc50c9916 | ||
![]() |
454fa43f8c | ||
![]() |
cdf6efde1d | ||
![]() |
c65863d606 | ||
![]() |
c5650e80bd | ||
![]() |
8d21dc8acc | ||
![]() |
263c036e49 | ||
![]() |
f0351246fc | ||
![]() |
30f405f233 | ||
![]() |
94052b6e01 | ||
![]() |
ab9302e790 | ||
![]() |
f396732544 | ||
![]() |
0fb344fcf3 | ||
![]() |
78bb8bccd7 | ||
![]() |
027ba1acdb | ||
![]() |
2757873ef2 | ||
![]() |
6e1fdb2b74 | ||
![]() |
929f9b2a75 | ||
![]() |
db18e71906 | ||
![]() |
3f5b84ba45 | ||
![]() |
bb1dd9b207 | ||
![]() |
eee53b3131 | ||
![]() |
a86387a47e | ||
![]() |
b538c08b88 | ||
![]() |
ce38bc741b | ||
![]() |
142fd71b56 | ||
![]() |
a6ad9b63dd | ||
![]() |
8a901e89cb | ||
![]() |
fc93826016 | ||
![]() |
98b2d7d31b | ||
![]() |
33bdd01933 | ||
![]() |
32b87baeee | ||
![]() |
19c092dffc | ||
![]() |
81e7f78419 | ||
![]() |
a5416bd0ad | ||
![]() |
6d51b5bc76 | ||
![]() |
04e008fcfa | ||
![]() |
7ef4efa37a | ||
![]() |
1644076abe | ||
![]() |
5b43786432 | ||
![]() |
1e8b5510f1 | ||
![]() |
7adfc93190 | ||
![]() |
b9c156e5a7 | ||
![]() |
bcdf6cd9c7 | ||
![]() |
e17846571c | ||
![]() |
359381fec6 | ||
![]() |
42e75f50ff | ||
![]() |
454e1fcd55 | ||
![]() |
5584fa66da | ||
![]() |
87ec38d1dd | ||
![]() |
6db13b9eab | ||
![]() |
e678b4ce51 | ||
![]() |
b8de40a60f | ||
![]() |
c84d5a2a17 | ||
![]() |
9335556197 | ||
![]() |
40ed25816c | ||
![]() |
2a593b179a | ||
![]() |
a5b6b479ce | ||
![]() |
104ad3f744 | ||
![]() |
ea32a4cd33 | ||
![]() |
a3f378eca8 | ||
![]() |
bcc4237140 | ||
![]() |
4fec98f939 | ||
![]() |
f15eedfa9c | ||
![]() |
da683a3592 | ||
![]() |
7adfb6a0ae | ||
![]() |
a73883cc79 | ||
![]() |
3235e98c38 | ||
![]() |
bb38e3bdac | ||
![]() |
9092b64c1f | ||
![]() |
e798098a05 | ||
![]() |
c2da2e5806 | ||
![]() |
6e1be051e2 | ||
![]() |
a34d687203 | ||
![]() |
2746d565e4 | ||
![]() |
fda520bad3 | ||
![]() |
1abcc5045f | ||
![]() |
5e076a6eb7 | ||
![]() |
349f36df21 | ||
![]() |
9ec043ba34 | ||
![]() |
e51cbc6850 | ||
![]() |
26e26b60a7 | ||
![]() |
e35b14a883 | ||
![]() |
24e1506743 | ||
![]() |
51672734a6 | ||
![]() |
1a20159776 | ||
![]() |
bd840134ad | ||
![]() |
9740df6a97 | ||
![]() |
0ef84fea08 | ||
![]() |
2b4f9823ff | ||
![]() |
051627547e | ||
![]() |
16a19312a9 | ||
![]() |
7dedec17d9 | ||
![]() |
b9f055e052 | ||
![]() |
57d26f8003 | ||
![]() |
655541210a | ||
![]() |
f2affda157 | ||
![]() |
08fb8b3397 | ||
![]() |
09c409fc76 | ||
![]() |
6841f6c385 | ||
![]() |
99136f33d1 | ||
![]() |
41eb836634 | ||
![]() |
db9428961f | ||
![]() |
cc5805f410 | ||
![]() |
1c9e98ff2a | ||
![]() |
7152661210 | ||
![]() |
59774e7958 | ||
![]() |
bcd7215333 | ||
![]() |
a232f555c3 | ||
![]() |
ce71b10d1c | ||
![]() |
707070a06e | ||
![]() |
fca8980715 | ||
![]() |
4dc2978d61 | ||
![]() |
cfaec3fbc3 | ||
![]() |
d2bc7a25c0 | ||
![]() |
5f5260a639 | ||
![]() |
f6783cb13e | ||
![]() |
ee04005d69 | ||
![]() |
9125292aa8 | ||
![]() |
2c18af0aa7 | ||
![]() |
2d95212973 | ||
![]() |
0e7453a6fe | ||
![]() |
8c32893c91 | ||
![]() |
805b04a7f8 | ||
![]() |
8dfd4596be | ||
![]() |
8b4404df55 | ||
![]() |
23fa6ab097 | ||
![]() |
f18766c20a | ||
![]() |
d873ba10f9 | ||
![]() |
51d237d0f0 | ||
![]() |
6e76c173a7 | ||
![]() |
a3dd8282b3 | ||
![]() |
317a9ef595 | ||
![]() |
e6d7ee8f55 | ||
![]() |
fbf9c11191 | ||
![]() |
4392f25e97 | ||
![]() |
73c7788218 | ||
![]() |
835b93eaaf | ||
![]() |
092567a169 | ||
![]() |
028333fae3 | ||
![]() |
7b0aa49c21 | ||
![]() |
c624dc1777 | ||
![]() |
dc08715bc7 | ||
![]() |
11f6419b4f | ||
![]() |
448154f363 | ||
![]() |
cd8ff84f02 | ||
![]() |
97724b04df | ||
![]() |
6e9c0aed32 | ||
![]() |
de6470fd0e | ||
![]() |
bd21242410 | ||
![]() |
f21716d5a6 | ||
![]() |
49500956dd | ||
![]() |
9ff6c8d883 | ||
![]() |
6612dfd8b7 | ||
![]() |
93c1c11853 | ||
![]() |
49a8d04157 | ||
![]() |
1d1afe468c | ||
![]() |
20b3fd477f | ||
![]() |
e4273e5a1a | ||
![]() |
2c9e22ac6c | ||
![]() |
e717f56416 | ||
![]() |
96f04545db | ||
![]() |
cbfcce919f | ||
![]() |
1f3c025f36 | ||
![]() |
b4b0d624a6 | ||
![]() |
5a198f8f0b | ||
![]() |
fcc6fd035d | ||
![]() |
4fc4577be3 | ||
![]() |
dec79f2b28 | ||
![]() |
f14107dc44 | ||
![]() |
727640396e | ||
![]() |
e105492d27 | ||
![]() |
c450c4afc5 | ||
![]() |
13d3734dba | ||
![]() |
6977442b05 | ||
![]() |
3b063ac1fd | ||
![]() |
5609d4fd09 | ||
![]() |
66acbeee8b | ||
![]() |
5231770bab | ||
![]() |
ec5a5a8402 | ||
![]() |
e9c8940730 | ||
![]() |
333d0be409 | ||
![]() |
ffeec69333 | ||
![]() |
ac56a7b80d | ||
![]() |
9a07ae1e1b | ||
![]() |
08b7a1b17c | ||
![]() |
d232ebb207 | ||
![]() |
8550c99133 | ||
![]() |
f55ff91554 | ||
![]() |
f9ed43017f | ||
![]() |
c06e7b8694 | ||
![]() |
fe6ea82014 | ||
![]() |
39c0ec4c48 | ||
![]() |
107a7d48da | ||
![]() |
b57d7f95c3 | ||
![]() |
5face1c077 | ||
![]() |
a5a05b1e88 | ||
![]() |
ea6a4b15a8 | ||
![]() |
c60d8d2dc9 | ||
![]() |
bae43ad382 | ||
![]() |
74a42e7022 | ||
![]() |
c04530a1be | ||
![]() |
2074c1f65d | ||
![]() |
c0e3726775 | ||
![]() |
0f59685ae3 | ||
![]() |
dfcec7394f | ||
![]() |
8bf7380d82 | ||
![]() |
fa04341608 | ||
![]() |
167ea743a0 | ||
![]() |
30e7829d21 | ||
![]() |
1d1eaa0338 | ||
![]() |
a60880d327 | ||
![]() |
19c62e049c | ||
![]() |
0df821d1a4 | ||
![]() |
00a37a05f2 | ||
![]() |
93f22ab338 | ||
![]() |
ca5e76497c | ||
![]() |
b7d951bdb7 | ||
![]() |
bfc576b437 | ||
![]() |
5ac51366f2 | ||
![]() |
853ebe7437 | ||
![]() |
c635a322bb | ||
![]() |
70b6b0407c | ||
![]() |
ff1d7dfd2e | ||
![]() |
181ceefd55 | ||
![]() |
48f572168f | ||
![]() |
64ce1243b4 | ||
![]() |
9da4072b30 | ||
![]() |
52e25103d0 | ||
![]() |
2361be7d71 | ||
![]() |
5057f3eb9e | ||
![]() |
b4bb0a1910 | ||
![]() |
f913f76bd2 | ||
![]() |
45383c2230 | ||
![]() |
dbc6eb2b48 | ||
![]() |
3f814116de | ||
![]() |
db2aba9b1a | ||
![]() |
68cdec973a | ||
![]() |
82a99d7d17 | ||
![]() |
a90f289792 | ||
![]() |
9b2c4aa905 | ||
![]() |
d68891035b | ||
![]() |
6f8552fa70 | ||
![]() |
278b078937 | ||
![]() |
0cc8dc7927 | ||
![]() |
9dda665ddc | ||
![]() |
056abcd9f1 | ||
![]() |
98c99e05f3 | ||
![]() |
339f441d4f | ||
![]() |
72eb174946 | ||
![]() |
635f3e00d0 | ||
![]() |
9e5bbeae5a | ||
![]() |
0bc448f8e8 | ||
![]() |
dd1ce48646 | ||
![]() |
ae01ba64b2 | ||
![]() |
892f8f2aad | ||
![]() |
4e38e7ede2 | ||
![]() |
fbc4a6201a | ||
![]() |
5fb45c0d49 | ||
![]() |
2febc2bb56 | ||
![]() |
e1abef2319 | ||
![]() |
dd0ad744e6 | ||
![]() |
b86347a993 | ||
![]() |
196dfbcbda | ||
![]() |
cfc7d8a48c | ||
![]() |
06ee75d496 | ||
![]() |
b192a0151f | ||
![]() |
4d444e9bbc | ||
![]() |
45af3fbc5f | ||
![]() |
4a5e4353be | ||
![]() |
ab3e420085 | ||
![]() |
a437d2ed40 | ||
![]() |
d8ad1f6b87 | ||
![]() |
610f48b4ec | ||
![]() |
514bb6b520 | ||
![]() |
76855d6b5d | ||
![]() |
b30e57bf01 | ||
![]() |
f8fb57c9c6 | ||
![]() |
64c03bdfd3 | ||
![]() |
7f72784bfb | ||
![]() |
08aee72ab9 | ||
![]() |
50bcb7e289 | ||
![]() |
0b546a20be | ||
![]() |
d044ac6d8a | ||
![]() |
011c138439 | ||
![]() |
435e1b6399 | ||
![]() |
760ad2a51b | ||
![]() |
5fa78eda58 | ||
![]() |
3f888f909a | ||
![]() |
fbbfc70d39 | ||
![]() |
9e56f9f85e | ||
![]() |
e7295fa767 | ||
![]() |
b3682b1ee6 | ||
![]() |
498b45059b | ||
![]() |
306c36df85 | ||
![]() |
b71bba6a1e | ||
![]() |
e7491555e8 | ||
![]() |
ef64b8a8cb | ||
![]() |
05abc92ad9 | ||
![]() |
90241e9a8f | ||
![]() |
3469cc2adf | ||
![]() |
6ac556e819 | ||
![]() |
0fd9d3dcb4 | ||
![]() |
aa56154a28 | ||
![]() |
57abdd4fd9 | ||
![]() |
6b227688e4 | ||
![]() |
308ee3120e | ||
![]() |
fd9ce382db | ||
![]() |
67b810b06f | ||
![]() |
86dfe36714 | ||
![]() |
6ac0e3ebf2 | ||
![]() |
33fee182d2 | ||
![]() |
20410ba52c | ||
![]() |
49f948fdd1 | ||
![]() |
3d65d111ee | ||
![]() |
129582a446 | ||
![]() |
8084e11805 | ||
![]() |
dd46a28096 | ||
![]() |
9b2ac5fd49 | ||
![]() |
4f9cf56e69 | ||
![]() |
5e59f507af | ||
![]() |
9594ea0fc4 | ||
![]() |
2f77658f41 | ||
![]() |
6cd67c6498 | ||
![]() |
cfe2a005c0 | ||
![]() |
7131a6c878 | ||
![]() |
010cc10d53 | ||
![]() |
e82e058550 | ||
![]() |
1b954c1b16 | ||
![]() |
be743d9d23 | ||
![]() |
2c350cbceb | ||
![]() |
20091aaf43 | ||
![]() |
a5c193f192 | ||
![]() |
f777816e18 | ||
![]() |
f1f3df2bc8 | ||
![]() |
c4d29b5cbf | ||
![]() |
1b8f0df628 | ||
![]() |
def5e396e1 | ||
![]() |
6da68f09cd | ||
![]() |
9ddc932e89 | ||
![]() |
b47ff98bb6 | ||
![]() |
48298273dd | ||
![]() |
9548cb34fd | ||
![]() |
56f6ba90a6 | ||
![]() |
8d10baa35f | ||
![]() |
e61f3a4115 | ||
![]() |
4271a70b16 | ||
![]() |
49a4e56f48 | ||
![]() |
29482f4e31 | ||
![]() |
a90fd31b87 | ||
![]() |
35a9ecbc82 | ||
![]() |
defd10ab91 | ||
![]() |
f812033ccc | ||
![]() |
4c48d0c71d | ||
![]() |
52e166b330 | ||
![]() |
91d4f4a54d | ||
![]() |
6b7146486c | ||
![]() |
3a58e928b6 | ||
![]() |
b998d58dea | ||
![]() |
ff1aecce37 | ||
![]() |
4e1a2d07d6 | ||
![]() |
b0ee2e84d2 | ||
![]() |
42059247b2 | ||
![]() |
6c5383f83c | ||
![]() |
bcb671697c | ||
![]() |
a9aa28bd77 | ||
![]() |
bf98751ed5 | ||
![]() |
ebe5f5757a | ||
![]() |
fd1798875f | ||
![]() |
c4bdcd4152 | ||
![]() |
98f2e4bc31 | ||
![]() |
0952e8f6f8 | ||
![]() |
13d5b1a7fc | ||
![]() |
2c00ae5bdd | ||
![]() |
f562a3e8bc | ||
![]() |
81abf41e31 | ||
![]() |
db9a9327e5 | ||
![]() |
1377a3a589 | ||
![]() |
4b0e9f24b9 | ||
![]() |
766d156bf8 | ||
![]() |
a752c7914a | ||
![]() |
ae37218fcd | ||
![]() |
6040ee4873 | ||
![]() |
0c0238f664 | ||
![]() |
fad98021e4 | ||
![]() |
e5ebc34d84 | ||
![]() |
50410d640a | ||
![]() |
d0687df4de | ||
![]() |
b18390739f | ||
![]() |
9c1eb59961 | ||
![]() |
04b491621e | ||
![]() |
7dd40dc4aa | ||
![]() |
a8c98a0a05 | ||
![]() |
5181915e3c | ||
![]() |
021041218b | ||
![]() |
88971b672d | ||
![]() |
09f8ef88ea | ||
![]() |
3e7106f9aa | ||
![]() |
10687ea93c | ||
![]() |
714837c8df | ||
![]() |
b9acfbea2b | ||
![]() |
6f31f12be7 | ||
![]() |
6b0eb5f849 | ||
![]() |
3001ba26b1 | ||
![]() |
1ce6ddc060 | ||
![]() |
0db7f7d3e9 | ||
![]() |
886e86ef24 | ||
![]() |
44eba6b389 | ||
![]() |
07442c8292 | ||
![]() |
e61b61a220 | ||
![]() |
5450edb490 | ||
![]() |
f8f20ab955 | ||
![]() |
bea3e43937 | ||
![]() |
0708d4ce61 | ||
![]() |
e1ae8fd084 | ||
![]() |
46c7307736 | ||
![]() |
98e74c95dc | ||
![]() |
7b67e47059 | ||
![]() |
ac2dab4fa7 | ||
![]() |
db37e71782 | ||
![]() |
055f3d5aa9 | ||
![]() |
cb90f5f6d3 | ||
![]() |
4f5476c270 | ||
![]() |
9e4883ead6 | ||
![]() |
ac74827130 | ||
![]() |
f8a97527f6 | ||
![]() |
5c8072e0b8 | ||
![]() |
9f9a83f157 | ||
![]() |
a719129b64 | ||
![]() |
dfd0be23c6 | ||
![]() |
dc5e46e974 | ||
![]() |
2c732555b0 | ||
![]() |
ef545b8732 | ||
![]() |
b06a5300cb | ||
![]() |
1a03783d26 | ||
![]() |
bb372844dc | ||
![]() |
5f9e90ec67 | ||
![]() |
257c29391e | ||
![]() |
92d4092f1c | ||
![]() |
a528ee83ae | ||
![]() |
d09bcba9f3 | ||
![]() |
4442944cc6 | ||
![]() |
51f9873d6e | ||
![]() |
3e4eca9d45 | ||
![]() |
9c7a01406d | ||
![]() |
8b216f2bc4 | ||
![]() |
c6c0446c4e | ||
![]() |
691518c8c8 | ||
![]() |
fb482ded01 | ||
![]() |
f427efd2c8 | ||
![]() |
04d942c7db | ||
![]() |
7eeade987a | ||
![]() |
5f34bac033 | ||
![]() |
05e22d4db8 | ||
![]() |
418a6d5418 | ||
![]() |
3983c413f6 | ||
![]() |
2acf23d296 | ||
![]() |
b6b0b5170d | ||
![]() |
09132deb78 | ||
![]() |
7e41702de8 | ||
![]() |
f63706eb0a | ||
![]() |
5ba918f1a5 | ||
![]() |
64cd112d43 | ||
![]() |
2cc2ecae40 | ||
![]() |
cffcf11192 | ||
![]() |
3e0717c339 | ||
![]() |
be02170697 | ||
![]() |
3b67f3fb5f | ||
![]() |
9e2c84dd54 | ||
![]() |
152cd8738a | ||
![]() |
0fde164059 | ||
![]() |
1b7cc3fcf5 | ||
![]() |
313a396ba8 | ||
![]() |
7c09bcf0cf | ||
![]() |
8b93c63883 | ||
![]() |
5ec9939cbf | ||
![]() |
9673c62a14 | ||
![]() |
6cc76c9f8e | ||
![]() |
dfcfd78557 | ||
![]() |
e994d14537 | ||
![]() |
9bcb7466bd | ||
![]() |
4fa1c9638e | ||
![]() |
4387bbb7f9 | ||
![]() |
2a805b6709 | ||
![]() |
88c3bb432d | ||
![]() |
e5c8c71011 | ||
![]() |
a5242b3aea | ||
![]() |
480aadd38b | ||
![]() |
ca0bf90615 | ||
![]() |
2dc1270348 | ||
![]() |
ce0eb575e9 | ||
![]() |
a03f3c3699 | ||
![]() |
a041504243 | ||
![]() |
3ef506d129 | ||
![]() |
9e28cbd91d | ||
![]() |
ba91154ee8 | ||
![]() |
cf4ef949b5 | ||
![]() |
b41121e35b | ||
![]() |
c9b39327a5 | ||
![]() |
f7ac1a23bf | ||
![]() |
4a8a0b90e8 | ||
![]() |
4bf6d5168f | ||
![]() |
c53c40487c | ||
![]() |
9b591340a1 | ||
![]() |
66e4f8f74f | ||
![]() |
ae084819fe | ||
![]() |
b061ab5225 | ||
![]() |
872f6b9dfb | ||
![]() |
9988c7c00c | ||
![]() |
ef44acee7a | ||
![]() |
998c8edf24 | ||
![]() |
b2bdb12e5b | ||
![]() |
06726f8fc0 | ||
![]() |
1798cbcd0c | ||
![]() |
a634aa4f93 | ||
![]() |
fcc2e04b85 | ||
![]() |
ef30c07f4a | ||
![]() |
b94800033f | ||
![]() |
201cb455f5 | ||
![]() |
1dcce85c3a | ||
![]() |
4a3f043166 | ||
![]() |
ceda3a224a | ||
![]() |
8d5ec7966a | ||
![]() |
2dc5321128 | ||
![]() |
a258ba6cc2 | ||
![]() |
b27ef2570a | ||
![]() |
cf1dedabd4 | ||
![]() |
fc885476ef | ||
![]() |
aefa972804 | ||
![]() |
c02f762537 | ||
![]() |
122b624580 | ||
![]() |
7e304cacf0 | ||
![]() |
11854ec33e | ||
![]() |
a36603f7c2 | ||
![]() |
6e0a405f09 | ||
![]() |
2f71ba5380 | ||
![]() |
57f6597e77 | ||
![]() |
300e536053 | ||
![]() |
3d8b31b2dc | ||
![]() |
4e8aa4ae31 | ||
![]() |
daf6d1f760 | ||
![]() |
7be9b78ac4 | ||
![]() |
b4a411f343 | ||
![]() |
46a41c86ea | ||
![]() |
2c349e0832 | ||
![]() |
5d1da432c7 | ||
![]() |
3e91f16f27 | ||
![]() |
efd0dd8e8f | ||
![]() |
f1c9f3db53 | ||
![]() |
6f33180f9f | ||
![]() |
6e73f78bd3 | ||
![]() |
438582ad6a | ||
![]() |
6caafbf4ca | ||
![]() |
0bc1b3c30c | ||
![]() |
a1c135f5d0 | ||
![]() |
bfeb14b597 | ||
![]() |
27b30a8704 | ||
![]() |
aea9eb6a17 | ||
![]() |
0d05e4ecbd | ||
![]() |
f1ca73e05f | ||
![]() |
b365ec1db8 | ||
![]() |
cd16d4314e | ||
![]() |
aba362dbad | ||
![]() |
79863215b3 | ||
![]() |
6c12887f8d | ||
![]() |
a018373013 | ||
![]() |
a9a857389a | ||
![]() |
5fec0b01b7 | ||
![]() |
a62b1d54d6 | ||
![]() |
4bfc021cdf | ||
![]() |
e3ececc277 | ||
![]() |
2d6d074d94 | ||
![]() |
6ac4b8784e | ||
![]() |
34d75c3f46 | ||
![]() |
d21126882b | ||
![]() |
d7f0e6c949 | ||
![]() |
dc5ffd6ab1 | ||
![]() |
d1d497076b | ||
![]() |
e6d1517429 | ||
![]() |
eb2fd14f07 | ||
![]() |
1bcc0f217e | ||
![]() |
6724da9e8f | ||
![]() |
d3e0c64b58 | ||
![]() |
722b8cfa7f | ||
![]() |
0d0abf3ea0 | ||
![]() |
485432acfb | ||
![]() |
3ec10515fb | ||
![]() |
d3dfe38d60 | ||
![]() |
74841b0717 | ||
![]() |
5bcfe3c52d | ||
![]() |
6ac0562470 | ||
![]() |
d27b7442d8 | ||
![]() |
8479522970 | ||
![]() |
1ce4c7122a | ||
![]() |
e35a76a80e | ||
![]() |
dacf005117 | ||
![]() |
fad0f9770d | ||
![]() |
b5e90dd14f | ||
![]() |
17d30f1cc3 | ||
![]() |
a4a03857ac | ||
![]() |
0d0cc6eeb6 | ||
![]() |
d40deeff60 | ||
![]() |
6f7e0d71c2 | ||
![]() |
86a198d66a | ||
![]() |
5976ebb235 | ||
![]() |
02b973d0b5 | ||
![]() |
bdbf812941 | ||
![]() |
15be66ec26 | ||
![]() |
d53b0bae73 | ||
![]() |
4a5993160f | ||
![]() |
67e79bfa19 | ||
![]() |
c8eedead00 | ||
![]() |
109cb7279a | ||
![]() |
a0a62b5640 | ||
![]() |
5c7c976869 | ||
![]() |
6c423e5fc5 | ||
![]() |
5f6a7cf24e | ||
![]() |
ca4272d7a6 | ||
![]() |
d154f3e1ac | ||
![]() |
66e72c6537 | ||
![]() |
7a6628a95f | ||
![]() |
ecae3e90f1 | ||
![]() |
c48d9154ad | ||
![]() |
6624a0cc6b | ||
![]() |
22064c6178 | ||
![]() |
7ac37e235b | ||
![]() |
ae7fd47a5d | ||
![]() |
dfa045726b | ||
![]() |
e6b443043a | ||
![]() |
330a19e8c3 | ||
![]() |
fa4837487b | ||
![]() |
5c7765c97f | ||
![]() |
397c8bb7f7 | ||
![]() |
6b4dd70752 | ||
![]() |
2651ed6305 | ||
![]() |
849db90b32 | ||
![]() |
40676f8b14 | ||
![]() |
38bcb43e70 |
15
.env.emp
15
.env.emp
@@ -1,15 +0,0 @@
|
|||||||
app_debug=true
|
|
||||||
app_trace=true
|
|
||||||
|
|
||||||
db_connection=mysql
|
|
||||||
db_host=localhost
|
|
||||||
db_database=thinking
|
|
||||||
db_username=user
|
|
||||||
db_port=3306
|
|
||||||
db_password=password
|
|
||||||
|
|
||||||
redis_host=
|
|
||||||
redis_port=
|
|
||||||
redis_password=
|
|
||||||
|
|
||||||
|
|
1
.example.env
Normal file
1
.example.env
Normal file
@@ -0,0 +1 @@
|
|||||||
|
APP_DEBUG = false
|
24
.gitee/ISSUE_TEMPLATE.zh-CN.md
Normal file
24
.gitee/ISSUE_TEMPLATE.zh-CN.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# 环境
|
||||||
|
- 操作系统:
|
||||||
|
- php 版本:
|
||||||
|
- thinkphp 版本:
|
||||||
|
- Mysql 版本:
|
||||||
|
- web 服务器:
|
||||||
|
|
||||||
|
# 问题
|
||||||
|
- 问题描述:
|
||||||
|
- 问题截图:
|
||||||
|
|
||||||
|
# 结果
|
||||||
|
- 实际结果:
|
||||||
|
- 预期结果:
|
||||||
|
|
||||||
|
# 分析
|
||||||
|
- 所做的尝试:
|
||||||
|
-
|
||||||
|
-
|
||||||
|
|
||||||
|
# 方案:
|
||||||
|
- 解决方案:
|
||||||
|
|
||||||
|
> 请在问题解决后关闭 issue
|
25
.github/issue_template.md
vendored
Normal file
25
.github/issue_template.md
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# 环境
|
||||||
|
- 操作系统:
|
||||||
|
- php 版本:
|
||||||
|
- thinkphp 版本:
|
||||||
|
- Mysql 版本:
|
||||||
|
- web 服务器:
|
||||||
|
|
||||||
|
# 问题
|
||||||
|
- 问题描述:
|
||||||
|
|
||||||
|
- 问题截图:
|
||||||
|
|
||||||
|
# 结果
|
||||||
|
- 实际结果:
|
||||||
|
- 预期结果:
|
||||||
|
|
||||||
|
# 分析
|
||||||
|
- 所做的尝试:
|
||||||
|
-
|
||||||
|
-
|
||||||
|
|
||||||
|
# 方案:
|
||||||
|
- 解决方案:
|
||||||
|
|
||||||
|
> 请在问题解决后关闭 issue
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,7 +1,8 @@
|
|||||||
/.idea
|
/.idea
|
||||||
/.vscode
|
/.vscode
|
||||||
/vendor
|
/vendor
|
||||||
|
/package
|
||||||
*.log
|
*.log
|
||||||
thinkphp
|
|
||||||
.env
|
.env
|
||||||
.DS_Store
|
composer.lock
|
||||||
|
|
||||||
|
20
LICENSE
20
LICENSE
@@ -1,20 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2018 JaguarJack
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
|
||||||
the Software without restriction, including without limitation the rights to
|
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
201
LICENSE.txt
Normal file
201
LICENSE.txt
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {yyyy} {name of copyright owner}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
223
README.md
223
README.md
@@ -1,81 +1,160 @@
|
|||||||
# think-admin
|
<p align="center">
|
||||||
# ENV
|
<img src="https://cdn.learnku.com/uploads/images/202005/17/18206/zSuf7Ce5kM.png!large">
|
||||||
- php >= 7.1.3
|
</p>
|
||||||
- mysql >= 5.5
|
|
||||||
|
|
||||||
# install
|
|
||||||
- curl -sS http://install.phpcomposer.com/installer | php
|
|
||||||
- composer config -g repo.packagist composer https://packagist.laravel-china.org
|
|
||||||
- composer update
|
|
||||||
- 修改根目录下 .env.emp .env
|
|
||||||
- .env 配置数据库信息
|
|
||||||
- php think migrate:run
|
|
||||||
- php think seed:run
|
|
||||||
|
|
||||||
# Use
|
<p align="center"><code>CatchAdmin</code>是一款基于<a href="http://www.thinkphp.cn/" target="_blank">thinkphp framework</a>和
|
||||||
- 配置虚拟域名 OR 在根目录下执行 php think run
|
<a href="https://github.com/PanJiaChen/vue-element-admin/">element admin</a>二次开发而成后台管理系统。因为 thinkphp 的简单高效,文档齐全。在看了很多 thinkphp 生态中的后台管理系统,发现没有一款合适的前后端分离系统。遂开发了 CatchAdmin。
|
||||||
- yourUrl/login
|
完全利用了 thinkphp6 的新版本特性 ServiceProvider,将管理系统模块之间的耦合降到了最低限度。每个模块之间都有独立的 controller,路由,模型,数据表`。在开发上尽可能将模块之间的影响降到最低,降低了开发上的难度。基于 CatchAdmin 可以开发 cms,CRM,OA 等
|
||||||
- 默认用户名 admin 密码 admin
|
等系统。也封装了很多实用的工具,提升开发体验。
|
||||||
|
</p>
|
||||||
|
|
||||||
# nginx 配置
|
<p align="center">
|
||||||
|
<a href="http://doc.catchadmin.com/">文档</a> |
|
||||||
|
<a href="http://vue.catchadmin.com">演示地址</a> |
|
||||||
|
<a href="http://apidoc.catchadmin.com">接口文档</a> |
|
||||||
|
<a href="https://gitee.com/jaguarjack/catchAdmin">项目源码</a> |
|
||||||
|
<a href="https://www.kancloud.cn/akasishikelu/thinkphp6">看云分析</a>
|
||||||
|
<a href="#extensions">扩展</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://gitee.com/jaguarjack/catchAdmin" target="_blank">
|
||||||
|
<img src="https://svg.hamm.cn/gitee.svg?type=star&user=jaguarjack&project=catchAdmin"/>
|
||||||
|
</a >
|
||||||
|
<a href="https://gitee.com/jaguarjack/catchAdmin" target="_blank">
|
||||||
|
<img src="https://svg.hamm.cn/gitee.svg?type=fork&user=jaguarjack&project=catchAdmin"/>
|
||||||
|
</a >
|
||||||
|
<img src="https://svg.hamm.cn/badge.svg?key=Base&value=ThinkPHP6"/>
|
||||||
|
<img src="https://svg.hamm.cn/badge.svg?key=Data&value=MySQL5.5"/>
|
||||||
|
<img src="https://svg.hamm.cn/badge.svg?key=Runtime&value=PHP7.1"/>
|
||||||
|
<img src="https://svg.hamm.cn/badge.svg?key=License&value=Apache-2.0"/>
|
||||||
|
</p >
|
||||||
|
|
||||||
|
## AntDV 版本
|
||||||
|
- 请使用 `v1`分支
|
||||||
|
|
||||||
|
## 功能
|
||||||
|
- [x] `用户管理` 后台用户管理
|
||||||
|
- [x] `部门管理` 配置公司的部门结构,支持树形结构
|
||||||
|
- [x] `岗位管理` 配置后台用户的职务
|
||||||
|
- [x] `菜单管理` 配置系统菜单,按钮等等
|
||||||
|
- [x] `角色管理` 配置用户担当的角色,分配权限
|
||||||
|
- [x] `数据字典` 管理后台表结构
|
||||||
|
- [x] `操作日志` 后台用户操作记录
|
||||||
|
- [x] `登录日志` 后台系统用户的登录记录
|
||||||
|
- [x] `代码生成` 生成 API 端的 CURD 操作
|
||||||
|
- [x] `敏感词` 支持敏感词配置
|
||||||
|
- [x] `附件管理` 可管理上传的文件
|
||||||
|
- [x] `定时任务` 可管理定时任务,而不依赖于 Crontab
|
||||||
|
- [x] `短信平台` 短信云管理,支持 阿里大于,腾讯云,Ucloud,Submail
|
||||||
|
- [x] `云上传` 支持云上传,七牛,OSS,腾讯
|
||||||
|
- [ ] `微信管理`
|
||||||
|
|
||||||
|
## 项目地址
|
||||||
|
- [github 地址](https://github.com/yanwenwu/catch-admin)
|
||||||
|
- [gitee 地址](https://gitee.com/jaguarjack/catchAdmin)
|
||||||
|
- [前端 Vue 项目地址](https://github.com/yanwenwu/catch-admin-vue)
|
||||||
|
- [文档地址](https://github.com/catch-admin/document)[个人精力实在有限,希望可以小伙伴们可以一起维护文档]
|
||||||
|
## 预览
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucNXq.md.png"></td>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucm6I.md.png"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucZpd.md.png"></td>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wuce1A.md.png"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucnXt.md.png"></td>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucKnP.md.png"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wuc3tg.md.png"></td>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucM0f.md.png"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucQ78.md.png"></td>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wuc1AS.md.png"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wuc8hQ.md.png"></td>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucY1s.md.png"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wucJpj.md.png"></td>
|
||||||
|
<td><img src="https://s1.ax1x.com/2020/09/07/wuctcn.md.png"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
## 环境要求
|
||||||
|
- php7.1+ (需以下扩展)
|
||||||
|
- [x] mbstring
|
||||||
|
- [x] json
|
||||||
|
- [x] openssl
|
||||||
|
- [x] xml
|
||||||
|
- [x] pdo
|
||||||
|
- nginx
|
||||||
|
- mysql
|
||||||
|
|
||||||
|
### 如何安装
|
||||||
|
> 安装之前请确保已安装 Composer
|
||||||
|
|
||||||
|
#### 下载项目
|
||||||
|
- 通过 Git 下载(推荐)
|
||||||
|
```shell
|
||||||
|
git clone https://gitee.com/jaguarjack/catchAdmin && cd catchAdmin
|
||||||
|
|
||||||
|
curl -sS https://install.phpcomposer.com/installer | php
|
||||||
|
|
||||||
|
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
||||||
|
|
||||||
|
composer install --ignore-platform-reqs
|
||||||
```
|
```
|
||||||
server {
|
- composer 安装
|
||||||
listen 端口;
|
```shell
|
||||||
server_name 域名;
|
composer create-project jaguarjack/catchadmin:dev-master
|
||||||
|
|
||||||
access_log logs/wenwen.access.log;
|
|
||||||
|
|
||||||
root 项目目录/public;
|
|
||||||
index index.php index.html index.htm;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
index index.php index.html index.htm;
|
|
||||||
|
|
||||||
if (!-e $request_filename) {
|
|
||||||
rewrite ^(.*)$ /index.php?s=$1 last;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#error_page 404 /404.html;
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
root html;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ \.php$ {
|
|
||||||
root 项目目录/public;
|
|
||||||
fastcgi_pass phpfastcgi;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
include fastcgi_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ^~ /data {
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
```
|
||||||
# Problem
|
|
||||||
> SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at'
|
|
||||||
|
|
||||||
设置 sql_mode;
|
#### 安装
|
||||||
|
下载完成之后通过命令来进行安装, 一键安装 🚀
|
||||||
|
```shell
|
||||||
|
php think catch:install
|
||||||
```
|
```
|
||||||
show variables like 'sql_mode' ;
|
|
||||||
```
|
|
||||||
> remove 'NO_ZERO_IN_DATE,NO_ZERO_DATE'
|
|
||||||
```
|
|
||||||
SET GLOBAL sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
|
|
||||||
```
|
|
||||||
# Test Address
|
|
||||||
<a href="http://tp5.whwww.net" target="__BLANK">测试地址</a>
|
|
||||||
- 账号:admin
|
|
||||||
- 密码: 123456
|
|
||||||
|
|
||||||
# Talking
|
## 体验地址
|
||||||
- 可以提 ISSUE,请按照 issue 模板提问
|
|
||||||
- 欢迎进入 Q 群,可以及时反馈一些问题。
|
|
||||||
- 
|
|
||||||
|
|
||||||
仅供学习
|
[体验地址](http://vue.catchadmin.com)
|
||||||
|
- 账号: catch@admin.com
|
||||||
|
- 密码: catchadmin
|
||||||
|
|
||||||
|
[catchadmin 文档地址](http://doc.catchadmin.com)
|
||||||
|
|
||||||
|
### 系列文章
|
||||||
|
如果是刚开始使用 thinkphp6, 以下文章可能会对你有些许帮助,文章基于 RC3 版本。整体架构是不变的。
|
||||||
|
- [Tp6 启动分析](https://www.kancloud.cn/akasishikelu/thinkphp6/1129385)
|
||||||
|
- [Tp6 Request 解析](https://www.kancloud.cn/akasishikelu/thinkphp6/1134496)
|
||||||
|
- [TP6 应用初始化](https://www.kancloud.cn/akasishikelu/thinkphp6/1130427)
|
||||||
|
- [Tp6 中间件分析](https://www.kancloud.cn/akasishikelu/thinkphp6/1136616)
|
||||||
|
- [Tp6 请求流程](https://www.kancloud.cn/akasishikelu/thinkphp6/1136608)
|
||||||
|
|
||||||
|
### Donate
|
||||||
|
如果你觉得项目对你有帮助,可以请作者喝杯咖啡☕️!鼓励下
|
||||||
|
<!--<img src="https://cdn.learnku.com/uploads/images/202008/11/18206/e6qAAM8Bod.jpg!large">-->
|
||||||
|
|
||||||
|
### Talking
|
||||||
|
- [论坛讨论](http://bbs.catchadmin.com)
|
||||||
|
- 可以提 `ISSUE`,请按照 `issue` 模板提问
|
||||||
|
- 加入 Q 群 `302266230` 暗号 `catchadmin`。
|
||||||
|
|
||||||
|
### Thanks
|
||||||
|
> 排名部分先后
|
||||||
|
|
||||||
|
- [top-think/think](https://github.com/top-think/think)
|
||||||
|
- [element-admin](https://panjiachen.gitee.io/vue-element-admin-site/zh/)
|
||||||
|
- [thans/tp-jwt-auth](https://packagist.org/packages/thans/tp-jwt-auth)
|
||||||
|
- [jaguarjack/think-filesystem-cloud](https://github.com/yanwenwu/think-filesystem-cloud)
|
||||||
|
- [overtrue/wechat](https://github.com/overtrue/wechat)
|
||||||
|
- [jaguarjack/migration-generator](https://github.com/yanwenwu/migration-generator)
|
||||||
|
- [phpoffice/phpspreadsheet](https://github.com/PHPOffice/PhpSpreadsheet)
|
||||||
|
93
app/BaseController.php
Normal file
93
app/BaseController.php
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制器基础类
|
||||||
|
*/
|
||||||
|
abstract class BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Request实例
|
||||||
|
* @var \think\Request
|
||||||
|
*/
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用实例
|
||||||
|
* @var \think\App
|
||||||
|
*/
|
||||||
|
protected $app;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否批量验证
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $batchValidate = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制器中间件
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $middleware = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造方法
|
||||||
|
* @access public
|
||||||
|
* @param App $app 应用对象
|
||||||
|
*/
|
||||||
|
public function __construct(App $app)
|
||||||
|
{
|
||||||
|
$this->app = $app;
|
||||||
|
$this->request = $this->app->request;
|
||||||
|
|
||||||
|
// 控制器初始化
|
||||||
|
$this->initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
protected function initialize()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证数据
|
||||||
|
* @access protected
|
||||||
|
* @param array $data 数据
|
||||||
|
* @param string|array $validate 验证器名或者验证规则数组
|
||||||
|
* @param array $message 提示信息
|
||||||
|
* @param bool $batch 是否批量验证
|
||||||
|
* @return array|string|true
|
||||||
|
* @throws ValidateException
|
||||||
|
*/
|
||||||
|
protected function validate(array $data, $validate, array $message = [], bool $batch = false)
|
||||||
|
{
|
||||||
|
if (is_array($validate)) {
|
||||||
|
$v = new Validate();
|
||||||
|
$v->rule($validate);
|
||||||
|
} else {
|
||||||
|
if (strpos($validate, '.')) {
|
||||||
|
// 支持场景
|
||||||
|
list($validate, $scene) = explode('.', $validate);
|
||||||
|
}
|
||||||
|
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
|
||||||
|
$v = new $class();
|
||||||
|
if (!empty($scene)) {
|
||||||
|
$v->scene($scene);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$v->message($message);
|
||||||
|
|
||||||
|
// 是否批量验证
|
||||||
|
if ($batch || $this->batchValidate) {
|
||||||
|
$v->batch(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $v->failException(true)->check($data);
|
||||||
|
}
|
||||||
|
}
|
57
app/ExceptionHandle.php
Normal file
57
app/ExceptionHandle.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
namespace app;
|
||||||
|
|
||||||
|
use think\db\exception\DataNotFoundException;
|
||||||
|
use think\db\exception\ModelNotFoundException;
|
||||||
|
use think\exception\Handle;
|
||||||
|
use think\exception\HttpException;
|
||||||
|
use think\exception\HttpResponseException;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\Response;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用异常处理类
|
||||||
|
*/
|
||||||
|
class ExceptionHandle extends Handle
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 不需要记录信息(日志)的异常类列表
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $ignoreReport = [
|
||||||
|
HttpException::class,
|
||||||
|
HttpResponseException::class,
|
||||||
|
ModelNotFoundException::class,
|
||||||
|
DataNotFoundException::class,
|
||||||
|
ValidateException::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录异常信息(包括日志或者其它方式记录)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param Throwable $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function report(Throwable $exception): void
|
||||||
|
{
|
||||||
|
// 使用内置的方式记录异常日志
|
||||||
|
parent::report($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an exception into an HTTP response.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param \think\Request $request
|
||||||
|
* @param Throwable $e
|
||||||
|
* @return Response
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function render($request, Throwable $e): Response
|
||||||
|
{
|
||||||
|
// 其他错误交给系统处理
|
||||||
|
return parent::render($request, $e);
|
||||||
|
}
|
||||||
|
}
|
53
app/Request.php
Normal file
53
app/Request.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
namespace app;
|
||||||
|
|
||||||
|
// 应用请求对象类
|
||||||
|
|
||||||
|
use catchAdmin\permissions\model\Users;
|
||||||
|
use catcher\CatchAuth;
|
||||||
|
use catcher\Code;
|
||||||
|
use catcher\exceptions\FailedException;
|
||||||
|
use catcher\exceptions\LoginFailedException;
|
||||||
|
use thans\jwt\exception\TokenBlacklistException;
|
||||||
|
use thans\jwt\exception\TokenExpiredException;
|
||||||
|
use thans\jwt\exception\TokenInvalidException;
|
||||||
|
|
||||||
|
class Request extends \think\Request
|
||||||
|
{
|
||||||
|
protected $auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* login user
|
||||||
|
*
|
||||||
|
* @time 2020年01月09日
|
||||||
|
* @param null $guard
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function user($guard = null)
|
||||||
|
{
|
||||||
|
if (!$this->auth) {
|
||||||
|
$this->auth = new CatchAuth;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$user = $this->auth->guard($guard ? : config('catch.auth.default.guard'))->user();
|
||||||
|
|
||||||
|
if ($user->status == Users::DISABLE) {
|
||||||
|
throw new LoginFailedException('该用户已被禁用', Code::USER_FORBIDDEN);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
if ($e instanceof TokenExpiredException) {
|
||||||
|
throw new FailedException('token 过期', Code::LOGIN_EXPIRED);
|
||||||
|
}
|
||||||
|
if ($e instanceof TokenBlacklistException) {
|
||||||
|
throw new FailedException('token 被加入黑名单', Code::LOGIN_BLACKLIST);
|
||||||
|
}
|
||||||
|
if ($e instanceof TokenInvalidException) {
|
||||||
|
throw new FailedException('token 不合法', Code::LOST_LOGIN);
|
||||||
|
}
|
||||||
|
throw new FailedException('认证失败: '. $e->getMessage(), $e->getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
}
|
2
app/common.php
Normal file
2
app/common.php
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
// 应用公共文件
|
18
app/event.php
Normal file
18
app/event.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
// 事件定义文件
|
||||||
|
|
||||||
|
return [
|
||||||
|
'bind' => [],
|
||||||
|
|
||||||
|
'listen' => [
|
||||||
|
'AppInit' => [],
|
||||||
|
'HttpRun' => [],
|
||||||
|
'HttpEnd' => [],
|
||||||
|
'LogLevel' => [],
|
||||||
|
'LogWrite' => [],
|
||||||
|
'RouteLoaded' => [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'subscribe' => [
|
||||||
|
],
|
||||||
|
];
|
11
app/middleware.php
Normal file
11
app/middleware.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
// 全局中间件定义文件
|
||||||
|
return [
|
||||||
|
// 全局请求缓存
|
||||||
|
// \think\middleware\CheckRequestCache::class,
|
||||||
|
// 多语言加载
|
||||||
|
// \think\middleware\LoadLangPack::class,
|
||||||
|
// Session初始化
|
||||||
|
// \think\middleware\SessionInit::class
|
||||||
|
\think\middleware\AllowCrossDomain::class,
|
||||||
|
];
|
9
app/provider.php
Normal file
9
app/provider.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
use app\ExceptionHandle;
|
||||||
|
use app\Request;
|
||||||
|
|
||||||
|
// 容器Provider定义文件
|
||||||
|
return [
|
||||||
|
'think\Request' => Request::class,
|
||||||
|
'think\exception\Handle' => ExceptionHandle::class,
|
||||||
|
];
|
4
app/service.php
Normal file
4
app/service.php
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
\catcher\CatchAdminService::class,
|
||||||
|
];
|
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\controller;
|
|
||||||
|
|
||||||
use think\Controller;
|
|
||||||
use app\traits\ControllerTrait;
|
|
||||||
|
|
||||||
abstract class Base extends Controller
|
|
||||||
{
|
|
||||||
use ControllerTrait;
|
|
||||||
|
|
||||||
protected $limit = 10;
|
|
||||||
|
|
||||||
protected $page = 1;
|
|
||||||
|
|
||||||
protected $middleware = ['checkLogin', 'auth', 'logRecord'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 过滤参数
|
|
||||||
*
|
|
||||||
* @time at 2018年11月15日
|
|
||||||
* @param $params
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function checkParams(&$params)
|
|
||||||
{
|
|
||||||
$this->limit = $params['limit'] ?? $this->limit;
|
|
||||||
$this->page = $params['page'] ?? $this->page;
|
|
||||||
|
|
||||||
foreach ($params as $key => $param) {
|
|
||||||
if (!$param || $key == 'limit' || $key == 'page') {
|
|
||||||
unset($params[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->start = $this->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Table ID Start
|
|
||||||
*
|
|
||||||
* @time at 2018年11月16日
|
|
||||||
* @return float|int
|
|
||||||
*/
|
|
||||||
protected function start()
|
|
||||||
{
|
|
||||||
return (int)$this->limit * ((int)$this->page - 1) + 1;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2019/1/18
|
|
||||||
* Time: 10:36
|
|
||||||
*/
|
|
||||||
namespace app\admin\controller;
|
|
||||||
|
|
||||||
use think\Db;
|
|
||||||
|
|
||||||
class Database extends Base
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 数据字典列表
|
|
||||||
*
|
|
||||||
* @time at 2019年01月18日
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
$this->tables = Db::query('SHOW TABLE STATUS');
|
|
||||||
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优化表
|
|
||||||
*
|
|
||||||
* @time at 2019年01月18日
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function optimize()
|
|
||||||
{
|
|
||||||
$table = $this->request->post('table');
|
|
||||||
|
|
||||||
if (!$table) {
|
|
||||||
$this->error('参数错误, 未指定表');
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::query(sprintf('optimize table %s', $table)) ? $this->success('优化成功') : $this->error('优化失败');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @time at 2019年01月18日
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function view()
|
|
||||||
{
|
|
||||||
$table = $this->request->param('table');
|
|
||||||
|
|
||||||
if (!$table) {
|
|
||||||
$this->error('参数错误', '未指定表');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->table = Db::query('show full columns from ' . $table);
|
|
||||||
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\controller;
|
|
||||||
|
|
||||||
use think\permissions\facade\Permissions;
|
|
||||||
use think\permissions\facade\Roles;
|
|
||||||
use app\service\MenuService;
|
|
||||||
|
|
||||||
class Index extends Base
|
|
||||||
{
|
|
||||||
protected $middleware = [ 'checkLogin' ];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 首页
|
|
||||||
*
|
|
||||||
* @time at 2018年11月15日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function index(MenuService $menuService)
|
|
||||||
{
|
|
||||||
$loginUser = $this->getLoginUser();
|
|
||||||
$userHasRoles = $loginUser->getRoles();
|
|
||||||
$permissionIds = [];
|
|
||||||
$userHasRoles->each(function ($role, $key) use (&$permissionIds) {
|
|
||||||
$permissionIds = array_merge($permissionIds, Roles::getRoleBy($role->id)->getPermissions(false));
|
|
||||||
});
|
|
||||||
$permissions = Permissions::whereIn('id', $permissionIds)->where('is_show', 1)->select();
|
|
||||||
$this->permissions = $menuService->tree($permissions);
|
|
||||||
$this->loginUser = $loginUser;
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* main
|
|
||||||
*
|
|
||||||
* @time at 2018年11月16日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function main()
|
|
||||||
{
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2019/1/18
|
|
||||||
* Time: 9:01
|
|
||||||
*/
|
|
||||||
namespace app\admin\controller;
|
|
||||||
|
|
||||||
use app\model\LogRecordModel;
|
|
||||||
|
|
||||||
class Log extends Base
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 日志列表
|
|
||||||
*
|
|
||||||
* @time at 2019年01月18日
|
|
||||||
* @param LogRecordModel $logRecordModel
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function index(LogRecordModel $logRecordModel)
|
|
||||||
{
|
|
||||||
$params = $this->request->param();
|
|
||||||
$this->checkParams($params);
|
|
||||||
|
|
||||||
$this->list = $logRecordModel->getAll($params, $this->limit);
|
|
||||||
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\admin\controller;
|
|
||||||
|
|
||||||
use app\traits\Auth;
|
|
||||||
use think\Controller;
|
|
||||||
|
|
||||||
class Login extends Controller
|
|
||||||
{
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
protected $redirect = '/index';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Login Page
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function login()
|
|
||||||
{
|
|
||||||
// 登录逻辑
|
|
||||||
if ($this->request->isPost()) {
|
|
||||||
$this->authLogin($this->request);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->fetch('/index/login');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登出
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\think\response\Redirect
|
|
||||||
*/
|
|
||||||
public function logout()
|
|
||||||
{
|
|
||||||
$this->authLogout();
|
|
||||||
|
|
||||||
return redirect(url('login'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证规则
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function rule()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
$this->name() => 'require',
|
|
||||||
'password|密码' => 'require',
|
|
||||||
'captcha|验证码' => 'require|captcha'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\admin\controller;
|
|
||||||
|
|
||||||
use think\Collection;
|
|
||||||
use think\permissions\facade\Permissions;
|
|
||||||
use app\admin\request\PermissionRequest;
|
|
||||||
use app\service\MenuService;
|
|
||||||
|
|
||||||
class Permission extends Base
|
|
||||||
{
|
|
||||||
public function index(MenuService $menuService)
|
|
||||||
{
|
|
||||||
$this->permissions = new Collection($menuService->sort(Permissions::select()));
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function create(PermissionRequest $request, MenuService $menuService)
|
|
||||||
{
|
|
||||||
if ($request->isPost()) {
|
|
||||||
$data = $request->post();
|
|
||||||
Permissions::store($data) ? $this->success('添加成功', url('permission/index')) : $this->error('添加失败');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->permissions = $menuService->sort(Permissions::select());
|
|
||||||
$this->permissionId = $this->request->param('id') ?? 0;
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edit Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function edit(PermissionRequest $request, MenuService $menuService)
|
|
||||||
{
|
|
||||||
if ($request->isPost()) {
|
|
||||||
$data = $request->post();
|
|
||||||
Permissions::updateBy($data['id'], $data) !== false ? $this->success('编辑成功', url('permission/index')) : $this->error('');
|
|
||||||
}
|
|
||||||
$permissionId = $this->request->param('id');
|
|
||||||
if (!$permissionId) {
|
|
||||||
$this->error('不存在的数据');
|
|
||||||
}
|
|
||||||
$this->permissions = $menuService->sort(Permissions::select());
|
|
||||||
$this->permission = Permissions::getPermissionBy($permissionId);
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function delete()
|
|
||||||
{
|
|
||||||
$permissionId = $this->request->post('id');
|
|
||||||
if (!$permissionId) {
|
|
||||||
$this->error('不存在数据');
|
|
||||||
}
|
|
||||||
if (Permissions::where('pid', $permissionId)->find()) {
|
|
||||||
$this->error('请先删除子菜单');
|
|
||||||
}
|
|
||||||
// 删除权限关联的角色信息
|
|
||||||
Permissions::detachRole($permissionId);
|
|
||||||
if (Permissions::deleteBy($permissionId)) {
|
|
||||||
$this->success('删除成功', url('permission/index'));
|
|
||||||
}
|
|
||||||
$this->error('删除失败');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,115 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\admin\controller;
|
|
||||||
|
|
||||||
use think\permissions\facade\Roles;
|
|
||||||
use app\admin\request\RoleRequest;
|
|
||||||
use think\permissions\facade\Permissions;
|
|
||||||
use app\service\MenuService;
|
|
||||||
|
|
||||||
class Role extends Base
|
|
||||||
{
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
$this->roles = Roles::paginate(10);
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function create(RoleRequest $request)
|
|
||||||
{
|
|
||||||
if ($request->isPost()) {
|
|
||||||
Roles::store($request->post()) ? $this->success('创建成功', url('role/index')) : $this->error('创建失败');
|
|
||||||
}
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edit Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function edit(RoleRequest $request)
|
|
||||||
{
|
|
||||||
if ($this->request->isPost()) {
|
|
||||||
Roles::updateBy($request->post('id'), $request->post()) !== false ? $this->success('编辑成功', url('role/index')) : $this->error('编辑失败');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->role = Roles::getRoleBy($this->request->param('id'));
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function delete()
|
|
||||||
{
|
|
||||||
$roleId = $this->request->post('id');
|
|
||||||
if (!$roleId) {
|
|
||||||
$this->error('角色信息不存在');
|
|
||||||
}
|
|
||||||
// 删除角色相关的用户
|
|
||||||
Roles::detachUsers($roleId);
|
|
||||||
// 删除角色相关的权限
|
|
||||||
Roles::detachPermissions($roleId);
|
|
||||||
if (Roles::deleteBy($roleId)) {
|
|
||||||
$this->success('删除成功', url('role/index'));
|
|
||||||
}
|
|
||||||
$this->error('删除失败');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色权限
|
|
||||||
*
|
|
||||||
* @time at 2018年09月21日
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function getPermissionsOfRole(MenuService $menuService)
|
|
||||||
{
|
|
||||||
$field = ['name', 'id', 'pid'];
|
|
||||||
$roleId = $this->request->post('role_id');
|
|
||||||
$permissions = Permissions::field($field)->all();
|
|
||||||
$roleHasPermissions = Roles::getRoleBy($roleId)->getPermissions(false);
|
|
||||||
$permissions = $permissions->each(function ($item, $key) use ($roleHasPermissions){
|
|
||||||
if (!$item->pid) {
|
|
||||||
$item->open = true;
|
|
||||||
}
|
|
||||||
$item->checked = in_array($item->id, $roleHasPermissions) ? true : false;
|
|
||||||
return $item;
|
|
||||||
});
|
|
||||||
|
|
||||||
header('content-Type: application/json');
|
|
||||||
exit(json_encode($menuService->sort($permissions)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分配权限
|
|
||||||
*
|
|
||||||
* @time at 2018年11月15日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function givePermissions()
|
|
||||||
{
|
|
||||||
if ($this->request->isPost()) {
|
|
||||||
$postData = $this->request->post();
|
|
||||||
$roleId = $postData['role_id'];
|
|
||||||
if (!isset($postData['permissions'])) {
|
|
||||||
Roles::detachPermissions($roleId);
|
|
||||||
$this->success('分配成功', url('role/index'));
|
|
||||||
}
|
|
||||||
$permissions = $postData['permissions'];
|
|
||||||
Roles::detachPermissions($roleId);
|
|
||||||
Roles::attachPermissions($roleId, $permissions) ? $this->success('分配成功', url('role/index')) : $this->error('分配失败');
|
|
||||||
}
|
|
||||||
$this->role_id = $this->request->param('id');
|
|
||||||
return $this->fetch('role/givePermissions');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,126 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\controller;
|
|
||||||
|
|
||||||
use app\model\UserModel;
|
|
||||||
use app\admin\request\UserRequest;
|
|
||||||
use think\permissions\facade\Roles;
|
|
||||||
|
|
||||||
class User extends Base
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* User List
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function index(UserModel $userModel)
|
|
||||||
{
|
|
||||||
$params = $this->request->param();
|
|
||||||
$this->checkParams($params);
|
|
||||||
$this->users = $userModel->getList($params, $this->limit);
|
|
||||||
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function create(UserModel $userModel, UserRequest $request)
|
|
||||||
{
|
|
||||||
if ($request->isPost()) {
|
|
||||||
$data = $request->post();
|
|
||||||
$data['password'] = generatePassword($data['password']);
|
|
||||||
|
|
||||||
if ($userId = $userModel->store($data)) {
|
|
||||||
// 分配角色
|
|
||||||
$this->giveRoles($userModel, $userId, $data);
|
|
||||||
$this->success('添加成功', url('user/index'));
|
|
||||||
}
|
|
||||||
$this->error('添加失败');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->roles = Roles::all();
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edit Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
public function edit(UserModel $userModel, UserRequest $request)
|
|
||||||
{
|
|
||||||
if ($request->isPost()) {
|
|
||||||
$data = $request->post();
|
|
||||||
$this->giveRoles($userModel, $data['id'], $data);
|
|
||||||
$data['password'] = generatePassword($data['password']);
|
|
||||||
$userModel->updateBy($data['id'], $data) ? $this->success('修改成功', url('user/index')) : $this->error('修改失败');
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = $this->request->param('id');
|
|
||||||
if (!$id) {
|
|
||||||
$this->error('数据不存在');
|
|
||||||
}
|
|
||||||
$user = $userModel->findBy($id);
|
|
||||||
$userHasRoles = $user->getRoles(false);
|
|
||||||
$roles = Roles::all()->each(function($item, $key) use ($userHasRoles){
|
|
||||||
$item->checked = in_array($item->id, $userHasRoles) ? true : false;
|
|
||||||
return $item;
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->user = $user;
|
|
||||||
$this->roles = $roles;
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function delete(UserModel $userModel)
|
|
||||||
{
|
|
||||||
$id = $this->request->post('id');
|
|
||||||
|
|
||||||
if (!$id) {
|
|
||||||
$this->error('不存在的数据');
|
|
||||||
}
|
|
||||||
// 删除用户相关的角色
|
|
||||||
$userModel->detachRoles($id);
|
|
||||||
if ($userModel->deleteBy($id)) {
|
|
||||||
$this->success('删除成功', url('user/index'));
|
|
||||||
}
|
|
||||||
$this->error('删除失败');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分配角色
|
|
||||||
*
|
|
||||||
* @time at 2018年11月15日
|
|
||||||
* @param \app\model\UserModel $userModel
|
|
||||||
* @param int $userId
|
|
||||||
* @param $data
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function giveRoles(UserModel $userModel, int $userId, &$data)
|
|
||||||
{
|
|
||||||
if (isset($data['roles'])) {
|
|
||||||
$rolesIds = $data['roles'];
|
|
||||||
if (!is_array($rolesIds)) {
|
|
||||||
$rolesIds = [$rolesIds];
|
|
||||||
}
|
|
||||||
$userModel->detachRoles($userId);
|
|
||||||
$userModel->attachRoles($userId, $rolesIds);
|
|
||||||
unset($data['roles']);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$userModel->detachRoles($userId);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* UserRequest.php
|
|
||||||
* Created by wuyanwen <wuyanwen1992@gmail.com>
|
|
||||||
* Date: 2018/11/29 0029 21:56
|
|
||||||
*/
|
|
||||||
namespace app\admin\request;
|
|
||||||
|
|
||||||
use think\exception\HttpResponseException;
|
|
||||||
use think\Request;
|
|
||||||
|
|
||||||
abstract class FormRequest extends Request
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FormRequest constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
if ($this->withServer($_SERVER)->isAjax(true) && $err = $this->validate()) {
|
|
||||||
throw new HttpResponseException(json([
|
|
||||||
'code' => 0,
|
|
||||||
'msg' => $err,
|
|
||||||
'wait' => 3,
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* UserRequest.php
|
|
||||||
* Created by wuyanwen <wuyanwen1992@gmail.com>
|
|
||||||
* Date: 2018/11/29 0029 21:56
|
|
||||||
*/
|
|
||||||
namespace app\admin\request;
|
|
||||||
|
|
||||||
use app\admin\validates\PermissionValidate;
|
|
||||||
|
|
||||||
class PermissionRequest extends FormRequest
|
|
||||||
{
|
|
||||||
public function validate()
|
|
||||||
{
|
|
||||||
return (new PermissionValidate())->getErrors($this->post());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* UserRequest.php
|
|
||||||
* Created by wuyanwen <wuyanwen1992@gmail.com>
|
|
||||||
* Date: 2018/11/29 0029 21:56
|
|
||||||
*/
|
|
||||||
namespace app\admin\request;
|
|
||||||
|
|
||||||
use app\admin\validates\RoleValidate;
|
|
||||||
|
|
||||||
class RoleRequest extends FormRequest
|
|
||||||
{
|
|
||||||
public function validate()
|
|
||||||
{
|
|
||||||
return (new RoleValidate())->getErrors($this->post());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* UserRequest.php
|
|
||||||
* Created by wuyanwen <wuyanwen1992@gmail.com>
|
|
||||||
* Date: 2018/11/29 0029 21:56
|
|
||||||
*/
|
|
||||||
namespace app\admin\request;
|
|
||||||
|
|
||||||
use app\admin\validates\UserValidate;
|
|
||||||
|
|
||||||
class UserRequest extends FormRequest
|
|
||||||
{
|
|
||||||
public function validate()
|
|
||||||
{
|
|
||||||
return (new UserValidate())->getErrors($this->post());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/12 0012
|
|
||||||
* Time: 下午 16:31
|
|
||||||
*/
|
|
||||||
namespace app\admin\validates;;
|
|
||||||
|
|
||||||
use think\Validate;
|
|
||||||
|
|
||||||
abstract class AbstractValidate extends Validate
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Validate Errors
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @param $data
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getErrors($data)
|
|
||||||
{
|
|
||||||
$this->check($data);
|
|
||||||
|
|
||||||
return $this->getError();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function __set($name, $value)
|
|
||||||
{
|
|
||||||
// TODO: Implement __set() method.
|
|
||||||
$this->rule[$name] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/14 0014
|
|
||||||
* Time: 下午 18:21
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace app\admin\validates;
|
|
||||||
|
|
||||||
class PermissionValidate extends AbstractValidate
|
|
||||||
{
|
|
||||||
protected $rule = [
|
|
||||||
'name|菜单名称' => 'require|min:2|max:10|chs|unique:permissions',
|
|
||||||
'module|模块名称' => 'require|min:2|max:10|alpha',
|
|
||||||
'controller|控制器名称' => 'require|min:2|max:50|alpha',
|
|
||||||
'action|方法名称' => 'require|min:2|max:50|alpha',
|
|
||||||
];
|
|
||||||
}
|
|
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/14 0014
|
|
||||||
* Time: 下午 17:42
|
|
||||||
*/
|
|
||||||
namespace app\admin\validates;
|
|
||||||
|
|
||||||
class RoleValidate extends AbstractValidate
|
|
||||||
{
|
|
||||||
protected $rule = [
|
|
||||||
'name|角色名' => 'require|min:3|max:15|chs|unique:roles',
|
|
||||||
];
|
|
||||||
}
|
|
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/12 0012
|
|
||||||
* Time: 下午 16:38
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace app\admin\validates;
|
|
||||||
|
|
||||||
class UserValidate extends AbstractValidate
|
|
||||||
{
|
|
||||||
protected $rule = [
|
|
||||||
'name|用户名' => 'require|min:3|max:15|alphaNum|unique:users',
|
|
||||||
'email|邮箱' => 'email|unique:users',
|
|
||||||
'password|密码' => 'confirm|min:6|max:20|alphaDash',
|
|
||||||
];
|
|
||||||
}
|
|
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/13 0013
|
|
||||||
* Time: 上午 9:33
|
|
||||||
*/
|
|
||||||
namespace app\behavior;
|
|
||||||
|
|
||||||
class LoginRecord
|
|
||||||
{
|
|
||||||
public function run($params)
|
|
||||||
{
|
|
||||||
$user = $params['user'];
|
|
||||||
## 登录记录
|
|
||||||
$user->login_at = date('Y-m-d h:i:s', time());
|
|
||||||
$user->login_ip = request()->ip();
|
|
||||||
$user->save();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,154 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\command;
|
|
||||||
|
|
||||||
use think\console\Command;
|
|
||||||
use think\console\Input;
|
|
||||||
use think\console\input\Argument;
|
|
||||||
use think\console\input\Option;
|
|
||||||
use think\console\Output;
|
|
||||||
use think\DB;
|
|
||||||
|
|
||||||
class MakeCurd extends Command
|
|
||||||
{
|
|
||||||
protected $appPath;
|
|
||||||
protected $stubPath;
|
|
||||||
// view 默认的三个模板
|
|
||||||
protected $views = ['index', 'create', 'edit'];
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->appPath = env('app_path');
|
|
||||||
$this->stubPath = $this->appPath . 'command' . DIRECTORY_SEPARATOR . 'stub' .DIRECTORY_SEPARATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this->setName('make:curd')
|
|
||||||
->addArgument('controller', Argument::OPTIONAL, "controller name")
|
|
||||||
->addArgument('model', Argument::OPTIONAL, "model name")
|
|
||||||
->addOption('module', null, Option::VALUE_REQUIRED, 'module name')
|
|
||||||
->setDescription('Create curd option controller model --module?');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(Input $input, Output $output)
|
|
||||||
{
|
|
||||||
// 首先获取默认模块
|
|
||||||
$moduleName = config('app.default_module');
|
|
||||||
$controllerName = trim($input->getArgument('controller'));
|
|
||||||
if (!$controllerName) {
|
|
||||||
$output->writeln('Controller Name Must Set');exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$modelName = trim($input->getArgument('model'));
|
|
||||||
|
|
||||||
if (!$modelName) {
|
|
||||||
$output->writeln('Model Name Must Set');exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($input->hasOption('module')) {
|
|
||||||
$moduleName = $input->getOption('module');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->makeController($controllerName, $moduleName);
|
|
||||||
$output->writeln($controllerName . ' controller create success');
|
|
||||||
$this->makeModel($modelName, $moduleName);
|
|
||||||
$output->writeln($modelName . ' model create success');
|
|
||||||
$this->makeView($controllerName, $moduleName);
|
|
||||||
$output->writeln($controllerName . ' view create success');
|
|
||||||
}
|
|
||||||
// 创建控制器文件
|
|
||||||
protected function makeController($controllerName, $moduleName)
|
|
||||||
{
|
|
||||||
$controllerStub = $this->stubPath . 'Controller.stub';
|
|
||||||
$controllerStub = str_replace(['$controller', '$module'], [ucfirst($controllerName), strtolower($moduleName)], file_get_contents($controllerStub));
|
|
||||||
$controllerPath = $this->appPath . $moduleName . DIRECTORY_SEPARATOR . 'controller' . DIRECTORY_SEPARATOR;
|
|
||||||
if (!is_dir($controllerPath)) {
|
|
||||||
mkdir($controllerPath, 0777, true);
|
|
||||||
}
|
|
||||||
return file_put_contents( $controllerPath . $controllerName . '.php', $controllerStub);
|
|
||||||
}
|
|
||||||
// 创建模型文件
|
|
||||||
public function makeModel($modelName, $moduleName)
|
|
||||||
{
|
|
||||||
$modelPath = $this->appPath . DIRECTORY_SEPARATOR . 'model';
|
|
||||||
if (!is_dir($modelPath)) {
|
|
||||||
mkdir($modelPath, 0777, true);
|
|
||||||
}
|
|
||||||
$modelContents = "<?php \r\n \r\n";
|
|
||||||
$modelContents .= "namespace app\model;\r\n \r\n";
|
|
||||||
$modelContents .= 'class $modelModel extends BaseModel';
|
|
||||||
$modelContents .= "\r\n { \r\n \t";
|
|
||||||
$modelContents .= 'protected $table = \'' . config('database.prefix') . '$_table\';';
|
|
||||||
$modelContents = $this->writeField($modelContents, $modelName);
|
|
||||||
$modelContents = str_replace('$model', ucfirst($modelName), $modelContents);
|
|
||||||
$modelContents = str_replace('$_table', $this->unCamelize($modelName), $modelContents);
|
|
||||||
$modelContents .= "\r\n }";
|
|
||||||
|
|
||||||
return file_put_contents($modelPath . DIRECTORY_SEPARATOR . $modelName . 'Model.php', $modelContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function writeField($modelContents, $modelName)
|
|
||||||
{
|
|
||||||
$info = Db::query('show full columns from ' . config('database.prefix') . $this->unCamelize($modelName));
|
|
||||||
foreach ($info as $value) {
|
|
||||||
$modelContents .= sprintf("\r\n %s \t protected $%s = '%s'; \r\n", $this->fieldComment($value['Comment']), $this->combine($value['Field']), $value['Field']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $modelContents;
|
|
||||||
}
|
|
||||||
// 创建模板
|
|
||||||
public function makeView($controllerName, $moduleName)
|
|
||||||
{
|
|
||||||
$viewStub = $this->stubPath . 'View.stub';
|
|
||||||
$viewPath = (config('template.view_base') ? config('template.view_base') . $moduleName . DIRECTORY_SEPARATOR : env('app_path') . $moduleName . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR) . strtolower($controllerName);
|
|
||||||
if (!is_dir($viewPath)) {
|
|
||||||
mkdir($viewPath, 0777, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$stub = explode('||', file_get_contents($viewStub));
|
|
||||||
|
|
||||||
foreach ($this->views as $view) {
|
|
||||||
if ($view == 'index') {
|
|
||||||
file_put_contents($viewPath . DIRECTORY_SEPARATOR . $view .'.html', trim($stub[0]));
|
|
||||||
} else {
|
|
||||||
file_put_contents($viewPath . DIRECTORY_SEPARATOR . $view .'.html', trim($stub[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符注释
|
|
||||||
*
|
|
||||||
* @time at 2019年01月08日
|
|
||||||
* @param $comment
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function fieldComment($comment)
|
|
||||||
{
|
|
||||||
return sprintf("\t /** \r\n \t * @var string \r\n \t * @desc %s \r\n \t */ \r\n", $comment);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 驼峰分割
|
|
||||||
*
|
|
||||||
* @time at 2019年01月02日
|
|
||||||
* @param string $camelCaps
|
|
||||||
* @param string $separator
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function unCamelize(string $string, string $separator = '_')
|
|
||||||
{
|
|
||||||
return strtolower(preg_replace('/(?<=[a-z])([A-Z])/', $separator . '$1', $string));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function combine(string $string)
|
|
||||||
{
|
|
||||||
$s = explode('_', $string);
|
|
||||||
array_walk($s, function (&$value, $key) {
|
|
||||||
if ($key) {
|
|
||||||
$value = ucfirst($value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return implode($s, '');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\$module\controller;
|
|
||||||
|
|
||||||
class $controller extends Base
|
|
||||||
{
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
public function edit()
|
|
||||||
{
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
public function delete()
|
|
||||||
{}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
{extend name="public:base" /}
|
|
||||||
{block name="menu"}{/block}
|
|
||||||
{block name="search"}{/block}
|
|
||||||
{block name="button-create"}{/block}
|
|
||||||
{block name="table-head"}{/block}
|
|
||||||
{block name="table-body"}{/block}
|
|
||||||
{block name="paginate"}{/block}
|
|
||||||
||
|
|
||||||
{extend name="public:form" /}
|
|
||||||
{block name="menu"}{/block}
|
|
||||||
{block name='action'}{/block}
|
|
||||||
{block name="form"}{/block}
|
|
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Author: 流年 <liu21st@gmail.com>
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
|
|
||||||
// 应用公共文件
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 钩子行为
|
|
||||||
*/
|
|
||||||
if (!function_exists('hook')) {
|
|
||||||
function hook($behavior, $params) {
|
|
||||||
\think\facade\Hook::exec($behavior, $params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑按钮
|
|
||||||
*/
|
|
||||||
if (!function_exists('editButton')) {
|
|
||||||
function editButton(string $url, string $name = '编辑') {
|
|
||||||
return sprintf('<a href="%s"><button class="btn btn-info btn-xs edit" type="button"><i class="fa fa-paste"></i> %s</button></a>', $url, $name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加按钮
|
|
||||||
*/
|
|
||||||
if (!function_exists('createButton')) {
|
|
||||||
function createButton(string $url, string $name, $isBig = true) {
|
|
||||||
return $isBig ? sprintf('<a href="%s"> <button type="button" class="btn btn-w-m btn-primary"><i class="fa fa-check-square-o"></i> %s</button></a>', $url, $name) :
|
|
||||||
sprintf('<a href="%s"> <button type="button" class="btn btn-xs btn-primary"><i class="fa fa-check-square-o"></i> %s</button></a>', $url, $name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除按钮
|
|
||||||
*/
|
|
||||||
if (!function_exists('deleteButton')) {
|
|
||||||
function deleteButton(string $url, int $id, string $name="删除") {
|
|
||||||
return sprintf('<button class="btn btn-danger btn-xs delete" data-url="%s" data=%d type="button"><i class="fa fa-trash"></i> %s</button>', $url, $id, $name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索按钮
|
|
||||||
*/
|
|
||||||
if (!function_exists('searchButton')) {
|
|
||||||
function searchButton(string $name="搜索") {
|
|
||||||
return sprintf('<button class="btn btn-white" type="submit"><i class="fa fa-search"></i> %s</button>', $name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成密码
|
|
||||||
*/
|
|
||||||
if (!function_exists('generatePassword')) {
|
|
||||||
function generatePassword(string $password, int $algo = PASSWORD_DEFAULT) {
|
|
||||||
return password_hash($password, $algo);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/16 0016
|
|
||||||
* Time: 下午 14:51
|
|
||||||
*/
|
|
||||||
namespace app\component\upload;
|
|
||||||
|
|
||||||
use think\exception\ThrowableError;
|
|
||||||
use think\facade\Request;
|
|
||||||
use app\exceptions\UploadException;
|
|
||||||
|
|
||||||
class LocalUpload implements UploadInterface
|
|
||||||
{
|
|
||||||
protected $name = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Upload File
|
|
||||||
*
|
|
||||||
* @time at 2018年11月16日
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function file(){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Upload Image
|
|
||||||
*
|
|
||||||
* @time at 2018年11月16日
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function image()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$file = Request::file($this->name);
|
|
||||||
if (!$this->name) {
|
|
||||||
throw new UploadException('请选择上传的图片');
|
|
||||||
}
|
|
||||||
$info = $file->validate(config('admin.image'))->move(config('admin.local_upload_path'));
|
|
||||||
if (!$info) {
|
|
||||||
throw new UploadException($file->getError());
|
|
||||||
}
|
|
||||||
return $info->getSaveName();
|
|
||||||
} catch (UploadException $exception) {
|
|
||||||
return $exception->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set Image Name
|
|
||||||
*
|
|
||||||
* @time at 2018年11月16日
|
|
||||||
* @param $name
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function name($name)
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/16 0016
|
|
||||||
* Time: 下午 14:50
|
|
||||||
*/
|
|
||||||
namespace app\component\upload;
|
|
||||||
|
|
||||||
interface UploadInterface
|
|
||||||
{
|
|
||||||
public function file();
|
|
||||||
|
|
||||||
public function image();
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/13 0013
|
|
||||||
* Time: 上午 10:49
|
|
||||||
*/
|
|
||||||
namespace app\exceptions;
|
|
||||||
|
|
||||||
class AppException extends \Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/16 0016
|
|
||||||
* Time: 下午 15:03
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace app\exceptions;
|
|
||||||
|
|
||||||
class UploadException extends \Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\http\middleware;
|
|
||||||
|
|
||||||
class CheckLogin
|
|
||||||
{
|
|
||||||
public function handle($request, \Closure $next)
|
|
||||||
{
|
|
||||||
if (!$request->session('user')) {
|
|
||||||
return redirect(url('login'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\http\middleware;
|
|
||||||
|
|
||||||
use app\service\LogService;
|
|
||||||
|
|
||||||
class LogRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
public function handle($request, \Closure $next)
|
|
||||||
{
|
|
||||||
(new LogService())->record($request);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/12 0012
|
|
||||||
* Time: 上午 11:05
|
|
||||||
*/
|
|
||||||
namespace app\model;
|
|
||||||
|
|
||||||
use think\Model;
|
|
||||||
|
|
||||||
class BaseModel extends Model
|
|
||||||
{
|
|
||||||
const LIMIT = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @param array $data
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function store(array $data)
|
|
||||||
{
|
|
||||||
return $this->save($data) ? $this->id : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find By ID
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @param int $id
|
|
||||||
* @return array|false|\PDOStatement|string|\think\Model
|
|
||||||
*/
|
|
||||||
public function findBy(int $id)
|
|
||||||
{
|
|
||||||
return $this->where('id', $id)->find();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update By ID && Data
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @param int $id
|
|
||||||
* @param array $data
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function updateBy(int $id, array $data)
|
|
||||||
{
|
|
||||||
return $this->save($data, ['id' => $id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete By ID
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @param int $id
|
|
||||||
* @return bool|null
|
|
||||||
*/
|
|
||||||
public function deleteBy(int $id)
|
|
||||||
{
|
|
||||||
return $this->where('id', $id)->delete();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2019/1/17
|
|
||||||
* Time: 18:09
|
|
||||||
*/
|
|
||||||
namespace app\model;
|
|
||||||
|
|
||||||
use http\Env\Request;
|
|
||||||
|
|
||||||
class LogRecordModel extends BaseModel
|
|
||||||
{
|
|
||||||
protected $name = 'option_log';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志列表
|
|
||||||
*
|
|
||||||
* @time at 2019年01月18日
|
|
||||||
* @param array $params
|
|
||||||
* @param int $limit
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getAll(array $params, $limit = self::LIMIT)
|
|
||||||
{
|
|
||||||
if (!count($params)) {
|
|
||||||
return $this->order('created_at', 'desc')->paginate($limit, false, ['query' => request()->param()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($params['name'])) {
|
|
||||||
$list = $this->whereLike('user_name', '%'.$params['name'].'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $list->order('created_at', 'desc')->paginate($limit, false, ['query' => request()->param()]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\model;
|
|
||||||
|
|
||||||
use think\permissions\traits\hasRoles;
|
|
||||||
|
|
||||||
class UserModel extends BaseModel
|
|
||||||
{
|
|
||||||
use hasRoles;
|
|
||||||
|
|
||||||
protected $name = 'users';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Users List
|
|
||||||
*
|
|
||||||
* @time at 2018年11月14日
|
|
||||||
* @param $params
|
|
||||||
* @return \think\Paginator
|
|
||||||
*/
|
|
||||||
public function getList($params, $limit = self::LIMIT)
|
|
||||||
{
|
|
||||||
if (!count($params)) {
|
|
||||||
return $this->paginate($limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (isset($params['name'])) {
|
|
||||||
$user = $this->whereLike('name', '%'.$params['name'].'%');
|
|
||||||
}
|
|
||||||
if (isset($params['email'])) {
|
|
||||||
$user = $this->whereLike('email', '%'.$params['email'].'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $user->paginate($limit, false, ['query' => request()->param()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2019/1/17
|
|
||||||
* Time: 18:06
|
|
||||||
*/
|
|
||||||
namespace app\service;
|
|
||||||
|
|
||||||
use think\permissions\facade\Permissions;
|
|
||||||
use think\Request;
|
|
||||||
use app\model\LogRecordModel;
|
|
||||||
|
|
||||||
class LogService
|
|
||||||
{
|
|
||||||
|
|
||||||
public function record(Request $request)
|
|
||||||
{
|
|
||||||
$module = $request->module();
|
|
||||||
$controller = $request->controller();
|
|
||||||
$action = $request->action();
|
|
||||||
$user = $request->session('user');
|
|
||||||
$permission = Permissions::getPermissionByModuleAnd($module, $controller, $action);
|
|
||||||
|
|
||||||
(new LogRecordModel())->store([
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'user_name' => $user->name,
|
|
||||||
'module' => $module,
|
|
||||||
'controller' => $controller,
|
|
||||||
'action' => $action,
|
|
||||||
'option' => $permission->name,
|
|
||||||
'method' => $request->method(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/13 0013
|
|
||||||
* Time: 上午 10:50
|
|
||||||
*/
|
|
||||||
namespace app\service;
|
|
||||||
|
|
||||||
use think\Collection;
|
|
||||||
|
|
||||||
class MenuService
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树形结构
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @param $menu
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function tree(Collection $menus, int $pid = 0)
|
|
||||||
{
|
|
||||||
$collection = new Collection();
|
|
||||||
|
|
||||||
$menus->each(function ($item, $key) use ($pid, $menus, $collection){
|
|
||||||
if ($item->pid == $pid) {
|
|
||||||
$collection[$key] = $item;
|
|
||||||
$collection[$key][$item->id] = $this->tree($menus, $item->id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return $collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 顺序结构
|
|
||||||
*
|
|
||||||
* @time at 2018年11月13日
|
|
||||||
* @param $menu
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function sort(Collection $menus, int $pid = 0, int $level = 0)
|
|
||||||
{
|
|
||||||
$collection = [];
|
|
||||||
foreach ($menus as $menu) {
|
|
||||||
if ($menu->pid == $pid) {
|
|
||||||
$menu->level = $level;
|
|
||||||
$collection[] = $menu;
|
|
||||||
$collection = array_merge($collection, $this->sort($menus, $menu->id, $level+1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $collection;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/16 0016
|
|
||||||
* Time: 上午 11:01
|
|
||||||
*/
|
|
||||||
namespace app\service;
|
|
||||||
|
|
||||||
use think\paginator\driver\Bootstrap;
|
|
||||||
|
|
||||||
class PaginateService extends Bootstrap
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 渲染分页html
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
if ($this->hasPages()) {
|
|
||||||
if ($this->simple) {
|
|
||||||
return sprintf(
|
|
||||||
'<ul class="pager">%s %s</ul>',
|
|
||||||
$this->getPreviousButton(),
|
|
||||||
$this->getNextButton()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return sprintf(
|
|
||||||
'<ul class="pagination">%s %s %s %s</ul>',
|
|
||||||
$this->getPreviousButton(),
|
|
||||||
$this->getLinks(),
|
|
||||||
$this->getNextButton(),
|
|
||||||
$this->changeLimit()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function changeLimit()
|
|
||||||
{
|
|
||||||
$query = $this->options['query'];
|
|
||||||
$html = ' <li class="project_page">';
|
|
||||||
|
|
||||||
$pageLimit = config('admin.page_limit');
|
|
||||||
$html .= '<select class="page-form-control limit" name="limit">';
|
|
||||||
foreach ($pageLimit as $limit) {
|
|
||||||
if (isset($query['limit']) && $query['limit'] == $limit) {
|
|
||||||
$html .= sprintf('<option value="%s" selected>%s条/页</option>', $limit, $limit);
|
|
||||||
} else {
|
|
||||||
$html .= sprintf('<option value="%s">%s条/页</option>', $limit, $limit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$html .= '</select></li> <li>';
|
|
||||||
|
|
||||||
$html .= sprintf('<input name="page" class="page-form-control-input" value="%s"> 页 ', $query['page'] ?? 1);
|
|
||||||
$html .='</li>';
|
|
||||||
|
|
||||||
$html .= '<li><button class="btn btn-primary btn-xs hrefTo"><i class="fa fa-location-arrow"></i> 跳转</button></li>';
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Author: liu21st <liu21st@gmail.com>
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
|
|
||||||
// 应用行为扩展定义文件
|
|
||||||
return [
|
|
||||||
// 应用初始化
|
|
||||||
'app_init' => [],
|
|
||||||
// 应用开始
|
|
||||||
'app_begin' => [],
|
|
||||||
// 模块初始化
|
|
||||||
'module_init' => [],
|
|
||||||
// 操作开始执行
|
|
||||||
'action_begin' => [],
|
|
||||||
// 视图内容过滤
|
|
||||||
'view_filter' => [],
|
|
||||||
// 日志写入
|
|
||||||
'log_write' => [],
|
|
||||||
// 应用结束
|
|
||||||
'app_end' => [],
|
|
||||||
];
|
|
@@ -1,183 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\traits;
|
|
||||||
|
|
||||||
use think\Request;
|
|
||||||
use think\Validate;
|
|
||||||
use think\facade\Session;
|
|
||||||
use think\facade\Cookie;
|
|
||||||
use app\model\UserModel as User;
|
|
||||||
use app\behavior\LoginRecord;
|
|
||||||
|
|
||||||
trait Auth
|
|
||||||
{
|
|
||||||
protected $loginUserKey = 'user';
|
|
||||||
|
|
||||||
public function authLogin(Request $request)
|
|
||||||
{
|
|
||||||
$err = $this->validateLogin($request);
|
|
||||||
if ($err) {
|
|
||||||
$this->error($err);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 正常输入登录
|
|
||||||
$userModel = new User();
|
|
||||||
$field = explode('|', $this->name());
|
|
||||||
$user = $userModel::where($field[0], $request->param($field[0]))->find();
|
|
||||||
|
|
||||||
if (!$user) {
|
|
||||||
$this->error('登录失败');
|
|
||||||
}
|
|
||||||
if (password_verify($request->param('password'), $user->password)) {
|
|
||||||
Session::set($this->loginUserKey, $user);
|
|
||||||
# 记住登录
|
|
||||||
$this->LoginRemember($user, $request);
|
|
||||||
# 登录记录
|
|
||||||
hook(LoginRecord::class, ['user' => $user]);
|
|
||||||
$this->success('登录成功', url($this->redirect));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->error('登录失败');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 记住登录
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function rememberLogin()
|
|
||||||
{
|
|
||||||
// 如果记住登录
|
|
||||||
if (!Session::get($this->loginUserKey) && Cookie::get('remember_token') && $this->checkRememberToken()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退出
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function authLogout()
|
|
||||||
{
|
|
||||||
$user = Session::get($this->loginUserKey);
|
|
||||||
$this->deleteToken($user);
|
|
||||||
Session::delete($this->loginUserKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function deleteToken($user)
|
|
||||||
{
|
|
||||||
if ($user->remember_token) {
|
|
||||||
$user->remember_token = null;
|
|
||||||
$user->save();
|
|
||||||
Cookie::delete('remember_token');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 验证
|
|
||||||
* @param Request $request
|
|
||||||
* @return array|bool
|
|
||||||
*/
|
|
||||||
protected function validateLogin(Request $request)
|
|
||||||
{
|
|
||||||
$validate = new Validate($this->rule());
|
|
||||||
if (!$validate->check($request->except(['remember']))) {
|
|
||||||
return $validate->getError();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录验证规则
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function rule()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
$this->name() => 'require|token|alphaDash',
|
|
||||||
'password|密码' => 'require|alphaDash',
|
|
||||||
'captcha|验证码' => 'require|captcha'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置登录字段
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function name()
|
|
||||||
{
|
|
||||||
return 'name|用户名';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remember Token
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function generateRememberToken()
|
|
||||||
{
|
|
||||||
return uniqid(md5(time()+rand(10000, 99999)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加密 TOKEN
|
|
||||||
*
|
|
||||||
* @param $user_id
|
|
||||||
* @param $remember_token
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function secretRememberToken($user_id, $remember_token)
|
|
||||||
{
|
|
||||||
list($key, $method, $iv) = $this->getSecret();
|
|
||||||
return base64_encode(openssl_encrypt($user_id . ':' . $remember_token, $method, $key, OPENSSL_RAW_DATA, $iv));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查remember token 是否正确
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function checkRememberToken()
|
|
||||||
{
|
|
||||||
if (!Cookie::has('remember_token')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$rememberToken = Cookie::get('remember_token');
|
|
||||||
// 解密
|
|
||||||
list($key, $method, $iv) = $this->getSecret();
|
|
||||||
list($userID) = explode(':', (openssl_decrypt(base64_decode($rememberToken), $method, $key, OPENSSL_RAW_DATA, $iv)));
|
|
||||||
// 校验
|
|
||||||
$user = (new User())->findBy($userID);
|
|
||||||
Session::set('user', $user);
|
|
||||||
return $user->remember_token == $rememberToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加密
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function getSecret()
|
|
||||||
{
|
|
||||||
return ['admin_auth', 'AES-128-CBC', '1234567890123412'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 记住
|
|
||||||
*
|
|
||||||
* @param $user
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function LoginRemember($user, Request $request)
|
|
||||||
{
|
|
||||||
if ($request->has('remember')) {
|
|
||||||
$rememberToken = $this->secretRememberToken($user->id, $this->generateRememberToken());
|
|
||||||
$user->remember_token = $rememberToken;
|
|
||||||
Cookie::forever('remember_token', $rememberToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
|
||||||
* User: Administrator
|
|
||||||
* Date: 2018/11/12 0012
|
|
||||||
* Time: 上午 11:43
|
|
||||||
*/
|
|
||||||
namespace app\traits;
|
|
||||||
|
|
||||||
use think\facade\Session;
|
|
||||||
use app\component\upload\UploadInterface;
|
|
||||||
use app\component\upload\LocalUpload;
|
|
||||||
|
|
||||||
trait ControllerTrait
|
|
||||||
{
|
|
||||||
protected $vars = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 绑定实现
|
|
||||||
*
|
|
||||||
* @time at 2018年11月16日
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function initialize()
|
|
||||||
{
|
|
||||||
bind(UploadInterface::class, LocalUpload::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否登录
|
|
||||||
*
|
|
||||||
* @time at 2018年11月15日
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function isLogin()
|
|
||||||
{
|
|
||||||
return $this->getLoginUser() ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取登录用户
|
|
||||||
*
|
|
||||||
* @time at 2018年11月15日
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
protected function getLoginUser()
|
|
||||||
{
|
|
||||||
return Session::get('user');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* fetch 重写
|
|
||||||
*
|
|
||||||
* @time at 2018年11月15日
|
|
||||||
* @param string $template
|
|
||||||
* @param array $vars
|
|
||||||
* @param array $config
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
protected function fetch($template = '', $vars = [], $config = [])
|
|
||||||
{
|
|
||||||
$vars = array_merge($this->vars, $vars);
|
|
||||||
|
|
||||||
return $this->view->fetch($template, $vars, $config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Template Vars
|
|
||||||
*
|
|
||||||
* @time at 2018年11月12日
|
|
||||||
* @param $name
|
|
||||||
* @param $value
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __set($name, $value)
|
|
||||||
{
|
|
||||||
// TODO: Implement __set() method.
|
|
||||||
$this->vars[$name] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
26
build.php
26
build.php
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Author: liu21st <liu21st@gmail.com>
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
|
|
||||||
return [
|
|
||||||
// 生成应用公共文件
|
|
||||||
'__file__' => ['common.php'],
|
|
||||||
|
|
||||||
// 定义demo模块的自动生成 (按照实际定义的文件名生成)
|
|
||||||
'demo' => [
|
|
||||||
'__file__' => ['common.php'],
|
|
||||||
'__dir__' => ['behavior', 'controller', 'model', 'view'],
|
|
||||||
'controller' => ['Index', 'Test', 'UserType'],
|
|
||||||
'model' => ['User', 'UserType'],
|
|
||||||
'view' => ['index/index'],
|
|
||||||
],
|
|
||||||
|
|
||||||
// 其他更多的模块定义
|
|
||||||
];
|
|
BIN
catch/.DS_Store
vendored
Normal file
BIN
catch/.DS_Store
vendored
Normal file
Binary file not shown.
53
catch/domain/DomainService.php
Normal file
53
catch/domain/DomainService.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\domain;
|
||||||
|
|
||||||
|
use catchAdmin\domain\support\contract\DomainActionInterface;
|
||||||
|
use catchAdmin\domain\support\contract\DomainRecordInterface;
|
||||||
|
use catchAdmin\domain\support\driver\aliyun\Domain;
|
||||||
|
use catchAdmin\domain\support\driver\aliyun\DomainRecord;
|
||||||
|
use catcher\ModuleService;
|
||||||
|
|
||||||
|
class DomainService extends ModuleService
|
||||||
|
{
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
parent::register(); // TODO: Change the autogenerated stub
|
||||||
|
|
||||||
|
$this->registerInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadConfig()
|
||||||
|
{
|
||||||
|
return require __DIR__ . DIRECTORY_SEPARATOR . 'config.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function loadRouteFrom()
|
||||||
|
{
|
||||||
|
// TODO: Implement loadRouteFrom() method.
|
||||||
|
return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function registerInstance()
|
||||||
|
{
|
||||||
|
$default = config('catch.domains.default');
|
||||||
|
|
||||||
|
$this->app->instance(DomainActionInterface::class, $this->app->make(__NAMESPACE__ . '\\support\\driver\\' . $default . '\Domain'));
|
||||||
|
$this->app->instance(DomainRecordInterface::class, $this->app->make(__NAMESPACE__ . '\\support\\driver\\' . $default . '\DomainRecord'));
|
||||||
|
}
|
||||||
|
}
|
46
catch/domain/README.md
Normal file
46
catch/domain/README.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
## 域名管理
|
||||||
|
- 阿里云(主支持)
|
||||||
|
- 腾讯云(需要做适配)
|
||||||
|
|
||||||
|
#### 配置
|
||||||
|
首先在 .env 文件设置
|
||||||
|
```
|
||||||
|
[ALIYUN]
|
||||||
|
ACCESS_KEY=
|
||||||
|
ACCESS_SECRET=
|
||||||
|
|
||||||
|
[QCLOUD]
|
||||||
|
ACCESS_KEY=
|
||||||
|
ACCESS_SECRET=
|
||||||
|
```
|
||||||
|
也可以在 config.php 文件配置
|
||||||
|
```
|
||||||
|
'domains' => [
|
||||||
|
// 默认阿里云
|
||||||
|
'default' => 'aliyun',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云配置
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
'aliyun' => [
|
||||||
|
'api_domain' => 'http://alidns.aliyuncs.com',
|
||||||
|
|
||||||
|
'access_key' => Env::get('aliyun.access_key', ''),
|
||||||
|
|
||||||
|
'access_secret' => Env::get('aliyun.access_secret', ''),
|
||||||
|
],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 腾讯云配置
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
'qcloud' => [
|
||||||
|
'api_domain' => 'cns.api.qcloud.com',
|
||||||
|
|
||||||
|
'access_key' => Env::get('qcloud.access_key', ''),
|
||||||
|
|
||||||
|
'access_secret' => Env::get('qcloud.access_secret', ''),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
```
|
43
catch/domain/config.php
Normal file
43
catch/domain/config.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'domains' => [
|
||||||
|
// 默认阿里云
|
||||||
|
'default' => 'aliyun',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云配置
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
'aliyun' => [
|
||||||
|
'api_domain' => 'http://alidns.aliyuncs.com',
|
||||||
|
|
||||||
|
'access_key' => Env::get('aliyun.access_key', ''),
|
||||||
|
|
||||||
|
'access_secret' => Env::get('aliyun.access_secret', ''),
|
||||||
|
],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 腾讯云配置
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
'qcloud' => [
|
||||||
|
'api_domain' => 'cns.api.qcloud.com',
|
||||||
|
|
||||||
|
'access_key' => Env::get('qcloud.access_key', ''),
|
||||||
|
|
||||||
|
'access_secret' => Env::get('qcloud.access_secret', ''),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
50
catch/domain/controller/Domain.php
Normal file
50
catch/domain/controller/Domain.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\controller;
|
||||||
|
|
||||||
|
use catchAdmin\domain\support\contract\DomainActionInterface;
|
||||||
|
use catcher\base\CatchRequest as Request;
|
||||||
|
use catcher\CatchResponse;
|
||||||
|
use catcher\base\CatchController;
|
||||||
|
|
||||||
|
class Domain extends CatchController
|
||||||
|
{
|
||||||
|
protected $domain;
|
||||||
|
|
||||||
|
public function __construct(DomainActionInterface $domain)
|
||||||
|
{
|
||||||
|
$this->domain = $domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*
|
||||||
|
* @time 2020/09/11 18:14
|
||||||
|
* @param Request $request
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \think\Response
|
||||||
|
{
|
||||||
|
return CatchResponse::paginate($this->domain->getList($request->param()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取
|
||||||
|
*
|
||||||
|
* @time 2020/09/11 18:14
|
||||||
|
* @param $name
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function read($name)
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->domain->read(str_replace('-', '.', $name)));
|
||||||
|
}
|
||||||
|
}
|
99
catch/domain/controller/DomainRecord.php
Normal file
99
catch/domain/controller/DomainRecord.php
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\controller;
|
||||||
|
|
||||||
|
use catchAdmin\domain\support\contract\DomainRecordInterface;
|
||||||
|
use catcher\base\CatchRequest as Request;
|
||||||
|
use catcher\CatchResponse;
|
||||||
|
use catcher\base\CatchController;
|
||||||
|
|
||||||
|
class DomainRecord extends CatchController
|
||||||
|
{
|
||||||
|
protected $domainRecord;
|
||||||
|
|
||||||
|
public function __construct(DomainRecordInterface $record)
|
||||||
|
{
|
||||||
|
$this->domainRecord = $record;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*
|
||||||
|
* @time 2020/09/11 18:14
|
||||||
|
* @param Request $request
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \think\Response
|
||||||
|
{
|
||||||
|
return CatchResponse::paginate($this->domainRecord->getList($request->param()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*
|
||||||
|
* @time 2020/09/11 18:14
|
||||||
|
* @param Request Request
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function save(Request $request): \think\Response
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->domainRecord->store($request->post()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取
|
||||||
|
*
|
||||||
|
* @time 2020/09/11 18:14
|
||||||
|
* @param $name
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function read($name): \think\Response
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->domainRecord->read($name));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*
|
||||||
|
* @time 2020/09/11 18:14
|
||||||
|
* @param Request $request
|
||||||
|
* @param $id
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function update($id, Request $request): \think\Response
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->domainRecord->update($id, $request->post()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @time 2020/09/11 18:14
|
||||||
|
* @param $id
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function delete($id): \think\Response
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->domainRecord->delete($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置状态
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
* @param $status
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function enable($id, $status)
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->domainRecord->enable($id, $status));
|
||||||
|
}
|
||||||
|
}
|
97
catch/domain/database/seeds/DomainMenusSeed.php
Normal file
97
catch/domain/database/seeds/DomainMenusSeed.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
use think\migration\Seeder;
|
||||||
|
|
||||||
|
class DomainMenusSeed extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run Method.
|
||||||
|
*
|
||||||
|
* Write your database seeder using this method.
|
||||||
|
*
|
||||||
|
* More information on writing seeders is available here:
|
||||||
|
* http://docs.phinx.org/en/latest/seeding.html
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
\catcher\Utils::importTreeData($this->getPermissions(), 'permissions', 'parent_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPermissions()
|
||||||
|
{
|
||||||
|
return array (
|
||||||
|
0 =>
|
||||||
|
array (
|
||||||
|
'id' => 72,
|
||||||
|
'permission_name' => '域名管理',
|
||||||
|
'parent_id' => 0,
|
||||||
|
'level' => '',
|
||||||
|
'route' => '/domain',
|
||||||
|
'icon' => 'el-icon-stopwatch',
|
||||||
|
'module' => 'domain',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'domain',
|
||||||
|
'component' => 'layout',
|
||||||
|
'redirect' => '/domain/index',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1601105834,
|
||||||
|
'updated_at' => 1601105834,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
1 =>
|
||||||
|
array (
|
||||||
|
'id' => 73,
|
||||||
|
'permission_name' => '域名设置',
|
||||||
|
'parent_id' => 72,
|
||||||
|
'level' => '72',
|
||||||
|
'route' => '/domain/index',
|
||||||
|
'icon' => 'el-icon-setting',
|
||||||
|
'module' => 'domain',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'domain',
|
||||||
|
'component' => 'domain',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 8,
|
||||||
|
'created_at' => 1601105879,
|
||||||
|
'updated_at' => 1601112604,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
2 =>
|
||||||
|
array (
|
||||||
|
'id' => 84,
|
||||||
|
'permission_name' => '域名记录',
|
||||||
|
'parent_id' => 72,
|
||||||
|
'level' => '72',
|
||||||
|
'route' => '/domain/record/:domain',
|
||||||
|
'icon' => 'el-icon-document',
|
||||||
|
'module' => 'domain',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'domainRecord',
|
||||||
|
'component' => 'domainRecord',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'hidden' => 2,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1601112569,
|
||||||
|
'updated_at' => 1601112606,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
15
catch/domain/module.json
Normal file
15
catch/domain/module.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "域名管理",
|
||||||
|
"alias": "domain",
|
||||||
|
"description": "域名,阿里云,腾讯云",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"keywords": [],
|
||||||
|
"order": 0,
|
||||||
|
"services": [
|
||||||
|
"\\catchAdmin\\domain\\DomainService"
|
||||||
|
],
|
||||||
|
"aliases": {},
|
||||||
|
"files": [],
|
||||||
|
"requires": [],
|
||||||
|
"enable": false
|
||||||
|
}
|
23
catch/domain/route.php
Normal file
23
catch/domain/route.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// you should use `$router`
|
||||||
|
use catchAdmin\domain\controller\DomainRecord;
|
||||||
|
|
||||||
|
$router->group(function () use ($router){
|
||||||
|
// 域名管理
|
||||||
|
$router->get('domain', '\catchAdmin\domain\controller\Domain@index');
|
||||||
|
$router->get('domain/<name>', '\catchAdmin\domain\controller\Domain@read');
|
||||||
|
// 域名解析管理
|
||||||
|
$router->resource('record/domain', DomainRecord::class);
|
||||||
|
$router->put('record/domain/<id>/<status>', '\catchAdmin\domain\controller\DomainRecord@enable');
|
||||||
|
})->middleware('auth');
|
||||||
|
|
70
catch/domain/support/CommonParams.php
Normal file
70
catch/domain/support/CommonParams.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support;
|
||||||
|
|
||||||
|
use catchAdmin\domain\support\signature\Aliyun;
|
||||||
|
use catchAdmin\domain\support\signature\Qcloud;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公共参数
|
||||||
|
*
|
||||||
|
* Class CommonParams
|
||||||
|
* @package catchAdmin\domain\support
|
||||||
|
*/
|
||||||
|
class CommonParams
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 阿里云公共参数
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param string $method
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function aliyun(array $params, $method = 'GET')
|
||||||
|
{
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
|
$params = array_merge($params, [
|
||||||
|
'Format' => 'json',
|
||||||
|
'Version' => '2015-01-09',
|
||||||
|
'AccessKeyId' => config('catch.domains.aliyun.access_key'),
|
||||||
|
'SignatureMethod' => 'HMAC-SHA1',
|
||||||
|
'Timestamp' => date('Y-m-d\TH:i:s\Z'),
|
||||||
|
'SignatureVersion' => '1.0',
|
||||||
|
'SignatureNonce' => uniqid()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$params['Signature'] = (new Aliyun($params))->signature($method);
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 腾讯云公共参数
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param string $method
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function qcloud(array $params, $method = 'GET')
|
||||||
|
{
|
||||||
|
$params = array_merge($params, [
|
||||||
|
'SecretId' => config('catch.domains.qcloud.access_key'),
|
||||||
|
'SignatureMethod' => 'HmacSHA1',
|
||||||
|
'Timestamp' => time(),
|
||||||
|
'Nonce' => uniqid()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$params['Signature'] = (new Qcloud($params))->signature($method);
|
||||||
|
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
}
|
112
catch/domain/support/Transformer.php
Normal file
112
catch/domain/support/Transformer.php
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support;
|
||||||
|
|
||||||
|
use think\Paginator;
|
||||||
|
|
||||||
|
class Transformer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 分页展示
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function aliyunDomainPaginate(array $data)
|
||||||
|
{
|
||||||
|
$list = [];
|
||||||
|
|
||||||
|
foreach ($data['Domains']['Domain'] as $item) {
|
||||||
|
$list[] = [
|
||||||
|
'name' => $item['DomainName'],
|
||||||
|
'created_at' => date('Y-m-d', $item['CreateTimestamp']/1000),
|
||||||
|
'dns_server' => $item['DnsServers']['DnsServer'],
|
||||||
|
'from' => $item['VersionName'],
|
||||||
|
'free' => $item['VersionCode'] === 'mianfei',
|
||||||
|
'record_count' => $item['RecordCount'],
|
||||||
|
'tags' => $item['Tags']['Tag'],
|
||||||
|
'id' => $item['DomainId']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Paginator::make($list, $data['PageSize'], $data['PageNumber'], $data['TotalCount']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 腾讯云域名列表
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param $page
|
||||||
|
* @param $limit
|
||||||
|
* @return Paginator|\think\paginator\driver\Bootstrap
|
||||||
|
*/
|
||||||
|
public static function qcloudDomainPaginate(array $data, $page, $limit)
|
||||||
|
{
|
||||||
|
$info = $data['data']['info'];
|
||||||
|
$domains = $data['data']['domains'];
|
||||||
|
|
||||||
|
$list = [];
|
||||||
|
|
||||||
|
foreach ($domains as $item) {
|
||||||
|
$list[] = [
|
||||||
|
'name' => $item['name'],
|
||||||
|
'created_at' => $item['created_on'],
|
||||||
|
'dns_server' => [],
|
||||||
|
'from' => 'qcloud',
|
||||||
|
'free' => $item['grade'] === 'DP_Free',
|
||||||
|
'record_count' => $item['records'],
|
||||||
|
'tags' => [],
|
||||||
|
'id' => $item['id']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Paginator::make($list, $limit, $page + 1,$info['domain_total']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云域名解析
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function aliyunDomainRecordPaginate(array $data)
|
||||||
|
{
|
||||||
|
$list = [];
|
||||||
|
|
||||||
|
foreach ($data['DomainRecords']['Record'] as &$item) {
|
||||||
|
$list[] = array_change_key_case($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Paginator::make($list, $data['PageSize'], $data['PageNumber'], $data['TotalCount']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DNS 记录
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param $page
|
||||||
|
* @param $limit
|
||||||
|
* @return Paginator|\think\paginator\driver\Bootstrap
|
||||||
|
*/
|
||||||
|
public static function qcloudDomainRecordPaginate(array $data, $page, $limit)
|
||||||
|
{
|
||||||
|
$list = [];
|
||||||
|
|
||||||
|
foreach ($data['data']['records'] as &$item) {
|
||||||
|
$item['status'] = $item['status'] === 'enabled' ? 'ENABLE' : 'DISABLE';
|
||||||
|
$item['rr'] = $item['name'];
|
||||||
|
$item['recordid'] = $item['id'];
|
||||||
|
$list[] = array_change_key_case($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Paginator::make($list, $limit, $page + 1, $data['data']['info']['record_total']);
|
||||||
|
}
|
||||||
|
}
|
22
catch/domain/support/contract/DomainActionInterface.php
Normal file
22
catch/domain/support/contract/DomainActionInterface.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\contract;
|
||||||
|
|
||||||
|
interface DomainActionInterface
|
||||||
|
{
|
||||||
|
public function getList(array $params);
|
||||||
|
|
||||||
|
public function store(array $params);
|
||||||
|
|
||||||
|
public function delete(array $params);
|
||||||
|
|
||||||
|
public function read($name);
|
||||||
|
}
|
27
catch/domain/support/contract/DomainRecordInterface.php
Normal file
27
catch/domain/support/contract/DomainRecordInterface.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\contract;
|
||||||
|
|
||||||
|
interface DomainRecordInterface
|
||||||
|
{
|
||||||
|
public function getList(array $params);
|
||||||
|
|
||||||
|
public function store(array $params);
|
||||||
|
|
||||||
|
public function delete($recordId);
|
||||||
|
|
||||||
|
public function read(array $params);
|
||||||
|
|
||||||
|
public function update($recordId, array $params);
|
||||||
|
|
||||||
|
public function enable($recordId, $status);
|
||||||
|
|
||||||
|
}
|
32
catch/domain/support/driver/ApiTrait.php
Normal file
32
catch/domain/support/driver/ApiTrait.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\driver;
|
||||||
|
|
||||||
|
use catcher\facade\Http;
|
||||||
|
use catchAdmin\domain\support\CommonParams;
|
||||||
|
|
||||||
|
trait ApiTrait
|
||||||
|
{
|
||||||
|
public function get(array $params)
|
||||||
|
{
|
||||||
|
$name = config('catch.domains.default');
|
||||||
|
|
||||||
|
$apiDomain = config('catch.domains.' . $name . '.api_domain');
|
||||||
|
|
||||||
|
if (strpos($apiDomain, 'https') === false &&
|
||||||
|
strpos($apiDomain, 'http') === false) {
|
||||||
|
$apiDomain = 'https://' . $apiDomain . '/v2/index.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
return Http::ignoreSsl()->query(CommonParams::{$name}($params))
|
||||||
|
->get($apiDomain)->json();
|
||||||
|
}
|
||||||
|
}
|
55
catch/domain/support/driver/aliyun/Domain.php
Normal file
55
catch/domain/support/driver/aliyun/Domain.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\driver\aliyun;
|
||||||
|
|
||||||
|
use catchAdmin\domain\support\contract\DomainActionInterface;
|
||||||
|
use catchAdmin\domain\support\driver\ApiTrait;
|
||||||
|
use catchAdmin\domain\support\Transformer;
|
||||||
|
|
||||||
|
class Domain implements DomainActionInterface
|
||||||
|
{
|
||||||
|
use ApiTrait;
|
||||||
|
|
||||||
|
public function getList(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement getList() method.
|
||||||
|
return Transformer::aliyunDomainPaginate($this->get([
|
||||||
|
'Action' => 'DescribeDomains',
|
||||||
|
'StarMark' => true,
|
||||||
|
'SearchModel' => 'LIKE',
|
||||||
|
'PageNumber' => $params['page'] ?? 1,
|
||||||
|
'PageSize' => $params['limit'] ?? 20,
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement add() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement delete() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'DeleteDomain',
|
||||||
|
'DomainName' => $params['name'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function read($name)
|
||||||
|
{
|
||||||
|
// TODO: Implement info() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'DescribeDomainInfo',
|
||||||
|
'DomainName' => $name
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
147
catch/domain/support/driver/aliyun/DomainRecord.php
Normal file
147
catch/domain/support/driver/aliyun/DomainRecord.php
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\driver\aliyun;
|
||||||
|
|
||||||
|
use catchAdmin\domain\support\contract\DomainRecordInterface;
|
||||||
|
use catchAdmin\domain\support\driver\ApiTrait;
|
||||||
|
use catchAdmin\domain\support\Transformer;
|
||||||
|
|
||||||
|
class DomainRecord implements DomainRecordInterface
|
||||||
|
{
|
||||||
|
use ApiTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getList(array $params)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'Action' => 'DescribeDomainRecords',
|
||||||
|
'DomainName' => $params['name'],
|
||||||
|
'PageNumber' => $params['page'] ?? 1,
|
||||||
|
'PageSize' => $params['limit'] ?? 20,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($params['rr']) {
|
||||||
|
$data['RRKeyWord'] = $params['rr'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($params['type']) {
|
||||||
|
$data['TypeKeyWord'] = $params['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($params['value']) {
|
||||||
|
$data['ValueKeyWord'] = $params['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($params['line']) {
|
||||||
|
$data['Line'] = $params['line'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($params['status']) {
|
||||||
|
$data['Status'] = $params['status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement getList() method.
|
||||||
|
return Transformer::aliyunDomainRecordPaginate($this->get($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增解析
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function store(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement add() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'AddDomainRecord',
|
||||||
|
'DomainName' => $params['name'],
|
||||||
|
'RR' => $params['rr'],
|
||||||
|
'Type' => $params['type'],
|
||||||
|
'Value' => $params['value'],
|
||||||
|
'Line' => $params['line'],
|
||||||
|
'TTL' => $params['ttl'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除解析
|
||||||
|
*
|
||||||
|
* @param $recordId
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function delete($recordId)
|
||||||
|
{
|
||||||
|
// TODO: Implement delete() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'DeleteDomainRecord',
|
||||||
|
'RecordId' => $recordId
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取解析记录
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function read(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement info() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'DescribeDomainRecord',
|
||||||
|
'RecordId' => $params['record_id'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新解析
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param $recordId
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function update($recordId, array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'UpdateDomainRecord',
|
||||||
|
'RecordId' => $recordId,
|
||||||
|
'RR' => $params['rr'],
|
||||||
|
'Type' => $params['type'],
|
||||||
|
'Value' => $params['value'],
|
||||||
|
'Line' => $params['line'],
|
||||||
|
'TTL' => $params['ttl'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置状态
|
||||||
|
*
|
||||||
|
* @param $recordId
|
||||||
|
* @param $status
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function enable($recordId, $status)
|
||||||
|
{
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'SetDomainRecordStatus',
|
||||||
|
'RecordId' => $recordId,
|
||||||
|
'Status' => ucfirst(strtolower($status))
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
56
catch/domain/support/driver/qcloud/Domain.php
Normal file
56
catch/domain/support/driver/qcloud/Domain.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\driver\qcloud;
|
||||||
|
|
||||||
|
use catchAdmin\domain\support\contract\DomainActionInterface;
|
||||||
|
use catchAdmin\domain\support\driver\ApiTrait;
|
||||||
|
use catchAdmin\domain\support\Transformer;
|
||||||
|
|
||||||
|
class Domain implements DomainActionInterface
|
||||||
|
{
|
||||||
|
use ApiTrait;
|
||||||
|
|
||||||
|
public function getList(array $params)
|
||||||
|
{
|
||||||
|
$offset = ($params['page'] ?? 1) - 1;
|
||||||
|
$length = $params['limit'] ?? 10;
|
||||||
|
|
||||||
|
// TODO: Implement getList() method.
|
||||||
|
return Transformer::qcloudDomainPaginate($this->get([
|
||||||
|
'Action' => 'DomainList',
|
||||||
|
'offset' => $offset,
|
||||||
|
'length' => $length
|
||||||
|
]), $offset, $length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement add() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement delete() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'DeleteDomain',
|
||||||
|
'DomainName' => $params['name'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function read($name)
|
||||||
|
{
|
||||||
|
// TODO: Implement info() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'DescribeDomainInfo',
|
||||||
|
'DomainName' => $name
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
125
catch/domain/support/driver/qcloud/DomainRecord.php
Normal file
125
catch/domain/support/driver/qcloud/DomainRecord.php
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\driver\qcloud;
|
||||||
|
|
||||||
|
use catchAdmin\domain\support\contract\DomainRecordInterface;
|
||||||
|
use catchAdmin\domain\support\driver\ApiTrait;
|
||||||
|
use catchAdmin\domain\support\Transformer;
|
||||||
|
|
||||||
|
class DomainRecord implements DomainRecordInterface
|
||||||
|
{
|
||||||
|
use ApiTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getList(array $params)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'Action' => 'RecordList',
|
||||||
|
'domain' => $params['name'],
|
||||||
|
'offset' => ($params['page'] ?? 1) - 1,
|
||||||
|
'length' => $params['limit'] ?? 10,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($params['rr']) {
|
||||||
|
$data['subDomain'] = $params['rr'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($params['type']) {
|
||||||
|
$data['recordType'] = $params['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement getList() method.
|
||||||
|
return Transformer::qcloudDomainRecordPaginate($this->get($data), $data['offset'], $data['length']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增解析
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function store(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement add() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'RecordCreate',
|
||||||
|
'domain' => $params['name'],
|
||||||
|
'subDomain' => $params['rr'],
|
||||||
|
'recordType' => $params['type'],
|
||||||
|
'value' => $params['value'],
|
||||||
|
'recordLine' => $params['line'],
|
||||||
|
'ttl' => $params['ttl'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除解析
|
||||||
|
*
|
||||||
|
* @param $recordId
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function delete($recordId)
|
||||||
|
{
|
||||||
|
// TODO: Implement delete() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'RecordDelete',
|
||||||
|
'recordId' => $recordId
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新解析
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param $recordId
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function update($recordId, array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'RecordModify',
|
||||||
|
'recordId' => $recordId,
|
||||||
|
'subDomain' => $params['rr'],
|
||||||
|
'recordType' => $params['type'],
|
||||||
|
'value' => $params['value'],
|
||||||
|
'recordLine' => $params['line'],
|
||||||
|
'ttl' => $params['ttl'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置状态
|
||||||
|
*
|
||||||
|
* @param $recordId
|
||||||
|
* @param $status
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function enable($recordId, $status)
|
||||||
|
{
|
||||||
|
return $this->get([
|
||||||
|
'Action' => 'RecordStatus',
|
||||||
|
'recordId' => $recordId,
|
||||||
|
'Status' => strtolower($status)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function read(array $params)
|
||||||
|
{
|
||||||
|
// TODO: Implement read() method.
|
||||||
|
}
|
||||||
|
}
|
64
catch/domain/support/signature/Aliyun.php
Normal file
64
catch/domain/support/signature/Aliyun.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\signature;
|
||||||
|
|
||||||
|
class Aliyun
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aliyun constructor.
|
||||||
|
* @param $params
|
||||||
|
*/
|
||||||
|
public function __construct(array $params)
|
||||||
|
{
|
||||||
|
$this->params = $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* encode
|
||||||
|
*
|
||||||
|
* @time 2020年09月25日
|
||||||
|
* @param $str
|
||||||
|
* @return string|string[]|null
|
||||||
|
*/
|
||||||
|
protected function percentEncode(string $str)
|
||||||
|
{
|
||||||
|
return preg_replace(['/\+/', '/\*/', '/%7E/'], ['%20', '%2A', '~'], urlencode($str));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签名
|
||||||
|
*
|
||||||
|
* @time 2020年09月25日
|
||||||
|
* @param $method
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function signature(string $method)
|
||||||
|
{
|
||||||
|
ksort($this->params);
|
||||||
|
|
||||||
|
$queryString = '';
|
||||||
|
|
||||||
|
foreach ($this->params as $key => $param) {
|
||||||
|
$queryString .= '&' . $this->percentEncode($key) . '=' . $this->percentEncode($param);
|
||||||
|
}
|
||||||
|
|
||||||
|
$signString = $method . '&' .
|
||||||
|
$this->percentEncode('/') . '&' .
|
||||||
|
$this->percentEncode(substr($queryString, 1));
|
||||||
|
|
||||||
|
return base64_encode(hash_hmac('sha1', $signString, config('catch.domains.aliyun.access_secret'). '&', true));
|
||||||
|
}
|
||||||
|
}
|
63
catch/domain/support/signature/Qcloud.php
Normal file
63
catch/domain/support/signature/Qcloud.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\domain\support\signature;
|
||||||
|
|
||||||
|
class Qcloud
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Qcloud constructor.
|
||||||
|
* @param $params
|
||||||
|
*/
|
||||||
|
public function __construct(array $params)
|
||||||
|
{
|
||||||
|
$this->params = $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* key 替换
|
||||||
|
*
|
||||||
|
* @param $key
|
||||||
|
* @return mixed|string|string[]
|
||||||
|
*/
|
||||||
|
protected function replaceKey($key)
|
||||||
|
{
|
||||||
|
return strpos($key, '_') === false ?
|
||||||
|
$key : str_replace('_', '.', $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签名
|
||||||
|
*
|
||||||
|
* @time 2020年09月25日
|
||||||
|
* @param $method
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function signature(string $method)
|
||||||
|
{
|
||||||
|
ksort($this->params);
|
||||||
|
|
||||||
|
$queryString = '';
|
||||||
|
|
||||||
|
foreach ($this->params as $key => $param) {
|
||||||
|
$queryString .= '&' . $this->replaceKey($key) . '=' . $param;
|
||||||
|
}
|
||||||
|
|
||||||
|
$signString = $method . config('catch.domains.qcloud.api_domain') . '/v2/index.php?'
|
||||||
|
. substr($queryString, 1);
|
||||||
|
|
||||||
|
return base64_encode(hash_hmac('sha1', $signString, config('catch.domains.qcloud.access_secret'), true));
|
||||||
|
}
|
||||||
|
}
|
80
catch/login/LoginLogEvent.php
Normal file
80
catch/login/LoginLogEvent.php
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
namespace catchAdmin\login;
|
||||||
|
|
||||||
|
use catchAdmin\permissions\model\Users;
|
||||||
|
use catchAdmin\system\model\LoginLog;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
class LoginLogEvent
|
||||||
|
{
|
||||||
|
public function handle($params)
|
||||||
|
{
|
||||||
|
$agent = request()->header('user-agent');
|
||||||
|
|
||||||
|
app(LoginLog::class)->storeBy([
|
||||||
|
'login_name' => $params['login_name'],
|
||||||
|
'login_ip' => request()->ip(),
|
||||||
|
'browser' => $this->getBrowser($agent),
|
||||||
|
'os' => $this->getOs($agent),
|
||||||
|
'login_at' => time(),
|
||||||
|
'status' => $params['success'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @time 2019年12月12日
|
||||||
|
* @param $agent
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getOs($agent): string
|
||||||
|
{
|
||||||
|
if (false !== stripos($agent, 'win') && preg_match('/nt 6.1/i', $agent)) {
|
||||||
|
return 'Windows 7';
|
||||||
|
}
|
||||||
|
if (false !== stripos($agent, 'win') && preg_match('/nt 6.2/i', $agent)) {
|
||||||
|
return 'Windows 8';
|
||||||
|
}
|
||||||
|
if(false !== stripos($agent, 'win') && preg_match('/nt 10.0/i', $agent)) {
|
||||||
|
return 'Windows 10';#添加win10判断
|
||||||
|
}
|
||||||
|
if (false !== stripos($agent, 'win') && preg_match('/nt 5.1/i', $agent)) {
|
||||||
|
return 'Windows XP';
|
||||||
|
}
|
||||||
|
if (false !== stripos($agent, 'linux')) {
|
||||||
|
return 'Linux';
|
||||||
|
}
|
||||||
|
if (false !== stripos($agent, 'mac')) {
|
||||||
|
return 'mac';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '未知';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @time 2019年12月12日
|
||||||
|
* @param $agent
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getBrowser($agent): string
|
||||||
|
{
|
||||||
|
if (false !== stripos($agent, "MSIE")) {
|
||||||
|
return 'MSIE';
|
||||||
|
}
|
||||||
|
if (false !== stripos($agent, "Firefox")) {
|
||||||
|
return 'Firefox';
|
||||||
|
}
|
||||||
|
if (false !== stripos($agent, "Chrome")) {
|
||||||
|
return 'Chrome';
|
||||||
|
}
|
||||||
|
if (false !== stripos($agent, "Safari")) {
|
||||||
|
return 'Safari';
|
||||||
|
}
|
||||||
|
if (false !== stripos($agent, "Opera")) {
|
||||||
|
return 'Opera';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '未知';
|
||||||
|
}
|
||||||
|
}
|
30
catch/login/LoginService.php
Normal file
30
catch/login/LoginService.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\login;
|
||||||
|
|
||||||
|
use catcher\ModuleService;
|
||||||
|
use think\Service;
|
||||||
|
|
||||||
|
class LoginService extends ModuleService
|
||||||
|
{
|
||||||
|
public function loadRouteFrom()
|
||||||
|
{
|
||||||
|
// TODO: Implement loadRouteFrom() method.
|
||||||
|
return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadEvents()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'loginLog' => [ LoginLogEvent::class ],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
127
catch/login/controller/Index.php
Normal file
127
catch/login/controller/Index.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
namespace catchAdmin\login\controller;
|
||||||
|
|
||||||
|
use catchAdmin\login\request\LoginRequest;
|
||||||
|
use catchAdmin\permissions\model\Users;
|
||||||
|
use catcher\base\CatchController;
|
||||||
|
use catcher\CatchAuth;
|
||||||
|
use catcher\CatchResponse;
|
||||||
|
use catcher\Code;
|
||||||
|
use catcher\exceptions\LoginFailedException;
|
||||||
|
use thans\jwt\facade\JWTAuth;
|
||||||
|
|
||||||
|
class Index extends CatchController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 登陆
|
||||||
|
*
|
||||||
|
* @time 2019年11月28日
|
||||||
|
* @param LoginRequest $request
|
||||||
|
* @param CatchAuth $auth
|
||||||
|
* @return bool|string
|
||||||
|
*/
|
||||||
|
public function login(LoginRequest $request, CatchAuth $auth)
|
||||||
|
{
|
||||||
|
$condition = $request->param();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$token = $auth->attempt($condition);
|
||||||
|
|
||||||
|
$user = $auth->user();
|
||||||
|
|
||||||
|
$this->afterLoginSuccess($user, $token);
|
||||||
|
// 登录事件
|
||||||
|
$this->loginEvent($user->username);
|
||||||
|
|
||||||
|
return CatchResponse::success([
|
||||||
|
'token' => $token,
|
||||||
|
], '登录成功');
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$this->detailWithLoginFailed($exception, $condition);
|
||||||
|
$code = $exception->getCode();
|
||||||
|
return CatchResponse::fail($code == Code::USER_FORBIDDEN ?
|
||||||
|
'该账户已被禁用,请联系管理员' : '登录失败,请检查邮箱和密码', Code::LOGIN_FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理登录失败
|
||||||
|
*
|
||||||
|
* @time 2020年10月26日
|
||||||
|
* @param $exception
|
||||||
|
* @param $condition
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function detailWithLoginFailed($exception, $condition)
|
||||||
|
{
|
||||||
|
$message = $exception->getMessage();
|
||||||
|
|
||||||
|
if (strpos($message, '|') !== false) {
|
||||||
|
$username = explode('|', $message)[1];
|
||||||
|
} else {
|
||||||
|
$username = $condition['email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->loginEvent($username, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录成功后
|
||||||
|
*
|
||||||
|
* @time 2020年09月09日
|
||||||
|
* @param $user
|
||||||
|
* @param $token
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function afterLoginSuccess($user, $token)
|
||||||
|
{
|
||||||
|
$user->last_login_ip = request()->ip();
|
||||||
|
$user->last_login_time = time();
|
||||||
|
if ($user->hasField('remember_token')) {
|
||||||
|
$user->remember_token = $token;
|
||||||
|
}
|
||||||
|
$user->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录事件
|
||||||
|
*
|
||||||
|
* @time 2020年09月09日
|
||||||
|
* @param $name
|
||||||
|
* @param bool $success
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function loginEvent($name, $success = true)
|
||||||
|
{
|
||||||
|
$params['login_name'] = $name;
|
||||||
|
$params['success'] = $success ? 1 : 2;
|
||||||
|
event('loginLog', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登出
|
||||||
|
*
|
||||||
|
* @time 2019年11月28日
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function logout(): \think\response\Json
|
||||||
|
{
|
||||||
|
return CatchResponse::success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* refresh token
|
||||||
|
*
|
||||||
|
* @author JaguarJack
|
||||||
|
* @email njphper@gmail.com
|
||||||
|
* @time 2020/5/18
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function refreshToken()
|
||||||
|
{
|
||||||
|
return CatchResponse::success([
|
||||||
|
'token' => JWTAuth::refresh()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
15
catch/login/module.json
Normal file
15
catch/login/module.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "登陆",
|
||||||
|
"alias": "login",
|
||||||
|
"description": "login 模块",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"keywords": [],
|
||||||
|
"order": 100,
|
||||||
|
"services": [
|
||||||
|
"\\catchAdmin\\login\\LoginService"
|
||||||
|
],
|
||||||
|
"aliases": {},
|
||||||
|
"files": [],
|
||||||
|
"requires": [],
|
||||||
|
"enable": true
|
||||||
|
}
|
26
catch/login/request/LoginRequest.php
Normal file
26
catch/login/request/LoginRequest.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
namespace catchAdmin\login\request;
|
||||||
|
|
||||||
|
use catcher\base\CatchRequest;
|
||||||
|
|
||||||
|
class LoginRequest extends CatchRequest
|
||||||
|
{
|
||||||
|
protected $needCreatorId = false;
|
||||||
|
|
||||||
|
protected function rules(): array
|
||||||
|
{
|
||||||
|
// TODO: Implement rules() method.
|
||||||
|
return [
|
||||||
|
'email|用户名' => 'email',
|
||||||
|
'password|密码' => 'require',
|
||||||
|
// 'captcha|验证码' => 'require|captcha'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function message(): array
|
||||||
|
{
|
||||||
|
// TODO: Implement message() method.
|
||||||
|
return [];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
9
catch/login/route.php
Normal file
9
catch/login/route.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
$router->group(function () use ($router){
|
||||||
|
# 登入
|
||||||
|
$router->post('login', '\catchAdmin\login\controller\Index@login');
|
||||||
|
$router->post('logout', '\catchAdmin\login\controller\Index@logout');
|
||||||
|
$router->post('refresh/token', '\catchAdmin\login\controller\Index@refreshToken');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
34
catch/monitor/MonitorService.php
Normal file
34
catch/monitor/MonitorService.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor;
|
||||||
|
|
||||||
|
use catcher\ModuleService;
|
||||||
|
|
||||||
|
class MonitorService extends ModuleService
|
||||||
|
{
|
||||||
|
protected function loadConfig()
|
||||||
|
{
|
||||||
|
return require __DIR__ . DIRECTORY_SEPARATOR . 'config.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadRouteFrom()
|
||||||
|
{
|
||||||
|
// TODO: Implement loadRouteFrom() method.
|
||||||
|
return __DIR__ . DIRECTORY_SEPARATOR . 'route.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadCommands()
|
||||||
|
{
|
||||||
|
return [__NAMESPACE__, __DIR__ . DIRECTORY_SEPARATOR . 'command'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
175
catch/monitor/command/CatchCrontabCommand.php
Normal file
175
catch/monitor/command/CatchCrontabCommand.php
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\command;
|
||||||
|
|
||||||
|
use catchAdmin\monitor\command\process\Master;
|
||||||
|
use catchAdmin\monitor\command\process\Process;
|
||||||
|
use catcher\facade\FileSystem;
|
||||||
|
use think\console\Command;
|
||||||
|
use think\console\Input;
|
||||||
|
use think\console\input\Argument;
|
||||||
|
use think\console\input\Option;
|
||||||
|
use think\console\Output;
|
||||||
|
use think\console\Table;
|
||||||
|
|
||||||
|
class CatchCrontabCommand extends Command
|
||||||
|
{
|
||||||
|
protected $pid;
|
||||||
|
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
// 指令配置
|
||||||
|
$this->setName('catch:crontab')
|
||||||
|
->addArgument('action', Argument::OPTIONAL, '[start|reload|stop|restart]', 'start')
|
||||||
|
->addOption('daemon', '-d', Option::VALUE_NONE, 'daemon mode')
|
||||||
|
->addOption('pid', '-p', Option::VALUE_REQUIRED, 'you can send signal to the process of pid')
|
||||||
|
->addOption('static', '-s', Option::VALUE_REQUIRED, 'default static process number', 1)
|
||||||
|
->addOption('dynamic', '-dy', Option::VALUE_REQUIRED, 'default dynamic process number', 10)
|
||||||
|
->addOption('interval', '-i', Option::VALUE_REQUIRED, 'interval/seconds', 60)
|
||||||
|
->setDescription('start catch crontab schedule');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(Input $input, Output $output)
|
||||||
|
{
|
||||||
|
if (!$input->hasOption('pid')) {
|
||||||
|
$this->pid = Master::getMasterPid();
|
||||||
|
} else {
|
||||||
|
$this->pid = $input->getOption('pid');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extension_loaded('pcntl') || !extension_loaded('posix')) {
|
||||||
|
$output->error('you should install extension [pcntl && posix]');
|
||||||
|
} else {
|
||||||
|
$this->{$input->getArgument('action')}();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进程启动
|
||||||
|
*
|
||||||
|
* @time 2020年09月14日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function start()
|
||||||
|
{
|
||||||
|
$worker = new Master();
|
||||||
|
|
||||||
|
$worker->staticNumber($this->input->getOption('static'))
|
||||||
|
->dynamic($this->input->getOption('dynamic'))
|
||||||
|
->interval($this->input->getOption('interval'))
|
||||||
|
->asDaemon($this->input->hasOption('daemon'))
|
||||||
|
->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止任务
|
||||||
|
*
|
||||||
|
* @time 2020年07月07日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function stop()
|
||||||
|
{
|
||||||
|
$retryTimes = 0;
|
||||||
|
|
||||||
|
if (Process::isAlive($this->pid)) {
|
||||||
|
$this->output->info('🔨 catch crontab is running.');
|
||||||
|
Process::kill($this->pid, SIGTERM);
|
||||||
|
// 睡眠 1 秒
|
||||||
|
$this->output->info('⌛️ killing catch crontab service, please waiting...');
|
||||||
|
sleep(1);
|
||||||
|
if (!Process::isAlive($this->pid)) {
|
||||||
|
$this->output->info('🎉 catch crontab stopped!');
|
||||||
|
} else {
|
||||||
|
while (true) {
|
||||||
|
Process::kill($this->pid, SIGKILL);
|
||||||
|
if (Process::isAlive($this->pid)) {
|
||||||
|
$retryTimes++;
|
||||||
|
$this->output->info('🔥 retry $retryTimes times');
|
||||||
|
usleep(500 * 1000);
|
||||||
|
if ($retryTimes >= 3) {
|
||||||
|
$this->output->info('💔 catch crontab is running, stop failed, please use [kill -9 {$this->pid}] to Stop it');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->output->info('🎉 catch crontab stopped!');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Master::exitMasterDo();
|
||||||
|
} else {
|
||||||
|
$this->output->error('🤔️ catch crontab is not running, Please Check it!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->output->info('🎉 stop catch crontab successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重启任务
|
||||||
|
*
|
||||||
|
* @time 2020年07月07日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function reload()
|
||||||
|
{
|
||||||
|
Process::kill($this->pid, SIGUSR1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重启
|
||||||
|
*
|
||||||
|
* @time 2020年07月07日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function restart()
|
||||||
|
{
|
||||||
|
$this->stop();
|
||||||
|
|
||||||
|
$this->output->info('catch crontab restarting...');
|
||||||
|
|
||||||
|
usleep(500 * 1000);
|
||||||
|
|
||||||
|
$this->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* status
|
||||||
|
*
|
||||||
|
* @time 2020年07月22日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function status()
|
||||||
|
{
|
||||||
|
if ($this->pid) {
|
||||||
|
if (Process::isAlive($this->pid)) {
|
||||||
|
Process::kill($this->pid, SIGUSR2);
|
||||||
|
|
||||||
|
usleep(100000);
|
||||||
|
|
||||||
|
$worker = new Master;
|
||||||
|
$table = new Table;
|
||||||
|
|
||||||
|
$table->setHeader(['PID', '名称', '内存', '处理任务', '开始时间', '运行时间', '状态'], Table::ALIGN_CENTER);
|
||||||
|
|
||||||
|
$table->setRows($worker->getWorkerStatus(), Table::ALIGN_CENTER);
|
||||||
|
|
||||||
|
$this->output->info($table->render());
|
||||||
|
} else {
|
||||||
|
$this->output->error('🤔️ catch crontab is not running, Please Check it!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->output->error('🤔️ catch crontab is not running, Please Check it!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
145
catch/monitor/command/process/Attributes.php
Normal file
145
catch/monitor/command/process/Attributes.php
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\command\process;
|
||||||
|
|
||||||
|
use catcher\base\CatchCronTask;
|
||||||
|
|
||||||
|
trait Attributes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 是否以守护进程方式运行
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $daemon = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 静态进程数量
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $static;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态进程数量
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $dynamic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时器触发时间
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $interval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set name
|
||||||
|
*
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
protected $name = 'catch-crontab';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $crontabQueueName = 'catch-crontab-task';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全退出
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $exitSafely = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置守护进程
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @param bool $daemon
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function asDaemon($daemon = false)
|
||||||
|
{
|
||||||
|
$this->daemon = $daemon;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function staticNumber($n)
|
||||||
|
{
|
||||||
|
$this->static = $n;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可扩容
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @param $n
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function dynamic($n)
|
||||||
|
{
|
||||||
|
$this->dynamic = $n;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @param $n
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function interval($n)
|
||||||
|
{
|
||||||
|
$this->interval = $n;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 name
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @param $name
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function name($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置报告错误
|
||||||
|
*
|
||||||
|
* @time 2020年07月24日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function displayErrors()
|
||||||
|
{
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
error_reporting(E_ALL & ~E_WARNING);
|
||||||
|
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
|
||||||
|
ini_set('ignore_repeated_errors', 1);
|
||||||
|
}
|
||||||
|
}
|
361
catch/monitor/command/process/Master.php
Normal file
361
catch/monitor/command/process/Master.php
Normal file
@@ -0,0 +1,361 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\command\process;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use catcher\facade\Filesystem;
|
||||||
|
use think\cache\driver\Redis;
|
||||||
|
use think\facade\Cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* - 以后台形式工作 daemon
|
||||||
|
* - 分静态进程和动态扩容进程
|
||||||
|
* - 信号处理机制
|
||||||
|
* - 重启工作进程
|
||||||
|
* - 重启服务
|
||||||
|
* - 定时器 扩容工作进程
|
||||||
|
* - 关闭进程
|
||||||
|
* - 统计信息
|
||||||
|
* - 是否拉起进程,工作进程销毁后是否继续主进程保留
|
||||||
|
* - Fatal Error 处理
|
||||||
|
* - Exception 处理
|
||||||
|
* - 发生内存泄漏如何处理
|
||||||
|
* - 错误输出到哪里
|
||||||
|
* - 提供基础面板查看
|
||||||
|
* - Log 文件的记录
|
||||||
|
*
|
||||||
|
* @time 2020年07月29日
|
||||||
|
*/
|
||||||
|
class Master
|
||||||
|
{
|
||||||
|
use RegisterSignal, Attributes, Store, ParseTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存子进程 PID
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $workerIds = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
public $start_at;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
public $worker_start_at;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存当前工作进程的数量
|
||||||
|
*
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
protected $allWorkersCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存当前重定向输出文件
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected static $stdout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务对象
|
||||||
|
*
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
protected $taskService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理的任务数量
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $dealNum = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* busy waiting
|
||||||
|
*
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
protected $status = 'waiting';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
protected $redis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($this->daemon) {
|
||||||
|
Process::daemon();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->interval) {
|
||||||
|
Process::alarm($this->interval);
|
||||||
|
}
|
||||||
|
$this->init();
|
||||||
|
// 初始化进程池
|
||||||
|
$this->initWorkers();
|
||||||
|
// 设置进程名称
|
||||||
|
Process::setWorkerName($this->name . ' master');
|
||||||
|
// 注册信号
|
||||||
|
$this->registerSignal();
|
||||||
|
// 写入进程状态
|
||||||
|
$this->setWorkerStatus($this->name . ' master');
|
||||||
|
// 信号发送
|
||||||
|
while (true) {
|
||||||
|
Process::dispatch();
|
||||||
|
$pid = pcntl_waitpid(-1, $status, WNOHANG);
|
||||||
|
Process::dispatch();
|
||||||
|
if ($pid > 0) {
|
||||||
|
if (isset($this->workerIds[$pid])) {
|
||||||
|
unset($this->workerIds[$pid]);
|
||||||
|
$this->deleteWorkerStatusFile($pid);
|
||||||
|
$this->worker_start_at = time();
|
||||||
|
// 如果进程挂掉,正常退出码都是 0,当然这里可以自己定义,看 exit($status) 设置什么
|
||||||
|
// 真实的 exit code pcntl_wexitstatus 函数获取
|
||||||
|
// exit code > 0 都是由于异常导致的
|
||||||
|
$exitCode = pcntl_wexitstatus($status);
|
||||||
|
if (!in_array($exitCode, [255, 250])) {
|
||||||
|
$this->forkStatic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果静态工作进程全部退出,会发生 CPU 空转,所以这里需要 sleep 1
|
||||||
|
if (!count($this->workerIds)) {
|
||||||
|
// sleep(1);
|
||||||
|
self::exitMasterDo();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
usleep(500 * 1000);
|
||||||
|
}
|
||||||
|
} catch (\Throwable $exception) {
|
||||||
|
// todo
|
||||||
|
echo sprintf('[%s]: ', date('Y-m-d H:i:s')) . $exception->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected function init()
|
||||||
|
{
|
||||||
|
$this->displayErrors();
|
||||||
|
$this->start_at = $this->worker_start_at = time();
|
||||||
|
// 记录 masterID
|
||||||
|
FileSystem::put(self::masterPidStorePath(), posix_getpid());
|
||||||
|
// 保存信息
|
||||||
|
$this->saveTaskInfo();
|
||||||
|
// 初始化进程数量
|
||||||
|
$this->allWorkersCount = $this->static;
|
||||||
|
// 显示UI
|
||||||
|
$this->display();
|
||||||
|
// 重定向
|
||||||
|
$this->dup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化进程池
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function initWorkers()
|
||||||
|
{
|
||||||
|
$this->redis = $this->getRedisHandle();
|
||||||
|
|
||||||
|
for ($i = 0; $i < $this->static; $i++) {
|
||||||
|
$this->forkStatic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fork 进程
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function forkDynamic()
|
||||||
|
{
|
||||||
|
$process = new Process(function (Process $process) {
|
||||||
|
$redis = $this->getRedisHandle();
|
||||||
|
while($crontab = $redis->rpop($this->crontabQueueName)) {
|
||||||
|
$task = $this->getTaskObject(\json_decode($crontab, true));
|
||||||
|
$task->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
$process->exit();
|
||||||
|
});
|
||||||
|
|
||||||
|
$process->start();
|
||||||
|
|
||||||
|
$this->workerIds[$process->pid] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 静态进程
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function forkStatic()
|
||||||
|
{
|
||||||
|
$process = new Process(function (Process $process) {
|
||||||
|
$process->initMemory();
|
||||||
|
|
||||||
|
$name = $this->name . ' worker';
|
||||||
|
$this->setWorkerStatus($name, $this->dealNum, $this->status);
|
||||||
|
|
||||||
|
Process::setWorkerName($name);
|
||||||
|
|
||||||
|
Process::signal(SIGUSR2, function ($signal) use ($name) {
|
||||||
|
$this->setWorkerStatus($name, $this->dealNum, $this->status);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 该信号保证进程完成任务后安全退出
|
||||||
|
Process::signal(SIGTERM, function ($signal) {
|
||||||
|
$this->exitSafely = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
/************** 任务 *********************/
|
||||||
|
$this->status = 'busying';
|
||||||
|
$this->setWorkerStatus($name, $this->dealNum, 'busying');
|
||||||
|
|
||||||
|
// 处理定时任务
|
||||||
|
while ($crontab = $this->redis->rpop($this->crontabQueueName)) {
|
||||||
|
$task = $this->getTaskObject(\json_decode($crontab, true));
|
||||||
|
$task->run();
|
||||||
|
if ($task->shouldExit()) {
|
||||||
|
$process->exit(250);
|
||||||
|
}
|
||||||
|
$this->dealNum += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->status = 'waiting';
|
||||||
|
$this->setWorkerStatus($name, $this->dealNum, 'waiting');
|
||||||
|
/****************处理*********************/
|
||||||
|
// 暂停一秒 让出CPU调度
|
||||||
|
sleep(1);
|
||||||
|
// 信号调度
|
||||||
|
Process::dispatch();
|
||||||
|
// 是否需要安全退出 || 查看内存是否溢出
|
||||||
|
if ($this->exitSafely || $process->isMemoryOverflow()) {
|
||||||
|
$process->exit();
|
||||||
|
//exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$process->start();
|
||||||
|
|
||||||
|
$this->workerIds[$process->pid] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重定向文件流
|
||||||
|
*
|
||||||
|
* @time 2020年07月22日
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected function dup()
|
||||||
|
{
|
||||||
|
if (!$this->daemon) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $stdout, $stderr;
|
||||||
|
|
||||||
|
// 关闭标准输入输出
|
||||||
|
fclose(STDOUT);
|
||||||
|
fclose(STDIN);
|
||||||
|
fclose(STDERR);
|
||||||
|
|
||||||
|
// 重定向输出&错误
|
||||||
|
$stdoutPath = self::$stdout ?: self::stdoutPath();
|
||||||
|
|
||||||
|
!file_exists($stdoutPath) && touch($stdoutPath);
|
||||||
|
// 等待 100 毫秒
|
||||||
|
usleep(100 * 1000);
|
||||||
|
|
||||||
|
$stdout = fopen($stdoutPath, 'a');
|
||||||
|
|
||||||
|
$stderr = fopen($stdoutPath, 'a');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输出
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function output()
|
||||||
|
{
|
||||||
|
$isShowCtrlC = $this->daemon ? '' : 'Ctrl+c to stop' . "\r\n";
|
||||||
|
|
||||||
|
$info = <<<EOT
|
||||||
|
---------------------------------------------------------------- 🚀
|
||||||
|
| _ _ _ _ |
|
||||||
|
| | | | | | | | | |
|
||||||
|
| ___ __ _| |_ ___| |__ ___ _ __ ___ _ __ | |_ __ _| |__ |
|
||||||
|
| / __/ _` | __/ __| '_ \ / __| '__/ _ \| '_ \| __/ _` | '_ \ |
|
||||||
|
| | (_| (_| | || (__| | | | | (__| | | (_) | | | | || (_| | |_) ||
|
||||||
|
| \___\__,_|\__\___|_| |_| \___|_| \___/|_| |_|\__\__,_|_.__/ |
|
||||||
|
| | |
|
||||||
|
|----------------------------------------------------------------|
|
||||||
|
$isShowCtrlC
|
||||||
|
EOT;
|
||||||
|
return file_put_contents(self::statusPath(), $info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示
|
||||||
|
*
|
||||||
|
* @time 2020年07月22日
|
||||||
|
* @return false|int
|
||||||
|
*/
|
||||||
|
protected function display()
|
||||||
|
{
|
||||||
|
$this->output();
|
||||||
|
|
||||||
|
return fwrite(STDOUT, $this->renderStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 redis 句柄
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @return object|null
|
||||||
|
*/
|
||||||
|
protected function getRedisHandle()
|
||||||
|
{
|
||||||
|
return Cache::store('redis')->handler();
|
||||||
|
}
|
||||||
|
}
|
47
catch/monitor/command/process/ParseTask.php
Normal file
47
catch/monitor/command/process/ParseTask.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\monitor\command\process;
|
||||||
|
|
||||||
|
use catcher\facade\FileSystem;
|
||||||
|
use think\exception\ClassNotFoundException;
|
||||||
|
use think\helper\Str;
|
||||||
|
|
||||||
|
trait ParseTask
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取任务
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @param $crontab
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function getTaskObject($crontab)
|
||||||
|
{
|
||||||
|
$class = $this->getTaskNamespace() . ucfirst(Str::camel($crontab['task']));
|
||||||
|
|
||||||
|
if (class_exists($class)) {
|
||||||
|
return app()->make($class)->setCrontab($crontab);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ClassNotFoundException('Task '. $crontab['task'] . ' not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务命名空间
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function getTaskNamespace()
|
||||||
|
{
|
||||||
|
return config('catch.crontab.task_namespace');
|
||||||
|
}
|
||||||
|
}
|
213
catch/monitor/command/process/Process.php
Normal file
213
catch/monitor/command/process/Process.php
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\command\process;
|
||||||
|
|
||||||
|
use catcher\exceptions\FailedException;
|
||||||
|
|
||||||
|
class Process
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 保存工作进程 PID
|
||||||
|
*
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
public $pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户自定义方法
|
||||||
|
*
|
||||||
|
* @var callable
|
||||||
|
*/
|
||||||
|
protected $callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请最大内存 给出缓冲期
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $initMemory = '256M';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 超过最大内存报警
|
||||||
|
*
|
||||||
|
* @var float|int
|
||||||
|
*/
|
||||||
|
protected $allowMaxMemory = 128 * 1024 * 1024;
|
||||||
|
|
||||||
|
public function __construct(callable $callable)
|
||||||
|
{
|
||||||
|
$this->callable = $callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 守护进程
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
* @throws FailedException
|
||||||
|
*/
|
||||||
|
public static function daemon()
|
||||||
|
{
|
||||||
|
$pid = pcntl_fork();
|
||||||
|
|
||||||
|
if ($pid < 0) {
|
||||||
|
throw new FailedException('fork process failed');
|
||||||
|
}
|
||||||
|
// 退出父进程
|
||||||
|
if ($pid > 0) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
// 设置新的会话组
|
||||||
|
if (posix_setsid() < 0) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
chdir('/');
|
||||||
|
// 重置掩码 权限问题
|
||||||
|
umask(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动进程
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function start()
|
||||||
|
{
|
||||||
|
$pid = pcntl_fork();
|
||||||
|
|
||||||
|
if ($this->pid < 0) {
|
||||||
|
exit('fork failed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pid > 0) {
|
||||||
|
$this->pid = $pid;
|
||||||
|
} else {
|
||||||
|
call_user_func_array($this->callable, [$this]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 信号
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @param $signal
|
||||||
|
* @param $callable
|
||||||
|
* @param $restartSysCalls
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function signal($signal, $callable, $restartSysCalls = false)
|
||||||
|
{
|
||||||
|
pcntl_signal($signal, $callable, $restartSysCalls);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default 1 second
|
||||||
|
*
|
||||||
|
* @param $interval
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function alarm($interval = 1)
|
||||||
|
{
|
||||||
|
return pcntl_alarm($interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* linux 进程下设置进程名称
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @param $title
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function setWorkerName($title)
|
||||||
|
{
|
||||||
|
if (strtolower(PHP_OS) === 'linux') {
|
||||||
|
cli_set_process_title($title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全退出
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @param int $status
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function exit($status = 0)
|
||||||
|
{
|
||||||
|
exit($status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kill
|
||||||
|
*
|
||||||
|
* @time 2020年07月22日
|
||||||
|
* @param $pid
|
||||||
|
* @param $signal
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function kill($pid, $signal)
|
||||||
|
{
|
||||||
|
return posix_kill($pid, $signal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @time 2020年07月22日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function dispatch()
|
||||||
|
{
|
||||||
|
pcntl_signal_dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否存活
|
||||||
|
*
|
||||||
|
* @time 2020年07月22日
|
||||||
|
* @param $pid
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isAlive($pid)
|
||||||
|
{
|
||||||
|
return posix_kill($pid, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化进程内存
|
||||||
|
*
|
||||||
|
* @time 2020年07月22日
|
||||||
|
* @param int $memory
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function initMemory($memory = 0)
|
||||||
|
{
|
||||||
|
if (ini_get('memory_limit') != $this->initMemory) {
|
||||||
|
// 这里申请一块稍微大的内存
|
||||||
|
ini_set('memory_limit', $memory ?: $this->initMemory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否超过最大内存
|
||||||
|
*
|
||||||
|
* @time 2020年07月22日
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function isMemoryOverflow()
|
||||||
|
{
|
||||||
|
// 一旦超过了允许的内存 直接退出进程
|
||||||
|
return memory_get_usage() > $this->allowMaxMemory;
|
||||||
|
}
|
||||||
|
}
|
158
catch/monitor/command/process/RegisterSignal.php
Normal file
158
catch/monitor/command/process/RegisterSignal.php
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\command\process;
|
||||||
|
|
||||||
|
use catchAdmin\monitor\model\Crontab;
|
||||||
|
use catcher\facade\FileSystem;
|
||||||
|
use Cron\CronExpression;
|
||||||
|
use EasyWeChat\Kernel\Messages\News;
|
||||||
|
use think\cache\driver\Redis;
|
||||||
|
|
||||||
|
trait RegisterSignal
|
||||||
|
{
|
||||||
|
public function registerSignal()
|
||||||
|
{
|
||||||
|
// 退出信号
|
||||||
|
$this->exit();
|
||||||
|
// 等待子进程退出
|
||||||
|
$this->waitWorkersExit();
|
||||||
|
// 动态扩容
|
||||||
|
$this->workerChecked();
|
||||||
|
// 重启进程
|
||||||
|
$this->reload();
|
||||||
|
// 统计信息
|
||||||
|
$this->showStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进程退出
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function exit()
|
||||||
|
{
|
||||||
|
Process::signal(SIGTERM, function ($signal) {
|
||||||
|
foreach ($this->workerIds as $pid => $v) {
|
||||||
|
if (isset($this->workerIds[$pid])) {
|
||||||
|
unset($this->workerIds[$pid]);
|
||||||
|
}
|
||||||
|
Process::kill($pid, SIGTERM);
|
||||||
|
}
|
||||||
|
Process::kill(self::getMasterPid(), SIGKILL);
|
||||||
|
});
|
||||||
|
|
||||||
|
Process::signal(SIGINT, function ($signal) {
|
||||||
|
foreach ($this->workerIds as $pid => $v) {
|
||||||
|
if (isset($this->workerIds[$pid])) {
|
||||||
|
unset($this->workerIds[$pid]);
|
||||||
|
}
|
||||||
|
Process::kill($pid, SIGKILL);
|
||||||
|
}
|
||||||
|
Process::kill(self::getMasterPid(), SIGKILL);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子进程退出
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function waitWorkersExit()
|
||||||
|
{
|
||||||
|
Process::signal(SIGCHLD, function ($signal) {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进程检测
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function workerChecked()
|
||||||
|
{
|
||||||
|
Process::signal(SIGALRM, function ($signal) {
|
||||||
|
$process = new Process(function (Process $process) {
|
||||||
|
$crontabs = Crontab::where('status', Crontab::ENABLE)
|
||||||
|
->where('tactics', '<>', Crontab::EXECUTE_FORBIDDEN)
|
||||||
|
->select()->toArray();
|
||||||
|
|
||||||
|
// 任务
|
||||||
|
foreach ($crontabs as $crontab) {
|
||||||
|
$can = date('Y-m-d H:i', CronExpression::factory(trim($crontab['cron']))
|
||||||
|
->getNextRunDate(date('Y-m-d H:i:s'), 0 , true)
|
||||||
|
->getTimestamp()) == date('Y-m-d H:i', time());
|
||||||
|
|
||||||
|
if ($can) {
|
||||||
|
// 如果任务只执行一次 之后禁用该任务
|
||||||
|
if ($crontab['tactics'] === Crontab::EXECUTE_ONCE) {
|
||||||
|
Crontab::where('id', $crontab['id'])->update([
|
||||||
|
'status' => Crontab::DISABLE,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$redis = $this->getRedisHandle();
|
||||||
|
|
||||||
|
$redis->lpush($this->crontabQueueName, json_encode([
|
||||||
|
'id' => $crontab['id'],
|
||||||
|
'task' => $crontab['task'],
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$process->exit();
|
||||||
|
});
|
||||||
|
|
||||||
|
$process->start();
|
||||||
|
|
||||||
|
Process::alarm($this->interval);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重启
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function reload()
|
||||||
|
{
|
||||||
|
Process::signal(SIGUSR1, function ($signal) {
|
||||||
|
$this->worker_start_at = 0;
|
||||||
|
foreach ($this->workerIds as $pid => $v) {
|
||||||
|
Process::kill($pid, SIGTERM);
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预留信号
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function showStatus()
|
||||||
|
{
|
||||||
|
Process::signal(SIGUSR2, function ($signal) {
|
||||||
|
$this->setWorkerStatus($this->name . ' master');
|
||||||
|
foreach ($this->workerIds as $pid => $v) {
|
||||||
|
Process::kill($pid, SIGUSR2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
243
catch/monitor/command/process/Store.php
Normal file
243
catch/monitor/command/process/Store.php
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\command\process;
|
||||||
|
|
||||||
|
use catcher\facade\FileSystem;
|
||||||
|
|
||||||
|
trait Store
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* worker 根目录
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function storeTaskPath()
|
||||||
|
{
|
||||||
|
$path = config('catch.crontab.store_path');
|
||||||
|
|
||||||
|
if (!Filesystem::exists($path)) {
|
||||||
|
FileSystem::makeDirectory($path, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存信息备用
|
||||||
|
*
|
||||||
|
* @time 2020年07月29日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function saveTaskInfo()
|
||||||
|
{
|
||||||
|
FileSystem::put(self::storeTaskPath() . 'information.json', \json_encode([
|
||||||
|
'name' => $this->name,
|
||||||
|
'static' => $this->static,
|
||||||
|
'dynamic' => $this->dynamic,
|
||||||
|
'interval' => $this->interval,
|
||||||
|
], JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* worker master pid
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function masterPidStorePath()
|
||||||
|
{
|
||||||
|
return self::storeTaskPath() . 'master.pid';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* worker master status
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function statusPath()
|
||||||
|
{
|
||||||
|
return self::storeTaskPath() . 'master.status';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* worker status
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @param string $name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function workerStatusPath($name)
|
||||||
|
{
|
||||||
|
$path = self::storeTaskPath() . 'status/';
|
||||||
|
|
||||||
|
if (!FileSystem::exists($path)) {
|
||||||
|
FileSystem::makeDirectory($path, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path . $name . '.status';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getWorkerStatusPath()
|
||||||
|
{
|
||||||
|
return self::storeTaskPath() . 'status/';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* worker log
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function stdoutPath()
|
||||||
|
{
|
||||||
|
return self::storeTaskPath() . 'errors.log';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 master pid
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
|
public static function getMasterPid()
|
||||||
|
{
|
||||||
|
$pidFile = config('catch.crontab.master_pid_file');
|
||||||
|
|
||||||
|
if (!file_exists($pidFile)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FileSystem::sharedGet($pidFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* status
|
||||||
|
*
|
||||||
|
* @time 2020年07月21日
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
|
public function renderStatus()
|
||||||
|
{
|
||||||
|
return file_get_contents(self::statusPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行时间
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @param $runtime
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getRunningTime($runtime)
|
||||||
|
{
|
||||||
|
$day = 3600 * 24;
|
||||||
|
if ($runtime > $day) {
|
||||||
|
$days = floor($runtime / $day);
|
||||||
|
return $days . '天:' . gmstrftime('%H:%M:%S', $runtime % $day);
|
||||||
|
} else {
|
||||||
|
return gmstrftime('%H:%M:%S', $runtime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取工作进程
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getWorkerStatus()
|
||||||
|
{
|
||||||
|
usleep(500 * 1000);
|
||||||
|
|
||||||
|
$files = FileSystem::glob(self::storeTaskPath() . 'status/*.status');
|
||||||
|
|
||||||
|
$workerStatus = [];
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$workerStatus[] = explode("\t", FileSystem::sharedGet($file));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $workerStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置进程状态
|
||||||
|
*
|
||||||
|
* @time 2020年07月23日
|
||||||
|
* @param $name
|
||||||
|
* @param int $dealNum
|
||||||
|
* @param string $status
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function setWorkerStatus($name, $dealNum = 0, $status = 'running')
|
||||||
|
{
|
||||||
|
$startAt = strpos($name, 'worker') ? $this->worker_start_at : $this->start_at;
|
||||||
|
|
||||||
|
if ($this->daemon) {
|
||||||
|
FileSystem::put($this->workerStatusPath($this->workerStatusFileName($name)), implode("\t", [
|
||||||
|
posix_getpid(),
|
||||||
|
$name,
|
||||||
|
floor(memory_get_usage() / 1024 / 1024) . 'M',
|
||||||
|
$dealNum,
|
||||||
|
date('Y-m-d H:i:s', $startAt),
|
||||||
|
$this->getRunningTime(time() - $startAt),
|
||||||
|
$status
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进程名称
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @param $name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function workerStatusFileName($name)
|
||||||
|
{
|
||||||
|
return $name . '_' . posix_getpid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除进程状态文件
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @param $pid
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function deleteWorkerStatusFile($pid)
|
||||||
|
{
|
||||||
|
@unlink(self::workerStatusPath($this->name . ' worker_' . $pid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function exitMasterDo()
|
||||||
|
{
|
||||||
|
@unlink(self::masterPidStorePath());
|
||||||
|
@unlink(self::statusPath());
|
||||||
|
Filesystem::deleteDirectory(self::getWorkerStatusPath());
|
||||||
|
}
|
||||||
|
}
|
59
catch/monitor/config.php
Normal file
59
catch/monitor/config.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
return [
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 定时任务配置
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
'crontab' => [
|
||||||
|
/**
|
||||||
|
* 存储目录
|
||||||
|
*/
|
||||||
|
'store_path' => runtime_path('catch/crontab'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主进程 pid 存储
|
||||||
|
*/
|
||||||
|
'master_pid_file' => runtime_path('catch/crontab') . 'master.pid',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志配置
|
||||||
|
*/
|
||||||
|
'log' => [
|
||||||
|
// 日志记录方式
|
||||||
|
'type' => 'File',
|
||||||
|
// 日志保存目录
|
||||||
|
'path' => runtime_path('catch/schedule'),
|
||||||
|
// 单文件日志写入
|
||||||
|
'single' => false,
|
||||||
|
// 独立日志级别
|
||||||
|
'apart_level' => [],
|
||||||
|
// 最大日志文件数量
|
||||||
|
'max_files' => 0,
|
||||||
|
// 使用JSON格式记录
|
||||||
|
'json' => false,
|
||||||
|
// 日志处理
|
||||||
|
'processor' => null,
|
||||||
|
// 关闭通道日志写入
|
||||||
|
'close' => false,
|
||||||
|
// 日志输出格式化
|
||||||
|
'format' => '[%s][%s] %s',
|
||||||
|
// 是否实时写入
|
||||||
|
'realtime_write' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* crontab 任务命名空间
|
||||||
|
*/
|
||||||
|
'task_namespace' => '\\app\\task\\',
|
||||||
|
],
|
||||||
|
];
|
105
catch/monitor/controller/Crontab.php
Normal file
105
catch/monitor/controller/Crontab.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\controller;
|
||||||
|
|
||||||
|
use catcher\base\CatchRequest as Request;
|
||||||
|
use catcher\CatchResponse;
|
||||||
|
use catcher\base\CatchController;
|
||||||
|
use catchAdmin\monitor\model\Crontab as CrontabModel;
|
||||||
|
use Cron\CronExpression;
|
||||||
|
|
||||||
|
class Crontab extends CatchController
|
||||||
|
{
|
||||||
|
protected $model;
|
||||||
|
|
||||||
|
public function __construct(CrontabModel $model)
|
||||||
|
{
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*
|
||||||
|
* @time 2020/09/14 20:35
|
||||||
|
*
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return CatchResponse::paginate($this->model->getList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*
|
||||||
|
* @time 2020/09/14 20:35
|
||||||
|
* @param Request Request
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function save(Request $request)
|
||||||
|
{
|
||||||
|
CronExpression::factory($request->post('cron'));
|
||||||
|
|
||||||
|
return CatchResponse::success($this->model->storeBy($request->post()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取
|
||||||
|
*
|
||||||
|
* @time 2020/09/14 20:35
|
||||||
|
* @param $id
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function read($id)
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->model->findBy($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*
|
||||||
|
* @time 2020/09/14 20:35
|
||||||
|
* @param Request $request
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
CronExpression::factory($request->post('cron'));
|
||||||
|
|
||||||
|
return CatchResponse::success($this->model->updateBy($id, $request->post()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @time 2020/09/14 20:35
|
||||||
|
* @param $id
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->model->deleteBy($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用启用
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @param $id
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function disOrEnable($id)
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->model->disOrEnable($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
50
catch/monitor/controller/CrontabLog.php
Normal file
50
catch/monitor/controller/CrontabLog.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\monitor\controller;
|
||||||
|
|
||||||
|
use catchAdmin\monitor\model\CrontabLog as LogModel;
|
||||||
|
use catcher\base\CatchController;
|
||||||
|
use catcher\CatchResponse;
|
||||||
|
use think\Request;
|
||||||
|
|
||||||
|
class CrontabLog extends CatchController
|
||||||
|
{
|
||||||
|
protected $model;
|
||||||
|
|
||||||
|
public function __construct(LogModel $model)
|
||||||
|
{
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志列表
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return CatchResponse::paginate($this->model->getList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除日志
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @param $id
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
return CatchResponse::success($this->model->deleteBy($id));
|
||||||
|
}
|
||||||
|
}
|
46
catch/monitor/database/migrations/20200914203553_crontab.php
Normal file
46
catch/monitor/database/migrations/20200914203553_crontab.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
use think\migration\db\Column;
|
||||||
|
use Phinx\Db\Adapter\MysqlAdapter;
|
||||||
|
|
||||||
|
class Crontab extends Migrator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* Write your reversible migrations using this method.
|
||||||
|
*
|
||||||
|
* More information on writing migrations is available here:
|
||||||
|
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||||
|
*
|
||||||
|
* The following commands can be used in this method and Phinx will
|
||||||
|
* automatically reverse them when rolling back:
|
||||||
|
*
|
||||||
|
* createTable
|
||||||
|
* renameTable
|
||||||
|
* addColumn
|
||||||
|
* renameColumn
|
||||||
|
* addIndex
|
||||||
|
* addForeignKey
|
||||||
|
*
|
||||||
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||||
|
* with the Table class.
|
||||||
|
*/
|
||||||
|
public function change()
|
||||||
|
{
|
||||||
|
$table = $this->table('crontab', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '定时任务' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
|
||||||
|
$table->addColumn('name', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => false,'comment' => '任务名称',])
|
||||||
|
->addColumn('group', 'boolean', ['null' => false,'default' => 1,'signed' => false,'comment' => '1 默认 2 系统',])
|
||||||
|
->addColumn('task', 'string', ['limit' => 255,'null' => false,'default' => '','signed' => false,'comment' => '任务名称',])
|
||||||
|
->addColumn('cron', 'string', ['limit' => 50,'null' => false,'default' => '','signed' => false,'comment' => 'cron 表达式',])
|
||||||
|
->addColumn('tactics', 'boolean', ['null' => false,'default' => 1,'signed' => false,'comment' => '1 立即执行 2 执行一次 3 放弃执行',])
|
||||||
|
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => false,'comment' => '1 正常 2 禁用',])
|
||||||
|
->addColumn('remark', 'string', ['limit' => 1000,'null' => false,'default' => '','signed' => false,'comment' => '备注',])
|
||||||
|
->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建人ID',])
|
||||||
|
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||||
|
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||||
|
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
use think\migration\db\Column;
|
||||||
|
use Phinx\Db\Adapter\MysqlAdapter;
|
||||||
|
|
||||||
|
class CrontabLog extends Migrator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* Write your reversible migrations using this method.
|
||||||
|
*
|
||||||
|
* More information on writing migrations is available here:
|
||||||
|
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||||
|
*
|
||||||
|
* The following commands can be used in this method and Phinx will
|
||||||
|
* automatically reverse them when rolling back:
|
||||||
|
*
|
||||||
|
* createTable
|
||||||
|
* renameTable
|
||||||
|
* addColumn
|
||||||
|
* renameColumn
|
||||||
|
* addIndex
|
||||||
|
* addForeignKey
|
||||||
|
*
|
||||||
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||||
|
* with the Table class.
|
||||||
|
*/
|
||||||
|
public function change()
|
||||||
|
{
|
||||||
|
$table = $this->table('crontab_log', ['engine' => 'Myisam', 'collation' => 'utf8mb4_general_ci', 'comment' => '定时任务日志' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
|
||||||
|
$table->addColumn('crontab_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => 'crontab 任务ID',])
|
||||||
|
->addColumn('used_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '任务消耗时间',])
|
||||||
|
->addColumn('status', 'boolean', ['null' => false,'default' => 1,'signed' => false,'comment' => '1 成功 2 失败',])
|
||||||
|
->addColumn('error_message', 'string', ['limit' => 1000,'null' => false,'default' => '','signed' => false,'comment' => '错误信息',])
|
||||||
|
->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '创建时间',])
|
||||||
|
->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '更新时间',])
|
||||||
|
->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '软删除',])
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
}
|
253
catch/monitor/database/seeds/MonitorMenusSeed.php
Normal file
253
catch/monitor/database/seeds/MonitorMenusSeed.php
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
use think\migration\Seeder;
|
||||||
|
|
||||||
|
class MonitorMenusSeed extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run Method.
|
||||||
|
*
|
||||||
|
* Write your database seeder using this method.
|
||||||
|
*
|
||||||
|
* More information on writing seeders is available here:
|
||||||
|
* http://docs.phinx.org/en/latest/seeding.html
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
\catcher\Utils::importTreeData($this->getPermissions(), 'permissions', 'parent_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPermissions()
|
||||||
|
{
|
||||||
|
return array (
|
||||||
|
0 =>
|
||||||
|
array (
|
||||||
|
'id' => 103,
|
||||||
|
'permission_name' => '系统监控',
|
||||||
|
'parent_id' => 0,
|
||||||
|
'level' => '',
|
||||||
|
'route' => '/monitor',
|
||||||
|
'icon' => 'el-icon-view',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'monitor',
|
||||||
|
'component' => 'layout',
|
||||||
|
'redirect' => '/monitor/crontab',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600126383,
|
||||||
|
'updated_at' => 1600136975,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
'children' =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
|
array (
|
||||||
|
'id' => 104,
|
||||||
|
'permission_name' => '定时任务',
|
||||||
|
'parent_id' => 103,
|
||||||
|
'level' => '103',
|
||||||
|
'route' => '/monitor/crontab',
|
||||||
|
'icon' => 'el-icon-time',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'crontab',
|
||||||
|
'component' => 'crontab',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600126931,
|
||||||
|
'updated_at' => 1600136975,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
'children' =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
|
array (
|
||||||
|
'id' => 105,
|
||||||
|
'permission_name' => '列表',
|
||||||
|
'parent_id' => 104,
|
||||||
|
'level' => '103-104',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'crontab@index',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600127069,
|
||||||
|
'updated_at' => 1600136975,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
1 =>
|
||||||
|
array (
|
||||||
|
'id' => 106,
|
||||||
|
'permission_name' => '保存',
|
||||||
|
'parent_id' => 104,
|
||||||
|
'level' => '103-104',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'crontab@save',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600127078,
|
||||||
|
'updated_at' => 1600136975,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
2 =>
|
||||||
|
array (
|
||||||
|
'id' => 107,
|
||||||
|
'permission_name' => '更新',
|
||||||
|
'parent_id' => 104,
|
||||||
|
'level' => '103-104',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'crontab@update',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600127085,
|
||||||
|
'updated_at' => 1600136975,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
3 =>
|
||||||
|
array (
|
||||||
|
'id' => 108,
|
||||||
|
'permission_name' => '删除',
|
||||||
|
'parent_id' => 104,
|
||||||
|
'level' => '103-104',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'crontab@delete',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600127091,
|
||||||
|
'updated_at' => 1600136975,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
4 =>
|
||||||
|
array (
|
||||||
|
'id' => 109,
|
||||||
|
'permission_name' => '禁用/启用',
|
||||||
|
'parent_id' => 104,
|
||||||
|
'level' => '103-104',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'crontab@disOrEnable',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600129279,
|
||||||
|
'updated_at' => 1600136975,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
1 =>
|
||||||
|
array (
|
||||||
|
'id' => 110,
|
||||||
|
'permission_name' => '任务日志',
|
||||||
|
'parent_id' => 103,
|
||||||
|
'level' => '103-104',
|
||||||
|
'route' => '/monitor/crontab/log/:crontab_id?',
|
||||||
|
'icon' => 'el-icon-guide',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'CrontabLog',
|
||||||
|
'component' => 'crontabLog',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'hidden' => 2,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600167562,
|
||||||
|
'updated_at' => 1600188651,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
'children' =>
|
||||||
|
array (
|
||||||
|
0 =>
|
||||||
|
array (
|
||||||
|
'id' => 111,
|
||||||
|
'permission_name' => '列表',
|
||||||
|
'parent_id' => 110,
|
||||||
|
'level' => '103-104-110',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'CrontabLog@index',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600167574,
|
||||||
|
'updated_at' => 1600168082,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
1 =>
|
||||||
|
array (
|
||||||
|
'id' => 112,
|
||||||
|
'permission_name' => '删除',
|
||||||
|
'parent_id' => 110,
|
||||||
|
'level' => '103-104-110',
|
||||||
|
'route' => '',
|
||||||
|
'icon' => '',
|
||||||
|
'module' => 'monitor',
|
||||||
|
'creator_id' => 1,
|
||||||
|
'permission_mark' => 'CrontabLog@delete',
|
||||||
|
'component' => '',
|
||||||
|
'redirect' => '',
|
||||||
|
'keepalive' => 1,
|
||||||
|
'type' => 2,
|
||||||
|
'hidden' => 1,
|
||||||
|
'sort' => 1,
|
||||||
|
'created_at' => 1600167581,
|
||||||
|
'updated_at' => 1600168082,
|
||||||
|
'deleted_at' => 0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
43
catch/monitor/model/Crontab.php
Normal file
43
catch/monitor/model/Crontab.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\model;
|
||||||
|
|
||||||
|
use catchAdmin\monitor\model\search\CrontabSearch;
|
||||||
|
use catcher\base\CatchModel as Model;
|
||||||
|
|
||||||
|
class Crontab extends Model
|
||||||
|
{
|
||||||
|
use CrontabSearch;
|
||||||
|
|
||||||
|
protected $name = 'crontab';
|
||||||
|
|
||||||
|
protected $field = [
|
||||||
|
'id', //
|
||||||
|
'name', // 任务名称
|
||||||
|
'group', // 1 默认 2 系统
|
||||||
|
'task', // 任务名称
|
||||||
|
'cron', // cron 表达式
|
||||||
|
'tactics', // 1 立即执行 2 执行一次 3 放弃执行
|
||||||
|
'status', // 1 正常 2 禁用
|
||||||
|
'remark', // 备注
|
||||||
|
'creator_id', // 创建人ID
|
||||||
|
'created_at', // 创建时间
|
||||||
|
'updated_at', // 更新时间
|
||||||
|
'deleted_at', // 软删除
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
const EXECUTE_IMMEDIATELY = 1; // 立即执行
|
||||||
|
const EXECUTE_ONCE = 2; // 执行一次
|
||||||
|
const EXECUTE_FORBIDDEN = 3; // 停止执行
|
||||||
|
|
||||||
|
}
|
53
catch/monitor/model/CrontabLog.php
Normal file
53
catch/monitor/model/CrontabLog.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace catchAdmin\monitor\model;
|
||||||
|
|
||||||
|
use catchAdmin\monitor\model\search\CrontabLogSearch;
|
||||||
|
use catcher\base\CatchModel;
|
||||||
|
|
||||||
|
class CrontabLog extends CatchModel
|
||||||
|
{
|
||||||
|
use CrontabLogSearch;
|
||||||
|
|
||||||
|
protected $name = 'crontab_log';
|
||||||
|
|
||||||
|
protected $field = [
|
||||||
|
'id', //
|
||||||
|
'crontab_id', // crontab 任务ID
|
||||||
|
'used_time', // 任务消耗时间
|
||||||
|
'status', // 1 成功 2 失败
|
||||||
|
'error_message', // 错误信息
|
||||||
|
'created_at', // 创建时间
|
||||||
|
'updated_at', // 更新时间
|
||||||
|
'deleted_at', // 软删除
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
const SUCCESS = 1;
|
||||||
|
const FAILED = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取日志列表
|
||||||
|
*
|
||||||
|
* @time 2020年09月15日
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @return mixed|\think\Paginator
|
||||||
|
*/
|
||||||
|
public function getList()
|
||||||
|
{
|
||||||
|
return $this->catchLeftJoin(Crontab::class, 'id', 'crontab_id', ['name', 'group', 'task'])
|
||||||
|
->catchSearch()
|
||||||
|
->catchOrder()
|
||||||
|
->field(['used_time', 'error_message', 'crontab_log.status', 'crontab_log.id', 'crontab_log.created_at'])
|
||||||
|
->paginate();
|
||||||
|
}
|
||||||
|
}
|
39
catch/monitor/model/search/CrontabLogSearch.php
Normal file
39
catch/monitor/model/search/CrontabLogSearch.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\monitor\model\search;
|
||||||
|
|
||||||
|
trait CrontabLogSearch
|
||||||
|
{
|
||||||
|
public function searchCrontabIdAttr($query, $value, $data)
|
||||||
|
{
|
||||||
|
return $query->where('crontab_id', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchNameAttr($query, $value, $data)
|
||||||
|
{
|
||||||
|
return $query->whereLike('crontab.name', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchStatusAttr($query, $value, $data)
|
||||||
|
{
|
||||||
|
return $query->where('crontab_log.status', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchStartAtAttr($query, $value, $data)
|
||||||
|
{
|
||||||
|
return $query->where($this->aliasField('created_at'), '>=', strtotime($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchEndAtAttr($query, $value, $data)
|
||||||
|
{
|
||||||
|
return $query->where($this->aliasField('created_at'), '<=', strtotime($value));
|
||||||
|
}
|
||||||
|
}
|
24
catch/monitor/model/search/CrontabSearch.php
Normal file
24
catch/monitor/model/search/CrontabSearch.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
namespace catchAdmin\monitor\model\search;
|
||||||
|
|
||||||
|
trait CrontabSearch
|
||||||
|
{
|
||||||
|
public function searchNameAttr($query, $value, $data)
|
||||||
|
{
|
||||||
|
return $query->whereLike('name', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchStatusAttr($query, $value, $data)
|
||||||
|
{
|
||||||
|
return $query->whereLike('status', $value);
|
||||||
|
}
|
||||||
|
}
|
15
catch/monitor/module.json
Normal file
15
catch/monitor/module.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "系统监控",
|
||||||
|
"alias": "monitor",
|
||||||
|
"description": "系统监控模块",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"keywords": [],
|
||||||
|
"order": 0,
|
||||||
|
"services": [
|
||||||
|
"\\catchAdmin\\monitor\\MonitorService"
|
||||||
|
],
|
||||||
|
"aliases": [],
|
||||||
|
"files": [],
|
||||||
|
"requires": [],
|
||||||
|
"enable": true
|
||||||
|
}
|
22
catch/monitor/route.php
Normal file
22
catch/monitor/route.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// you should use `$router`
|
||||||
|
$router->group('monitor', function () use ($router){
|
||||||
|
// crontab路由
|
||||||
|
$router->resource('crontab', '\catchAdmin\monitor\controller\Crontab');
|
||||||
|
$router->put('crontab/enable/<id>', '\catchAdmin\monitor\controller\Crontab@disOrEnable');
|
||||||
|
|
||||||
|
// crontab 日志
|
||||||
|
$router->get('crontab/log', '\catchAdmin\monitor\controller\CrontabLog@index');
|
||||||
|
$router->delete('crontab/log/<id>', '\catchAdmin\monitor\controller\CrontabLog@delete');
|
||||||
|
|
||||||
|
})->middleware('auth');
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user