mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-10-11 16:00:35 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3a55ea44d | ||
|
|
270411f7fd | ||
|
|
3c01198e61 | ||
|
|
483b47ad63 | ||
|
|
b10de66ed3 | ||
|
|
305eff048c | ||
|
|
da7968d364 | ||
|
|
d3e2c8e9d3 | ||
|
|
e3a9f2dfb7 | ||
|
|
3c967f8906 | ||
|
|
39bb7acdba | ||
|
|
a30066989b | ||
|
|
0c30dfa092 | ||
|
|
7a44493d13 | ||
|
|
9b726d5d22 | ||
|
|
78e3d9e5fb | ||
|
|
d74b41a5f2 | ||
|
|
f122afdbec | ||
|
|
37308b5c42 | ||
|
|
9c5a6e3925 | ||
|
|
58b95ef2ba | ||
|
|
f617c9d5dd | ||
|
|
c661cc37b3 | ||
|
|
7c49f6c79b | ||
|
|
12b9356c17 | ||
|
|
d3a34293f7 | ||
|
|
c131061f81 | ||
|
|
6a5e1ebaa5 | ||
|
|
a07d016951 | ||
|
|
9d343a90db | ||
|
|
4c813be09d | ||
|
|
d48166f546 | ||
|
|
0f138c1b7c | ||
|
|
8542323c0b | ||
|
|
00f103c66a | ||
|
|
430c75e7ed | ||
|
|
67ffb5e938 | ||
|
|
9c292bebf0 | ||
|
|
ba4307c1dc | ||
|
|
b8b2041a0c | ||
|
|
c45bb60b50 | ||
|
|
fba46be47a | ||
|
|
be0a460935 | ||
|
|
c0a041d024 | ||
|
|
2ce5ad82ce | ||
|
|
50dcb6c7e4 | ||
|
|
017424bf7b | ||
|
|
c7e7407f7c | ||
|
|
cab42b3c7d | ||
|
|
78f280c88f | ||
|
|
22f5a975c3 | ||
|
|
90ba036e39 | ||
|
|
d1e18e43ee | ||
|
|
a801140a82 | ||
|
|
951ab2502e | ||
|
|
0316cb0662 | ||
|
|
04b9cbd87a | ||
|
|
4565c5b300 | ||
|
|
bf9a9bf17a | ||
|
|
70df4dc6c4 | ||
|
|
ed3e738fff | ||
|
|
bc376ec495 | ||
|
|
40314e9079 | ||
|
|
82f978c683 | ||
|
|
ed288368ea | ||
|
|
db8fa144eb | ||
|
|
57b76d97ec | ||
|
|
28d8210ce6 | ||
|
|
80ce60c56c | ||
|
|
2758ab07dc | ||
|
|
0828804de2 | ||
|
|
134b17d2f0 | ||
|
|
3af254cdda | ||
|
|
f3d3d54722 | ||
|
|
fa419809f6 | ||
|
|
da606826c6 | ||
|
|
b3d9cc156a | ||
|
|
ba03d26b2c | ||
|
|
40f02889fe | ||
|
|
4f8fb26d89 | ||
|
|
0ca11e2b88 | ||
|
|
0daf0d690c | ||
|
|
0cfdf0f335 | ||
|
|
cca1863b63 | ||
|
|
033f08a6d2 | ||
|
|
a83a6690ff | ||
|
|
83df457379 | ||
|
|
657e55cde3 | ||
|
|
90e76e3a0f | ||
|
|
2af1993383 | ||
|
|
6e650d977e | ||
|
|
8a76171dbe | ||
|
|
949b6fe944 | ||
|
|
3f90333090 | ||
|
|
aeaca0c5cd | ||
|
|
fb7f638a54 | ||
|
|
7994193a39 | ||
|
|
3334bf594d | ||
|
|
71193cc912 | ||
|
|
9fde8c447d | ||
|
|
117faa952e | ||
|
|
6427337728 | ||
|
|
81f97f6f88 | ||
|
|
b3b472d711 | ||
|
|
1c22e1cf99 | ||
|
|
3110d91bf6 | ||
|
|
624a11407a | ||
|
|
ead6d1268f | ||
|
|
80c00c5a8c | ||
|
|
da0f6acd01 | ||
|
|
485aa99dea | ||
|
|
5f68d7ce90 | ||
|
|
685fca6c8c | ||
|
|
9c609da332 | ||
|
|
84608b7d42 | ||
|
|
02cf2a80cb | ||
|
|
a74c6dd522 | ||
|
|
5d4ab23d95 | ||
|
|
a8faba3206 | ||
|
|
c603495b12 | ||
|
|
adce6103bd | ||
|
|
6b673017c5 | ||
|
|
e66bd43fc6 | ||
|
|
ff5cdb9a02 | ||
|
|
1aec5e443d | ||
|
|
0b1f7e9322 | ||
|
|
3ec2dec49b | ||
|
|
7cbebc8236 | ||
|
|
700076f278 | ||
|
|
7bf1bf61a7 | ||
|
|
ef2cb1b315 | ||
|
|
75bfc3a114 | ||
|
|
70f63090fe | ||
|
|
ab2cf0d0c3 | ||
|
|
ea1a34f57a | ||
|
|
765add6184 | ||
|
|
e5263d6c05 | ||
|
|
c391177d34 | ||
|
|
7d5f0aa906 | ||
|
|
2694a725d6 | ||
|
|
54ca40bbcd | ||
|
|
b20411f8f1 | ||
|
|
355e656caa | ||
|
|
383bdd5f15 | ||
|
|
96208c786d | ||
|
|
4c7b04cf27 | ||
|
|
a067a97e21 | ||
|
|
4a07603a7c | ||
|
|
7196c5b656 | ||
|
|
b5de2df119 | ||
|
|
2f72eb37ee | ||
|
|
0128cd3138 | ||
|
|
157d3093f8 | ||
|
|
4ca188973e | ||
|
|
f387d89a45 | ||
|
|
54567db22f | ||
|
|
2bee68dd40 | ||
|
|
e2b6ea5253 | ||
|
|
9974c5fa20 | ||
|
|
997b706d8a | ||
|
|
3f26412585 | ||
|
|
ac99d77fbb | ||
|
|
4f6f7632f5 | ||
|
|
f74248f0d7 | ||
|
|
bb8a15ca56 | ||
|
|
52432002c7 | ||
|
|
3fade48f8f | ||
|
|
fc81801c4c | ||
|
|
c23c5b2859 | ||
|
|
ccec57e32d | ||
|
|
56ae5fbf70 | ||
|
|
735b44856e | ||
|
|
1f6ea9f494 | ||
|
|
afa643519f | ||
|
|
1767b84026 | ||
|
|
e855e7692e | ||
|
|
94d37eb68a | ||
|
|
e10b19bcde | ||
|
|
e9192e75ea | ||
|
|
2fa4f68b1e | ||
|
|
08f53a4a37 | ||
|
|
c522295c56 | ||
|
|
7a45548387 | ||
|
|
810ea9c421 | ||
|
|
ba6a4fe6d7 | ||
|
|
4d144f7a8e | ||
|
|
45c41184c1 | ||
|
|
5c29c5e7dd | ||
|
|
4da9a84363 | ||
|
|
22d8fb7867 | ||
|
|
c7058cb3e6 | ||
|
|
e6092b2658 | ||
|
|
ae19b72e61 | ||
|
|
da117582d6 | ||
|
|
c7ca1ccbd7 | ||
|
|
911b5c406d | ||
|
|
71ed4b946a | ||
|
|
4ef9fcde59 | ||
|
|
7889b5ad69 | ||
|
|
be6d3ea337 | ||
|
|
64fd715973 | ||
|
|
315f99a03a | ||
|
|
7e1351c543 | ||
|
|
bd3c829653 | ||
|
|
4f6dde02d2 | ||
|
|
8cc7d1f67f | ||
|
|
2bbba9d755 | ||
|
|
e9e4755348 | ||
|
|
9fbb63df95 | ||
|
|
5b5a649589 | ||
|
|
79556affbd | ||
|
|
9cba19d4db | ||
|
|
4f377c04b8 | ||
|
|
763df5606b | ||
|
|
e1d20e3ec9 | ||
|
|
215c082a04 | ||
|
|
984985e650 | ||
|
|
249b3c3245 | ||
|
|
725786d6aa | ||
|
|
2edddaf487 | ||
|
|
49cbab08c1 | ||
|
|
a75df66151 | ||
|
|
43e9c13c5e | ||
|
|
5ad06f121b | ||
|
|
0eaaf7aacb | ||
|
|
dd44fdd1f2 | ||
|
|
669855de70 | ||
|
|
193ae2b7d6 | ||
|
|
af4b23e0e0 | ||
|
|
c35991315d | ||
|
|
9aa852370c | ||
|
|
8f18497551 | ||
|
|
4c59951e8c | ||
|
|
eb2a80d216 | ||
|
|
41d0175a6d | ||
|
|
2f6aa0f45b | ||
|
|
17c685bc4c | ||
|
|
cf230ca6e7 | ||
|
|
bb99853000 | ||
|
|
0c64c8ff52 | ||
|
|
e3e2006c19 | ||
|
|
eddc1b6a8d | ||
|
|
83e1db723e | ||
|
|
76c608c703 | ||
|
|
d61a77bec7 | ||
|
|
a6a2d9991c | ||
|
|
060dd08167 | ||
|
|
dd1d93e096 | ||
|
|
e4b24f51fc | ||
|
|
e472269a4e | ||
|
|
4032276556 | ||
|
|
420537f092 | ||
|
|
3867e536b2 | ||
|
|
4bc7b96ae4 | ||
|
|
9f0338382f | ||
|
|
692c77eb1a | ||
|
|
0778e3e81d | ||
|
|
80e217e839 | ||
|
|
47547ad4e1 | ||
|
|
8b22acce27 | ||
|
|
754ac64bf6 | ||
|
|
3b37d5ae72 | ||
|
|
4e2f24a8f0 | ||
|
|
23a1fbdd4b | ||
|
|
795223e7fa | ||
|
|
10039c6173 | ||
|
|
146b628cc1 | ||
|
|
0c31fcc8a3 | ||
|
|
2c290dbbf7 | ||
|
|
0df8a33b9e | ||
|
|
1278e910f5 | ||
|
|
429e2c6cbe | ||
|
|
00a5cc654a | ||
|
|
d68a0b076b | ||
|
|
99ef8e9310 | ||
|
|
5e549fdb71 | ||
|
|
8f7b026f0e | ||
|
|
fabf33a83b | ||
|
|
211c956c4b | ||
|
|
55d966a52e | ||
|
|
a0d5319cd9 | ||
|
|
d9358b87c4 | ||
|
|
89526d9075 | ||
|
|
b1799d8c06 | ||
|
|
185eaf1211 | ||
|
|
4aa7dbfa9f | ||
|
|
daef59b568 | ||
|
|
be2c30c9e0 | ||
|
|
3b166801d6 | ||
|
|
c289a5f14f | ||
|
|
5dfb4def56 | ||
|
|
c6d70f4dc8 | ||
|
|
254a6e6dbf | ||
|
|
62c010ce13 | ||
|
|
272536a3b5 | ||
|
|
13dc94aca5 | ||
|
|
b9a80f15e6 | ||
|
|
5cab80d842 | ||
|
|
8a4ff3c809 | ||
|
|
5b9e13f35b | ||
|
|
fd5437139b | ||
|
|
26852b6676 | ||
|
|
b8a02cc094 | ||
|
|
f7fa6cf567 | ||
|
|
64e74e87c4 | ||
|
|
f843438baf | ||
|
|
4528f1feaf | ||
|
|
1eae519e1a | ||
|
|
1416fb0f6e | ||
|
|
e9257735ba | ||
|
|
81caf126f7 | ||
|
|
8b9337b45a | ||
|
|
24d909d285 | ||
|
|
fa8f7f83af | ||
|
|
3af68cdb54 | ||
|
|
ed2e305508 | ||
|
|
46a2c3f81b | ||
|
|
b786d507e0 | ||
|
|
8acf8b0b96 | ||
|
|
721e370ad3 | ||
|
|
349c97f06f | ||
|
|
4074b94800 | ||
|
|
7f823ecd7c | ||
|
|
2ae5c9f0d4 | ||
|
|
8614e63b86 | ||
|
|
470d7881cd | ||
|
|
067a5f8415 | ||
|
|
da8c52da37 | ||
|
|
c021e4322a | ||
|
|
705642c3c3 | ||
|
|
1d58810a78 | ||
|
|
109dc26281 | ||
|
|
7bc2bbc1d7 | ||
|
|
a7ec06e066 | ||
|
|
a9e8c79e09 | ||
|
|
ce86e8c31f | ||
|
|
36b81f6dba | ||
|
|
8c8a4d2881 | ||
|
|
93d45bf36f | ||
|
|
71d92c30e3 | ||
|
|
a4d63434cb | ||
|
|
1771bc7dc8 | ||
|
|
0a5f62fe4b | ||
|
|
27836742a8 | ||
|
|
610be1755a | ||
|
|
ee04f4afc8 | ||
|
|
7bcfa78573 | ||
|
|
5d25f972ee | ||
|
|
1716e42ffe | ||
|
|
a36c0eb22f | ||
|
|
06d88219c2 | ||
|
|
548929b2e8 | ||
|
|
c65eb7fac8 | ||
|
|
c323db7e01 | ||
|
|
9cf3db8d81 | ||
|
|
61ef754a1d | ||
|
|
9d692b76bf | ||
|
|
69e143845a | ||
|
|
433a911ef6 | ||
|
|
28ab4e2527 | ||
|
|
38a668fbeb | ||
|
|
fe6c2a2c76 | ||
|
|
6ee2bf2bca | ||
|
|
aa8277dc03 | ||
|
|
6bd9bb7c06 | ||
|
|
8e808903fc | ||
|
|
3d1f1a8379 | ||
|
|
eac4e15ef5 | ||
|
|
80475bd8db | ||
|
|
b4ce1febd5 | ||
|
|
d2cd5e226a | ||
|
|
e2876ed1c5 | ||
|
|
f445959269 | ||
|
|
b308e4632a | ||
|
|
057dcaf2e5 | ||
|
|
58d9c068e4 | ||
|
|
41b2dd82f0 | ||
|
|
6d8d6f05f1 | ||
|
|
c2101824ed | ||
|
|
538468a81d | ||
|
|
431f6aa966 | ||
|
|
8080ae1fb3 | ||
|
|
9822427de8 | ||
|
|
658db55d91 | ||
|
|
1336b93efa | ||
|
|
bf7935e313 | ||
|
|
9732b09cf0 | ||
|
|
80c7d68cf4 | ||
|
|
5892ef222f | ||
|
|
1735baf657 | ||
|
|
8e5e0b0d88 | ||
|
|
12eb00d638 | ||
|
|
8c46078b03 | ||
|
|
c7c3572ecd | ||
|
|
f9ccd10cc9 | ||
|
|
9a0488628a | ||
|
|
b47308cd71 | ||
|
|
64e4c23d12 | ||
|
|
7ad31f532a | ||
|
|
7210cd15f2 | ||
|
|
c72bbaa5f7 | ||
|
|
b817f13212 | ||
|
|
b4581714fe | ||
|
|
e2ce52f580 | ||
|
|
41b9087110 | ||
|
|
d6723e20b8 | ||
|
|
93f80e64cf | ||
|
|
5d579660e3 | ||
|
|
ebaa629342 | ||
|
|
c9f8c93083 | ||
|
|
0941b0aad3 | ||
|
|
7fc829d3a6 | ||
|
|
9d198f7dfe | ||
|
|
404e551f7b | ||
|
|
6ecfb1f239 | ||
|
|
300680d08e | ||
|
|
4bed644a71 | ||
|
|
a9e25889dd | ||
|
|
788e7e6261 | ||
|
|
8a9f70851b | ||
|
|
8a85fe6461 | ||
|
|
db02dbed16 | ||
|
|
d3dfd72a39 | ||
|
|
27d7844004 | ||
|
|
cd395b31bd | ||
|
|
6d908a2d11 | ||
|
|
02a9267fa1 | ||
|
|
bb5f04a9b0 | ||
|
|
32b9b3f31f | ||
|
|
ac922ae879 | ||
|
|
d6af9cd088 | ||
|
|
a0dfbde0d3 | ||
|
|
746882bc73 | ||
|
|
55bab2e255 | ||
|
|
633dbe1aec | ||
|
|
fff7bfc3d2 | ||
|
|
6fdddc201f | ||
|
|
f0375a83bb | ||
|
|
123a2e8998 | ||
|
|
f9a035f380 | ||
|
|
48575f5691 | ||
|
|
3afef6fa99 | ||
|
|
e1635aa39d | ||
|
|
6dd99dbb25 | ||
|
|
a401829ff3 | ||
|
|
55ee480ba1 | ||
|
|
69d24a8b90 | ||
|
|
099ca7ff6c | ||
|
|
2b0e932ca5 | ||
|
|
f1cd0927d8 | ||
|
|
af2b53412d | ||
|
|
a400caa114 | ||
|
|
36e0aece06 | ||
|
|
7534b680a7 | ||
|
|
74708dfa7a | ||
|
|
3c81aced62 | ||
|
|
bdeff3d281 | ||
|
|
64a14a6b2a | ||
|
|
91843382c3 | ||
|
|
16ec5fb997 | ||
|
|
47d9c996aa | ||
|
|
c460d9fd7d | ||
|
|
3533eed5f4 | ||
|
|
4b5526a028 | ||
|
|
b382bd922b | ||
|
|
043bfc8b45 | ||
|
|
f94a04b067 | ||
|
|
4ecdbcb01f | ||
|
|
a3f6dc334f | ||
|
|
b0a7efe9c3 | ||
|
|
4dfa421c1a | ||
|
|
ea12a22575 | ||
|
|
9cc4f25185 | ||
|
|
1b8e049ad3 | ||
|
|
8bd712d891 | ||
|
|
0b581b748b | ||
|
|
01578092e2 | ||
|
|
e44a56e301 | ||
|
|
2bde755fc4 | ||
|
|
3f9eaecf37 | ||
|
|
48dc8dcebf | ||
|
|
d6fde84dc9 | ||
|
|
e5bd5d17ba | ||
|
|
8338582051 | ||
|
|
6eacf0738e | ||
|
|
937ab76183 | ||
|
|
39502b355f | ||
|
|
e75449f19d | ||
|
|
d025fc6abd | ||
|
|
147db1ac0d | ||
|
|
3fc4d9557d | ||
|
|
cad4ee824a | ||
|
|
ec1db8b5e9 | ||
|
|
f4038e879e | ||
|
|
4aa628121c | ||
|
|
f485b1729c | ||
|
|
d8f1c462f1 | ||
|
|
46120a74ed | ||
|
|
f367a6eaaf | ||
|
|
929da600a2 | ||
|
|
b4cc3e4ab8 | ||
|
|
c5c5addcb3 | ||
|
|
7dd39fa363 | ||
|
|
9d48e591af | ||
|
|
86cef9803c | ||
|
|
176a78ced6 | ||
|
|
3b6bb9bd22 | ||
|
|
3370bac67a | ||
|
|
86e6721be5 | ||
|
|
9ee8cc86aa | ||
|
|
0d857d2f0c | ||
|
|
c29c00f4b7 | ||
|
|
66aeb38419 | ||
|
|
5a1e010788 | ||
|
|
779260145c | ||
|
|
52ec3b9887 | ||
|
|
b520b748c6 | ||
|
|
9ffc601cf0 | ||
|
|
0ee7e1d675 | ||
|
|
dafeab8704 | ||
|
|
d10d83b648 | ||
|
|
c59105f050 | ||
|
|
e6433d6fbc | ||
|
|
981037e250 | ||
|
|
ce4a770e23 | ||
|
|
04f1722cce | ||
|
|
898be9e420 | ||
|
|
0934534ac5 | ||
|
|
d67dfe2dfd | ||
|
|
00885c5c97 | ||
|
|
a5de96e08a | ||
|
|
45dadc60e4 | ||
|
|
f5c174b839 | ||
|
|
b41afc152a | ||
|
|
afbfd6b66c | ||
|
|
5cdc316293 | ||
|
|
e352de6744 | ||
|
|
949e3c25a7 | ||
|
|
fdf95297a5 | ||
|
|
7364d580d7 | ||
|
|
4669be6669 | ||
|
|
4a249ba772 | ||
|
|
c93d229bae | ||
|
|
eaefac4be4 | ||
|
|
578fa45bb3 | ||
|
|
4fd50cc3ad | ||
|
|
302877771c | ||
|
|
ac722054d2 | ||
|
|
c7b6e15c1d | ||
|
|
5ee392b11e | ||
|
|
076f3f0e0a | ||
|
|
79c8349747 | ||
|
|
1908a59174 | ||
|
|
d09a3d82b9 | ||
|
|
d4213daa58 | ||
|
|
220b6223a3 | ||
|
|
732bbd8951 | ||
|
|
1b2f19560e | ||
|
|
f13d496b35 | ||
|
|
b3cd10b743 | ||
|
|
0425cdcbb3 | ||
|
|
11349642da | ||
|
|
b871c710b2 | ||
|
|
06b7ae2a38 | ||
|
|
0bddeef63e | ||
|
|
a617424786 | ||
|
|
6a2ab8598b | ||
|
|
7d81dad822 | ||
|
|
818ef0e1f0 | ||
|
|
49d42061be | ||
|
|
7c8e233bb1 | ||
|
|
337dad2ca6 | ||
|
|
57f7cb30b4 | ||
|
|
f3369e8a9b | ||
|
|
c05d5e0238 | ||
|
|
4470b13d18 | ||
|
|
eeda0125bb | ||
|
|
b4f7549b7c | ||
|
|
be76d25b58 | ||
|
|
727c6e6d32 | ||
|
|
47d5e919a2 | ||
|
|
e7124b26df | ||
|
|
ba1d5bfbc0 | ||
|
|
9cd83cd5dc | ||
|
|
5c048a590d | ||
|
|
cfb48b95e4 | ||
|
|
23f83068f1 | ||
|
|
e64b3f2d7d | ||
|
|
af5d12bfee | ||
|
|
e9e425038c | ||
|
|
80a0afc135 | ||
|
|
7eeca73337 | ||
|
|
35f384a0f6 | ||
|
|
1220a0c1ae | ||
|
|
47d8c405dd | ||
|
|
4ff06401d9 | ||
|
|
c2dc38f02f | ||
|
|
2ed3aaa99b | ||
|
|
fc649ded94 | ||
|
|
0d4abe8e8f | ||
|
|
0e1046c0a5 | ||
|
|
2dfccdd2a9 | ||
|
|
ce22f8a2d8 | ||
|
|
6ba44a239d | ||
|
|
fa8f90c493 | ||
|
|
99d3e65df5 | ||
|
|
6ae1eea7b1 | ||
|
|
fcc82360b2 | ||
|
|
c56456203f | ||
|
|
6c251e1a49 | ||
|
|
1f842b49cc | ||
|
|
63631b1118 | ||
|
|
f4685b2831 | ||
|
|
c3ab1bde7e | ||
|
|
cd019750b4 | ||
|
|
7ef81bd9c7 | ||
|
|
08e2a70206 | ||
|
|
f80dffd908 | ||
|
|
dd66622be1 | ||
|
|
07f2a34373 | ||
|
|
b13302775e | ||
|
|
9c238ce7aa | ||
|
|
e4c096295f | ||
|
|
e118a51ae0 | ||
|
|
7f7731a52e | ||
|
|
d3efd02d69 | ||
|
|
80e3693c5f | ||
|
|
858322e1fa | ||
|
|
53a99400c0 | ||
|
|
a37fa5c77c | ||
|
|
8d2ea2f233 | ||
|
|
4b1154209b | ||
|
|
7a6e5376c4 | ||
|
|
6092e768ef | ||
|
|
9ee3832cda | ||
|
|
f71ff7d80c | ||
|
|
f242f71661 | ||
|
|
660dc62f3c | ||
|
|
4cfc3439cb | ||
|
|
adbf44a176 | ||
|
|
451b69072d | ||
|
|
a2716ef62f | ||
|
|
569aaf3c0a | ||
|
|
c3bd196a23 | ||
|
|
5963e28b25 | ||
|
|
2dec061603 | ||
|
|
6b0445763b | ||
|
|
9a597adff3 | ||
|
|
36c5e648e5 | ||
|
|
3de37a7cba | ||
|
|
7b1980f7b7 | ||
|
|
aae839f921 | ||
|
|
24cabd214b | ||
|
|
189ba73f51 | ||
|
|
50979f69eb | ||
|
|
19a3967603 | ||
|
|
d36311cff1 | ||
|
|
a81d5645ea | ||
|
|
1289e15776 | ||
|
|
1f716cb85d | ||
|
|
5e2bb27a47 | ||
|
|
109c77a4b6 | ||
|
|
fb299179e8 | ||
|
|
51bb42c493 | ||
|
|
f18a37ad47 | ||
|
|
df156ad1f6 | ||
|
|
d64ed8c718 | ||
|
|
79b8d17887 | ||
|
|
ec746c021a | ||
|
|
90eca45347 | ||
|
|
efa2fa9eac | ||
|
|
68146ec70b | ||
|
|
e6c1094c08 | ||
|
|
ff32281257 | ||
|
|
4087a7af3c | ||
|
|
b80c55c59c | ||
|
|
8e645d97b3 | ||
|
|
48abf71b29 | ||
|
|
736200bd57 | ||
|
|
33e23655d3 | ||
|
|
79ecd60ea8 | ||
|
|
b6dcf33114 | ||
|
|
4da557fada | ||
|
|
ab03d5e40e | ||
|
|
9a73537dfb | ||
|
|
9020110328 | ||
|
|
e7cb8e2417 | ||
|
|
a0d01d9a55 | ||
|
|
364edbe2ca | ||
|
|
8c2bb231c6 | ||
|
|
368203443f | ||
|
|
8b30308a4b | ||
|
|
a86d56bef5 | ||
|
|
8440d77fd7 | ||
|
|
6cd72f1a56 | ||
|
|
88684c7cf0 | ||
|
|
b2fa0aa2d4 | ||
|
|
46967db3ae | ||
|
|
6744504443 | ||
|
|
d093c0b25b | ||
|
|
55592dbf1d | ||
|
|
40b099a978 | ||
|
|
edf24dbc49 | ||
|
|
90354451d2 | ||
|
|
6a8e41937d | ||
|
|
77f8db7d38 | ||
|
|
8283cd7d02 | ||
|
|
d6b21f4ab5 | ||
|
|
e66eb00bd0 | ||
|
|
680e237ef3 | ||
|
|
fcc3f8e216 | ||
|
|
0d15a28f93 | ||
|
|
4f1a56e66c | ||
|
|
31057377c8 | ||
|
|
b90a90c0c8 | ||
|
|
bb250557a2 | ||
|
|
78199a49ed | ||
|
|
c4f9d29bcb | ||
|
|
e2354b8528 | ||
|
|
2185c3d2e0 | ||
|
|
022580bbb2 | ||
|
|
b1adafec2d | ||
|
|
dc020499b8 | ||
|
|
8e4b162b59 | ||
|
|
6122aa3a3d | ||
|
|
c7936e656b | ||
|
|
992fecb16a | ||
|
|
b1fbdcc566 | ||
|
|
68698217ee | ||
|
|
79fea272aa | ||
|
|
ba1d65f35f | ||
|
|
72c86c3525 | ||
|
|
4d548adbf7 | ||
|
|
554d2ab177 | ||
|
|
8fe40b7a97 | ||
|
|
5dbd16a28d | ||
|
|
e56c0c7fba | ||
|
|
008c369a9b | ||
|
|
4a4e568d4a | ||
|
|
e11a0d5766 | ||
|
|
42c97f6eeb | ||
|
|
b719383943 | ||
|
|
542512fc58 | ||
|
|
c6346b7b6f | ||
|
|
18321d6e5a | ||
|
|
9e551edf31 | ||
|
|
da73f26ebe | ||
|
|
cd266d2567 | ||
|
|
d103813311 | ||
|
|
ddd8b6b63d | ||
|
|
909b10f422 | ||
|
|
75142b33a4 | ||
|
|
7008774bb5 | ||
|
|
7631c237e9 | ||
|
|
7cb987434e | ||
|
|
07e4f34913 | ||
|
|
55a6cdcf10 | ||
|
|
f6475e7c7f | ||
|
|
05a92f0b0d | ||
|
|
524c7144d3 | ||
|
|
d1feb502df | ||
|
|
a627aa9915 | ||
|
|
a8170a499a | ||
|
|
e5660a0d91 | ||
|
|
841d1a31bf | ||
|
|
9b0916f0ed | ||
|
|
943cf2f9f9 | ||
|
|
cfa08556fa | ||
|
|
14c4d3c862 | ||
|
|
ff0606b896 | ||
|
|
45362a9819 | ||
|
|
df3f105cf0 | ||
|
|
b6641b2776 | ||
|
|
7067da7a8a | ||
|
|
a16810ed6d | ||
|
|
82e15cb3e1 | ||
|
|
03e9077c9a | ||
|
|
9e82e2837d | ||
|
|
b721050c4d | ||
|
|
b31ed9b920 | ||
|
|
eab475a631 | ||
|
|
25311a729d | ||
|
|
638f390308 | ||
|
|
c52dddfa67 | ||
|
|
f79adc9bc0 | ||
|
|
ef793f278a | ||
|
|
a03b131057 | ||
|
|
4b84124801 | ||
|
|
4bb0974c4a | ||
|
|
810891236b | ||
|
|
5821cf0061 | ||
|
|
f50c473cf6 | ||
|
|
9c5da23a38 | ||
|
|
14bbb8c65d | ||
|
|
bfa111541b | ||
|
|
c8971dd0ef | ||
|
|
86bf7ea73a | ||
|
|
f3fd02fcb3 | ||
|
|
07bdcdc91b | ||
|
|
72311617d9 | ||
|
|
1184c7d60e | ||
|
|
d027a9a2ba | ||
|
|
b6aac773ea | ||
|
|
2565373db6 | ||
|
|
958993f81f | ||
|
|
e359e1c544 | ||
|
|
e3329597bc | ||
|
|
6c3311ba3c | ||
|
|
5beb93dde2 | ||
|
|
4d560a3764 | ||
|
|
53e9af1a62 | ||
|
|
ed75ecc63b | ||
|
|
4f1bdf5338 | ||
|
|
157fff8481 | ||
|
|
c101dfb694 | ||
|
|
1e1fce4c77 | ||
|
|
f8431c787f | ||
|
|
7add6ab190 | ||
|
|
4720bda29b | ||
|
|
3c0dca6992 | ||
|
|
6a4897b0aa | ||
|
|
8a5cb6c946 | ||
|
|
1bca3a182e | ||
|
|
417ad81aa4 | ||
|
|
68433c922b | ||
|
|
88961e4ab7 | ||
|
|
ad3670c9ad | ||
|
|
7aefd0df1a | ||
|
|
1af83c1aeb | ||
|
|
44336c2ea2 | ||
|
|
ba9feb0941 | ||
|
|
2538944701 | ||
|
|
42f904e25a | ||
|
|
c492796cf8 | ||
|
|
bc8a2511d1 | ||
|
|
6f1e5074ed | ||
|
|
7b9456453c | ||
|
|
53cfb2e755 | ||
|
|
4ac5ff7cf0 | ||
|
|
3c19a07226 | ||
|
|
034645f50c | ||
|
|
5865a958fc | ||
|
|
cfe4fa7a92 | ||
|
|
12b7f806f9 | ||
|
|
a44c4d96d8 | ||
|
|
1215e3bb30 | ||
|
|
6dec845848 | ||
|
|
37df602ae8 | ||
|
|
7fb42d7b47 | ||
|
|
bf82fe743c | ||
|
|
2c2228192f | ||
|
|
226bf9d8d2 | ||
|
|
46fda7ecfb | ||
|
|
6da0445509 | ||
|
|
f0274701cf | ||
|
|
d100edb75b | ||
|
|
c7c5f75d17 | ||
|
|
e0f628c59f | ||
|
|
62dfae8fc8 | ||
|
|
fecba858a5 | ||
|
|
9114df9c2a | ||
|
|
e003d74506 | ||
|
|
a225d2d79a | ||
|
|
94b5a7fae4 | ||
|
|
3d2d4318c7 | ||
|
|
2f34e1727f | ||
|
|
b359c7d990 | ||
|
|
5cf174be84 | ||
|
|
f2a2c7996f | ||
|
|
d005e7b4c9 | ||
|
|
e59072e5a7 | ||
|
|
370463366b | ||
|
|
9f4d9a3f00 | ||
|
|
9b36f047fd | ||
|
|
0f70d37950 | ||
|
|
1ae5f945b1 | ||
|
|
25b189069c | ||
|
|
bdece10868 | ||
|
|
636e149b29 | ||
|
|
82d8997217 | ||
|
|
256c4ceecc | ||
|
|
1e9494fa2b | ||
|
|
0e5d6e825e | ||
|
|
865b6cba3f | ||
|
|
d6c5cab08d | ||
|
|
c0b39ffcbf | ||
|
|
fafa042ee9 | ||
|
|
cabca70ee5 | ||
|
|
8d28b7db94 | ||
|
|
45c9aaa591 | ||
|
|
b277fc0fa5 | ||
|
|
9cdc4a7303 | ||
|
|
ef03a75aea | ||
|
|
2ef7b8b3b1 | ||
|
|
afcf509ec0 | ||
|
|
f3fac23a84 | ||
|
|
d91ce3da65 | ||
|
|
ed2f5c42d0 | ||
|
|
a1b1790935 | ||
|
|
87be4af655 |
@@ -47,4 +47,4 @@ body:
|
|||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: "Additional Information"
|
label: "Additional Information"
|
||||||
description: "If you have any additional information to provide, you can include it here (screenshots, videos, etc., are welcome)."
|
description: "If you have any additional information to provide, you can include it here (screenshots, videos, etc., are welcome)."
|
||||||
@@ -2,4 +2,4 @@ blank_issues_enabled: false
|
|||||||
contact_links:
|
contact_links:
|
||||||
- name: Questions & Discussions
|
- name: Questions & Discussions
|
||||||
url: https://github.com/1Panel-dev/1Panel/discussions
|
url: https://github.com/1Panel-dev/1Panel/discussions
|
||||||
about: Raise questions about the installation, deployment, use and other aspects of the project.
|
about: Raise questions about the installation, deployment, use and other aspects of the project.
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
name: General PR Handling for 1Panel
|
name: General PR Handling for 1Panel
|
||||||
on: pull_request
|
on: pull_request
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '22.19.0'
|
node-version: '20.2'
|
||||||
- name: Build Web
|
- name: Build Web
|
||||||
run: |
|
run: |
|
||||||
cd frontend && npm install && npm run build:pro
|
cd frontend && npm install && npm run build:pro
|
||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: '1.23'
|
||||||
- name: Build Release
|
- name: Build Release
|
||||||
uses: goreleaser/goreleaser-action@v6
|
uses: goreleaser/goreleaser-action@v6
|
||||||
with:
|
with:
|
||||||
@@ -44,4 +44,4 @@ jobs:
|
|||||||
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
|
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
|
||||||
ossutil-version: '1.7.18'
|
ossutil-version: '1.7.18'
|
||||||
- name: Upload Assets to OSS
|
- name: Upload Assets to OSS
|
||||||
run: ossutil cp -r dist/ oss://resource-fit2cloud-com/1panel/package/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --only-current-dir --force
|
run: ossutil cp -r dist/ oss://resource-fit2cloud-com/1panel/package/v2/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --only-current-dir --force
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '22.19.0'
|
node-version: '20.2'
|
||||||
- name: Build Web
|
- name: Build Web
|
||||||
run: |
|
run: |
|
||||||
cd frontend && npm install && npm run build:pro
|
cd frontend && npm install && npm run build:pro
|
||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: '1.23'
|
||||||
- name: Build Release
|
- name: Build Release
|
||||||
uses: goreleaser/goreleaser-action@v6
|
uses: goreleaser/goreleaser-action@v6
|
||||||
with:
|
with:
|
||||||
@@ -42,4 +42,4 @@ jobs:
|
|||||||
rclone_config: ${{ secrets.RCLONE_CONFIG }}
|
rclone_config: ${{ secrets.RCLONE_CONFIG }}
|
||||||
- name: Upload to Cloudflare R2
|
- name: Upload to Cloudflare R2
|
||||||
run: |
|
run: |
|
||||||
rclone copy dist/ cloudflare_r2:package/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --progress
|
rclone copy dist/ cloudflare_r2:package/v2/stable/${{ github.ref_name }}/release/ --include "*.tar.gz" --include "checksums.txt" --progress
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ jobs:
|
|||||||
- uses: usthe/issues-translate-action@v2.7
|
- uses: usthe/issues-translate-action@v2.7
|
||||||
with:
|
with:
|
||||||
IS_MODIFY_TITLE: true
|
IS_MODIFY_TITLE: true
|
||||||
BOT_GITHUB_TOKEN: ${{ secrets.ISSUE_TRANSLATOR_TOKEN }}
|
BOT_GITHUB_TOKEN: ${{ secrets.ISSUE_TRANSLATOR_TOKEN }}
|
||||||
@@ -22,4 +22,4 @@ jobs:
|
|||||||
# max_tokens: 10000
|
# max_tokens: 10000
|
||||||
MAX_PATCH_LENGTH: 10000
|
MAX_PATCH_LENGTH: 10000
|
||||||
IGNORE_PATTERNS: "/node_modules,*.md,/dist,/.github"
|
IGNORE_PATTERNS: "/node_modules,*.md,/dist,/.github"
|
||||||
FILE_PATTERNS: "*.java,*.go,*.py,*.vue,*.ts,*.js,*.css,*.scss,*.html"
|
FILE_PATTERNS: "*.java,*.go,*.py,*.vue,*.ts,*.js,*.css,*.scss,*.html"
|
||||||
@@ -17,4 +17,4 @@ jobs:
|
|||||||
uses: SonarSource/sonarcloud-github-action@master
|
uses: SonarSource/sonarcloud-github-action@master
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
@@ -12,4 +12,4 @@ jobs:
|
|||||||
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
|
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
|
||||||
dst_token: ${{ secrets.GITEE_TOKEN }}
|
dst_token: ${{ secrets.GITEE_TOKEN }}
|
||||||
static_list: "1Panel"
|
static_list: "1Panel"
|
||||||
force_update: true
|
force_update: true
|
||||||
@@ -8,4 +8,4 @@ jobs:
|
|||||||
- name: Checkout Actions Repository
|
- name: Checkout Actions Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Check spelling
|
- name: Check spelling
|
||||||
uses: crate-ci/typos@master
|
uses: crate-ci/typos@master
|
||||||
+21
-7
@@ -4,7 +4,8 @@
|
|||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
build/1panel
|
build/1panel-agent
|
||||||
|
build/1panel-core
|
||||||
|
|
||||||
# Mac
|
# Mac
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@@ -14,6 +15,7 @@ build/1panel
|
|||||||
.vscode
|
.vscode
|
||||||
*.project
|
*.project
|
||||||
*.factorypath
|
*.factorypath
|
||||||
|
__debug*
|
||||||
|
|
||||||
# IntelliJ IDEA
|
# IntelliJ IDEA
|
||||||
.idea/*
|
.idea/*
|
||||||
@@ -22,6 +24,7 @@ build/1panel
|
|||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
@@ -31,15 +34,23 @@ build/1panel
|
|||||||
# Dependency directories
|
# Dependency directories
|
||||||
/pkg/
|
/pkg/
|
||||||
backend/__debug_bin
|
backend/__debug_bin
|
||||||
cmd/server/__debug_bin
|
core/cmd/server/__debug_bin
|
||||||
cmd/server/web/assets
|
core/cmd/server/web/assets
|
||||||
cmd/server/web/monacoeditorwork
|
core/cmd/server/web/monacoeditorwork
|
||||||
cmd/server/web/index.html
|
core/cmd/server/web/index.html
|
||||||
frontend/auto-imports.d.ts
|
frontend/auto-imports.d.ts
|
||||||
frontend/components.d.ts
|
frontend/components.d.ts
|
||||||
frontend/src/xpack
|
frontend/src/xpack
|
||||||
backend/xpack
|
agent/xpack
|
||||||
*_xpack.go
|
agent/router/entry_xpack.go
|
||||||
|
agent/server/init_xpack.go
|
||||||
|
agent/utils/xpack/xpack_xpack.go
|
||||||
|
core/xpack
|
||||||
|
core/router/entry_xpack.go
|
||||||
|
core/server/init_xpack.go
|
||||||
|
core/utils/xpack/xpack_xpack.go
|
||||||
|
xpack
|
||||||
|
|
||||||
.history/
|
.history/
|
||||||
dist/
|
dist/
|
||||||
1pctl
|
1pctl
|
||||||
@@ -49,3 +60,6 @@ quick_start.sh
|
|||||||
cmd/server/fileList.txt
|
cmd/server/fileList.txt
|
||||||
.fileList.txt
|
.fileList.txt
|
||||||
1Panel.code-workspace
|
1Panel.code-workspace
|
||||||
|
|
||||||
|
core/.golangci.yml
|
||||||
|
agent/.golangci.yml
|
||||||
+37
-8
@@ -9,11 +9,12 @@ before:
|
|||||||
- chmod +x ./ci/script.sh
|
- chmod +x ./ci/script.sh
|
||||||
- ./ci/script.sh
|
- ./ci/script.sh
|
||||||
- sed -i 's@ORIGINAL_VERSION=.*@ORIGINAL_VERSION=v{{ .Version }}@g' 1pctl
|
- sed -i 's@ORIGINAL_VERSION=.*@ORIGINAL_VERSION=v{{ .Version }}@g' 1pctl
|
||||||
- go mod tidy
|
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
- main: ./cmd/server/main.go
|
- id: agent
|
||||||
binary: 1panel
|
dir: agent
|
||||||
|
main: cmd/server/main.go
|
||||||
|
binary: 1panel-agent
|
||||||
flags:
|
flags:
|
||||||
- -tags=xpack
|
- -tags=xpack
|
||||||
- -trimpath
|
- -trimpath
|
||||||
@@ -31,19 +32,47 @@ builds:
|
|||||||
- arm
|
- arm
|
||||||
- ppc64le
|
- ppc64le
|
||||||
- s390x
|
- s390x
|
||||||
- riscv64
|
hooks:
|
||||||
|
post:
|
||||||
|
- ./ci/script.sh compress_binary {{ .Path }} {{ .Arch }}
|
||||||
|
|
||||||
|
- id: core
|
||||||
|
dir: core
|
||||||
|
main: cmd/server/main.go
|
||||||
|
binary: 1panel-core
|
||||||
|
flags:
|
||||||
|
- -tags=xpack
|
||||||
|
- -trimpath
|
||||||
|
ldflags:
|
||||||
|
- -w -s
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarm:
|
||||||
|
- 7
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm64
|
||||||
|
- arm
|
||||||
|
- ppc64le
|
||||||
|
- s390x
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- ./ci/script.sh compress_binary {{ .Path }} {{ .Arch }}
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- formats: [ 'tar.gz' ]
|
- formats: [ 'tar.gz' ]
|
||||||
|
ids: [core, agent]
|
||||||
name_template: "1panel-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}"
|
name_template: "1panel-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}"
|
||||||
wrap_in_directory: true
|
wrap_in_directory: true
|
||||||
files:
|
files:
|
||||||
- 1pctl
|
- 1pctl
|
||||||
|
- 1panel-core.service
|
||||||
|
- 1panel-agent.service
|
||||||
- install.sh
|
- install.sh
|
||||||
- 1panel.service
|
|
||||||
- initscript/*
|
|
||||||
- lang/*
|
|
||||||
- GeoIP.mmdb
|
- GeoIP.mmdb
|
||||||
|
- lang/*
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: 'checksums.txt'
|
name_template: 'checksums.txt'
|
||||||
|
|||||||
Generated
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 6.1 KiB |
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"ansible.python.interpreterPath": "/opt/homebrew/bin/python3"
|
||||||
|
}
|
||||||
@@ -2,33 +2,48 @@ GOCMD=go
|
|||||||
GOBUILD=$(GOCMD) build
|
GOBUILD=$(GOCMD) build
|
||||||
GOCLEAN=$(GOCMD) clean
|
GOCLEAN=$(GOCMD) clean
|
||||||
GOARCH=$(shell go env GOARCH)
|
GOARCH=$(shell go env GOARCH)
|
||||||
GOOS=$(shell go env GOOS)
|
GOOS=$(shell go env GOOS )
|
||||||
|
|
||||||
BASE_PATH := $(shell pwd)
|
BASE_PATH := $(shell pwd)
|
||||||
BUILD_PATH = $(BASE_PATH)/build
|
BUILD_PATH = $(BASE_PATH)/build
|
||||||
WEB_PATH=$(BASE_PATH)/frontend
|
WEB_PATH=$(BASE_PATH)/frontend
|
||||||
SERVER_PATH=$(BASE_PATH)/backend
|
ASSERT_PATH= $(BASE_PATH)/core/cmd/server/web/assets
|
||||||
MAIN= $(BASE_PATH)/cmd/server/main.go
|
|
||||||
APP_NAME=1panel
|
CORE_PATH=$(BASE_PATH)/core
|
||||||
ASSERT_PATH= $(BASE_PATH)/cmd/server/web/assets
|
CORE_MAIN=$(CORE_PATH)/cmd/server/main.go
|
||||||
|
CORE_NAME=1panel-core
|
||||||
|
|
||||||
|
AGENT_PATH=$(BASE_PATH)/agent
|
||||||
|
AGENT_MAIN=$(AGENT_PATH)/cmd/server/main.go
|
||||||
|
AGENT_NAME=1panel-agent
|
||||||
|
|
||||||
|
|
||||||
clean_assets:
|
clean_assets:
|
||||||
rm -rf $(ASSERT_PATH)
|
rm -rf $(ASSERT_PATH)
|
||||||
|
|
||||||
upx_bin:
|
upx_bin:
|
||||||
upx $(BUILD_PATH)/$(APP_NAME)
|
upx $(BUILD_PATH)/$(CORE_NAME)
|
||||||
|
upx $(BUILD_PATH)/$(AGENT_NAME)
|
||||||
|
|
||||||
build_frontend:
|
build_frontend:
|
||||||
cd $(WEB_PATH) && npm install && npm run build:pro
|
cd $(WEB_PATH) && npm install && npm run build:pro
|
||||||
|
|
||||||
build_backend_on_linux:
|
build_core_on_linux:
|
||||||
cd $(SERVER_PATH) \
|
cd $(CORE_PATH) \
|
||||||
&& CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)
|
&& GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(CORE_NAME) $(CORE_MAIN)
|
||||||
|
|
||||||
build_backend_on_darwin:
|
build_agent_on_linux:
|
||||||
cd $(SERVER_PATH) \
|
cd $(AGENT_PATH) \
|
||||||
&& GOOS=linux GOARCH=amd64 $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)
|
&& GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(AGENT_NAME) $(AGENT_MAIN)
|
||||||
|
|
||||||
build_all: build_frontend build_backend_on_linux
|
build_core_on_darwin:
|
||||||
|
cd $(CORE_PATH) \
|
||||||
|
&& GOOS=linux GOARCH=amd64 $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(CORE_NAME) $(CORE_MAIN)
|
||||||
|
|
||||||
build_on_local: clean_assets build_frontend build_backend_on_darwin
|
build_agent_on_darwin:
|
||||||
|
cd $(AGENT_PATH) \
|
||||||
|
&& GOOS=linux GOARCH=amd64 $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(AGENT_NAME) $(AGENT_MAIN)
|
||||||
|
|
||||||
|
build_all: build_frontend build_core_on_linux build_agent_on_linux
|
||||||
|
|
||||||
|
build_on_local: clean_assets build_frontend build_core_on_darwin build_agent_on_darwin upx_bin
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p align="center"><a href="https://1panel.pro"><img src="https://resource.1panel.pro/img/1panel-logo.png" alt="1Panel" width="300" /></a></p>
|
<p align="center"><a href="https://1panel.pro"><img src="https://resource.1panel.pro/img/1panel-logo.png" alt="1Panel" width="300" /></a></p>
|
||||||
<p align="center"><b>Simplify Linux Server Management</b></p>
|
<p align="center"><b>Top-Rated Web-based Linux Server Management Tool</b><br>Best VPS control panel<br>新一代的 Linux 服务器运维管理面板</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://trendshift.io/repositories/2462" target="_blank"><img src="https://trendshift.io/api/badge/repositories/2462" alt="1Panel-dev%2F1Panel | Trendshift" style="width: 240px; height: auto;" /></a>
|
<a href="https://trendshift.io/repositories/2462" target="_blank"><img src="https://trendshift.io/api/badge/repositories/2462" alt="1Panel-dev%2F1Panel | Trendshift" style="width: 240px; height: auto;" /></a>
|
||||||
</p>
|
</p>
|
||||||
@@ -31,14 +31,13 @@
|
|||||||
|
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
1Panel provides an intuitive web interface and MCP Server to manage websites, files, containers, databases, and LLMs on a Linux server.
|
1Panel is an open-source, modern web-based control panel for Linux server management.
|
||||||
|
|
||||||
- **Efficient Management**: Through a user-friendly web graphical interface, 1Panel enables users to effortlessly manage their Linux servers. Key features include host monitoring, file management, database administration, container management, LLMs management.
|
- **Efficient Management**: Through a user-friendly web graphical interface, 1Panel enables users to effortlessly manage their Linux servers. Key features include host monitoring, file management, database administration, container management, LLMs management.
|
||||||
- **Rapid Website Deployment**: With deep integration of the popular open-source website building software WordPress, 1Panel streamlines the process of domain binding and SSL certificate configuration, all achievable with just one click.
|
- **Rapid Website Deployment**: With deep integration of the popular open-source website building software WordPress, 1Panel streamlines the process of domain binding and SSL certificate configuration, all achievable with just one click.
|
||||||
- **Application Store**: 1Panel curates a wide range of high-quality open-source tools and applications, facilitating easy installation and updates for its users.
|
- **Application Store**: 1Panel curates a wide range of high-quality open-source tools and applications, facilitating easy installation and updates for its users.
|
||||||
- **Security and Reliability**: By leveraging containerization and secure application deployment practices, 1Panel minimizes vulnerability exposure. It further enhances security through integrated firewall management and log auditing capabilities.
|
- **Security and Reliability**: By leveraging containerization and secure application deployment practices, 1Panel minimizes vulnerability exposure. It further enhances security through integrated firewall management and log auditing capabilities.
|
||||||
- **One-Click Backup & Restore**: Data protection is made simple with 1Panel's one-click backup and restore functionality, supporting various cloud storage solutions to ensure data integrity and availability.
|
- **One-Click Backup & Restore**: Data protection is made simple with 1Panel's one-click backup and restore functionality, supporting various cloud storage solutions to ensure data integrity and availability.
|
||||||
- **MCP Server**: [1Panel MCP Server](https://github.com/1Panel-dev/mcp-1panel) allow user to execute server operations via natural language.
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ curl -sSL https://resource.1panel.pro/quick_start.sh -o quick_start.sh && bash q
|
|||||||
|
|
||||||
Please refer to our [documentation](https://docs.1panel.pro/quick_start/) for more details.
|
Please refer to our [documentation](https://docs.1panel.pro/quick_start/) for more details.
|
||||||
|
|
||||||
中国用户请使用此 [安装脚本](https://1panel.cn/docs/v2/installation/online_installation/),默认安装 V2 版本,应用数量相较国际版本更丰富。
|
中国用户请使用这个 [安装脚本](https://1panel.cn/docs/installation/online_installation/),其应用数量比国际版本更丰富。
|
||||||
|
|
||||||
## Screenshot
|
## Screenshot
|
||||||
|
|
||||||
@@ -62,26 +61,16 @@ Please refer to our [documentation](https://docs.1panel.pro/quick_start/) for mo
|
|||||||
|
|
||||||
## Pro Edition
|
## Pro Edition
|
||||||
|
|
||||||
Compared to the OSS Edition, 1Panel Pro Edition provides users with a wealth of enhanced features and technical support services. Enhanced features include WAF enhancement, Website monitoring, Mobile APP, custom logo and theme, etc.
|
Compared to the OSS Edition, 1Panel Pro Edition provides users with a wealth of enhanced features and technical support services. Enhanced features include WAF enhancement, website tamper protection, website monitoring, GPU monitoring, custom logo and theme color, etc. [Click to view the detailed introduction of the Pro Edition](https://1panel.pro/pricing).
|
||||||
|
|
||||||
[Click to see Pro Edition details](https://1panel.pro/pricing).
|
|
||||||
|
|
||||||
## Security Information
|
## Security Information
|
||||||
|
|
||||||
If you discover any security issues, please refer to [SECURITY.md](/SECURITY.md).
|
If you discover any security issues, please refer to [SECURITY.md](/SECURITY.md).
|
||||||
|
|
||||||
## GitAds Sponsored
|
|
||||||
|
|
||||||
[](https://gitads.dev/v1/ad-track?source=1panel-dev/1panel@github)
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Licensed under The GNU General Public License version 3 (GPLv3) (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
Licensed under The GNU General Public License version 3 (GPLv3) (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
<https://www.gnu.org/licenses/gpl-3.0.html>
|
<https://www.gnu.org/licenses/gpl-3.0.html>
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
<!-- GitAds-Verify: 9M8AMBB11GYJ3RUNXGB5R1MR71KPATU9 -->
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/agent/utils/ai_tools/gpu"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu"
|
"github.com/1Panel-dev/1Panel/agent/utils/ai_tools/gpu/common"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/gpu/common"
|
"github.com/1Panel-dev/1Panel/agent/utils/ai_tools/xpu"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/ai_tools/xpu"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,8 +24,8 @@ func (b *BaseApi) CreateOllamaModel(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := AIToolService.Create(req.Name); err != nil {
|
if err := aiToolService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.SuccessWithData(c, nil)
|
||||||
@@ -47,8 +46,8 @@ func (b *BaseApi) RecreateOllamaModel(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := AIToolService.Recreate(req.Name); err != nil {
|
if err := aiToolService.Recreate(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.SuccessWithData(c, nil)
|
||||||
@@ -69,8 +68,8 @@ func (b *BaseApi) CloseOllamaModel(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := AIToolService.Close(req.Name); err != nil {
|
if err := aiToolService.Close(req.Name); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.SuccessWithData(c, nil)
|
||||||
@@ -84,9 +83,9 @@ func (b *BaseApi) CloseOllamaModel(c *gin.Context) {
|
|||||||
// @Router /ai/ollama/model/sync [post]
|
// @Router /ai/ollama/model/sync [post]
|
||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步 Ollama 模型列表","formatEN":"sync Ollama model list"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步 Ollama 模型列表","formatEN":"sync Ollama model list"}
|
||||||
func (b *BaseApi) SyncOllamaModel(c *gin.Context) {
|
func (b *BaseApi) SyncOllamaModel(c *gin.Context) {
|
||||||
list, err := AIToolService.Sync()
|
list, err := aiToolService.Sync()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
@@ -106,9 +105,9 @@ func (b *BaseApi) SearchOllamaModel(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
total, list, err := AIToolService.Search(req)
|
total, list, err := aiToolService.Search(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,9 +131,9 @@ func (b *BaseApi) LoadOllamaModelDetail(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
detail, err := AIToolService.LoadDetail(req.Name)
|
detail, err := aiToolService.LoadDetail(req.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,12 +155,12 @@ func (b *BaseApi) DeleteOllamaModel(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := AIToolService.Delete(req); err != nil {
|
if err := aiToolService.Delete(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags AI
|
// @Tags AI
|
||||||
@@ -176,7 +175,7 @@ func (b *BaseApi) LoadGpuInfo(c *gin.Context) {
|
|||||||
if ok {
|
if ok {
|
||||||
info, err := client.LoadGpuInfo()
|
info, err := client.LoadGpuInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, info)
|
helper.SuccessWithData(c, info)
|
||||||
@@ -186,7 +185,7 @@ func (b *BaseApi) LoadGpuInfo(c *gin.Context) {
|
|||||||
if xpuOK {
|
if xpuOK {
|
||||||
info, err := xpuClient.LoadGpuInfo()
|
info, err := xpuClient.LoadGpuInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, info)
|
helper.SuccessWithData(c, info)
|
||||||
@@ -208,11 +207,11 @@ func (b *BaseApi) BindDomain(c *gin.Context) {
|
|||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := AIToolService.BindDomain(req); err != nil {
|
if err := aiToolService.BindDomain(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags AI
|
// @Tags AI
|
||||||
@@ -228,9 +227,9 @@ func (b *BaseApi) GetBindDomain(c *gin.Context) {
|
|||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res, err := AIToolService.GetBindDomain(req)
|
res, err := aiToolService.GetBindDomain(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -249,9 +248,9 @@ func (b *BaseApi) UpdateBindDomain(c *gin.Context) {
|
|||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := AIToolService.UpdateBindDomain(req); err != nil {
|
if err := aiToolService.UpdateBindDomain(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (b *BaseApi) PageAlert(c *gin.Context) {
|
||||||
|
var req dto.AlertSearch
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
total, alerts, err := alertService.PageAlert(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
|
Total: total,
|
||||||
|
Items: alerts,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetAlerts(c *gin.Context) {
|
||||||
|
alerts, err := alertService.GetAlerts()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, alerts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) CreateAlert(c *gin.Context) {
|
||||||
|
var req dto.AlertCreate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := alertService.CreateAlert(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) DeleteAlert(c *gin.Context) {
|
||||||
|
var req dto.DeleteRequest
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := alertService.DeleteAlert(req.ID)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) UpdateAlert(c *gin.Context) {
|
||||||
|
var req dto.AlertUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := alertService.UpdateAlert(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetAlert(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, errors.New("no such id in request param"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
alert, err := alertService.GetAlert(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, alert)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) UpdateAlertStatus(c *gin.Context) {
|
||||||
|
var req dto.AlertUpdateStatus
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := alertService.UpdateStatus(req.ID, req.Status); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetDisks(c *gin.Context) {
|
||||||
|
alerts, err := alertService.GetDisks()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, alerts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) PageAlertLogs(c *gin.Context) {
|
||||||
|
var req dto.AlertLogSearch
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
total, alertLogs, err := alertService.PageAlertLogs(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
|
Total: total,
|
||||||
|
Items: alertLogs,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) CleanAlertLogs(c *gin.Context) {
|
||||||
|
if err := alertService.CleanAlertLogs(); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetClams(c *gin.Context) {
|
||||||
|
clams, err := alertService.GetClams()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, clams)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetCronJobs(c *gin.Context) {
|
||||||
|
var req dto.CronJobReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cronJobs, err := alertService.GetCronJobs(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, cronJobs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetAlertConfig(c *gin.Context) {
|
||||||
|
config, err := alertService.GetAlertConfig()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) UpdateAlertConfig(c *gin.Context) {
|
||||||
|
var req dto.AlertConfigUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := alertService.UpdateAlertConfig(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) DeleteAlertConfig(c *gin.Context) {
|
||||||
|
var req dto.DeleteRequest
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := alertService.DeleteAlertConfig(req.ID)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) TestAlertConfig(c *gin.Context) {
|
||||||
|
var req dto.AlertConfigTest
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
flag, err := alertService.TestAlertConfig(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, flag)
|
||||||
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/agent/i18n"
|
||||||
"github.com/1Panel-dev/1Panel/backend/i18n"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,27 +23,29 @@ func (b *BaseApi) SearchApp(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
list, err := appService.PageApp(c, req)
|
list, err := appService.PageApp(c, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags App
|
// @Tags App
|
||||||
// @Summary Sync app list
|
// @Summary Sync remote app list
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/sync [post]
|
// @Router /apps/sync/remote [post]
|
||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"}
|
||||||
func (b *BaseApi) SyncApp(c *gin.Context) {
|
func (b *BaseApi) SyncApp(c *gin.Context) {
|
||||||
go appService.SyncAppListFromLocal()
|
var req dto.OperateWithTask
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
res, err := appService.GetAppUpdate()
|
res, err := appService.GetAppUpdate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !res.CanUpdate {
|
if !res.CanUpdate {
|
||||||
if res.IsSyncing {
|
if res.IsSyncing {
|
||||||
helper.SuccessWithMsg(c, i18n.GetMsgByKey("AppStoreIsSyncing"))
|
helper.SuccessWithMsg(c, i18n.GetMsgByKey("AppStoreIsSyncing"))
|
||||||
@@ -53,12 +54,27 @@ func (b *BaseApi) SyncApp(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go func() {
|
if err = appService.SyncAppListFromRemote(req.TaskID); err != nil {
|
||||||
if err := appService.SyncAppListFromRemote(); err != nil {
|
helper.InternalServer(c, err)
|
||||||
global.LOG.Errorf("Synchronization with the App Store failed [%s]", err.Error())
|
return
|
||||||
}
|
}
|
||||||
}()
|
helper.Success(c)
|
||||||
helper.SuccessWithData(c, "")
|
}
|
||||||
|
|
||||||
|
// @Tags App
|
||||||
|
// @Summary Sync local app list
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /apps/sync/local [post]
|
||||||
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"}
|
||||||
|
func (b *BaseApi) SyncLocalApp(c *gin.Context) {
|
||||||
|
var req dto.OperateWithTask
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
go appService.SyncAppListFromLocal(req.TaskID)
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags App
|
// @Tags App
|
||||||
@@ -68,16 +84,16 @@ func (b *BaseApi) SyncApp(c *gin.Context) {
|
|||||||
// @Success 200 {object} response.AppDTO
|
// @Success 200 {object} response.AppDTO
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/{key} [get]
|
// @Router /apps/:key [get]
|
||||||
func (b *BaseApi) GetApp(c *gin.Context) {
|
func (b *BaseApi) GetApp(c *gin.Context) {
|
||||||
appKey, err := helper.GetStrParamByKey(c, "key")
|
appKey, err := helper.GetStrParamByKey(c, "key")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
appDTO, err := appService.GetApp(c, appKey)
|
appDTO, err := appService.GetApp(c, appKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, appDTO)
|
helper.SuccessWithData(c, appDTO)
|
||||||
@@ -87,23 +103,23 @@ func (b *BaseApi) GetApp(c *gin.Context) {
|
|||||||
// @Summary Search app detail by appid
|
// @Summary Search app detail by appid
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param appId path integer true "app id"
|
// @Param appId path integer true "app id"
|
||||||
// @Param version path string true "app version"
|
// @Param version path string true "app 版本"
|
||||||
// @Param type path string true "app type"
|
// @Param version path string true "app 类型"
|
||||||
// @Success 200 {object} response.AppDetailDTO
|
// @Success 200 {object} response.AppDetailDTO
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/detail/{appId}/{version}/{type} [get]
|
// @Router /apps/detail/:appId/:version/:type [get]
|
||||||
func (b *BaseApi) GetAppDetail(c *gin.Context) {
|
func (b *BaseApi) GetAppDetail(c *gin.Context) {
|
||||||
appID, err := helper.GetIntParamByKey(c, "appId")
|
appID, err := helper.GetIntParamByKey(c, "appId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
version := c.Param("version")
|
version := c.Param("version")
|
||||||
appType := c.Param("type")
|
appType := c.Param("type")
|
||||||
appDetailDTO, err := appService.GetAppDetail(appID, version, appType)
|
appDetailDTO, err := appService.GetAppDetail(appID, version, appType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, appDetailDTO)
|
helper.SuccessWithData(c, appDetailDTO)
|
||||||
@@ -112,41 +128,25 @@ func (b *BaseApi) GetAppDetail(c *gin.Context) {
|
|||||||
// @Tags App
|
// @Tags App
|
||||||
// @Summary Get app detail by id
|
// @Summary Get app detail by id
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param id path integer true "id"
|
// @Param appId path integer true "id"
|
||||||
// @Success 200 {object} response.AppDetailDTO
|
// @Success 200 {object} response.AppDetailDTO
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/details/{id} [get]
|
// @Router /apps/details/:id [get]
|
||||||
func (b *BaseApi) GetAppDetailByID(c *gin.Context) {
|
func (b *BaseApi) GetAppDetailByID(c *gin.Context) {
|
||||||
appDetailID, err := helper.GetIntParamByKey(c, "id")
|
appDetailID, err := helper.GetIntParamByKey(c, "id")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
appDetailDTO, err := appService.GetAppDetailByID(appDetailID)
|
appDetailDTO, err := appService.GetAppDetailByID(appDetailID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, appDetailDTO)
|
helper.SuccessWithData(c, appDetailDTO)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags App
|
|
||||||
// @Summary Get Ignore App
|
|
||||||
// @Accept json
|
|
||||||
// @Success 200 {object} response.IgnoredApp
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /apps/ignored [get]
|
|
||||||
func (b *BaseApi) GetIgnoredApp(c *gin.Context) {
|
|
||||||
res, err := appService.GetIgnoredApp()
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, res)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags App
|
// @Tags App
|
||||||
// @Summary Install app
|
// @Summary Install app
|
||||||
// @Accept json
|
// @Accept json
|
||||||
@@ -161,21 +161,18 @@ func (b *BaseApi) InstallApp(c *gin.Context) {
|
|||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tx, ctx := helper.GetTxAndContext()
|
install, err := appService.Install(req)
|
||||||
install, err := appService.Install(ctx, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
helper.InternalServer(c, err)
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tx.Commit()
|
|
||||||
helper.SuccessWithData(c, install)
|
helper.SuccessWithData(c, install)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) GetAppTags(c *gin.Context) {
|
func (b *BaseApi) GetAppTags(c *gin.Context) {
|
||||||
tags, err := appService.GetAppTags(c)
|
tags, err := appService.GetAppTags(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, tags)
|
helper.SuccessWithData(c, tags)
|
||||||
@@ -190,7 +187,7 @@ func (b *BaseApi) GetAppTags(c *gin.Context) {
|
|||||||
func (b *BaseApi) GetAppListUpdate(c *gin.Context) {
|
func (b *BaseApi) GetAppListUpdate(c *gin.Context) {
|
||||||
res, err := appService.GetAppUpdate()
|
res, err := appService.GetAppUpdate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @Tags App
|
||||||
|
// @Summary List Upgrade Ignored App
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200 {array} model.AppIgnoreUpgrade
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /apps/ignored/detail [get]
|
||||||
|
func (b *BaseApi) ListAppIgnored(c *gin.Context) {
|
||||||
|
res, err := appIgnoreUpgradeService.List()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags App
|
||||||
|
// @Summary Ignore Upgrade App
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.AppIgnoreUpgradeReq true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /apps/installed/ignore [post]
|
||||||
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"忽略应用升级","formatEN":"Ignore application upgrade"}
|
||||||
|
func (b *BaseApi) IgnoreAppUpgrade(c *gin.Context) {
|
||||||
|
var req request.AppIgnoreUpgradeReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := appIgnoreUpgradeService.CreateAppIgnore(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 写一个去掉忽略的接口
|
||||||
|
// @Tags App
|
||||||
|
// @Summary Cancel Ignore Upgrade App
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.ReqWithID true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /apps/ignored/cancel [post]
|
||||||
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"取消忽略应用升级","formatEN":"Cancel ignore application upgrade"}
|
||||||
|
func (b *BaseApi) CancelIgnoreAppUpgrade(c *gin.Context) {
|
||||||
|
var req request.ReqWithID
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := appIgnoreUpgradeService.Delete(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
|
|||||||
if req.All {
|
if req.All {
|
||||||
list, err := appInstallService.SearchForWebsite(req)
|
list, err := appInstallService.SearchForWebsite(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -35,7 +34,7 @@ func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
total, list, err := appInstallService.Page(req)
|
total, list, err := appInstallService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -55,7 +54,7 @@ func (b *BaseApi) SearchAppInstalled(c *gin.Context) {
|
|||||||
func (b *BaseApi) ListAppInstalled(c *gin.Context) {
|
func (b *BaseApi) ListAppInstalled(c *gin.Context) {
|
||||||
list, err := appInstallService.GetInstallList()
|
list, err := appInstallService.GetInstallList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
@@ -76,7 +75,7 @@ func (b *BaseApi) CheckAppInstalled(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
checkData, err := appInstallService.CheckExist(req)
|
checkData, err := appInstallService.CheckExist(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, checkData)
|
helper.SuccessWithData(c, checkData)
|
||||||
@@ -97,7 +96,7 @@ func (b *BaseApi) LoadPort(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
port, err := appInstallService.LoadPort(req)
|
port, err := appInstallService.LoadPort(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, port)
|
helper.SuccessWithData(c, port)
|
||||||
@@ -107,11 +106,10 @@ func (b *BaseApi) LoadPort(c *gin.Context) {
|
|||||||
// @Summary Search app password by key
|
// @Summary Search app password by key
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.OperationWithNameAndType true "request"
|
// @Param request body dto.OperationWithNameAndType true "request"
|
||||||
// @Param key path string true "key"
|
|
||||||
// @Success 200 {object} response.DatabaseConn
|
// @Success 200 {object} response.DatabaseConn
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/installed/conninfo/{key} [get]
|
// @Router /apps/installed/conninfo/:key [get]
|
||||||
func (b *BaseApi) LoadConnInfo(c *gin.Context) {
|
func (b *BaseApi) LoadConnInfo(c *gin.Context) {
|
||||||
var req dto.OperationWithNameAndType
|
var req dto.OperationWithNameAndType
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
@@ -119,7 +117,7 @@ func (b *BaseApi) LoadConnInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
conn, err := appInstallService.LoadConnInfo(req)
|
conn, err := appInstallService.LoadConnInfo(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, conn)
|
helper.SuccessWithData(c, conn)
|
||||||
@@ -132,16 +130,16 @@ func (b *BaseApi) LoadConnInfo(c *gin.Context) {
|
|||||||
// @Success 200 {array} dto.AppResource
|
// @Success 200 {array} dto.AppResource
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/installed/delete/check/{appInstallId} [get]
|
// @Router /apps/installed/delete/check/:appInstallId [get]
|
||||||
func (b *BaseApi) DeleteCheck(c *gin.Context) {
|
func (b *BaseApi) DeleteCheck(c *gin.Context) {
|
||||||
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
|
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checkData, err := appInstallService.DeleteCheck(appInstallId)
|
checkData, err := appInstallService.DeleteCheck(appInstallId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, checkData)
|
helper.SuccessWithData(c, checkData)
|
||||||
@@ -157,10 +155,10 @@ func (b *BaseApi) DeleteCheck(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步已安装应用列表","formatEN":"Sync the list of installed apps"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步已安装应用列表","formatEN":"Sync the list of installed apps"}
|
||||||
func (b *BaseApi) SyncInstalled(c *gin.Context) {
|
func (b *BaseApi) SyncInstalled(c *gin.Context) {
|
||||||
if err := appInstallService.SyncAll(false); err != nil {
|
if err := appInstallService.SyncAll(false); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, "")
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags App
|
// @Tags App
|
||||||
@@ -178,10 +176,10 @@ func (b *BaseApi) OperateInstalled(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := appInstallService.Operate(req); err != nil {
|
if err := appInstallService.Operate(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags App
|
// @Tags App
|
||||||
@@ -191,12 +189,12 @@ func (b *BaseApi) OperateInstalled(c *gin.Context) {
|
|||||||
// @Success 200 {array} response.AppService
|
// @Success 200 {array} response.AppService
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/services/{key} [get]
|
// @Router /apps/services/:key [get]
|
||||||
func (b *BaseApi) GetServices(c *gin.Context) {
|
func (b *BaseApi) GetServices(c *gin.Context) {
|
||||||
key := c.Param("key")
|
key := c.Param("key")
|
||||||
services, err := appInstallService.GetServices(key)
|
services, err := appInstallService.GetServices(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, services)
|
helper.SuccessWithData(c, services)
|
||||||
@@ -205,6 +203,7 @@ func (b *BaseApi) GetServices(c *gin.Context) {
|
|||||||
// @Tags App
|
// @Tags App
|
||||||
// @Summary Search app update version by install id
|
// @Summary Search app update version by install id
|
||||||
// @Accept json
|
// @Accept json
|
||||||
|
// @Param appInstallId path integer true "request"
|
||||||
// @Success 200 {array} dto.AppVersion
|
// @Success 200 {array} dto.AppVersion
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
@@ -216,7 +215,7 @@ func (b *BaseApi) GetUpdateVersions(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
versions, err := appInstallService.GetUpdateVersions(req)
|
versions, err := appInstallService.GetUpdateVersions(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, versions)
|
helper.SuccessWithData(c, versions)
|
||||||
@@ -237,10 +236,10 @@ func (b *BaseApi) ChangeAppPort(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := appInstallService.ChangeAppPort(req); err != nil {
|
if err := appInstallService.ChangeAppPort(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags App
|
// @Tags App
|
||||||
@@ -258,7 +257,7 @@ func (b *BaseApi) GetDefaultConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
content, err := appInstallService.GetDefaultConfigByKey(req.Type, req.Name)
|
content, err := appInstallService.GetDefaultConfigByKey(req.Type, req.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,16 +271,16 @@ func (b *BaseApi) GetDefaultConfig(c *gin.Context) {
|
|||||||
// @Success 200 {object} response.AppConfig
|
// @Success 200 {object} response.AppConfig
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/installed/params/{appInstallId} [get]
|
// @Router /apps/installed/params/:appInstallId [get]
|
||||||
func (b *BaseApi) GetParams(c *gin.Context) {
|
func (b *BaseApi) GetParams(c *gin.Context) {
|
||||||
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
|
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
content, err := appInstallService.GetParams(appInstallId)
|
content, err := appInstallService.GetParams(appInstallId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, content)
|
helper.SuccessWithData(c, content)
|
||||||
@@ -302,29 +301,51 @@ func (b *BaseApi) UpdateInstalled(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := appInstallService.Update(req); err != nil {
|
if err := appInstallService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags App
|
// @Tags App
|
||||||
// @Summary ignore App Update
|
// @Summary Update app config
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.AppInstalledIgnoreUpgrade true "request"
|
// @Param request body request.AppConfigUpdate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /apps/installed/ignore [post]
|
// @Router /apps/installed/config/update [post]
|
||||||
// @x-panel-log {"bodyKeys":["installId"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"忽略应用 [installId] 版本升级","formatEN":"Application param update [installId]"}
|
// @x-panel-log {"bodyKeys":["installID","webUI"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用配置更新 [installID]","formatEN":"Application config update [installID]"}
|
||||||
func (b *BaseApi) IgnoreUpgrade(c *gin.Context) {
|
func (b *BaseApi) UpdateAppConfig(c *gin.Context) {
|
||||||
var req request.AppInstalledIgnoreUpgrade
|
var req request.AppConfigUpdate
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := appInstallService.IgnoreUpgrade(req); err != nil {
|
if err := appInstallService.UpdateAppConfig(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags App
|
||||||
|
// @Summary Get app install info
|
||||||
|
// @Accept json
|
||||||
|
// @Param appInstallId path integer true "App install id"
|
||||||
|
// @Success 200 {object} dto.AppInstallInfo
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /apps/installed/info/:appInstallId [get]
|
||||||
|
func (b *BaseApi) GetAppInstallInfo(c *gin.Context) {
|
||||||
|
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
info, err := appInstallService.GetAppInstallInfo(appInstallId)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, info)
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,30 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (b *BaseApi) CheckBackupUsed(c *gin.Context) {
|
||||||
|
name, err := helper.GetStrParamByKey(c, "name")
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := backupService.CheckUsed(name, true); err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
// @Summary Create backup account
|
// @Summary Create backup account
|
||||||
// @Accept json
|
// @Accept json
|
||||||
@@ -18,46 +32,39 @@ import (
|
|||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup [post]
|
// @Router /backups [post]
|
||||||
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建备份账号 [type]","formatEN":"create backup account [type]"}
|
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建备份账号 [type]","formatEN":"create backup account [type]"}
|
||||||
func (b *BaseApi) CreateBackup(c *gin.Context) {
|
func (b *BaseApi) CreateBackup(c *gin.Context) {
|
||||||
var req dto.BackupOperate
|
var req dto.BackupOperate
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(req.Credential) != 0 {
|
|
||||||
credential, err := base64.StdEncoding.DecodeString(req.Credential)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.Credential = string(credential)
|
|
||||||
}
|
|
||||||
if len(req.AccessKey) != 0 {
|
|
||||||
accessKey, err := base64.StdEncoding.DecodeString(req.AccessKey)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.AccessKey = string(accessKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := backupService.Create(req); err != nil {
|
if err := backupService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
// @Summary Refresh OneDrive token
|
// @Summary Refresh token
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.BackupOperate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/refresh/onedrive [post]
|
// @Router /backups/refresh/token [post]
|
||||||
func (b *BaseApi) RefreshOneDriveToken(c *gin.Context) {
|
func (b *BaseApi) RefreshToken(c *gin.Context) {
|
||||||
backupService.Run()
|
var req dto.OperateByID
|
||||||
helper.SuccessWithData(c, nil)
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := backupService.RefreshToken(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
@@ -67,53 +74,21 @@ func (b *BaseApi) RefreshOneDriveToken(c *gin.Context) {
|
|||||||
// @Success 200 {array} object
|
// @Success 200 {array} object
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/search [post]
|
// @Router /buckets [post]
|
||||||
func (b *BaseApi) ListBuckets(c *gin.Context) {
|
func (b *BaseApi) ListBuckets(c *gin.Context) {
|
||||||
var req dto.ForBuckets
|
var req dto.ForBuckets
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(req.Credential) != 0 {
|
|
||||||
credential, err := base64.StdEncoding.DecodeString(req.Credential)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.Credential = string(credential)
|
|
||||||
}
|
|
||||||
if len(req.AccessKey) != 0 {
|
|
||||||
accessKey, err := base64.StdEncoding.DecodeString(req.AccessKey)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.AccessKey = string(accessKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
buckets, err := backupService.GetBuckets(req)
|
buckets, err := backupService.GetBuckets(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, buckets)
|
helper.SuccessWithData(c, buckets)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
|
||||||
// @Summary Load OneDrive info
|
|
||||||
// @Accept json
|
|
||||||
// @Success 200 {object} dto.OneDriveInfo
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/backup/onedrive [get]
|
|
||||||
func (b *BaseApi) LoadOneDriveInfo(c *gin.Context) {
|
|
||||||
data, err := backupService.LoadOneDriveInfo()
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
// @Summary Delete backup account
|
// @Summary Delete backup account
|
||||||
// @Accept json
|
// @Accept json
|
||||||
@@ -121,7 +96,7 @@ func (b *BaseApi) LoadOneDriveInfo(c *gin.Context) {
|
|||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/del [post]
|
// @Router /backups/del [post]
|
||||||
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"backup_accounts","output_column":"type","output_value":"types"}],"formatZH":"删除备份账号 [types]","formatEN":"delete backup account [types]"}
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"backup_accounts","output_column":"type","output_value":"types"}],"formatZH":"删除备份账号 [types]","formatEN":"delete backup account [types]"}
|
||||||
func (b *BaseApi) DeleteBackup(c *gin.Context) {
|
func (b *BaseApi) DeleteBackup(c *gin.Context) {
|
||||||
var req dto.OperateByID
|
var req dto.OperateByID
|
||||||
@@ -130,153 +105,10 @@ func (b *BaseApi) DeleteBackup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := backupService.Delete(req.ID); err != nil {
|
if err := backupService.Delete(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Backup Account
|
|
||||||
// @Summary Page backup records
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.RecordSearch true "request"
|
|
||||||
// @Success 200 {object} dto.PageResult
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/backup/record/search [post]
|
|
||||||
func (b *BaseApi) SearchBackupRecords(c *gin.Context) {
|
|
||||||
var req dto.RecordSearch
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
total, list, err := backupService.SearchRecordsWithPage(req)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
|
||||||
Items: list,
|
|
||||||
Total: total,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Backup Account
|
|
||||||
// @Summary Load backup records size
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.RecordSearch true "request"
|
|
||||||
// @Success 200 {array} dto.BackupFile
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/backup/record/size [post]
|
|
||||||
func (b *BaseApi) LoadBackupSize(c *gin.Context) {
|
|
||||||
var req dto.RecordSearch
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
list, err := backupService.LoadSize(req)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
helper.SuccessWithData(c, list)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Backup Account
|
|
||||||
// @Summary Page backup records by cronjob
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.RecordSearchByCronjob true "request"
|
|
||||||
// @Success 200 {object} dto.PageResult
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/backup/record/search/bycronjob [post]
|
|
||||||
func (b *BaseApi) SearchBackupRecordsByCronjob(c *gin.Context) {
|
|
||||||
var req dto.RecordSearchByCronjob
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
total, list, err := backupService.SearchRecordsByCronjobWithPage(req)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
|
||||||
Items: list,
|
|
||||||
Total: total,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Backup Account
|
|
||||||
// @Summary Load backup records size for cronjob
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.RecordSearchByCronjob true "request"
|
|
||||||
// @Success 200 {array} dto.BackupFile
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/backup/record/size/bycronjob [post]
|
|
||||||
func (b *BaseApi) LoadBackupSizeByCronjob(c *gin.Context) {
|
|
||||||
var req dto.RecordSearchByCronjob
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
list, err := backupService.LoadSizeByCronjob(req)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
helper.SuccessWithData(c, list)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Backup Account
|
|
||||||
// @Summary Download backup record
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.DownloadRecord true "request"
|
|
||||||
// @Success 200 {string} filePath
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/backup/record/download [post]
|
|
||||||
// @x-panel-log {"bodyKeys":["source","fileName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载备份记录 [source][fileName]","formatEN":"download backup records [source][fileName]"}
|
|
||||||
func (b *BaseApi) DownloadRecord(c *gin.Context) {
|
|
||||||
var req dto.DownloadRecord
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
filePath, err := backupService.DownloadRecord(req)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, filePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Backup Account
|
|
||||||
// @Summary Delete backup record
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.BatchDeleteReq true "request"
|
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/backup/record/del [post]
|
|
||||||
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"backup_records","output_column":"file_name","output_value":"files"}],"formatZH":"删除备份记录 [files]","formatEN":"delete backup records [files]"}
|
|
||||||
func (b *BaseApi) DeleteBackupRecord(c *gin.Context) {
|
|
||||||
var req dto.BatchDeleteReq
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := backupService.BatchDeleteRecord(req.Ids); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
@@ -286,7 +118,7 @@ func (b *BaseApi) DeleteBackupRecord(c *gin.Context) {
|
|||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/update [post]
|
// @Router /backups/update [post]
|
||||||
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新备份账号 [types]","formatEN":"update backup account [types]"}
|
// @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新备份账号 [types]","formatEN":"update backup account [types]"}
|
||||||
func (b *BaseApi) UpdateBackup(c *gin.Context) {
|
func (b *BaseApi) UpdateBackup(c *gin.Context) {
|
||||||
var req dto.BackupOperate
|
var req dto.BackupOperate
|
||||||
@@ -294,61 +126,227 @@ func (b *BaseApi) UpdateBackup(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.Credential) != 0 {
|
|
||||||
credential, err := base64.StdEncoding.DecodeString(req.Credential)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.Credential = string(credential)
|
|
||||||
}
|
|
||||||
if len(req.AccessKey) != 0 {
|
|
||||||
accessKey, err := base64.StdEncoding.DecodeString(req.AccessKey)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.AccessKey = string(accessKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := backupService.Update(req); err != nil {
|
if err := backupService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
// @Summary List backup accounts
|
// @Summary Load backup account options
|
||||||
// @Success 200 {array} dto.BackupInfo
|
// @Accept json
|
||||||
|
// @Success 200 {array} dto.BackupOption
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/search [get]
|
// @Router /backups/options [get]
|
||||||
func (b *BaseApi) ListBackup(c *gin.Context) {
|
func (b *BaseApi) LoadBackupOptions(c *gin.Context) {
|
||||||
data, err := backupService.List()
|
list, err := backupService.LoadBackupOptions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, list)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Backup Account
|
||||||
|
// @Summary Search backup accounts with page
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.SearchPageWithType true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /backups/search [post]
|
||||||
|
func (b *BaseApi) SearchBackup(c *gin.Context) {
|
||||||
|
var req dto.SearchPageWithType
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, data)
|
total, list, err := backupService.SearchWithPage(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
|
Items: list,
|
||||||
|
Total: total,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Backup Account
|
||||||
|
// @Summary get local backup dir
|
||||||
|
// @Success 200 {string} dir
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /backups/local [get]
|
||||||
|
func (b *BaseApi) GetLocalDir(c *gin.Context) {
|
||||||
|
dir, err := backupService.GetLocalDir()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.SuccessWithData(c, dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Backup Account
|
||||||
|
// @Summary Load backup record size
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.SearchForSize true "request"
|
||||||
|
// @Success 200 {array} dto.RecordFileSize
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /backups/record/size [post]
|
||||||
|
func (b *BaseApi) LoadBackupRecordSize(c *gin.Context) {
|
||||||
|
var req dto.SearchForSize
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
list, err := backupRecordService.LoadRecordSize(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.SuccessWithData(c, list)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Backup Account
|
||||||
|
// @Summary Page backup records
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.RecordSearch true "request"
|
||||||
|
// @Success 200 {object} dto.PageResult
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /backups/record/search [post]
|
||||||
|
func (b *BaseApi) SearchBackupRecords(c *gin.Context) {
|
||||||
|
var req dto.RecordSearch
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
total, list, err := backupRecordService.SearchRecordsWithPage(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
|
Items: list,
|
||||||
|
Total: total,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Backup Account
|
||||||
|
// @Summary Page backup records by cronjob
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.RecordSearchByCronjob true "request"
|
||||||
|
// @Success 200 {object} dto.PageResult
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /backups/record/search/bycronjob [post]
|
||||||
|
func (b *BaseApi) SearchBackupRecordsByCronjob(c *gin.Context) {
|
||||||
|
var req dto.RecordSearchByCronjob
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
total, list, err := backupRecordService.SearchRecordsByCronjobWithPage(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
|
Items: list,
|
||||||
|
Total: total,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Backup Account
|
||||||
|
// @Summary Download backup record
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.DownloadRecord true "request"
|
||||||
|
// @Success 200 {string} filePath
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /backup/record/download [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["source","fileName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"下载备份记录 [source][fileName]","formatEN":"download backup records [source][fileName]"}
|
||||||
|
func (b *BaseApi) DownloadRecord(c *gin.Context) {
|
||||||
|
var req dto.DownloadRecord
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
filePath, err := backupRecordService.DownloadRecord(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, filePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Backup Account
|
||||||
|
// @Summary Update backup record description
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.UpdateDescription true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /backup/record/description/update [post]
|
||||||
|
func (b *BaseApi) UpdateRecordDescription(c *gin.Context) {
|
||||||
|
var req dto.UpdateDescription
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := backupRecordService.UpdateDescription(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Backup Account
|
||||||
|
// @Summary Delete backup record
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.BatchDeleteReq true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /record/del [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["ids"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"ids","isList":true,"db":"backup_records","output_column":"file_name","output_value":"files"}],"formatZH":"删除备份记录 [files]","formatEN":"delete backup records [files]"}
|
||||||
|
func (b *BaseApi) DeleteBackupRecord(c *gin.Context) {
|
||||||
|
var req dto.BatchDeleteReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := backupRecordService.BatchDeleteRecord(req.Ids); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
// @Summary List files from backup accounts
|
// @Summary List files from backup accounts
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.BackupSearchFile true "request"
|
// @Param request body dto.OperateByID true "request"
|
||||||
// @Success 200 {array} string
|
// @Success 200 {array} string
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/search/files [post]
|
// @Router /backups/search/files [post]
|
||||||
func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) {
|
func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) {
|
||||||
var req dto.BackupSearchFile
|
var req dto.OperateByID
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data := backupService.ListFiles(req)
|
data := backupRecordService.ListFiles(req)
|
||||||
helper.SuccessWithData(c, data)
|
helper.SuccessWithData(c, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +357,7 @@ func (b *BaseApi) LoadFilesFromBackup(c *gin.Context) {
|
|||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/backup [post]
|
// @Router /backups/backup [post]
|
||||||
// @x-panel-log {"bodyKeys":["type","name","detailName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"备份 [type] 数据 [name][detailName]","formatEN":"backup [type] data [name][detailName]"}
|
// @x-panel-log {"bodyKeys":["type","name","detailName"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"备份 [type] 数据 [name][detailName]","formatEN":"backup [type] data [name][detailName]"}
|
||||||
func (b *BaseApi) Backup(c *gin.Context) {
|
func (b *BaseApi) Backup(c *gin.Context) {
|
||||||
var req dto.CommonBackup
|
var req dto.CommonBackup
|
||||||
@@ -370,31 +368,31 @@ func (b *BaseApi) Backup(c *gin.Context) {
|
|||||||
switch req.Type {
|
switch req.Type {
|
||||||
case "app":
|
case "app":
|
||||||
if _, err := backupService.AppBackup(req); err != nil {
|
if _, err := backupService.AppBackup(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "mysql", "mariadb":
|
case "mysql", "mariadb", constant.AppMysqlCluster:
|
||||||
if err := backupService.MysqlBackup(req); err != nil {
|
if err := backupService.MysqlBackup(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case constant.AppPostgresql:
|
case constant.AppPostgresql, constant.AppPostgresqlCluster:
|
||||||
if err := backupService.PostgresqlBackup(req); err != nil {
|
if err := backupService.PostgresqlBackup(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "website":
|
case "website":
|
||||||
if err := backupService.WebsiteBackup(req); err != nil {
|
if err := backupService.WebsiteBackup(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "redis":
|
case "redis", constant.AppRedisCluster:
|
||||||
if err := backupService.RedisBackup(req); err != nil {
|
if err := backupService.RedisBackup(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
@@ -404,7 +402,7 @@ func (b *BaseApi) Backup(c *gin.Context) {
|
|||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/recover [post]
|
// @Router /backups/recover [post]
|
||||||
// @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"}
|
// @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"}
|
||||||
func (b *BaseApi) Recover(c *gin.Context) {
|
func (b *BaseApi) Recover(c *gin.Context) {
|
||||||
var req dto.CommonRecover
|
var req dto.CommonRecover
|
||||||
@@ -412,40 +410,44 @@ func (b *BaseApi) Recover(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadPath, err := backupService.DownloadRecord(dto.DownloadRecord{Source: req.Source, FileDir: path.Dir(req.File), FileName: path.Base(req.File)})
|
downloadPath, err := backupRecordService.DownloadRecord(dto.DownloadRecord{
|
||||||
|
DownloadAccountID: req.DownloadAccountID,
|
||||||
|
FileDir: path.Dir(req.File),
|
||||||
|
FileName: path.Base(req.File),
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, fmt.Errorf("download file failed, err: %v", err))
|
helper.BadRequest(c, fmt.Errorf("download file failed, err: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.File = downloadPath
|
req.File = downloadPath
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
case "mysql", "mariadb":
|
case "mysql", "mariadb", constant.AppMysqlCluster:
|
||||||
if err := backupService.MysqlRecover(req); err != nil {
|
if err := backupService.MysqlRecover(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case constant.AppPostgresql:
|
case constant.AppPostgresql, constant.AppPostgresqlCluster:
|
||||||
if err := backupService.PostgresqlRecover(req); err != nil {
|
if err := backupService.PostgresqlRecover(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "website":
|
case "website":
|
||||||
if err := backupService.WebsiteRecover(req); err != nil {
|
if err := backupService.WebsiteRecover(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "redis":
|
case "redis", constant.AppRedisCluster:
|
||||||
if err := backupService.RedisRecover(req); err != nil {
|
if err := backupService.RedisRecover(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "app":
|
case "app":
|
||||||
if err := backupService.AppRecover(req); err != nil {
|
if err := backupService.AppRecover(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Backup Account
|
// @Tags Backup Account
|
||||||
@@ -455,7 +457,7 @@ func (b *BaseApi) Recover(c *gin.Context) {
|
|||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /settings/backup/recover/byupload [post]
|
// @Router /backups/recover/byupload [post]
|
||||||
// @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"}
|
// @x-panel-log {"bodyKeys":["type","name","detailName","file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"从 [file] 恢复 [type] 数据 [name][detailName]","formatEN":"recover [type] data [name][detailName] from [file]"}
|
||||||
func (b *BaseApi) RecoverByUpload(c *gin.Context) {
|
func (b *BaseApi) RecoverByUpload(c *gin.Context) {
|
||||||
var req dto.CommonRecover
|
var req dto.CommonRecover
|
||||||
@@ -464,26 +466,26 @@ func (b *BaseApi) RecoverByUpload(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
case "mysql", "mariadb":
|
case "mysql", "mariadb", constant.AppMysqlCluster:
|
||||||
if err := backupService.MysqlRecoverByUpload(req); err != nil {
|
if err := backupService.MysqlRecoverByUpload(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case constant.AppPostgresql:
|
case constant.AppPostgresql, constant.AppPostgresqlCluster:
|
||||||
if err := backupService.PostgresqlRecoverByUpload(req); err != nil {
|
if err := backupService.PostgresqlRecoverByUpload(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "app":
|
case "app":
|
||||||
if err := backupService.AppRecover(req); err != nil {
|
if err := backupService.AppRecover(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "website":
|
case "website":
|
||||||
if err := backupService.WebsiteRecover(req); err != nil {
|
if err := backupService.WebsiteRecover(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,10 +22,10 @@ func (b *BaseApi) CreateClam(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := clamService.Create(req); err != nil {
|
if err := clamService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Clam
|
// @Tags Clam
|
||||||
@@ -45,10 +44,10 @@ func (b *BaseApi) UpdateClam(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := clamService.Update(req); err != nil {
|
if err := clamService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Clam
|
// @Tags Clam
|
||||||
@@ -67,10 +66,10 @@ func (b *BaseApi) UpdateClamStatus(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := clamService.UpdateStatus(req.ID, req.Status); err != nil {
|
if err := clamService.UpdateStatus(req.ID, req.Status); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Clam
|
// @Tags Clam
|
||||||
@@ -89,7 +88,7 @@ func (b *BaseApi) SearchClam(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := clamService.SearchWithPage(req)
|
total, list, err := clamService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +108,7 @@ func (b *BaseApi) SearchClam(c *gin.Context) {
|
|||||||
func (b *BaseApi) LoadClamBaseInfo(c *gin.Context) {
|
func (b *BaseApi) LoadClamBaseInfo(c *gin.Context) {
|
||||||
info, err := clamService.LoadBaseInfo()
|
info, err := clamService.LoadBaseInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,8 +118,8 @@ func (b *BaseApi) LoadClamBaseInfo(c *gin.Context) {
|
|||||||
// @Tags Clam
|
// @Tags Clam
|
||||||
// @Summary Operate Clam
|
// @Summary Operate Clam
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.Operate true "request"
|
|
||||||
// @Success 200
|
// @Success 200
|
||||||
|
// @Param request body dto.Operate true "request"
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /toolbox/clam/operate [post]
|
// @Router /toolbox/clam/operate [post]
|
||||||
@@ -132,11 +131,11 @@ func (b *BaseApi) OperateClam(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := clamService.Operate(req.Operation); err != nil {
|
if err := clamService.Operate(req.Operation); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Clam
|
// @Tags Clam
|
||||||
@@ -154,11 +153,11 @@ func (b *BaseApi) CleanClamRecord(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := clamService.CleanRecord(req); err != nil {
|
if err := clamService.CleanRecord(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Clam
|
// @Tags Clam
|
||||||
@@ -177,7 +176,7 @@ func (b *BaseApi) SearchClamRecord(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := clamService.LoadRecords(req)
|
total, list, err := clamService.LoadRecords(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +202,7 @@ func (b *BaseApi) LoadClamRecordLog(c *gin.Context) {
|
|||||||
|
|
||||||
content, err := clamService.LoadRecordLog(req)
|
content, err := clamService.LoadRecordLog(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +225,7 @@ func (b *BaseApi) SearchClamFile(c *gin.Context) {
|
|||||||
|
|
||||||
content, err := clamService.LoadFile(req)
|
content, err := clamService.LoadFile(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,10 +246,10 @@ func (b *BaseApi) UpdateFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := clamService.UpdateFile(req); err != nil {
|
if err := clamService.UpdateFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Clam
|
// @Tags Clam
|
||||||
@@ -269,10 +268,10 @@ func (b *BaseApi) DeleteClam(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := clamService.Delete(req); err != nil {
|
if err := clamService.Delete(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Clam
|
// @Tags Clam
|
||||||
@@ -291,8 +290,8 @@ func (b *BaseApi) HandleClamScan(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := clamService.HandleOnce(req); err != nil {
|
if err := clamService.HandleOnce(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,10 +22,10 @@ func (b *BaseApi) CreateComposeTemplate(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := composeTemplateService.Create(req); err != nil {
|
if err := composeTemplateService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Compose-template
|
// @Tags Container Compose-template
|
||||||
@@ -46,7 +45,7 @@ func (b *BaseApi) SearchComposeTemplate(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := composeTemplateService.SearchWithPage(req)
|
total, list, err := composeTemplateService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +65,7 @@ func (b *BaseApi) SearchComposeTemplate(c *gin.Context) {
|
|||||||
func (b *BaseApi) ListComposeTemplate(c *gin.Context) {
|
func (b *BaseApi) ListComposeTemplate(c *gin.Context) {
|
||||||
list, err := composeTemplateService.List()
|
list, err := composeTemplateService.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,10 +88,10 @@ func (b *BaseApi) DeleteComposeTemplate(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := composeTemplateService.Delete(req.Ids); err != nil {
|
if err := composeTemplateService.Delete(req.Ids); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Compose-template
|
// @Tags Container Compose-template
|
||||||
@@ -114,8 +113,8 @@ func (b *BaseApi) UpdateComposeTemplate(c *gin.Context) {
|
|||||||
upMap["content"] = req.Content
|
upMap["content"] = req.Content
|
||||||
upMap["description"] = req.Description
|
upMap["description"] = req.Description
|
||||||
if err := composeTemplateService.Update(req.ID, upMap); err != nil {
|
if err := composeTemplateService.Update(req.ID, upMap); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
@@ -28,7 +26,7 @@ func (b *BaseApi) SearchContainer(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := containerService.Page(req)
|
total, list, err := containerService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -37,6 +35,24 @@ func (b *BaseApi) SearchContainer(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Tags Container
|
||||||
|
// @Summary Load container users
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.OperationWithName true "request"
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {array} string
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /containers/users [post]
|
||||||
|
func (b *BaseApi) LoadContainerUsers(c *gin.Context) {
|
||||||
|
var req dto.OperationWithName
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.SuccessWithData(c, containerService.LoadUsers(req))
|
||||||
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
// @Summary List containers
|
// @Summary List containers
|
||||||
// @Accept json
|
// @Accept json
|
||||||
@@ -46,12 +62,24 @@ func (b *BaseApi) SearchContainer(c *gin.Context) {
|
|||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/list [post]
|
// @Router /containers/list [post]
|
||||||
func (b *BaseApi) ListContainer(c *gin.Context) {
|
func (b *BaseApi) ListContainer(c *gin.Context) {
|
||||||
list, err := containerService.List()
|
helper.SuccessWithData(c, containerService.List())
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Container
|
||||||
|
// @Summary Load containers status
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} dto.ContainerStatus
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /containers/status [get]
|
||||||
|
func (b *BaseApi) LoadContainerStatus(c *gin.Context) {
|
||||||
|
data, err := containerService.LoadStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Compose
|
// @Tags Container Compose
|
||||||
@@ -70,7 +98,7 @@ func (b *BaseApi) SearchCompose(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := containerService.PageCompose(req)
|
total, list, err := containerService.PageCompose(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -96,7 +124,7 @@ func (b *BaseApi) TestCompose(c *gin.Context) {
|
|||||||
|
|
||||||
isOK, err := containerService.TestCompose(req)
|
isOK, err := containerService.TestCompose(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, isOK)
|
helper.SuccessWithData(c, isOK)
|
||||||
@@ -106,7 +134,7 @@ func (b *BaseApi) TestCompose(c *gin.Context) {
|
|||||||
// @Summary Create compose
|
// @Summary Create compose
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ComposeCreate true "request"
|
// @Param request body dto.ComposeCreate true "request"
|
||||||
// @Success 200 {string} log
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/compose [post]
|
// @Router /containers/compose [post]
|
||||||
@@ -117,12 +145,11 @@ func (b *BaseApi) CreateCompose(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log, err := containerService.CreateCompose(req)
|
if err := containerService.CreateCompose(req); err != nil {
|
||||||
if err != nil {
|
helper.InternalServer(c, err)
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, log)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Compose
|
// @Tags Container Compose
|
||||||
@@ -141,10 +168,10 @@ func (b *BaseApi) OperatorCompose(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ComposeOperation(req); err != nil {
|
if err := containerService.ComposeOperation(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
@@ -163,10 +190,10 @@ func (b *BaseApi) ContainerUpdate(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerUpdate(req); err != nil {
|
if err := containerService.ContainerUpdate(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
@@ -185,7 +212,7 @@ func (b *BaseApi) ContainerInfo(c *gin.Context) {
|
|||||||
|
|
||||||
data, err := containerService.ContainerInfo(req)
|
data, err := containerService.ContainerInfo(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, data)
|
helper.SuccessWithData(c, data)
|
||||||
@@ -199,7 +226,7 @@ func (b *BaseApi) ContainerInfo(c *gin.Context) {
|
|||||||
func (b *BaseApi) LoadResourceLimit(c *gin.Context) {
|
func (b *BaseApi) LoadResourceLimit(c *gin.Context) {
|
||||||
data, err := containerService.LoadResourceLimit()
|
data, err := containerService.LoadResourceLimit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, data)
|
helper.SuccessWithData(c, data)
|
||||||
@@ -213,7 +240,7 @@ func (b *BaseApi) LoadResourceLimit(c *gin.Context) {
|
|||||||
func (b *BaseApi) ContainerListStats(c *gin.Context) {
|
func (b *BaseApi) ContainerListStats(c *gin.Context) {
|
||||||
data, err := containerService.ContainerListStats()
|
data, err := containerService.ContainerListStats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, data)
|
helper.SuccessWithData(c, data)
|
||||||
@@ -234,11 +261,32 @@ func (b *BaseApi) ContainerCreate(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerCreate(req); err != nil {
|
if err := containerService.ContainerCreate(req, true); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Container
|
||||||
|
// @Summary Create container by command
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.ContainerCreateByCommand true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /containers/command [post]
|
||||||
|
func (b *BaseApi) ContainerCreateByCommand(c *gin.Context) {
|
||||||
|
var req dto.ContainerCreateByCommand
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := containerService.ContainerCreateByCommand(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
@@ -257,17 +305,17 @@ func (b *BaseApi) ContainerUpgrade(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerUpgrade(req); err != nil {
|
if err := containerService.ContainerUpgrade(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
// @Summary Clean container
|
// @Summary Clean container
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ContainerPrune true "request"
|
// @Param request body dto.ContainerPrune true "request"
|
||||||
// @Success 200 {object} dto.ContainerPruneReport
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/prune [post]
|
// @Router /containers/prune [post]
|
||||||
@@ -278,12 +326,11 @@ func (b *BaseApi) ContainerPrune(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
report, err := containerService.Prune(req)
|
if err := containerService.Prune(req); err != nil {
|
||||||
if err != nil {
|
helper.InternalServer(c, err)
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, report)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
@@ -302,28 +349,10 @@ func (b *BaseApi) CleanContainerLog(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerLogClean(req); err != nil {
|
if err := containerService.ContainerLogClean(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Container
|
|
||||||
// @Summary Load container log
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.OperationWithNameAndType true "request"
|
|
||||||
// @Success 200 {string} content
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /containers/load/log [post]
|
|
||||||
func (b *BaseApi) LoadContainerLog(c *gin.Context) {
|
|
||||||
var req dto.OperationWithNameAndType
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
content := containerService.LoadContainerLogs(req)
|
|
||||||
helper.SuccessWithData(c, content)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
@@ -342,10 +371,10 @@ func (b *BaseApi) ContainerRename(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerRename(req); err != nil {
|
if err := containerService.ContainerRename(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
@@ -353,6 +382,8 @@ func (b *BaseApi) ContainerRename(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ContainerCommit true "request"
|
// @Param request body dto.ContainerCommit true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
// @Router /containers/commit [post]
|
// @Router /containers/commit [post]
|
||||||
func (b *BaseApi) ContainerCommit(c *gin.Context) {
|
func (b *BaseApi) ContainerCommit(c *gin.Context) {
|
||||||
var req dto.ContainerCommit
|
var req dto.ContainerCommit
|
||||||
@@ -361,10 +392,10 @@ func (b *BaseApi) ContainerCommit(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerCommit(req); err != nil {
|
if err := containerService.ContainerCommit(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
@@ -383,29 +414,29 @@ func (b *BaseApi) ContainerOperation(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ContainerOperation(req); err != nil {
|
if err := containerService.ContainerOperation(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
// @Tags Container
|
||||||
// @Summary Container stats
|
// @Summary Container stats
|
||||||
// @Param id path string true "container id"
|
// @Param id path string true "容器id"
|
||||||
// @Success 200 {object} dto.ContainerStats
|
// @Success 200 {object} dto.ContainerStats
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/stats/{id} [get]
|
// @Router /containers/stats/:id [get]
|
||||||
func (b *BaseApi) ContainerStats(c *gin.Context) {
|
func (b *BaseApi) ContainerStats(c *gin.Context) {
|
||||||
containerID, ok := c.Params.Get("id")
|
containerID, ok := c.Params.Get("id")
|
||||||
if !ok {
|
if !ok {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, errors.New("error container id in path"))
|
helper.BadRequest(c, errors.New("error container id in path"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := containerService.ContainerStats(containerID)
|
result, err := containerService.ContainerStats(containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, result)
|
helper.SuccessWithData(c, result)
|
||||||
@@ -427,48 +458,12 @@ func (b *BaseApi) Inspect(c *gin.Context) {
|
|||||||
|
|
||||||
result, err := containerService.Inspect(req)
|
result, err := containerService.Inspect(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, result)
|
helper.SuccessWithData(c, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container
|
|
||||||
// @Summary Container logs
|
|
||||||
// @Param container query string false "container name"
|
|
||||||
// @Param since query string false "since"
|
|
||||||
// @Param follow query string false "follow"
|
|
||||||
// @Param tail query string false "tail"
|
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /containers/search/log [post]
|
|
||||||
func (b *BaseApi) ContainerLogs(c *gin.Context) {
|
|
||||||
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
|
|
||||||
if err != nil {
|
|
||||||
global.LOG.Errorf("gin context http handler failed, err: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer wsConn.Close()
|
|
||||||
|
|
||||||
container := c.Query("container")
|
|
||||||
since := c.Query("since")
|
|
||||||
follow := c.Query("follow") == "true"
|
|
||||||
tail := c.Query("tail")
|
|
||||||
|
|
||||||
if err := containerService.ContainerLogs(wsConn, "container", container, since, tail, follow); err != nil {
|
|
||||||
_ = wsConn.WriteMessage(1, []byte(err.Error()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Container
|
|
||||||
// @Summary Download Container logs
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.ContainerLog true "request"
|
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /containers/download/log [post]
|
// @Router /containers/download/log [post]
|
||||||
func (b *BaseApi) DownloadContainerLogs(c *gin.Context) {
|
func (b *BaseApi) DownloadContainerLogs(c *gin.Context) {
|
||||||
var req dto.ContainerLog
|
var req dto.ContainerLog
|
||||||
@@ -477,7 +472,7 @@ func (b *BaseApi) DownloadContainerLogs(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := containerService.DownloadContainerLogs(req.ContainerType, req.Container, req.Since, strconv.Itoa(int(req.Tail)), c)
|
err := containerService.DownloadContainerLogs(req.ContainerType, req.Container, req.Since, strconv.Itoa(int(req.Tail)), c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,7 +493,7 @@ func (b *BaseApi) SearchNetwork(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := containerService.PageNetwork(req)
|
total, list, err := containerService.PageNetwork(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -518,7 +513,7 @@ func (b *BaseApi) SearchNetwork(c *gin.Context) {
|
|||||||
func (b *BaseApi) ListNetwork(c *gin.Context) {
|
func (b *BaseApi) ListNetwork(c *gin.Context) {
|
||||||
list, err := containerService.ListNetwork()
|
list, err := containerService.ListNetwork()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
@@ -540,10 +535,10 @@ func (b *BaseApi) DeleteNetwork(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.DeleteNetwork(req); err != nil {
|
if err := containerService.DeleteNetwork(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Network
|
// @Tags Container Network
|
||||||
@@ -562,14 +557,14 @@ func (b *BaseApi) CreateNetwork(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.CreateNetwork(req); err != nil {
|
if err := containerService.CreateNetwork(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Volume
|
// @Tags Container Volume
|
||||||
// @Summary Page Container Volumes
|
// @Summary Page volumes
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.SearchWithPage true "request"
|
// @Param request body dto.SearchWithPage true "request"
|
||||||
// @Produce json
|
// @Produce json
|
||||||
@@ -585,7 +580,7 @@ func (b *BaseApi) SearchVolume(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := containerService.PageVolume(req)
|
total, list, err := containerService.PageVolume(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -595,7 +590,7 @@ func (b *BaseApi) SearchVolume(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Volume
|
// @Tags Container Volume
|
||||||
// @Summary List Container Volumes
|
// @Summary List volumes
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {array} dto.Options
|
// @Success 200 {array} dto.Options
|
||||||
@@ -605,14 +600,14 @@ func (b *BaseApi) SearchVolume(c *gin.Context) {
|
|||||||
func (b *BaseApi) ListVolume(c *gin.Context) {
|
func (b *BaseApi) ListVolume(c *gin.Context) {
|
||||||
list, err := containerService.ListVolume()
|
list, err := containerService.ListVolume()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Volume
|
// @Tags Container Volume
|
||||||
// @Summary Delete Container Volume
|
// @Summary Delete volume
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.BatchDelete true "request"
|
// @Param request body dto.BatchDelete true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -627,14 +622,14 @@ func (b *BaseApi) DeleteVolume(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.DeleteVolume(req); err != nil {
|
if err := containerService.DeleteVolume(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Volume
|
// @Tags Container Volume
|
||||||
// @Summary Create Container Volume
|
// @Summary Create volume
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.VolumeCreate true "request"
|
// @Param request body dto.VolumeCreate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -649,14 +644,14 @@ func (b *BaseApi) CreateVolume(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.CreateVolume(req); err != nil {
|
if err := containerService.CreateVolume(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Compose
|
// @Tags Container Compose
|
||||||
// @Summary Update Container Compose
|
// @Summary Update compose
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ComposeUpdate true "request"
|
// @Param request body dto.ComposeUpdate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -671,37 +666,44 @@ func (b *BaseApi) ComposeUpdate(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := containerService.ComposeUpdate(req); err != nil {
|
if err := containerService.ComposeUpdate(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Compose
|
// @Tags Container
|
||||||
// @Summary Container Compose logs
|
// @Summary Container logs
|
||||||
// @Param compose query string false "compose file address"
|
// @Param container query string false "容器名称"
|
||||||
// @Param since query string false "date"
|
// @Param since query string false "时间筛选"
|
||||||
// @Param follow query string false "follow"
|
// @Param follow query string false "是否追踪"
|
||||||
// @Param tail query string false "tail"
|
// @Param tail query string false "显示行号"
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/compose/search/log [get]
|
// @Router /containers/search/log [post]
|
||||||
func (b *BaseApi) ComposeLogs(c *gin.Context) {
|
func (b *BaseApi) ContainerStreamLogs(c *gin.Context) {
|
||||||
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
|
c.Header("Content-Type", "text/event-stream")
|
||||||
if err != nil {
|
c.Header("Cache-Control", "no-cache")
|
||||||
global.LOG.Errorf("gin context http handler failed, err: %v", err)
|
c.Header("Connection", "keep-alive")
|
||||||
return
|
c.Header("Transfer-Encoding", "chunked")
|
||||||
}
|
|
||||||
defer wsConn.Close()
|
|
||||||
|
|
||||||
compose := c.Query("compose")
|
|
||||||
since := c.Query("since")
|
since := c.Query("since")
|
||||||
follow := c.Query("follow") == "true"
|
follow := c.Query("follow") == "true"
|
||||||
tail := c.Query("tail")
|
tail := c.Query("tail")
|
||||||
|
|
||||||
if err := containerService.ContainerLogs(wsConn, "compose", compose, since, tail, follow); err != nil {
|
container := c.Query("container")
|
||||||
_ = wsConn.WriteMessage(1, []byte(err.Error()))
|
compose := c.Query("compose")
|
||||||
return
|
streamLog := dto.StreamLog{
|
||||||
|
Compose: compose,
|
||||||
|
Container: container,
|
||||||
|
Since: since,
|
||||||
|
Follow: follow,
|
||||||
|
Tail: tail,
|
||||||
|
Type: "container",
|
||||||
}
|
}
|
||||||
|
if compose != "" {
|
||||||
|
streamLog.Type = "compose"
|
||||||
|
}
|
||||||
|
|
||||||
|
containerService.StreamLogs(c, streamLog)
|
||||||
}
|
}
|
||||||
@@ -1,35 +1,133 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/agent/utils/common"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Tags Cronjob
|
// @Tags Cronjob
|
||||||
// @Summary Create cronjob
|
// @Summary Create cronjob
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.CronjobCreate true "request"
|
// @Param request body dto.CronjobOperate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /cronjobs [post]
|
// @Router /cronjobs [post]
|
||||||
// @x-panel-log {"bodyKeys":["type","name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建计划任务 [type][name]","formatEN":"create cronjob [type][name]"}
|
// @x-panel-log {"bodyKeys":["type","name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建计划任务 [type][name]","formatEN":"create cronjob [type][name]"}
|
||||||
func (b *BaseApi) CreateCronjob(c *gin.Context) {
|
func (b *BaseApi) CreateCronjob(c *gin.Context) {
|
||||||
var req dto.CronjobCreate
|
var req dto.CronjobOperate
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cronjobService.Create(req); err != nil {
|
if err := cronjobService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Cronjob
|
||||||
|
// @Summary Load cronjob info
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.OperateByID true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /cronjobs/load/info [post]
|
||||||
|
func (b *BaseApi) LoadCronjobInfo(c *gin.Context) {
|
||||||
|
var req dto.OperateByID
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := cronjobService.LoadInfo(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Cronjob
|
||||||
|
// @Summary Export cronjob list
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.OperateByIDs true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /cronjobs/export [post]
|
||||||
|
func (b *BaseApi) ExportCronjob(c *gin.Context) {
|
||||||
|
var req dto.OperateByIDs
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
content, err := cronjobService.Export(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
http.ServeContent(c.Writer, c.Request, "", time.Now(), strings.NewReader(content))
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Cronjob
|
||||||
|
// @Summary Import cronjob list
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.CronjobImport true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /cronjobs/import [post]
|
||||||
|
func (b *BaseApi) ImportCronjob(c *gin.Context) {
|
||||||
|
var req dto.CronjobImport
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cronjobService.Import(req.Cronjobs); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Cronjob
|
||||||
|
// @Summary Load script options
|
||||||
|
// @Success 200 {array} dto.ScriptOptions
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /cronjobs/script/options [get]
|
||||||
|
func (b *BaseApi) LoadScriptOptions(c *gin.Context) {
|
||||||
|
helper.SuccessWithData(c, cronjobService.LoadScriptOptions())
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Cronjob
|
||||||
|
// @Summary Load cronjob spec time
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.CronjobSpec true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /cronjobs/next [post]
|
||||||
|
func (b *BaseApi) LoadNextHandle(c *gin.Context) {
|
||||||
|
var req dto.CronjobSpec
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
list, err := cronjobService.LoadNextHandle(req.Spec)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Cronjob
|
// @Tags Cronjob
|
||||||
@@ -48,7 +146,7 @@ func (b *BaseApi) SearchCronjob(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := cronjobService.SearchWithPage(req)
|
total, list, err := cronjobService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +176,7 @@ func (b *BaseApi) SearchJobRecords(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := cronjobService.SearchRecords(req)
|
total, list, err := cronjobService.SearchRecords(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,11 +219,11 @@ func (b *BaseApi) CleanRecord(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := cronjobService.CleanRecord(req); err != nil {
|
if err := cronjobService.CleanRecord(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Cronjob
|
// @Tags Cronjob
|
||||||
@@ -144,32 +242,54 @@ func (b *BaseApi) DeleteCronjob(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := cronjobService.Delete(req); err != nil {
|
if err := cronjobService.Delete(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Cronjob
|
// @Tags Cronjob
|
||||||
// @Summary Update cronjob
|
// @Summary Update cronjob
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.CronjobUpdate true "request"
|
// @Param request body dto.CronjobOperate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /cronjobs/update [post]
|
// @Router /cronjobs/update [post]
|
||||||
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"更新计划任务 [name]","formatEN":"update cronjob [name]"}
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"更新计划任务 [name]","formatEN":"update cronjob [name]"}
|
||||||
func (b *BaseApi) UpdateCronjob(c *gin.Context) {
|
func (b *BaseApi) UpdateCronjob(c *gin.Context) {
|
||||||
var req dto.CronjobUpdate
|
var req dto.CronjobOperate
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cronjobService.Update(req.ID, req); err != nil {
|
if err := cronjobService.Update(req.ID, req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Cronjob
|
||||||
|
// @Summary Update cronjob group
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.ChangeGroup true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /cronjobs/group/update [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"cronjobs","output_column":"name","output_value":"name"}],"formatZH":"更新计划任务分组 [name]","formatEN":"update cronjob group [name]"}
|
||||||
|
func (b *BaseApi) UpdateCronjobGroup(c *gin.Context) {
|
||||||
|
var req dto.ChangeGroup
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cronjobService.UpdateGroup(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Cronjob
|
// @Tags Cronjob
|
||||||
@@ -188,10 +308,10 @@ func (b *BaseApi) UpdateCronjobStatus(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := cronjobService.UpdateStatus(req.ID, req.Status); err != nil {
|
if err := cronjobService.UpdateStatus(req.ID, req.Status); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Cronjob
|
// @Tags Cronjob
|
||||||
@@ -211,7 +331,7 @@ func (b *BaseApi) TargetDownload(c *gin.Context) {
|
|||||||
|
|
||||||
filePath, err := cronjobService.Download(req)
|
filePath, err := cronjobService.Download(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,8 +354,8 @@ func (b *BaseApi) HandleOnce(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := cronjobService.HandleOnce(req.ID); err != nil {
|
if err := cronjobService.HandleOnce(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @Tags Dashboard
|
||||||
|
// @Summary Load os info
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200 {object} dto.OsInfo
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /dashboard/base/os [get]
|
||||||
|
func (b *BaseApi) LoadDashboardOsInfo(c *gin.Context) {
|
||||||
|
data, err := dashboardService.LoadOsInfo()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Dashboard
|
||||||
|
// @Summary Load app launcher
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200 {Array} dto.AppLauncher
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /dashboard/app/launcher [get]
|
||||||
|
func (b *BaseApi) LoadAppLauncher(c *gin.Context) {
|
||||||
|
data, err := dashboardService.LoadAppLauncher(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Dashboard
|
||||||
|
// @Summary Load app launcher options
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.SearchByFilter true "request"
|
||||||
|
// @Success 200 {Array} dto.LauncherOption
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /dashboard/app/launcher/option [post]
|
||||||
|
func (b *BaseApi) LoadAppLauncherOption(c *gin.Context) {
|
||||||
|
var req dto.SearchByFilter
|
||||||
|
if err := helper.CheckBind(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := dashboardService.ListLauncherOption(req.Filter)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Dashboard
|
||||||
|
// @Summary Update app Launcher
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.SettingUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /dashboard/app/launcher/show [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"首页应用 [key] => 显示:[value]","formatEN":"app launcher [key] => show: [value]"}
|
||||||
|
func (b *BaseApi) UpdateAppLauncher(c *gin.Context) {
|
||||||
|
var req dto.SettingUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := dashboardService.ChangeShow(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Dashboard
|
||||||
|
// @Summary Load dashboard base info
|
||||||
|
// @Accept json
|
||||||
|
// @Param ioOption path string true "request"
|
||||||
|
// @Param netOption path string true "request"
|
||||||
|
// @Success 200 {object} dto.DashboardBase
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /dashboard/base/:ioOption/:netOption [get]
|
||||||
|
func (b *BaseApi) LoadDashboardBaseInfo(c *gin.Context) {
|
||||||
|
ioOption, ok := c.Params.Get("ioOption")
|
||||||
|
if !ok {
|
||||||
|
helper.BadRequest(c, errors.New("error ioOption in path"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
netOption, ok := c.Params.Get("netOption")
|
||||||
|
if !ok {
|
||||||
|
helper.BadRequest(c, errors.New("error ioOption in path"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := dashboardService.LoadBaseInfo(ioOption, netOption)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Dashboard
|
||||||
|
// @Summary Load dashboard current info for node
|
||||||
|
// @Success 200 {object} dto.NodeCurrent
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /dashboard/current/node [get]
|
||||||
|
func (b *BaseApi) LoadCurrentInfoForNode(c *gin.Context) {
|
||||||
|
data := dashboardService.LoadCurrentInfoForNode()
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Dashboard
|
||||||
|
// @Summary Load dashboard current info
|
||||||
|
// @Accept json
|
||||||
|
// @Param ioOption path string true "request"
|
||||||
|
// @Param netOption path string true "request"
|
||||||
|
// @Success 200 {object} dto.DashboardCurrent
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /dashboard/current/:ioOption/:netOption [get]
|
||||||
|
func (b *BaseApi) LoadDashboardCurrentInfo(c *gin.Context) {
|
||||||
|
ioOption, ok := c.Params.Get("ioOption")
|
||||||
|
if !ok {
|
||||||
|
helper.BadRequest(c, errors.New("error ioOption in path"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
netOption, ok := c.Params.Get("netOption")
|
||||||
|
if !ok {
|
||||||
|
helper.BadRequest(c, errors.New("error netOption in path"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data := dashboardService.LoadCurrentInfo(ioOption, netOption)
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Dashboard
|
||||||
|
// @Summary System restart
|
||||||
|
// @Accept json
|
||||||
|
// @Param operation path string true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /dashboard/system/restart/:operation [post]
|
||||||
|
func (b *BaseApi) SystemRestart(c *gin.Context) {
|
||||||
|
operation, ok := c.Params.Get("operation")
|
||||||
|
if !ok {
|
||||||
|
helper.BadRequest(c, errors.New("error operation in path"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := dashboardService.Restart(operation); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,10 +32,10 @@ func (b *BaseApi) CreateDatabase(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := databaseService.Create(req); err != nil {
|
if err := databaseService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database
|
// @Tags Database
|
||||||
@@ -81,7 +80,7 @@ func (b *BaseApi) SearchDatabase(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := databaseService.SearchWithPage(req)
|
total, list, err := databaseService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,20 +92,19 @@ func (b *BaseApi) SearchDatabase(c *gin.Context) {
|
|||||||
|
|
||||||
// @Tags Database
|
// @Tags Database
|
||||||
// @Summary List databases
|
// @Summary List databases
|
||||||
// @Param type path string true "type"
|
|
||||||
// @Success 200 {array} dto.DatabaseOption
|
// @Success 200 {array} dto.DatabaseOption
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /databases/db/list/{type} [get]
|
// @Router /databases/db/list/:type [get]
|
||||||
func (b *BaseApi) ListDatabase(c *gin.Context) {
|
func (b *BaseApi) ListDatabase(c *gin.Context) {
|
||||||
dbType, err := helper.GetStrParamByKey(c, "type")
|
dbType, err := helper.GetStrParamByKey(c, "type")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
list, err := databaseService.List(dbType)
|
list, err := databaseService.List(dbType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,21 +112,20 @@ func (b *BaseApi) ListDatabase(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database
|
// @Tags Database
|
||||||
// @Summary Retrieve database list based on type
|
// @Summary List databases
|
||||||
// @Param type path string true "type"
|
|
||||||
// @Success 200 {array} dto.DatabaseItem
|
// @Success 200 {array} dto.DatabaseItem
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /databases/db/item/{type} [get]
|
// @Router /databases/db/item/:type [get]
|
||||||
func (b *BaseApi) LoadDatabaseItems(c *gin.Context) {
|
func (b *BaseApi) LoadDatabaseItems(c *gin.Context) {
|
||||||
dbType, err := helper.GetStrParamByKey(c, "type")
|
dbType, err := helper.GetStrParamByKey(c, "type")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
list, err := databaseService.LoadItems(dbType)
|
list, err := databaseService.LoadItems(dbType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,20 +134,19 @@ func (b *BaseApi) LoadDatabaseItems(c *gin.Context) {
|
|||||||
|
|
||||||
// @Tags Database
|
// @Tags Database
|
||||||
// @Summary Get databases
|
// @Summary Get databases
|
||||||
// @Param name path string true "name"
|
|
||||||
// @Success 200 {object} dto.DatabaseInfo
|
// @Success 200 {object} dto.DatabaseInfo
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /databases/db/{name} [get]
|
// @Router /databases/db/:name [get]
|
||||||
func (b *BaseApi) GetDatabase(c *gin.Context) {
|
func (b *BaseApi) GetDatabase(c *gin.Context) {
|
||||||
name, err := helper.GetStrParamByKey(c, "name")
|
name, err := helper.GetStrParamByKey(c, "name")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := databaseService.Get(name)
|
data, err := databaseService.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +169,7 @@ func (b *BaseApi) DeleteCheckDatabase(c *gin.Context) {
|
|||||||
|
|
||||||
apps, err := databaseService.DeleteCheck(req.ID)
|
apps, err := databaseService.DeleteCheck(req.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, apps)
|
helper.SuccessWithData(c, apps)
|
||||||
@@ -195,10 +191,10 @@ func (b *BaseApi) DeleteDatabase(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := databaseService.Delete(req); err != nil {
|
if err := databaseService.Delete(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database
|
// @Tags Database
|
||||||
@@ -225,8 +221,8 @@ func (b *BaseApi) UpdateDatabase(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := databaseService.Update(req); err != nil {
|
if err := databaseService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ func (b *BaseApi) LoadDBBaseInfo(c *gin.Context) {
|
|||||||
|
|
||||||
data, err := dbCommonService.LoadBaseInfo(req)
|
data, err := dbCommonService.LoadBaseInfo(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ func (b *BaseApi) LoadDBFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
content, err := dbCommonService.LoadDatabaseFile(req)
|
content, err := dbCommonService.LoadDatabaseFile(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, content)
|
helper.SuccessWithData(c, content)
|
||||||
@@ -67,9 +66,9 @@ func (b *BaseApi) UpdateDBConfByFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := dbCommonService.UpdateConfByFile(req); err != nil {
|
if err := dbCommonService.UpdateConfByFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,17 +27,17 @@ func (b *BaseApi) CreateMysql(c *gin.Context) {
|
|||||||
if len(req.Password) != 0 {
|
if len(req.Password) != 0 {
|
||||||
password, err := base64.StdEncoding.DecodeString(req.Password)
|
password, err := base64.StdEncoding.DecodeString(req.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Password = string(password)
|
req.Password = string(password)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := mysqlService.Create(context.Background(), req); err != nil {
|
if _, err := mysqlService.Create(context.Background(), req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Mysql
|
// @Tags Database Mysql
|
||||||
@@ -59,17 +58,17 @@ func (b *BaseApi) BindUser(c *gin.Context) {
|
|||||||
if len(req.Password) != 0 {
|
if len(req.Password) != 0 {
|
||||||
password, err := base64.StdEncoding.DecodeString(req.Password)
|
password, err := base64.StdEncoding.DecodeString(req.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Password = string(password)
|
req.Password = string(password)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.BindUser(req); err != nil {
|
if err := mysqlService.BindUser(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Mysql
|
// @Tags Database Mysql
|
||||||
@@ -88,10 +87,10 @@ func (b *BaseApi) UpdateMysqlDescription(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.UpdateDescription(req); err != nil {
|
if err := mysqlService.UpdateDescription(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Mysql
|
// @Tags Database Mysql
|
||||||
@@ -112,17 +111,17 @@ func (b *BaseApi) ChangeMysqlPassword(c *gin.Context) {
|
|||||||
if len(req.Value) != 0 {
|
if len(req.Value) != 0 {
|
||||||
value, err := base64.StdEncoding.DecodeString(req.Value)
|
value, err := base64.StdEncoding.DecodeString(req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Value = string(value)
|
req.Value = string(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.ChangePassword(req); err != nil {
|
if err := mysqlService.ChangePassword(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Mysql
|
// @Tags Database Mysql
|
||||||
@@ -141,10 +140,10 @@ func (b *BaseApi) ChangeMysqlAccess(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.ChangeAccess(req); err != nil {
|
if err := mysqlService.ChangeAccess(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Mysql
|
// @Tags Database Mysql
|
||||||
@@ -163,10 +162,10 @@ func (b *BaseApi) UpdateMysqlVariables(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.UpdateVariables(req); err != nil {
|
if err := mysqlService.UpdateVariables(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Mysql
|
// @Tags Database Mysql
|
||||||
@@ -185,7 +184,7 @@ func (b *BaseApi) SearchMysql(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := mysqlService.SearchWithPage(req)
|
total, list, err := mysqlService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +205,7 @@ func (b *BaseApi) SearchMysql(c *gin.Context) {
|
|||||||
func (b *BaseApi) ListDBName(c *gin.Context) {
|
func (b *BaseApi) ListDBName(c *gin.Context) {
|
||||||
list, err := mysqlService.ListDBOption()
|
list, err := mysqlService.ListDBOption()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +216,6 @@ func (b *BaseApi) ListDBName(c *gin.Context) {
|
|||||||
// @Summary Load mysql database from remote
|
// @Summary Load mysql database from remote
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.MysqlLoadDB true "request"
|
// @Param request body dto.MysqlLoadDB true "request"
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /databases/load [post]
|
// @Router /databases/load [post]
|
||||||
@@ -228,11 +226,11 @@ func (b *BaseApi) LoadDBFromRemote(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := mysqlService.LoadFromRemote(req); err != nil {
|
if err := mysqlService.LoadFromRemote(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Mysql
|
// @Tags Database Mysql
|
||||||
@@ -251,7 +249,7 @@ func (b *BaseApi) DeleteCheckMysql(c *gin.Context) {
|
|||||||
|
|
||||||
apps, err := mysqlService.DeleteCheck(req)
|
apps, err := mysqlService.DeleteCheck(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, apps)
|
helper.SuccessWithData(c, apps)
|
||||||
@@ -274,12 +272,12 @@ func (b *BaseApi) DeleteMysql(c *gin.Context) {
|
|||||||
|
|
||||||
tx, ctx := helper.GetTxAndContext()
|
tx, ctx := helper.GetTxAndContext()
|
||||||
if err := mysqlService.Delete(ctx, req); err != nil {
|
if err := mysqlService.Delete(ctx, req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Mysql
|
// @Tags Database Mysql
|
||||||
@@ -297,7 +295,7 @@ func (b *BaseApi) LoadRemoteAccess(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
isRemote, err := mysqlService.LoadRemoteAccess(req)
|
isRemote, err := mysqlService.LoadRemoteAccess(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +318,7 @@ func (b *BaseApi) LoadStatus(c *gin.Context) {
|
|||||||
|
|
||||||
data, err := mysqlService.LoadStatus(req)
|
data, err := mysqlService.LoadStatus(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +341,7 @@ func (b *BaseApi) LoadVariables(c *gin.Context) {
|
|||||||
|
|
||||||
data, err := mysqlService.LoadVariables(req)
|
data, err := mysqlService.LoadVariables(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
+32
-35
@@ -1,16 +1,15 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Create postgresql database
|
// @Summary Create postgresql database
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PostgresqlDBCreate true "request"
|
// @Param request body dto.PostgresqlDBCreate true "request"
|
||||||
@@ -28,20 +27,20 @@ func (b *BaseApi) CreatePostgresql(c *gin.Context) {
|
|||||||
if len(req.Password) != 0 {
|
if len(req.Password) != 0 {
|
||||||
password, err := base64.StdEncoding.DecodeString(req.Password)
|
password, err := base64.StdEncoding.DecodeString(req.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Password = string(password)
|
req.Password = string(password)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := postgresqlService.Create(context.Background(), req); err != nil {
|
if _, err := postgresqlService.Create(context.Background(), req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Bind postgresql user
|
// @Summary Bind postgresql user
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PostgresqlBindUser true "request"
|
// @Param request body dto.PostgresqlBindUser true "request"
|
||||||
@@ -57,13 +56,13 @@ func (b *BaseApi) BindPostgresqlUser(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := postgresqlService.BindUser(req); err != nil {
|
if err := postgresqlService.BindUser(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Update postgresql database description
|
// @Summary Update postgresql database description
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.UpdateDescription true "request"
|
// @Param request body dto.UpdateDescription true "request"
|
||||||
@@ -79,13 +78,13 @@ func (b *BaseApi) UpdatePostgresqlDescription(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := postgresqlService.UpdateDescription(req); err != nil {
|
if err := postgresqlService.UpdateDescription(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Change postgresql privileges
|
// @Summary Change postgresql privileges
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ChangeDBInfo true "request"
|
// @Param request body dto.ChangeDBInfo true "request"
|
||||||
@@ -101,13 +100,13 @@ func (b *BaseApi) ChangePostgresqlPrivileges(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := postgresqlService.ChangePrivileges(req); err != nil {
|
if err := postgresqlService.ChangePrivileges(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Change postgresql password
|
// @Summary Change postgresql password
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ChangeDBInfo true "request"
|
// @Param request body dto.ChangeDBInfo true "request"
|
||||||
@@ -125,20 +124,20 @@ func (b *BaseApi) ChangePostgresqlPassword(c *gin.Context) {
|
|||||||
if len(req.Value) != 0 {
|
if len(req.Value) != 0 {
|
||||||
value, err := base64.StdEncoding.DecodeString(req.Value)
|
value, err := base64.StdEncoding.DecodeString(req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Value = string(value)
|
req.Value = string(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := postgresqlService.ChangePassword(req); err != nil {
|
if err := postgresqlService.ChangePassword(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Page postgresql databases
|
// @Summary Page postgresql databases
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PostgresqlDBSearch true "request"
|
// @Param request body dto.PostgresqlDBSearch true "request"
|
||||||
@@ -154,7 +153,7 @@ func (b *BaseApi) SearchPostgresql(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := postgresqlService.SearchWithPage(req)
|
total, list, err := postgresqlService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,31 +163,29 @@ func (b *BaseApi) SearchPostgresql(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Load postgresql database from remote
|
// @Summary Load postgresql database from remote
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PostgresqlLoadDB true "request"
|
// @Param request body dto.PostgresqlLoadDB true "request"
|
||||||
// @Param database path string true "database"
|
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /databases/pg/{database}/load [post]
|
// @Router /databases/pg/:database/load [post]
|
||||||
func (b *BaseApi) LoadPostgresqlDBFromRemote(c *gin.Context) {
|
func (b *BaseApi) LoadPostgresqlDBFromRemote(c *gin.Context) {
|
||||||
database, err := helper.GetStrParamByKey(c, "database")
|
database, err := helper.GetStrParamByKey(c, "database")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := postgresqlService.LoadFromRemote(database); err != nil {
|
if err := postgresqlService.LoadFromRemote(database); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Check before delete postgresql database
|
// @Summary Check before delete postgresql database
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PostgresqlDBDeleteCheck true "request"
|
// @Param request body dto.PostgresqlDBDeleteCheck true "request"
|
||||||
@@ -204,13 +201,13 @@ func (b *BaseApi) DeleteCheckPostgresql(c *gin.Context) {
|
|||||||
|
|
||||||
apps, err := postgresqlService.DeleteCheck(req)
|
apps, err := postgresqlService.DeleteCheck(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, apps)
|
helper.SuccessWithData(c, apps)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Postgresql
|
// @Tags Database PostgreSQL
|
||||||
// @Summary Delete postgresql database
|
// @Summary Delete postgresql database
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PostgresqlDBDelete true "request"
|
// @Param request body dto.PostgresqlDBDelete true "request"
|
||||||
@@ -226,10 +223,10 @@ func (b *BaseApi) DeletePostgresql(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
tx, ctx := helper.GetTxAndContext()
|
tx, ctx := helper.GetTxAndContext()
|
||||||
if err := postgresqlService.Delete(ctx, req); err != nil {
|
if err := postgresqlService.Delete(ctx, req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,30 +1,29 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Tags Database Redis
|
// @Tags Database Redis
|
||||||
// @Summary Load redis status info
|
// @Summary Load redis status info
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.OperationWithName true "request"
|
// @Param request body dto.LoadRedisStatus true "request"
|
||||||
// @Success 200 {object} dto.RedisStatus
|
// @Success 200 {object} dto.RedisStatus
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /databases/redis/status [post]
|
// @Router /databases/redis/status [post]
|
||||||
func (b *BaseApi) LoadRedisStatus(c *gin.Context) {
|
func (b *BaseApi) LoadRedisStatus(c *gin.Context) {
|
||||||
var req dto.OperationWithName
|
var req dto.LoadRedisStatus
|
||||||
if err := helper.CheckBind(&req, c); err != nil {
|
if err := helper.CheckBind(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := redisService.LoadStatus(req)
|
data, err := redisService.LoadStatus(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,19 +33,19 @@ func (b *BaseApi) LoadRedisStatus(c *gin.Context) {
|
|||||||
// @Tags Database Redis
|
// @Tags Database Redis
|
||||||
// @Summary Load redis conf
|
// @Summary Load redis conf
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.OperationWithName true "request"
|
// @Param request body dto.LoadRedisStatus true "request"
|
||||||
// @Success 200 {object} dto.RedisConf
|
// @Success 200 {object} dto.RedisConf
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /databases/redis/conf [post]
|
// @Router /databases/redis/conf [post]
|
||||||
func (b *BaseApi) LoadRedisConf(c *gin.Context) {
|
func (b *BaseApi) LoadRedisConf(c *gin.Context) {
|
||||||
var req dto.OperationWithName
|
var req dto.LoadRedisStatus
|
||||||
if err := helper.CheckBind(&req, c); err != nil {
|
if err := helper.CheckBind(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := redisService.LoadConf(req)
|
data, err := redisService.LoadConf(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,19 +55,19 @@ func (b *BaseApi) LoadRedisConf(c *gin.Context) {
|
|||||||
// @Tags Database Redis
|
// @Tags Database Redis
|
||||||
// @Summary Load redis persistence conf
|
// @Summary Load redis persistence conf
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.OperationWithName true "request"
|
// @Param request body dto.LoadRedisStatus true "request"
|
||||||
// @Success 200 {object} dto.RedisPersistence
|
// @Success 200 {object} dto.RedisPersistence
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /databases/redis/persistence/conf [post]
|
// @Router /databases/redis/persistence/conf [post]
|
||||||
func (b *BaseApi) LoadPersistenceConf(c *gin.Context) {
|
func (b *BaseApi) LoadPersistenceConf(c *gin.Context) {
|
||||||
var req dto.OperationWithName
|
var req dto.LoadRedisStatus
|
||||||
if err := helper.CheckBind(&req, c); err != nil {
|
if err := helper.CheckBind(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := redisService.LoadPersistenceConf(req)
|
data, err := redisService.LoadPersistenceConf(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,11 +86,11 @@ func (b *BaseApi) CheckHasCli(c *gin.Context) {
|
|||||||
// @Router /databases/redis/install/cli [post]
|
// @Router /databases/redis/install/cli [post]
|
||||||
func (b *BaseApi) InstallCli(c *gin.Context) {
|
func (b *BaseApi) InstallCli(c *gin.Context) {
|
||||||
if err := redisService.InstallCli(); err != nil {
|
if err := redisService.InstallCli(); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Redis
|
// @Tags Database Redis
|
||||||
@@ -110,10 +109,10 @@ func (b *BaseApi) UpdateRedisConf(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := redisService.UpdateConf(req); err != nil {
|
if err := redisService.UpdateConf(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Redis
|
// @Tags Database Redis
|
||||||
@@ -134,17 +133,17 @@ func (b *BaseApi) ChangeRedisPassword(c *gin.Context) {
|
|||||||
if len(req.Value) != 0 {
|
if len(req.Value) != 0 {
|
||||||
value, err := base64.StdEncoding.DecodeString(req.Value)
|
value, err := base64.StdEncoding.DecodeString(req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Value = string(value)
|
req.Value = string(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := redisService.ChangePassword(req); err != nil {
|
if err := redisService.ChangePassword(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Database Redis
|
// @Tags Database Redis
|
||||||
@@ -163,8 +162,8 @@ func (b *BaseApi) UpdateRedisPersistenceConf(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := redisService.UpdatePersistenceConf(req); err != nil {
|
if err := redisService.UpdatePersistenceConf(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ import (
|
|||||||
func (b *BaseApi) LoadDeviceBaseInfo(c *gin.Context) {
|
func (b *BaseApi) LoadDeviceBaseInfo(c *gin.Context) {
|
||||||
data, err := deviceService.LoadBaseInfo()
|
data, err := deviceService.LoadBaseInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,14 +27,14 @@ func (b *BaseApi) LoadDeviceBaseInfo(c *gin.Context) {
|
|||||||
// @Tags Device
|
// @Tags Device
|
||||||
// @Summary list time zone options
|
// @Summary list time zone options
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Success 200 {array} string
|
// @Success 200 {Array} string
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /toolbox/device/zone/options [get]
|
// @Router /toolbox/device/zone/options [get]
|
||||||
func (b *BaseApi) LoadTimeOption(c *gin.Context) {
|
func (b *BaseApi) LoadTimeOption(c *gin.Context) {
|
||||||
list, err := deviceService.LoadTimeZone()
|
list, err := deviceService.LoadTimeZone()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +57,7 @@ func (b *BaseApi) LoadDeviceConf(c *gin.Context) {
|
|||||||
|
|
||||||
list, err := deviceService.LoadConf(req.Name)
|
list, err := deviceService.LoadConf(req.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,11 +78,26 @@ func (b *BaseApi) UpdateDeviceByFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := deviceService.UpdateByConf(req); err != nil {
|
if err := deviceService.UpdateByConf(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Device
|
||||||
|
// @Summary Load user list
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /toolbox/device/users [get]
|
||||||
|
func (b *BaseApi) LoadUsers(c *gin.Context) {
|
||||||
|
users, err := deviceService.LoadUsers()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, users)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Device
|
// @Tags Device
|
||||||
@@ -102,11 +116,11 @@ func (b *BaseApi) UpdateDeviceConf(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := deviceService.Update(req.Key, req.Value); err != nil {
|
if err := deviceService.Update(req.Key, req.Value); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Device
|
// @Tags Device
|
||||||
@@ -123,11 +137,11 @@ func (b *BaseApi) UpdateDeviceHost(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := deviceService.UpdateHosts(req); err != nil {
|
if err := deviceService.UpdateHosts(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Device
|
// @Tags Device
|
||||||
@@ -146,17 +160,17 @@ func (b *BaseApi) UpdateDevicePasswd(c *gin.Context) {
|
|||||||
if len(req.Passwd) != 0 {
|
if len(req.Passwd) != 0 {
|
||||||
password, err := base64.StdEncoding.DecodeString(req.Passwd)
|
password, err := base64.StdEncoding.DecodeString(req.Passwd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Passwd = string(password)
|
req.Passwd = string(password)
|
||||||
}
|
}
|
||||||
if err := deviceService.UpdatePasswd(req); err != nil {
|
if err := deviceService.UpdatePasswd(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Device
|
// @Tags Device
|
||||||
@@ -174,11 +188,11 @@ func (b *BaseApi) UpdateDeviceSwap(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := deviceService.UpdateSwap(req); err != nil {
|
if err := deviceService.UpdateSwap(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Device
|
// @Tags Device
|
||||||
@@ -197,7 +211,7 @@ func (b *BaseApi) CheckDNS(c *gin.Context) {
|
|||||||
|
|
||||||
data, err := deviceService.CheckDNS(req.Key, req.Value)
|
data, err := deviceService.CheckDNS(req.Key, req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,5 +246,5 @@ func (b *BaseApi) SystemClean(c *gin.Context) {
|
|||||||
|
|
||||||
deviceService.Clean(req)
|
deviceService.Clean(req)
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Tags Container Docker
|
// @Tags Container Docker
|
||||||
// @Summary Load docker status
|
// @Summary Load docker status
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {string} status
|
// @Success 200 {string} dto.DockerStatus
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/docker/status [get]
|
// @Router /containers/docker/status [get]
|
||||||
@@ -35,7 +35,7 @@ func (b *BaseApi) LoadDaemonJsonFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
content, err := os.ReadFile(constant.DaemonJsonPath)
|
content, err := os.ReadFile(constant.DaemonJsonPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, string(content))
|
helper.SuccessWithData(c, string(content))
|
||||||
@@ -49,7 +49,11 @@ func (b *BaseApi) LoadDaemonJsonFile(c *gin.Context) {
|
|||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/daemonjson [get]
|
// @Router /containers/daemonjson [get]
|
||||||
func (b *BaseApi) LoadDaemonJson(c *gin.Context) {
|
func (b *BaseApi) LoadDaemonJson(c *gin.Context) {
|
||||||
conf := dockerService.LoadDockerConf()
|
conf, err := dockerService.LoadDockerConf()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
helper.SuccessWithData(c, conf)
|
helper.SuccessWithData(c, conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,12 +72,12 @@ func (b *BaseApi) UpdateDaemonJson(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := dockerService.UpdateConf(req); err != nil {
|
if err := dockerService.UpdateConf(req, true); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Docker
|
// @Tags Container Docker
|
||||||
@@ -92,11 +96,11 @@ func (b *BaseApi) UpdateLogOption(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := dockerService.UpdateLogOption(req); err != nil {
|
if err := dockerService.UpdateLogOption(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Docker
|
// @Tags Container Docker
|
||||||
@@ -115,11 +119,11 @@ func (b *BaseApi) UpdateIpv6Option(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := dockerService.UpdateIpv6Option(req); err != nil {
|
if err := dockerService.UpdateIpv6Option(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Docker
|
// @Tags Container Docker
|
||||||
@@ -138,11 +142,11 @@ func (b *BaseApi) UpdateDaemonJsonByFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := dockerService.UpdateConfByFile(req); err != nil {
|
if err := dockerService.UpdateConfByFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Docker
|
// @Tags Container Docker
|
||||||
@@ -161,9 +165,9 @@ func (b *BaseApi) OperateDocker(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := dockerService.OperateDocker(req); err != nil {
|
if err := dockerService.OperateDocker(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import "github.com/1Panel-dev/1Panel/backend/app/service"
|
import "github.com/1Panel-dev/1Panel/agent/app/service"
|
||||||
|
|
||||||
type ApiGroup struct {
|
type ApiGroup struct {
|
||||||
BaseApi
|
BaseApi
|
||||||
@@ -8,14 +8,17 @@ type ApiGroup struct {
|
|||||||
|
|
||||||
var ApiGroupApp = new(ApiGroup)
|
var ApiGroupApp = new(ApiGroup)
|
||||||
|
|
||||||
|
type BaseApi struct{}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
authService = service.NewIAuthService()
|
|
||||||
dashboardService = service.NewIDashboardService()
|
dashboardService = service.NewIDashboardService()
|
||||||
|
|
||||||
appService = service.NewIAppService()
|
appService = service.NewIAppService()
|
||||||
appInstallService = service.NewIAppInstalledService()
|
appInstallService = service.NewIAppInstalledService()
|
||||||
|
appIgnoreUpgradeService = service.NewIAppIgnoreUpgradeService()
|
||||||
|
|
||||||
AIToolService = service.NewIAIToolService()
|
aiToolService = service.NewIAIToolService()
|
||||||
|
mcpServerService = service.NewIMcpServerService()
|
||||||
|
|
||||||
containerService = service.NewIContainerService()
|
containerService = service.NewIContainerService()
|
||||||
composeTemplateService = service.NewIComposeTemplateService()
|
composeTemplateService = service.NewIComposeTemplateService()
|
||||||
@@ -31,21 +34,19 @@ var (
|
|||||||
|
|
||||||
cronjobService = service.NewICronjobService()
|
cronjobService = service.NewICronjobService()
|
||||||
|
|
||||||
hostService = service.NewIHostService()
|
|
||||||
groupService = service.NewIGroupService()
|
|
||||||
fileService = service.NewIFileService()
|
fileService = service.NewIFileService()
|
||||||
sshService = service.NewISSHService()
|
sshService = service.NewISSHService()
|
||||||
firewallService = service.NewIFirewallService()
|
firewallService = service.NewIFirewallService()
|
||||||
|
monitorService = service.NewIMonitorService()
|
||||||
|
|
||||||
deviceService = service.NewIDeviceService()
|
deviceService = service.NewIDeviceService()
|
||||||
fail2banService = service.NewIFail2BanService()
|
fail2banService = service.NewIFail2BanService()
|
||||||
ftpService = service.NewIFtpService()
|
ftpService = service.NewIFtpService()
|
||||||
clamService = service.NewIClamService()
|
clamService = service.NewIClamService()
|
||||||
|
|
||||||
settingService = service.NewISettingService()
|
settingService = service.NewISettingService()
|
||||||
backupService = service.NewIBackupService()
|
backupService = service.NewIBackupService()
|
||||||
|
backupRecordService = service.NewIBackupRecordService()
|
||||||
commandService = service.NewICommandService()
|
|
||||||
|
|
||||||
websiteService = service.NewIWebsiteService()
|
websiteService = service.NewIWebsiteService()
|
||||||
websiteDnsAccountService = service.NewIWebsiteDnsAccountService()
|
websiteDnsAccountService = service.NewIWebsiteDnsAccountService()
|
||||||
@@ -56,7 +57,6 @@ var (
|
|||||||
|
|
||||||
logService = service.NewILogService()
|
logService = service.NewILogService()
|
||||||
snapshotService = service.NewISnapshotService()
|
snapshotService = service.NewISnapshotService()
|
||||||
upgradeService = service.NewIUpgradeService()
|
|
||||||
|
|
||||||
runtimeService = service.NewRuntimeService()
|
runtimeService = service.NewRuntimeService()
|
||||||
processService = service.NewIProcessService()
|
processService = service.NewIProcessService()
|
||||||
@@ -68,6 +68,7 @@ var (
|
|||||||
favoriteService = service.NewIFavoriteService()
|
favoriteService = service.NewIFavoriteService()
|
||||||
|
|
||||||
websiteCAService = service.NewIWebsiteCAService()
|
websiteCAService = service.NewIWebsiteCAService()
|
||||||
|
taskService = service.NewITaskService()
|
||||||
mcpServerService = service.NewIMcpServerService()
|
groupService = service.NewIGroupService()
|
||||||
|
alertService = service.NewIAlertService()
|
||||||
)
|
)
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ import (
|
|||||||
func (b *BaseApi) LoadFail2BanBaseInfo(c *gin.Context) {
|
func (b *BaseApi) LoadFail2BanBaseInfo(c *gin.Context) {
|
||||||
data, err := fail2banService.LoadBaseInfo()
|
data, err := fail2banService.LoadBaseInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ func (b *BaseApi) LoadFail2BanBaseInfo(c *gin.Context) {
|
|||||||
// @Summary Page fail2ban ip list
|
// @Summary Page fail2ban ip list
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.Fail2BanSearch true "request"
|
// @Param request body dto.Fail2BanSearch true "request"
|
||||||
// @Success 200 {array} string
|
// @Success 200 {Array} string
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /toolbox/fail2ban/search [post]
|
// @Router /toolbox/fail2ban/search [post]
|
||||||
@@ -41,7 +40,7 @@ func (b *BaseApi) SearchFail2Ban(c *gin.Context) {
|
|||||||
|
|
||||||
list, err := fail2banService.Search(req)
|
list, err := fail2banService.Search(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +51,6 @@ func (b *BaseApi) SearchFail2Ban(c *gin.Context) {
|
|||||||
// @Summary Operate fail2ban
|
// @Summary Operate fail2ban
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.Operate true "request"
|
// @Param request body dto.Operate true "request"
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /toolbox/fail2ban/operate [post]
|
// @Router /toolbox/fail2ban/operate [post]
|
||||||
@@ -64,18 +62,17 @@ func (b *BaseApi) OperateFail2Ban(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := fail2banService.Operate(req.Operation); err != nil {
|
if err := fail2banService.Operate(req.Operation); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Fail2ban
|
// @Tags Fail2ban
|
||||||
// @Summary Operate sshd of fail2ban
|
// @Summary Operate sshd of fail2ban
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.Operate true "request"
|
// @Param request body dto.Operate true "request"
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /toolbox/fail2ban/operate/sshd [post]
|
// @Router /toolbox/fail2ban/operate/sshd [post]
|
||||||
@@ -86,11 +83,11 @@ func (b *BaseApi) OperateSSHD(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := fail2banService.OperateSSHD(req); err != nil {
|
if err := fail2banService.OperateSSHD(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Fail2ban
|
// @Tags Fail2ban
|
||||||
@@ -109,10 +106,10 @@ func (b *BaseApi) UpdateFail2BanConf(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := fail2banService.UpdateConf(req); err != nil {
|
if err := fail2banService.UpdateConf(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Fail2ban
|
// @Tags Fail2ban
|
||||||
@@ -126,7 +123,7 @@ func (b *BaseApi) LoadFail2BanConf(c *gin.Context) {
|
|||||||
path := "/etc/fail2ban/jail.local"
|
path := "/etc/fail2ban/jail.local"
|
||||||
file, err := os.ReadFile(path)
|
file, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,9 +144,9 @@ func (b *BaseApi) UpdateFail2BanConfByFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fail2banService.UpdateConfByFile(req); err != nil {
|
if err := fail2banService.UpdateConfByFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ func (b *BaseApi) SearchFavorite(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
total, list, err := favoriteService.Page(req)
|
total, list, err := favoriteService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -48,7 +47,7 @@ func (b *BaseApi) CreateFavorite(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
favorite, err := favoriteService.Create(req)
|
favorite, err := favoriteService.Create(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, favorite)
|
helper.SuccessWithData(c, favorite)
|
||||||
@@ -69,8 +68,8 @@ func (b *BaseApi) DeleteFavorite(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := favoriteService.Delete(req.ID); err != nil {
|
if err := favoriteService.Delete(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -13,15 +14,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/response"
|
||||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
"github.com/1Panel-dev/1Panel/agent/buserr"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/agent/global"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
"github.com/1Panel-dev/1Panel/agent/utils/files"
|
||||||
websocket2 "github.com/1Panel-dev/1Panel/backend/utils/websocket"
|
websocket2 "github.com/1Panel-dev/1Panel/agent/utils/websocket"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
)
|
)
|
||||||
@@ -41,7 +42,7 @@ func (b *BaseApi) ListFiles(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
fileList, err := fileService.GetFileList(req)
|
fileList, err := fileService.GetFileList(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, fileList)
|
helper.SuccessWithData(c, fileList)
|
||||||
@@ -62,7 +63,7 @@ func (b *BaseApi) SearchUploadWithPage(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
total, files, err := fileService.SearchUploadWithPage(req)
|
total, files, err := fileService.SearchUploadWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -86,7 +87,7 @@ func (b *BaseApi) GetFileTree(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
tree, err := fileService.GetFileTree(req)
|
tree, err := fileService.GetFileTree(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, tree)
|
helper.SuccessWithData(c, tree)
|
||||||
@@ -108,10 +109,10 @@ func (b *BaseApi) CreateFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := fileService.Create(req)
|
err := fileService.Create(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -130,10 +131,10 @@ func (b *BaseApi) DeleteFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := fileService.Delete(req)
|
err := fileService.Delete(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -152,10 +153,10 @@ func (b *BaseApi) BatchDeleteFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := fileService.BatchDelete(req)
|
err := fileService.BatchDelete(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -174,10 +175,10 @@ func (b *BaseApi) ChangeFileMode(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := fileService.ChangeMode(req)
|
err := fileService.ChangeMode(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -195,10 +196,10 @@ func (b *BaseApi) ChangeFileOwner(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileService.ChangeOwner(req); err != nil {
|
if err := fileService.ChangeOwner(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -217,10 +218,10 @@ func (b *BaseApi) CompressFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := fileService.Compress(req)
|
err := fileService.Compress(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -239,10 +240,10 @@ func (b *BaseApi) DeCompressFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := fileService.DeCompress(req)
|
err := fileService.DeCompress(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -261,7 +262,7 @@ func (b *BaseApi) GetContent(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
info, err := fileService.GetContent(req)
|
info, err := fileService.GetContent(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, info)
|
helper.SuccessWithData(c, info)
|
||||||
@@ -282,25 +283,24 @@ func (b *BaseApi) SaveContent(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileService.SaveContent(req); err != nil {
|
if err := fileService.SaveContent(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
// @Summary Upload file
|
// @Summary Upload file
|
||||||
// @Accept multipart/form-data
|
|
||||||
// @Param file formData file true "request"
|
// @Param file formData file true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /files/upload [post]
|
// @Router /files/upload [post]
|
||||||
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"上传文件 [path]","formatEN":"Upload file [path]"}
|
// @x-panel-log {"bodyKeys":["path", "file"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"上传文件 [path]/[file]","formatEN":"Upload file [path]/[file]"}
|
||||||
func (b *BaseApi) UploadFiles(c *gin.Context) {
|
func (b *BaseApi) UploadFiles(c *gin.Context) {
|
||||||
form, err := c.MultipartForm()
|
form, err := c.MultipartForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uploadFiles := form.File["file"]
|
uploadFiles := form.File["file"]
|
||||||
@@ -315,7 +315,7 @@ func (b *BaseApi) UploadFiles(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(paths) == 0 || !strings.Contains(paths[0], "/") {
|
if len(paths) == 0 || !strings.Contains(paths[0], "/") {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, errors.New("error paths in request"))
|
helper.BadRequest(c, errors.New("error paths in request"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dir := path.Dir(paths[0])
|
dir := path.Dir(paths[0])
|
||||||
@@ -324,27 +324,27 @@ func (b *BaseApi) UploadFiles(c *gin.Context) {
|
|||||||
if err != nil && os.IsNotExist(err) {
|
if err != nil && os.IsNotExist(err) {
|
||||||
mode, err := files.GetParentMode(dir)
|
mode, err := files.GetParentMode(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = os.MkdirAll(dir, mode); err != nil {
|
if err = os.MkdirAll(dir, mode); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, fmt.Errorf("mkdir %s failed, err: %v", dir, err))
|
helper.BadRequest(c, fmt.Errorf("mkdir %s failed, err: %v", dir, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info, err := os.Stat(dir)
|
info, err := os.Stat(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mode := info.Mode()
|
mode := info.Mode()
|
||||||
|
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
stat, ok := info.Sys().(*syscall.Stat_t)
|
stat, ok := info.Sys().(*syscall.Stat_t)
|
||||||
uid, gid := -1, -1
|
uid, gid := -1, -1
|
||||||
if ok {
|
if ok {
|
||||||
uid, gid = int(stat.Uid), int(stat.Gid)
|
uid, gid = int(stat.Uid), int(stat.Gid)
|
||||||
}
|
}
|
||||||
|
|
||||||
success := 0
|
success := 0
|
||||||
failures := make(buserr.MultiErr)
|
failures := make(buserr.MultiErr)
|
||||||
for _, file := range uploadFiles {
|
for _, file := range uploadFiles {
|
||||||
@@ -391,7 +391,7 @@ func (b *BaseApi) UploadFiles(c *gin.Context) {
|
|||||||
success++
|
success++
|
||||||
}
|
}
|
||||||
if success == 0 {
|
if success == 0 {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, failures)
|
helper.InternalServer(c, failures)
|
||||||
} else {
|
} else {
|
||||||
helper.SuccessWithMsg(c, fmt.Sprintf("%d files upload success", success))
|
helper.SuccessWithMsg(c, fmt.Sprintf("%d files upload success", success))
|
||||||
}
|
}
|
||||||
@@ -458,10 +458,10 @@ func (b *BaseApi) ChangeFileName(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileService.ChangeName(req); err != nil {
|
if err := fileService.ChangeName(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -480,7 +480,7 @@ func (b *BaseApi) WgetFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
key, err := fileService.Wget(req)
|
key, err := fileService.Wget(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, response.FileWgetRes{
|
helper.SuccessWithData(c, response.FileWgetRes{
|
||||||
@@ -503,10 +503,10 @@ func (b *BaseApi) MoveFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileService.MvFile(req); err != nil {
|
if err := fileService.MvFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
@@ -520,7 +520,7 @@ func (b *BaseApi) Download(c *gin.Context) {
|
|||||||
filePath := c.Query("path")
|
filePath := c.Query("path")
|
||||||
file, err := os.Open(filePath)
|
file, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
info, _ := file.Stat()
|
info, _ := file.Stat()
|
||||||
@@ -545,22 +545,22 @@ func (b *BaseApi) DownloadChunkFiles(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
if !fileOp.Stat(req.Path) {
|
if !fileOp.Stat(req.Path) {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrPathNotFound, nil)
|
helper.ErrorWithDetail(c, http.StatusInternalServerError, "ErrPathNotFound", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
filePath := req.Path
|
filePath := req.Path
|
||||||
fstFile, err := fileOp.OpenFile(filePath)
|
fstFile, err := fileOp.OpenFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
info, err := fstFile.Stat()
|
info, err := fstFile.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrFileDownloadDir, err)
|
helper.ErrorWithDetail(c, http.StatusInternalServerError, "ErrFileDownloadDir", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +589,7 @@ func (b *BaseApi) DownloadChunkFiles(c *gin.Context) {
|
|||||||
buffer := make([]byte, 1024*1024)
|
buffer := make([]byte, 1024*1024)
|
||||||
file, err := os.Open(filePath)
|
file, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
@@ -598,7 +598,7 @@ func (b *BaseApi) DownloadChunkFiles(c *gin.Context) {
|
|||||||
reader := io.LimitReader(file, endPos-startPos+1)
|
reader := io.LimitReader(file, endPos-startPos+1)
|
||||||
_, err = io.CopyBuffer(c.Writer, reader, buffer)
|
_, err = io.CopyBuffer(c.Writer, reader, buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -622,7 +622,29 @@ func (b *BaseApi) Size(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := fileService.DirSize(req)
|
res, err := fileService.DirSize(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags File
|
||||||
|
// @Summary Multi file size
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.DirSizeReq true "request"
|
||||||
|
// @Success 200 {array} response.DepthDirSizeRes
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /files/depth/size [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"获取目录及其第一层子目录文件夹大小 [path]","formatEN":"Multi file size [path]"}
|
||||||
|
func (b *BaseApi) DepthDirSize(c *gin.Context) {
|
||||||
|
var req request.DirSizeReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := fileService.DepthDirSize(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -637,19 +659,11 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int,
|
|||||||
dstDir = strings.TrimSpace(dstDir)
|
dstDir = strings.TrimSpace(dstDir)
|
||||||
mode, _ := files.GetParentMode(dstDir)
|
mode, _ := files.GetParentMode(dstDir)
|
||||||
if mode == 0 {
|
if mode == 0 {
|
||||||
mode = 0755
|
mode = constant.DirPerm
|
||||||
}
|
}
|
||||||
uid, gid := -1, -1
|
if _, err := os.Stat(dstDir); err != nil && os.IsNotExist(err) {
|
||||||
if info, err := os.Stat(dstDir); err != nil {
|
if err = op.CreateDir(dstDir, mode); err != nil {
|
||||||
if os.IsNotExist(err) {
|
return err
|
||||||
if err = op.CreateDir(dstDir, mode); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stat, ok := info.Sys().(*syscall.Stat_t)
|
|
||||||
if ok {
|
|
||||||
uid, gid = int(stat.Uid), int(stat.Gid)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dstFileName := filepath.Join(dstDir, fileName)
|
dstFileName := filepath.Join(dstDir, fileName)
|
||||||
@@ -659,7 +673,6 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int,
|
|||||||
} else {
|
} else {
|
||||||
mode = 0644
|
mode = 0644
|
||||||
}
|
}
|
||||||
|
|
||||||
if overwrite {
|
if overwrite {
|
||||||
_ = os.Remove(dstFileName)
|
_ = os.Remove(dstFileName)
|
||||||
}
|
}
|
||||||
@@ -680,16 +693,12 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int,
|
|||||||
}
|
}
|
||||||
_ = os.Remove(chunkPath)
|
_ = os.Remove(chunkPath)
|
||||||
}
|
}
|
||||||
if uid != -1 && gid != -1 {
|
|
||||||
_ = os.Chown(dstFileName, uid, gid)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
// @Summary Chunk upload file
|
// @Summary ChunkUpload file
|
||||||
// @Accept multipart/form-data
|
|
||||||
// @Param file formData file true "request"
|
// @Param file formData file true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
@@ -699,30 +708,30 @@ func (b *BaseApi) UploadChunkFiles(c *gin.Context) {
|
|||||||
var err error
|
var err error
|
||||||
fileForm, err := c.FormFile("chunk")
|
fileForm, err := c.FormFile("chunk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uploadFile, err := fileForm.Open()
|
uploadFile, err := fileForm.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer uploadFile.Close()
|
defer uploadFile.Close()
|
||||||
chunkIndex, err := strconv.Atoi(c.PostForm("chunkIndex"))
|
chunkIndex, err := strconv.Atoi(c.PostForm("chunkIndex"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
chunkCount, err := strconv.Atoi(c.PostForm("chunkCount"))
|
chunkCount, err := strconv.Atoi(c.PostForm("chunkCount"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
tmpDir := path.Join(global.CONF.System.TmpDir, "upload")
|
tmpDir := path.Join(global.Dir.TmpDir, "upload")
|
||||||
if !fileOp.Stat(tmpDir) {
|
if !fileOp.Stat(tmpDir) {
|
||||||
if err := fileOp.CreateDir(tmpDir, 0755); err != nil {
|
if err := fileOp.CreateDir(tmpDir, constant.DirPerm); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -732,7 +741,7 @@ func (b *BaseApi) UploadChunkFiles(c *gin.Context) {
|
|||||||
if fileOp.Stat(fileDir) {
|
if fileOp.Stat(fileDir) {
|
||||||
_ = fileOp.DeleteDir(fileDir)
|
_ = fileOp.DeleteDir(fileDir)
|
||||||
}
|
}
|
||||||
_ = os.MkdirAll(fileDir, 0755)
|
_ = os.MkdirAll(fileDir, constant.DirPerm)
|
||||||
}
|
}
|
||||||
filePath := filepath.Join(fileDir, filename)
|
filePath := filepath.Join(fileDir, filename)
|
||||||
|
|
||||||
@@ -748,21 +757,21 @@ func (b *BaseApi) UploadChunkFiles(c *gin.Context) {
|
|||||||
|
|
||||||
emptyFile, err = os.Create(filePath)
|
emptyFile, err = os.Create(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer emptyFile.Close()
|
defer emptyFile.Close()
|
||||||
|
|
||||||
chunkData, err = io.ReadAll(uploadFile)
|
chunkData, err = io.ReadAll(uploadFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, buserr.WithMap(constant.ErrFileUpload, map[string]interface{}{"name": filename, "detail": err.Error()}, err))
|
helper.InternalServer(c, buserr.WithMap("ErrFileUpload", map[string]interface{}{"name": filename, "detail": err.Error()}, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkPath := filepath.Join(fileDir, fmt.Sprintf("%s.%d", filename, chunkIndex))
|
chunkPath := filepath.Join(fileDir, fmt.Sprintf("%s.%d", filename, chunkIndex))
|
||||||
err = os.WriteFile(chunkPath, chunkData, 0644)
|
err = os.WriteFile(chunkPath, chunkData, constant.DirPerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, buserr.WithMap(constant.ErrFileUpload, map[string]interface{}{"name": filename, "detail": err.Error()}, err))
|
helper.InternalServer(c, buserr.WithMap("ErrFileUpload", map[string]interface{}{"name": filename, "detail": err.Error()}, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,7 +782,7 @@ func (b *BaseApi) UploadChunkFiles(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err = mergeChunks(filename, fileDir, c.PostForm("path"), chunkCount, overwrite)
|
err = mergeChunks(filename, fileDir, c.PostForm("path"), chunkCount, overwrite)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, buserr.WithMap(constant.ErrFileUpload, map[string]interface{}{"name": filename, "detail": err.Error()}, err))
|
helper.InternalServer(c, buserr.WithMap("ErrFileUpload", map[string]interface{}{"name": filename, "detail": err.Error()}, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, true)
|
helper.SuccessWithData(c, true)
|
||||||
@@ -788,7 +797,7 @@ var wsUpgrade = websocket.Upgrader{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) Ws(c *gin.Context) {
|
func (b *BaseApi) WgetProcess(c *gin.Context) {
|
||||||
ws, err := wsUpgrade.Upgrade(c.Writer, c.Request, nil)
|
ws, err := wsUpgrade.Upgrade(c.Writer, c.Request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -798,14 +807,20 @@ func (b *BaseApi) Ws(c *gin.Context) {
|
|||||||
go wsClient.Write()
|
go wsClient.Write()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) Keys(c *gin.Context) {
|
func (b *BaseApi) ProcessKeys(c *gin.Context) {
|
||||||
res := &response.FileProcessKeys{}
|
res := &response.FileProcessKeys{}
|
||||||
keys, err := global.CACHE.PrefixScanKey("file-wget-")
|
keys := global.CACHE.PrefixScanKey("file-wget-")
|
||||||
if err != nil {
|
for _, key := range keys {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
value := global.CACHE.Get(key)
|
||||||
return
|
if value == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var process files.Process
|
||||||
|
if err := json.Unmarshal([]byte(value), &process); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
res.Keys = append(res.Keys, key)
|
||||||
}
|
}
|
||||||
res.Keys = keys
|
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,7 +838,7 @@ func (b *BaseApi) ReadFileByLine(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := fileService.ReadLogByLine(req)
|
res, err := fileService.ReadLogByLine(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -844,7 +859,45 @@ func (b *BaseApi) BatchChangeModeAndOwner(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileService.BatchChangeModeAndOwner(req); err != nil {
|
if err := fileService.BatchChangeModeAndOwner(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetPathByType(c *gin.Context) {
|
||||||
|
pathType, ok := c.Params.Get("type")
|
||||||
|
if !ok {
|
||||||
|
helper.BadRequest(c, errors.New("error pathType id in path"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resPath := fileService.GetPathByType(pathType)
|
||||||
|
helper.SuccessWithData(c, resPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags File
|
||||||
|
// @Summary system mount
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200 {object} dto.DiskInfo
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /mount [post]
|
||||||
|
func (b *BaseApi) GetHostMount(c *gin.Context) {
|
||||||
|
disks := fileService.GetHostMount()
|
||||||
|
helper.SuccessWithData(c, disks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags File
|
||||||
|
// @Summary system user and group
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200 {object} response.UserGroupResponse
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /user/group [post]
|
||||||
|
func (b *BaseApi) GetUsersAndGroups(c *gin.Context) {
|
||||||
|
res, err := fileService.GetUsersAndGroups()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ import (
|
|||||||
func (b *BaseApi) LoadFirewallBaseInfo(c *gin.Context) {
|
func (b *BaseApi) LoadFirewallBaseInfo(c *gin.Context) {
|
||||||
data, err := firewallService.LoadBaseInfo()
|
data, err := firewallService.LoadBaseInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ func (b *BaseApi) SearchFirewallRule(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := firewallService.SearchWithPage(req)
|
total, list, err := firewallService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ func (b *BaseApi) SearchFirewallRule(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Firewall
|
// @Tags Firewall
|
||||||
// @Summary Page firewall status
|
// @Summary Operate firewall
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.FirewallOperation true "request"
|
// @Param request body dto.FirewallOperation true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -65,15 +64,15 @@ func (b *BaseApi) OperateFirewall(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.OperateFirewall(req.Operation); err != nil {
|
if err := firewallService.OperateFirewall(req.Operation); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Firewall
|
// @Tags Firewall
|
||||||
// @Summary Create firewall port group
|
// @Summary Create group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PortRuleOperate true "request"
|
// @Param request body dto.PortRuleOperate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -88,15 +87,15 @@ func (b *BaseApi) OperatePortRule(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.OperatePortRule(req, true); err != nil {
|
if err := firewallService.OperatePortRule(req, true); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OperateForwardRule
|
// OperateForwardRule
|
||||||
// @Tags Firewall
|
// @Tags Firewall
|
||||||
// @Summary Update firewall port group
|
// @Summary Create group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ForwardRuleOperate true "request"
|
// @Param request body dto.ForwardRuleOperate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -111,14 +110,14 @@ func (b *BaseApi) OperateForwardRule(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.OperateForwardRule(req); err != nil {
|
if err := firewallService.OperateForwardRule(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Firewall
|
// @Tags Firewall
|
||||||
// @Summary Create firewall group
|
// @Summary Create group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.AddrRuleOperate true "request"
|
// @Param request body dto.AddrRuleOperate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -133,14 +132,14 @@ func (b *BaseApi) OperateIPRule(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.OperateAddressRule(req, true); err != nil {
|
if err := firewallService.OperateAddressRule(req, true); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Firewall
|
// @Tags Firewall
|
||||||
// @Summary Batch create group
|
// @Summary Create group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.BatchRuleOperate true "request"
|
// @Param request body dto.BatchRuleOperate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -154,10 +153,10 @@ func (b *BaseApi) BatchOperateRule(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.BatchOperateRule(req); err != nil {
|
if err := firewallService.BatchOperateRule(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Firewall
|
// @Tags Firewall
|
||||||
@@ -175,14 +174,14 @@ func (b *BaseApi) UpdateFirewallDescription(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.UpdateDescription(req); err != nil {
|
if err := firewallService.UpdateDescription(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Firewall
|
// @Tags Firewall
|
||||||
// @Summary Update firewall group
|
// @Summary Create group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PortRuleUpdate true "request"
|
// @Param request body dto.PortRuleUpdate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -196,14 +195,14 @@ func (b *BaseApi) UpdatePortRule(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.UpdatePortRule(req); err != nil {
|
if err := firewallService.UpdatePortRule(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Firewall
|
// @Tags Firewall
|
||||||
// @Summary Update address group
|
// @Summary Create group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.AddrRuleUpdate true "request"
|
// @Param request body dto.AddrRuleUpdate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -217,8 +216,8 @@ func (b *BaseApi) UpdateAddrRule(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := firewallService.UpdateAddrRule(req); err != nil {
|
if err := firewallService.UpdateAddrRule(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ import (
|
|||||||
func (b *BaseApi) LoadFtpBaseInfo(c *gin.Context) {
|
func (b *BaseApi) LoadFtpBaseInfo(c *gin.Context) {
|
||||||
data, err := ftpService.LoadBaseInfo()
|
data, err := ftpService.LoadBaseInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ func (b *BaseApi) LoadFtpLogInfo(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := ftpService.LoadLog(req)
|
total, list, err := ftpService.LoadLog(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +54,6 @@ func (b *BaseApi) LoadFtpLogInfo(c *gin.Context) {
|
|||||||
// @Summary Operate FTP
|
// @Summary Operate FTP
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.Operate true "request"
|
// @Param request body dto.Operate true "request"
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /toolbox/ftp/operate [post]
|
// @Router /toolbox/ftp/operate [post]
|
||||||
@@ -67,11 +65,11 @@ func (b *BaseApi) OperateFtp(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := ftpService.Operate(req.Operation); err != nil {
|
if err := ftpService.Operate(req.Operation); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags FTP
|
// @Tags FTP
|
||||||
@@ -90,7 +88,7 @@ func (b *BaseApi) SearchFtp(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := ftpService.SearchWithPage(req)
|
total, list, err := ftpService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,16 +116,16 @@ func (b *BaseApi) CreateFtp(c *gin.Context) {
|
|||||||
if len(req.Password) != 0 {
|
if len(req.Password) != 0 {
|
||||||
pass, err := base64.StdEncoding.DecodeString(req.Password)
|
pass, err := base64.StdEncoding.DecodeString(req.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Password = string(pass)
|
req.Password = string(pass)
|
||||||
}
|
}
|
||||||
if _, err := ftpService.Create(req); err != nil {
|
if _, err := ftpService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags FTP
|
// @Tags FTP
|
||||||
@@ -146,10 +144,10 @@ func (b *BaseApi) DeleteFtp(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := ftpService.Delete(req); err != nil {
|
if err := ftpService.Delete(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags FTP
|
// @Tags FTP
|
||||||
@@ -163,10 +161,10 @@ func (b *BaseApi) DeleteFtp(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步 FTP 账户","formatEN":"sync FTP users"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步 FTP 账户","formatEN":"sync FTP users"}
|
||||||
func (b *BaseApi) SyncFtp(c *gin.Context) {
|
func (b *BaseApi) SyncFtp(c *gin.Context) {
|
||||||
if err := ftpService.Sync(); err != nil {
|
if err := ftpService.Sync(); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags FTP
|
// @Tags FTP
|
||||||
@@ -187,14 +185,14 @@ func (b *BaseApi) UpdateFtp(c *gin.Context) {
|
|||||||
if len(req.Password) != 0 {
|
if len(req.Password) != 0 {
|
||||||
pass, err := base64.StdEncoding.DecodeString(req.Password)
|
pass, err := base64.StdEncoding.DecodeString(req.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Password = string(pass)
|
req.Password = string(pass)
|
||||||
}
|
}
|
||||||
if err := ftpService.Update(req); err != nil {
|
if err := ftpService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Tags System Group
|
// @Tags System Group
|
||||||
// @Summary Create system group
|
// @Summary Create group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.GroupCreate true "request"
|
// @Param request body dto.GroupCreate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /groups [post]
|
// @Router /agent/groups [post]
|
||||||
// @x-panel-log {"bodyKeys":["name","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建组 [name][type]","formatEN":"create group [name][type]"}
|
// @x-panel-log {"bodyKeys":["name","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建组 [name][type]","formatEN":"create group [name][type]"}
|
||||||
func (b *BaseApi) CreateGroup(c *gin.Context) {
|
func (b *BaseApi) CreateGroup(c *gin.Context) {
|
||||||
var req dto.GroupCreate
|
var req dto.GroupCreate
|
||||||
@@ -23,20 +22,20 @@ func (b *BaseApi) CreateGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := groupService.Create(req); err != nil {
|
if err := groupService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Group
|
// @Tags System Group
|
||||||
// @Summary Delete system group
|
// @Summary Delete group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.OperateByID true "request"
|
// @Param request body dto.OperateByID true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /groups/del [post]
|
// @Router /agent/groups/del [post]
|
||||||
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"groups","output_column":"name","output_value":"name"},{"input_column":"id","input_value":"id","isList":false,"db":"groups","output_column":"type","output_value":"type"}],"formatZH":"删除组 [type][name]","formatEN":"delete group [type][name]"}
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"groups","output_column":"name","output_value":"name"},{"input_column":"id","input_value":"id","isList":false,"db":"groups","output_column":"type","output_value":"type"}],"formatZH":"删除组 [type][name]","formatEN":"delete group [type][name]"}
|
||||||
func (b *BaseApi) DeleteGroup(c *gin.Context) {
|
func (b *BaseApi) DeleteGroup(c *gin.Context) {
|
||||||
var req dto.OperateByID
|
var req dto.OperateByID
|
||||||
@@ -45,20 +44,20 @@ func (b *BaseApi) DeleteGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := groupService.Delete(req.ID); err != nil {
|
if err := groupService.Delete(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Group
|
// @Tags System Group
|
||||||
// @Summary Update system group
|
// @Summary Update group
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.GroupUpdate true "request"
|
// @Param request body dto.GroupUpdate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /groups/update [post]
|
// @Router /agent/groups/update [post]
|
||||||
// @x-panel-log {"bodyKeys":["name","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新组 [name][type]","formatEN":"update group [name][type]"}
|
// @x-panel-log {"bodyKeys":["name","type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新组 [name][type]","formatEN":"update group [name][type]"}
|
||||||
func (b *BaseApi) UpdateGroup(c *gin.Context) {
|
func (b *BaseApi) UpdateGroup(c *gin.Context) {
|
||||||
var req dto.GroupUpdate
|
var req dto.GroupUpdate
|
||||||
@@ -67,29 +66,29 @@ func (b *BaseApi) UpdateGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := groupService.Update(req); err != nil {
|
if err := groupService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Group
|
// @Tags System Group
|
||||||
// @Summary List system groups
|
// @Summary List groups
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.GroupSearch true "request"
|
// @Param request body dto.GroupSearch true "request"
|
||||||
// @Success 200 {array} dto.GroupInfo
|
// @Success 200 {array} dto.OperateByType
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /groups/search [post]
|
// @Router /agent/groups/search [post]
|
||||||
func (b *BaseApi) ListGroup(c *gin.Context) {
|
func (b *BaseApi) ListGroup(c *gin.Context) {
|
||||||
var req dto.GroupSearch
|
var req dto.OperateByType
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
list, err := groupService.List(req)
|
list, err := groupService.List(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (b *BaseApi) CheckHealth(c *gin.Context) {
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package helper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/global"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/i18n"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ErrorWithDetail(ctx *gin.Context, code int, msgKey string, err error) {
|
||||||
|
res := dto.Response{
|
||||||
|
Code: code,
|
||||||
|
Message: "",
|
||||||
|
}
|
||||||
|
res.Message = i18n.GetMsgWithDetail(msgKey, err.Error())
|
||||||
|
ctx.JSON(http.StatusOK, res)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
|
||||||
|
func InternalServer(ctx *gin.Context, err error) {
|
||||||
|
ErrorWithDetail(ctx, http.StatusInternalServerError, "ErrInternalServer", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BadRequest(ctx *gin.Context, err error) {
|
||||||
|
ErrorWithDetail(ctx, http.StatusBadRequest, "ErrInvalidParams", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SuccessWithData(ctx *gin.Context, data interface{}) {
|
||||||
|
if data == nil {
|
||||||
|
data = gin.H{}
|
||||||
|
}
|
||||||
|
res := dto.Response{
|
||||||
|
Code: http.StatusOK,
|
||||||
|
Data: data,
|
||||||
|
}
|
||||||
|
ctx.JSON(http.StatusOK, res)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Success(ctx *gin.Context) {
|
||||||
|
res := dto.Response{
|
||||||
|
Code: http.StatusOK,
|
||||||
|
Message: "success",
|
||||||
|
}
|
||||||
|
ctx.JSON(http.StatusOK, res)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
|
||||||
|
func SuccessWithMsg(ctx *gin.Context, msg string) {
|
||||||
|
res := dto.Response{
|
||||||
|
Code: http.StatusOK,
|
||||||
|
Message: msg,
|
||||||
|
}
|
||||||
|
ctx.JSON(http.StatusOK, res)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetParamID(c *gin.Context) (uint, error) {
|
||||||
|
idParam, ok := c.Params.Get("id")
|
||||||
|
if !ok {
|
||||||
|
return 0, errors.New("error id in path")
|
||||||
|
}
|
||||||
|
intNum, _ := strconv.Atoi(idParam)
|
||||||
|
return uint(intNum), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetIntParamByKey(c *gin.Context, key string) (uint, error) {
|
||||||
|
idParam, ok := c.Params.Get(key)
|
||||||
|
if !ok {
|
||||||
|
return 0, fmt.Errorf("error %s in path", key)
|
||||||
|
}
|
||||||
|
intNum, _ := strconv.Atoi(idParam)
|
||||||
|
return uint(intNum), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStrParamByKey(c *gin.Context, key string) (string, error) {
|
||||||
|
idParam, ok := c.Params.Get(key)
|
||||||
|
if !ok {
|
||||||
|
return "", fmt.Errorf("error %s in path", key)
|
||||||
|
}
|
||||||
|
return idParam, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetTxAndContext() (tx *gorm.DB, ctx context.Context) {
|
||||||
|
tx = global.DB.Begin()
|
||||||
|
ctx = context.WithValue(context.Background(), constant.DB, tx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckBindAndValidate(req interface{}, c *gin.Context) error {
|
||||||
|
if err := c.ShouldBindJSON(req); err != nil {
|
||||||
|
ErrorWithDetail(c, http.StatusBadRequest, "ErrInvalidParams", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := global.VALID.Struct(req); err != nil {
|
||||||
|
ErrorWithDetail(c, http.StatusBadRequest, "ErrInvalidParams", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckBind(req interface{}, c *gin.Context) error {
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
ErrorWithDetail(c, http.StatusBadRequest, "ErrInvalidParams", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ErrResponse(ctx *gin.Context, code int) {
|
||||||
|
ctx.JSON(code, nil)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ func (b *BaseApi) GetToolStatus(c *gin.Context) {
|
|||||||
|
|
||||||
config, err := hostToolService.GetToolStatus(req)
|
config, err := hostToolService.GetToolStatus(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, config)
|
helper.SuccessWithData(c, config)
|
||||||
@@ -45,10 +44,10 @@ func (b *BaseApi) InitToolConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := hostToolService.CreateToolConfig(req); err != nil {
|
if err := hostToolService.CreateToolConfig(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Host tool
|
// @Tags Host tool
|
||||||
@@ -67,10 +66,10 @@ func (b *BaseApi) OperateTool(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := hostToolService.OperateTool(req)
|
err := hostToolService.OperateTool(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Host tool
|
// @Tags Host tool
|
||||||
@@ -90,7 +89,7 @@ func (b *BaseApi) OperateToolConfig(c *gin.Context) {
|
|||||||
|
|
||||||
config, err := hostToolService.OperateToolConfig(req)
|
config, err := hostToolService.OperateToolConfig(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, config)
|
helper.SuccessWithData(c, config)
|
||||||
@@ -112,7 +111,7 @@ func (b *BaseApi) GetToolLog(c *gin.Context) {
|
|||||||
|
|
||||||
logContent, err := hostToolService.GetToolLog(req)
|
logContent, err := hostToolService.GetToolLog(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, logContent)
|
helper.SuccessWithData(c, logContent)
|
||||||
@@ -135,10 +134,10 @@ func (b *BaseApi) OperateProcess(c *gin.Context) {
|
|||||||
|
|
||||||
err := hostToolService.OperateSupervisorProcess(req)
|
err := hostToolService.OperateSupervisorProcess(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Host tool
|
// @Tags Host tool
|
||||||
@@ -151,14 +150,14 @@ func (b *BaseApi) OperateProcess(c *gin.Context) {
|
|||||||
func (b *BaseApi) GetProcess(c *gin.Context) {
|
func (b *BaseApi) GetProcess(c *gin.Context) {
|
||||||
configs, err := hostToolService.GetSupervisorProcessConfig()
|
configs, err := hostToolService.GetSupervisorProcessConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, configs)
|
helper.SuccessWithData(c, configs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Host tool
|
// @Tags Host tool
|
||||||
// @Summary Get Supervisor process config
|
// @Summary Get Supervisor process config file
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.SupervisorProcessFileReq true "request"
|
// @Param request body request.SupervisorProcessFileReq true "request"
|
||||||
// @Success 200 {string} content
|
// @Success 200 {string} content
|
||||||
@@ -173,7 +172,7 @@ func (b *BaseApi) GetProcessFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
content, err := hostToolService.OperateSupervisorProcessFile(req)
|
content, err := hostToolService.OperateSupervisorProcessFile(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, content)
|
helper.SuccessWithData(c, content)
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ func (b *BaseApi) SearchImage(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := imageService.Page(req)
|
total, list, err := imageService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ func (b *BaseApi) SearchImage(c *gin.Context) {
|
|||||||
func (b *BaseApi) ListAllImage(c *gin.Context) {
|
func (b *BaseApi) ListAllImage(c *gin.Context) {
|
||||||
list, err := imageService.ListAll()
|
list, err := imageService.ListAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
@@ -60,7 +59,7 @@ func (b *BaseApi) ListAllImage(c *gin.Context) {
|
|||||||
func (b *BaseApi) ListImage(c *gin.Context) {
|
func (b *BaseApi) ListImage(c *gin.Context) {
|
||||||
list, err := imageService.List()
|
list, err := imageService.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
@@ -81,20 +80,19 @@ func (b *BaseApi) ImageBuild(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log, err := imageService.ImageBuild(req)
|
if err := imageService.ImageBuild(req); err != nil {
|
||||||
if err != nil {
|
helper.InternalServer(c, err)
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, log)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image
|
// @Tags Container Image
|
||||||
// @Summary Pull image
|
// @Summary Pull image
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ImagePull true "request"
|
// @Param request body dto.ImagePull true "request"
|
||||||
// @Success 200 {string} logPath
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/image/pull [post]
|
// @Router /containers/image/pull [post]
|
||||||
@@ -105,20 +103,19 @@ func (b *BaseApi) ImagePull(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logPath, err := imageService.ImagePull(req)
|
if err := imageService.ImagePull(req); err != nil {
|
||||||
if err != nil {
|
helper.InternalServer(c, err)
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, logPath)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image
|
// @Tags Container Image
|
||||||
// @Summary Push image
|
// @Summary Push image
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ImagePush true "request"
|
// @Param request body dto.ImagePush true "request"
|
||||||
// @Success 200 {string} logPath
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /containers/image/push [post]
|
// @Router /containers/image/push [post]
|
||||||
@@ -129,13 +126,12 @@ func (b *BaseApi) ImagePush(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logPath, err := imageService.ImagePush(req)
|
if err := imageService.ImagePush(req); err != nil {
|
||||||
if err != nil {
|
helper.InternalServer(c, err)
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, logPath)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image
|
// @Tags Container Image
|
||||||
@@ -154,11 +150,11 @@ func (b *BaseApi) ImageRemove(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := imageService.ImageRemove(req); err != nil {
|
if err := imageService.ImageRemove(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image
|
// @Tags Container Image
|
||||||
@@ -177,11 +173,11 @@ func (b *BaseApi) ImageSave(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := imageService.ImageSave(req); err != nil {
|
if err := imageService.ImageSave(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image
|
// @Tags Container Image
|
||||||
@@ -200,11 +196,11 @@ func (b *BaseApi) ImageTag(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := imageService.ImageTag(req); err != nil {
|
if err := imageService.ImageTag(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image
|
// @Tags Container Image
|
||||||
@@ -223,9 +219,9 @@ func (b *BaseApi) ImageLoad(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := imageService.ImageLoad(req); err != nil {
|
if err := imageService.ImageLoad(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ func (b *BaseApi) SearchRepo(c *gin.Context) {
|
|||||||
|
|
||||||
total, list, err := imageRepoService.Page(req)
|
total, list, err := imageRepoService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ func (b *BaseApi) SearchRepo(c *gin.Context) {
|
|||||||
func (b *BaseApi) ListRepo(c *gin.Context) {
|
func (b *BaseApi) ListRepo(c *gin.Context) {
|
||||||
list, err := imageRepoService.List()
|
list, err := imageRepoService.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,16 +66,16 @@ func (b *BaseApi) CheckRepoStatus(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := imageRepoService.Login(req); err != nil {
|
if err := imageRepoService.Login(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image-repo
|
// @Tags Container Image-repo
|
||||||
// @Summary Create image repo
|
// @Summary Create image repo
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.ImageRepoCreate true "request"
|
// @Param request body dto.ImageRepoDelete true "request"
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
@@ -90,10 +89,10 @@ func (b *BaseApi) CreateRepo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := imageRepoService.Create(req); err != nil {
|
if err := imageRepoService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image-repo
|
// @Tags Container Image-repo
|
||||||
@@ -113,10 +112,10 @@ func (b *BaseApi) DeleteRepo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := imageRepoService.Delete(req); err != nil {
|
if err := imageRepoService.Delete(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Container Image-repo
|
// @Tags Container Image-repo
|
||||||
@@ -136,8 +135,8 @@ func (b *BaseApi) UpdateRepo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := imageRepoService.Update(req); err != nil {
|
if err := imageRepoService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @Tags Logs
|
||||||
|
// @Summary Load system log files
|
||||||
|
// @Success 200 {array} string
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /logs/system/files [get]
|
||||||
|
func (b *BaseApi) GetSystemFiles(c *gin.Context) {
|
||||||
|
data, err := logService.ListSystemLogFile()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,10 +38,10 @@ func (b *BaseApi) CreateMcpServer(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := mcpServerService.Create(req)
|
err := mcpServerService.Create(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags McpServer
|
// @Tags McpServer
|
||||||
@@ -60,10 +59,10 @@ func (b *BaseApi) UpdateMcpServer(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := mcpServerService.Update(req)
|
err := mcpServerService.Update(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags McpServer
|
// @Tags McpServer
|
||||||
@@ -81,10 +80,10 @@ func (b *BaseApi) DeleteMcpServer(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := mcpServerService.Delete(req.ID)
|
err := mcpServerService.Delete(req.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags McpServer
|
// @Tags McpServer
|
||||||
@@ -102,10 +101,10 @@ func (b *BaseApi) OperateMcpServer(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := mcpServerService.Operate(req)
|
err := mcpServerService.Operate(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags McpServer
|
// @Tags McpServer
|
||||||
@@ -123,10 +122,10 @@ func (b *BaseApi) BindMcpDomain(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := mcpServerService.BindDomain(req)
|
err := mcpServerService.BindDomain(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags McpServer
|
// @Tags McpServer
|
||||||
@@ -144,10 +143,10 @@ func (b *BaseApi) UpdateMcpBindDomain(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := mcpServerService.UpdateBindDomain(req)
|
err := mcpServerService.UpdateBindDomain(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags McpServer
|
// @Tags McpServer
|
||||||
@@ -160,7 +159,7 @@ func (b *BaseApi) UpdateMcpBindDomain(c *gin.Context) {
|
|||||||
func (b *BaseApi) GetMcpBindDomain(c *gin.Context) {
|
func (b *BaseApi) GetMcpBindDomain(c *gin.Context) {
|
||||||
res, err := mcpServerService.GetBindDomain()
|
res, err := mcpServerService.GetBindDomain()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sort"
|
||||||
|
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/shirou/gopsutil/v3/disk"
|
||||||
|
"github.com/shirou/gopsutil/v3/net"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @Tags Monitor
|
||||||
|
// @Summary Load monitor data
|
||||||
|
// @Param request body dto.MonitorSearch true "request"
|
||||||
|
// @Success 200 {array} dto.MonitorData
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /hosts/monitor/search [post]
|
||||||
|
func (b *BaseApi) LoadMonitor(c *gin.Context) {
|
||||||
|
var req dto.MonitorSearch
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := monitorService.LoadMonitorData(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Monitor
|
||||||
|
// @Summary Clean monitor data
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /hosts/monitor/clean [post]
|
||||||
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空监控数据","formatEN":"clean monitor datas"}
|
||||||
|
func (b *BaseApi) CleanMonitor(c *gin.Context) {
|
||||||
|
if err := monitorService.CleanData(); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Monitor
|
||||||
|
// @Summary Load monitor setting
|
||||||
|
// @Success 200 {object} dto.MonitorSetting
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /hosts/monitor/setting [get]
|
||||||
|
func (b *BaseApi) LoadMonitorSetting(c *gin.Context) {
|
||||||
|
setting, err := monitorService.LoadSetting()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.SuccessWithData(c, setting)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Monitor
|
||||||
|
// @Summary Update monitor setting
|
||||||
|
// @Param request body dto.MonitorSettingUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /hosts/monitor/setting/update [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改默认监控网卡 [name]-[value]","formatEN":"update default monitor [name]-[value]"}
|
||||||
|
func (b *BaseApi) UpdateMonitorSetting(c *gin.Context) {
|
||||||
|
var req dto.MonitorSettingUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := monitorService.UpdateSetting(req.Key, req.Value); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetNetworkOptions(c *gin.Context) {
|
||||||
|
netStat, _ := net.IOCounters(true)
|
||||||
|
var options []string
|
||||||
|
options = append(options, "all")
|
||||||
|
for _, net := range netStat {
|
||||||
|
options = append(options, net.Name)
|
||||||
|
}
|
||||||
|
sort.Strings(options)
|
||||||
|
helper.SuccessWithData(c, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) GetIOOptions(c *gin.Context) {
|
||||||
|
diskStat, _ := disk.IOCounters()
|
||||||
|
var options []string
|
||||||
|
options = append(options, "all")
|
||||||
|
for _, net := range diskStat {
|
||||||
|
options = append(options, net.Name)
|
||||||
|
}
|
||||||
|
sort.Strings(options)
|
||||||
|
helper.SuccessWithData(c, options)
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ import (
|
|||||||
func (b *BaseApi) GetNginx(c *gin.Context) {
|
func (b *BaseApi) GetNginx(c *gin.Context) {
|
||||||
fileInfo, err := nginxService.GetNginxConfig()
|
fileInfo, err := nginxService.GetNginxConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, fileInfo)
|
helper.SuccessWithData(c, fileInfo)
|
||||||
@@ -38,7 +37,7 @@ func (b *BaseApi) GetNginxConfigByScope(c *gin.Context) {
|
|||||||
|
|
||||||
params, err := nginxService.GetConfigByScope(req)
|
params, err := nginxService.GetConfigByScope(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, params)
|
helper.SuccessWithData(c, params)
|
||||||
@@ -59,10 +58,10 @@ func (b *BaseApi) UpdateNginxConfigByScope(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := nginxService.UpdateConfigByScope(req); err != nil {
|
if err := nginxService.UpdateConfigByScope(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags OpenResty
|
// @Tags OpenResty
|
||||||
@@ -74,7 +73,7 @@ func (b *BaseApi) UpdateNginxConfigByScope(c *gin.Context) {
|
|||||||
func (b *BaseApi) GetNginxStatus(c *gin.Context) {
|
func (b *BaseApi) GetNginxStatus(c *gin.Context) {
|
||||||
res, err := nginxService.GetStatus()
|
res, err := nginxService.GetStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -96,23 +95,101 @@ func (b *BaseApi) UpdateNginxFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := nginxService.UpdateConfigFile(req); err != nil {
|
if err := nginxService.UpdateConfigFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags OpenResty
|
// @Tags OpenResty
|
||||||
// @Summary Clear OpenResty proxy cache
|
// @Summary Build OpenResty
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NginxBuildReq true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /openresty/clear [post]
|
// @Router /openresty/build [post]
|
||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理 Openresty 代理缓存","formatEN":"Clear nginx proxy cache"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"构建 OpenResty","formatEN":"Build OpenResty"}
|
||||||
func (b *BaseApi) ClearNginxProxyCache(c *gin.Context) {
|
func (b *BaseApi) BuildNginx(c *gin.Context) {
|
||||||
if err := nginxService.ClearProxyCache(); err != nil {
|
var req request.NginxBuildReq
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
if err := nginxService.Build(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags OpenResty
|
||||||
|
// @Summary Update OpenResty module
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NginxModuleUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /openresty/module/update [post]
|
||||||
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新 OpenResty 模块","formatEN":"Update OpenResty module"}
|
||||||
|
func (b *BaseApi) UpdateNginxModule(c *gin.Context) {
|
||||||
|
var req request.NginxModuleUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := nginxService.UpdateModule(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags OpenResty
|
||||||
|
// @Summary Get OpenResty modules
|
||||||
|
// @Success 200 {object} response.NginxBuildConfig
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /openresty/modules [get]
|
||||||
|
func (b *BaseApi) GetNginxModules(c *gin.Context) {
|
||||||
|
modules, err := nginxService.GetModules()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, modules)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags OpenResty
|
||||||
|
// @Summary Operate default HTTPs
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NginxOperateReq true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /openresty/https [post]
|
||||||
|
func (b *BaseApi) OperateDefaultHTTPs(c *gin.Context) {
|
||||||
|
var req request.NginxOperateReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := nginxService.OperateDefaultHTTPs(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags OpenResty
|
||||||
|
// @Summary Get default HTTPs status
|
||||||
|
// @Success 200 {object} response.NginxConfigRes
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /openresty/https [get]
|
||||||
|
func (b *BaseApi) GetDefaultHTTPsStatus(c *gin.Context) {
|
||||||
|
res, err := nginxService.GetDefaultHttpsStatus()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ func (b *BaseApi) PagePHPExtensions(c *gin.Context) {
|
|||||||
if req.All {
|
if req.All {
|
||||||
list, err := phpExtensionsService.List()
|
list, err := phpExtensionsService.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -34,7 +33,7 @@ func (b *BaseApi) PagePHPExtensions(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
total, list, err := phpExtensionsService.Page(req)
|
total, list, err := phpExtensionsService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -59,10 +58,10 @@ func (b *BaseApi) CreatePHPExtensions(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := phpExtensionsService.Create(req); err != nil {
|
if err := phpExtensionsService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags PHP Extensions
|
// @Tags PHP Extensions
|
||||||
@@ -79,10 +78,10 @@ func (b *BaseApi) UpdatePHPExtensions(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := phpExtensionsService.Update(req); err != nil {
|
if err := phpExtensionsService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags PHP Extensions
|
// @Tags PHP Extensions
|
||||||
@@ -99,8 +98,8 @@ func (b *BaseApi) DeletePHPExtensions(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := phpExtensionsService.Delete(req); err != nil {
|
if err := phpExtensionsService.Delete(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
websocket2 "github.com/1Panel-dev/1Panel/agent/utils/websocket"
|
||||||
websocket2 "github.com/1Panel-dev/1Panel/backend/utils/websocket"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,8 +31,8 @@ func (b *BaseApi) StopProcess(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := processService.StopProcess(req); err != nil {
|
if err := processService.StopProcess(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
// @Summary List Recycle Bin files
|
// @Summary List RecycleBin files
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.PageInfo true "request"
|
// @Param request body dto.PageInfo true "request"
|
||||||
// @Success 200 {object} dto.PageResult
|
// @Success 200 {object} dto.PageResult
|
||||||
@@ -23,7 +22,7 @@ func (b *BaseApi) SearchRecycleBinFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
total, list, err := recycleBinService.Page(req)
|
total, list, err := recycleBinService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -33,7 +32,7 @@ func (b *BaseApi) SearchRecycleBinFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
// @Summary Reduce Recycle Bin files
|
// @Summary Reduce RecycleBin files
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.RecycleBinReduce true "request"
|
// @Param request body request.RecycleBinReduce true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -47,14 +46,14 @@ func (b *BaseApi) ReduceRecycleBinFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := recycleBinService.Reduce(req); err != nil {
|
if err := recycleBinService.Reduce(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
// @Summary Clear Recycle Bin files
|
// @Summary Clear RecycleBin files
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
@@ -63,14 +62,14 @@ func (b *BaseApi) ReduceRecycleBinFile(c *gin.Context) {
|
|||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空回收站","formatEN":"清空回收站"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空回收站","formatEN":"清空回收站"}
|
||||||
func (b *BaseApi) ClearRecycleBinFile(c *gin.Context) {
|
func (b *BaseApi) ClearRecycleBinFile(c *gin.Context) {
|
||||||
if err := recycleBinService.Clear(); err != nil {
|
if err := recycleBinService.Clear(); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
// @Summary Get Recycle Bin status
|
// @Summary Get RecycleBin status
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Success 200 {string} content
|
// @Success 200 {string} content
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
@@ -79,7 +78,7 @@ func (b *BaseApi) ClearRecycleBinFile(c *gin.Context) {
|
|||||||
func (b *BaseApi) GetRecycleStatus(c *gin.Context) {
|
func (b *BaseApi) GetRecycleStatus(c *gin.Context) {
|
||||||
settingInfo, err := settingService.GetSettingInfo()
|
settingInfo, err := settingService.GetSettingInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, settingInfo.FileRecycleBin)
|
helper.SuccessWithData(c, settingInfo.FileRecycleBin)
|
||||||
@@ -0,0 +1,557 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary List runtimes
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.RuntimeSearch true "request"
|
||||||
|
// @Success 200 {object} dto.PageResult
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/search [post]
|
||||||
|
func (b *BaseApi) SearchRuntimes(c *gin.Context) {
|
||||||
|
var req request.RuntimeSearch
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
total, items, err := runtimeService.Page(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
|
Total: total,
|
||||||
|
Items: items,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Create runtime
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.RuntimeCreate true "request"
|
||||||
|
// @Success 200 {object} model.Runtime
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建运行环境 [name]","formatEN":"Create runtime [name]"}
|
||||||
|
func (b *BaseApi) CreateRuntime(c *gin.Context) {
|
||||||
|
var req request.RuntimeCreate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ssl, err := runtimeService.Create(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, ssl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Delete runtime
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.RuntimeDelete true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/del [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除运行环境 [name]","formatEN":"Delete runtime [name]"}
|
||||||
|
func (b *BaseApi) DeleteRuntime(c *gin.Context) {
|
||||||
|
var req request.RuntimeDelete
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := runtimeService.Delete(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Delete runtime
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200 {array} dto.AppResource
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /installed/delete/check/:id [get]
|
||||||
|
func (b *BaseApi) DeleteRuntimeCheck(c *gin.Context) {
|
||||||
|
runTimeId, err := helper.GetIntParamByKey(c, "id")
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
checkData, err := runtimeService.DeleteCheck(runTimeId)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, checkData)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Update runtime
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.RuntimeUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/update [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新运行环境 [name]","formatEN":"Update runtime [name]"}
|
||||||
|
func (b *BaseApi) UpdateRuntime(c *gin.Context) {
|
||||||
|
var req request.RuntimeUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := runtimeService.Update(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Get runtime
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path string true "request"
|
||||||
|
// @Success 200 {object} response.RuntimeDTO
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/:id [get]
|
||||||
|
func (b *BaseApi) GetRuntime(c *gin.Context) {
|
||||||
|
id, err := helper.GetIntParamByKey(c, "id")
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := runtimeService.Get(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Get Node package scripts
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NodePackageReq true "request"
|
||||||
|
// @Success 200 {array} response.PackageScripts
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/node/package [post]
|
||||||
|
func (b *BaseApi) GetNodePackageRunScript(c *gin.Context) {
|
||||||
|
var req request.NodePackageReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := runtimeService.GetNodePackageRunScript(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Operate runtime
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.RuntimeOperate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/operate [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"操作运行环境 [name]","formatEN":"Operate runtime [name]"}
|
||||||
|
func (b *BaseApi) OperateRuntime(c *gin.Context) {
|
||||||
|
var req request.RuntimeOperate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := runtimeService.OperateRuntime(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Get Node modules
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NodeModuleReq true "request"
|
||||||
|
// @Success 200 {array} response.NodeModule
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/node/modules [post]
|
||||||
|
func (b *BaseApi) GetNodeModules(c *gin.Context) {
|
||||||
|
var req request.NodeModuleReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := runtimeService.GetNodeModules(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Operate Node modules
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NodeModuleReq true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/node/modules/operate [post]
|
||||||
|
func (b *BaseApi) OperateNodeModules(c *gin.Context) {
|
||||||
|
var req request.NodeModuleOperateReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := runtimeService.OperateNodeModules(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Sync runtime status
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Router /runtimes/sync [post]
|
||||||
|
func (b *BaseApi) SyncStatus(c *gin.Context) {
|
||||||
|
err := runtimeService.SyncRuntimeStatus()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Get php runtime extension
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path string true "request"
|
||||||
|
// @Success 200 {object} response.PHPExtensionRes
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/:id/extensions [get]
|
||||||
|
func (b *BaseApi) GetRuntimeExtension(c *gin.Context) {
|
||||||
|
id, err := helper.GetIntParamByKey(c, "id")
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := runtimeService.GetPHPExtensions(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Install php extension
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.PHPExtensionInstallReq true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/extensions/install [post]
|
||||||
|
func (b *BaseApi) InstallPHPExtension(c *gin.Context) {
|
||||||
|
var req request.PHPExtensionInstallReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := runtimeService.InstallPHPExtension(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary UnInstall php extension
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.PHPExtensionInstallReq true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/extensions/uninstall [post]
|
||||||
|
func (b *BaseApi) UnInstallPHPExtension(c *gin.Context) {
|
||||||
|
var req request.PHPExtensionInstallReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := runtimeService.UnInstallPHPExtension(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Load php runtime conf
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path integer true "request"
|
||||||
|
// @Success 200 {object} response.PHPConfig
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/config/:id [get]
|
||||||
|
func (b *BaseApi) GetPHPConfig(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := runtimeService.GetPHPConfig(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Update runtime php conf
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.PHPConfigUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/config [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] PHP 配置修改","formatEN":"[domain] PHP conf update"}
|
||||||
|
func (b *BaseApi) UpdatePHPConfig(c *gin.Context) {
|
||||||
|
var req request.PHPConfigUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := runtimeService.UpdatePHPConfig(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Update php conf file
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.PHPFileUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/update [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 配置修改 [domain]","formatEN":"Nginx conf update [domain]"}
|
||||||
|
func (b *BaseApi) UpdatePHPFile(c *gin.Context) {
|
||||||
|
var req request.PHPFileUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := runtimeService.UpdatePHPConfigFile(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Get php conf file
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.PHPFileReq true "request"
|
||||||
|
// @Success 200 {object} response.FileInfo
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/file [post]
|
||||||
|
func (b *BaseApi) GetPHPConfigFile(c *gin.Context) {
|
||||||
|
var req request.PHPFileReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := runtimeService.GetPHPConfigFile(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Update fpm config
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.FPMConfig true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/fpm/config [post]
|
||||||
|
func (b *BaseApi) UpdateFPMConfig(c *gin.Context) {
|
||||||
|
var req request.FPMConfig
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := runtimeService.UpdateFPMConfig(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Get fpm config
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path integer true "request"
|
||||||
|
// @Success 200 {object} request.FPMConfig
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/fpm/config/:id [get]
|
||||||
|
func (b *BaseApi) GetFPMConfig(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := runtimeService.GetFPMConfig(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Get supervisor process
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path integer true "request"
|
||||||
|
// @Success 200 {array} response.SupervisorProcessConfig
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/supervisor/process/:id [get]
|
||||||
|
func (b *BaseApi) GetSupervisorProcess(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := runtimeService.GetSupervisorProcess(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Operate supervisor process
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.PHPSupervisorProcessConfig true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/supervisor/process/operate [post]
|
||||||
|
func (b *BaseApi) OperateSupervisorProcess(c *gin.Context) {
|
||||||
|
var req request.PHPSupervisorProcessConfig
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := runtimeService.OperateSupervisorProcess(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Operate supervisor process file
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.PHPSupervisorProcessFileReq true "request"
|
||||||
|
// @Success 200 {string} content
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/supervisor/process/file/operate [post]
|
||||||
|
func (b *BaseApi) OperateSupervisorProcessFile(c *gin.Context) {
|
||||||
|
var req request.PHPSupervisorProcessFileReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := runtimeService.OperateSupervisorProcessFile(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Update PHP container config
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.PHPContainerUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/container/update [post]
|
||||||
|
func (b *BaseApi) UpdatePHPContainer(c *gin.Context) {
|
||||||
|
var req request.PHPContainerConfig
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := runtimeService.UpdatePHPContainer(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Get PHP container config
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path integer true "request"
|
||||||
|
// @Success 200 {object} response.PHPContainerConfig
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/php/container/:id [get]
|
||||||
|
func (b *BaseApi) GetPHPContainerConfig(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := runtimeService.GetPHPContainerConfig(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Runtime
|
||||||
|
// @Summary Update runtime remark
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.RuntimeRemarkUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /runtimes/remark [post]
|
||||||
|
func (b *BaseApi) UpdateRuntimeRemark(c *gin.Context) {
|
||||||
|
var req request.RuntimeRemark
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := runtimeService.UpdateRemark(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"path"
|
||||||
|
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/global"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/utils/ssh"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Load system setting info
|
||||||
|
// @Success 200 {object} dto.SettingInfo
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/search [post]
|
||||||
|
func (b *BaseApi) GetSettingInfo(c *gin.Context) {
|
||||||
|
setting, err := settingService.GetSettingInfo()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, setting)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Load system available status
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/search/available [get]
|
||||||
|
func (b *BaseApi) GetSystemAvailable(c *gin.Context) {
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Update system setting
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.SettingUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/update [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["key","value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统配置 [key] => [value]","formatEN":"update system setting [key] => [value]"}
|
||||||
|
func (b *BaseApi) UpdateSetting(c *gin.Context) {
|
||||||
|
var req dto.SettingUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := settingService.Update(req.Key, req.Value); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Load local backup dir
|
||||||
|
// @Success 200 {string} path
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/basedir [get]
|
||||||
|
func (b *BaseApi) LoadBaseDir(c *gin.Context) {
|
||||||
|
helper.SuccessWithData(c, global.Dir.DataDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) CheckLocalConn(c *gin.Context) {
|
||||||
|
_, err := loadLocalConn()
|
||||||
|
helper.SuccessWithData(c, err == nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Check local conn info
|
||||||
|
// @Success 200 {bool} isOk
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/ssh/check/info [post]
|
||||||
|
func (b *BaseApi) CheckLocalConnByInfo(c *gin.Context) {
|
||||||
|
var req dto.SSHConnData
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, settingService.TestConnByInfo(req))
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Save local conn info
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/ssh [post]
|
||||||
|
func (b *BaseApi) SaveLocalConnInfo(c *gin.Context) {
|
||||||
|
var req dto.SSHConnData
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, settingService.SaveConnInfo(req))
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadLocalConn() (*ssh.SSHClient, error) {
|
||||||
|
itemPath := ""
|
||||||
|
currentInfo, _ := user.Current()
|
||||||
|
if len(currentInfo.HomeDir) == 0 {
|
||||||
|
itemPath = "/root/.ssh/id_ed25519_1panel"
|
||||||
|
} else {
|
||||||
|
itemPath = path.Join(currentInfo.HomeDir, ".ssh/id_ed25519_1panel")
|
||||||
|
}
|
||||||
|
if _, err := os.Stat(itemPath); err != nil {
|
||||||
|
_ = sshService.CreateRootCert(dto.CreateRootCert{EncryptionMode: "ed25519", Name: "1panel", Description: "1Panel Terminal"})
|
||||||
|
}
|
||||||
|
|
||||||
|
privateKey, _ := os.ReadFile(itemPath)
|
||||||
|
connWithKey := ssh.ConnInfo{
|
||||||
|
Addr: "127.0.0.1",
|
||||||
|
User: "root",
|
||||||
|
Port: 22,
|
||||||
|
AuthMode: "key",
|
||||||
|
PrivateKey: privateKey,
|
||||||
|
}
|
||||||
|
client, err := ssh.NewClient(connWithKey)
|
||||||
|
if err == nil {
|
||||||
|
return client, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
connInfoInDB, err := settingService.GetSSHInfo()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(connInfoInDB) == 0 {
|
||||||
|
return nil, errors.New("no such ssh conn info in db!")
|
||||||
|
}
|
||||||
|
var connInDB ssh.ConnInfo
|
||||||
|
if err := json.Unmarshal([]byte(connInfoInDB), &connInDB); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ssh.NewClient(connInDB)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Load system setting by key
|
||||||
|
// @Param key path string true "key"
|
||||||
|
// @Success 200 {object} dto.SettingInfo
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/get/{key} [get]
|
||||||
|
func (b *BaseApi) GetSettingByKey(c *gin.Context) {
|
||||||
|
key := c.Param("key")
|
||||||
|
if len(key) == 0 {
|
||||||
|
helper.BadRequest(c, errors.New("key is empty"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
value := settingService.GetSettingByKey(key)
|
||||||
|
helper.SuccessWithData(c, value)
|
||||||
|
}
|
||||||
@@ -1,12 +1,26 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Load system snapshot data
|
||||||
|
// @Success 200 {object} dto.SnapshotData
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/snapshot/load [get]
|
||||||
|
func (b *BaseApi) LoadSnapshotData(c *gin.Context) {
|
||||||
|
data, err := snapshotService.LoadSnapshotData()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, data)
|
||||||
|
}
|
||||||
|
|
||||||
// @Tags System Setting
|
// @Tags System Setting
|
||||||
// @Summary Create system snapshot
|
// @Summary Create system snapshot
|
||||||
// @Accept json
|
// @Accept json
|
||||||
@@ -22,11 +36,33 @@ func (b *BaseApi) CreateSnapshot(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.SnapshotCreate(req); err != nil {
|
if err := snapshotService.SnapshotCreate(nil, req, 0, 0, 0); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags System Setting
|
||||||
|
// @Summary Recreate system snapshot
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.OperateByID true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /settings/snapshot/recrete [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"snapshots","output_column":"name","output_value":"name"}],"formatZH":"重试创建快照 [name]","formatEN":"recrete the snapshot [name]"}
|
||||||
|
func (b *BaseApi) RecreateSnapshot(c *gin.Context) {
|
||||||
|
var req dto.OperateByID
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := snapshotService.SnapshotReCreate(req.ID); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Setting
|
// @Tags System Setting
|
||||||
@@ -45,32 +81,10 @@ func (b *BaseApi) ImportSnapshot(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.SnapshotImport(req); err != nil {
|
if err := snapshotService.SnapshotImport(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags System Setting
|
|
||||||
// @Summary Load Snapshot status
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.OperateByID true "request"
|
|
||||||
// @Success 200 {object} dto.SnapshotStatus
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/snapshot/status [post]
|
|
||||||
func (b *BaseApi) LoadSnapShotStatus(c *gin.Context) {
|
|
||||||
var req dto.OperateByID
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := snapshotService.LoadSnapShotStatus(req.ID)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Setting
|
// @Tags System Setting
|
||||||
@@ -89,10 +103,10 @@ func (b *BaseApi) UpdateSnapDescription(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.UpdateDescription(req); err != nil {
|
if err := snapshotService.UpdateDescription(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Setting
|
// @Tags System Setting
|
||||||
@@ -111,7 +125,7 @@ func (b *BaseApi) SearchSnapshot(c *gin.Context) {
|
|||||||
|
|
||||||
total, accounts, err := snapshotService.SearchWithPage(req)
|
total, accounts, err := snapshotService.SearchWithPage(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -120,28 +134,6 @@ func (b *BaseApi) SearchSnapshot(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Setting
|
|
||||||
// @Summary Load system snapshot size
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body dto.PageSnapshot true "request"
|
|
||||||
// @Success 200 {array} dto.SnapshotFile
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /settings/snapshot/size [post]
|
|
||||||
func (b *BaseApi) LoadSnapshotSize(c *gin.Context) {
|
|
||||||
var req dto.PageSnapshot
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := snapshotService.LoadSize(req)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags System Setting
|
// @Tags System Setting
|
||||||
// @Summary Recover system backup
|
// @Summary Recover system backup
|
||||||
// @Accept json
|
// @Accept json
|
||||||
@@ -158,10 +150,10 @@ func (b *BaseApi) RecoverSnapshot(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.SnapshotRecover(req); err != nil {
|
if err := snapshotService.SnapshotRecover(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Setting
|
// @Tags System Setting
|
||||||
@@ -180,10 +172,10 @@ func (b *BaseApi) RollbackSnapshot(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.SnapshotRollback(req); err != nil {
|
if err := snapshotService.SnapshotRollback(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags System Setting
|
// @Tags System Setting
|
||||||
@@ -202,8 +194,8 @@ func (b *BaseApi) DeleteSnapshot(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := snapshotService.Delete(req); err != nil {
|
if err := snapshotService.Delete(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"encoding/base64"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ import (
|
|||||||
func (b *BaseApi) GetSSHInfo(c *gin.Context) {
|
func (b *BaseApi) GetSSHInfo(c *gin.Context) {
|
||||||
info, err := sshService.GetSSHInfo()
|
info, err := sshService.GetSSHInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, info)
|
helper.SuccessWithData(c, info)
|
||||||
@@ -38,10 +39,10 @@ func (b *BaseApi) OperateSSH(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := sshService.OperateSSH(req.Operation); err != nil {
|
if err := sshService.OperateSSH(req.Operation); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags SSH
|
// @Tags SSH
|
||||||
@@ -60,10 +61,10 @@ func (b *BaseApi) UpdateSSH(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := sshService.Update(req); err != nil {
|
if err := sshService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags SSH
|
// @Tags SSH
|
||||||
@@ -82,54 +83,118 @@ func (b *BaseApi) UpdateSSHByfile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := sshService.UpdateByFile(req.File); err != nil {
|
if err := sshService.UpdateByFile(req.File); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags SSH
|
// @Tags SSH
|
||||||
// @Summary Generate host SSH secret
|
// @Summary Generate host SSH secret
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.GenerateSSH true "request"
|
// @Param request body dto.CreateRootCert true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /hosts/ssh/generate [post]
|
// @Router /hosts/ssh/cert [post]
|
||||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"生成 SSH 密钥 ","formatEN":"generate SSH secret"}
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"生成 SSH 密钥 ","formatEN":"generate SSH secret"}
|
||||||
func (b *BaseApi) GenerateSSH(c *gin.Context) {
|
func (b *BaseApi) CreateRootCert(c *gin.Context) {
|
||||||
var req dto.GenerateSSH
|
var req dto.CreateRootCert
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(req.PassPhrase) != 0 {
|
||||||
|
passPhrase, err := base64.StdEncoding.DecodeString(req.PassPhrase)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.PassPhrase = string(passPhrase)
|
||||||
|
}
|
||||||
|
if len(req.PrivateKey) != 0 {
|
||||||
|
privateKey, err := base64.StdEncoding.DecodeString(req.PrivateKey)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.PrivateKey = string(privateKey)
|
||||||
|
}
|
||||||
|
if len(req.PublicKey) != 0 {
|
||||||
|
publicKey, err := base64.StdEncoding.DecodeString(req.PublicKey)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.PublicKey = string(publicKey)
|
||||||
|
}
|
||||||
|
|
||||||
if err := sshService.GenerateSSH(req); err != nil {
|
if err := sshService.CreateRootCert(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags SSH
|
||||||
|
// @Summary Sycn host SSH secret
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /hosts/ssh/cert/sync [post]
|
||||||
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"同步 SSH 密钥 ","formatEN":"sync SSH secret"}
|
||||||
|
func (b *BaseApi) SyncRootCert(c *gin.Context) {
|
||||||
|
if err := sshService.SyncRootCert(); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags SSH
|
// @Tags SSH
|
||||||
// @Summary Load host SSH secret
|
// @Summary Load host SSH secret
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body dto.GenerateLoad true "request"
|
// @Param request body dto.SearchWithPage true "request"
|
||||||
// @Success 200 {string} data
|
// @Success 200 {object} dto.PageResult
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /hosts/ssh/secret [post]
|
// @Router /hosts/ssh/cert/search [post]
|
||||||
func (b *BaseApi) LoadSSHSecret(c *gin.Context) {
|
func (b *BaseApi) SearchRootCert(c *gin.Context) {
|
||||||
var req dto.GenerateLoad
|
var req dto.SearchWithPage
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := sshService.LoadSSHSecret(req.EncryptionMode)
|
total, data, err := sshService.SearchRootCerts(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, data)
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
|
Total: total,
|
||||||
|
Items: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags SSH
|
||||||
|
// @Summary Delete host SSH secret
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.ForceDelete true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /hosts/ssh/cert/delete [post]
|
||||||
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除 SSH 密钥 ","formatEN":"delete SSH secret"}
|
||||||
|
func (b *BaseApi) DeleteRootCert(c *gin.Context) {
|
||||||
|
var req dto.ForceDelete
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := sshService.DeleteRootCerts(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags SSH
|
// @Tags SSH
|
||||||
@@ -148,7 +213,7 @@ func (b *BaseApi) LoadSSHLogs(c *gin.Context) {
|
|||||||
|
|
||||||
data, err := sshService.LoadLog(c, req)
|
data, err := sshService.LoadLog(c, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, data)
|
helper.SuccessWithData(c, data)
|
||||||
@@ -156,14 +221,14 @@ func (b *BaseApi) LoadSSHLogs(c *gin.Context) {
|
|||||||
|
|
||||||
// @Tags SSH
|
// @Tags SSH
|
||||||
// @Summary Load host SSH conf
|
// @Summary Load host SSH conf
|
||||||
// @Success 200 {string} data
|
// @Success 200 {string} conf
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /hosts/ssh/conf [get]
|
// @Router /hosts/ssh/conf [get]
|
||||||
func (b *BaseApi) LoadSSHConf(c *gin.Context) {
|
func (b *BaseApi) LoadSSHConf(c *gin.Context) {
|
||||||
data, err := sshService.LoadSSHConf()
|
data, err := sshService.LoadSSHConf()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, data)
|
helper.SuccessWithData(c, data)
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package v2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @Tags TaskLog
|
||||||
|
// @Summary Page task logs
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body dto.SearchTaskLogReq true "request"
|
||||||
|
// @Success 200 {object} dto.PageResult
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /logs/tasks/search [post]
|
||||||
|
func (b *BaseApi) PageTasks(c *gin.Context) {
|
||||||
|
var req dto.SearchTaskLogReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
total, list, err := taskService.Page(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
|
Items: list,
|
||||||
|
Total: total,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags TaskLog
|
||||||
|
// @Summary Get the number of executing tasks
|
||||||
|
// @Success 200 {object} int64
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /logs/tasks/executing/count [get]
|
||||||
|
func (b *BaseApi) CountExecutingTasks(c *gin.Context) {
|
||||||
|
count, err := taskService.CountExecutingTask()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, count)
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
@@ -9,18 +9,16 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/agent/global"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
"github.com/1Panel-dev/1Panel/agent/utils/cmd"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/copier"
|
"github.com/1Panel-dev/1Panel/agent/utils/terminal"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/ssh"
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/terminal"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (b *BaseApi) WsSsh(c *gin.Context) {
|
func (b *BaseApi) WsSSH(c *gin.Context) {
|
||||||
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
|
wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.LOG.Errorf("gin context http handler failed, err: %v", err)
|
global.LOG.Errorf("gin context http handler failed, err: %v", err)
|
||||||
@@ -28,10 +26,12 @@ func (b *BaseApi) WsSsh(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
defer wsConn.Close()
|
defer wsConn.Close()
|
||||||
|
|
||||||
id, err := strconv.Atoi(c.Query("id"))
|
if global.CONF.Base.IsDemo {
|
||||||
if wshandleError(wsConn, errors.WithMessage(err, "invalid param id in request")) {
|
if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) {
|
||||||
return
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cols, err := strconv.Atoi(c.DefaultQuery("cols", "80"))
|
cols, err := strconv.Atoi(c.DefaultQuery("cols", "80"))
|
||||||
if wshandleError(wsConn, errors.WithMessage(err, "invalid param cols in request")) {
|
if wshandleError(wsConn, errors.WithMessage(err, "invalid param cols in request")) {
|
||||||
return
|
return
|
||||||
@@ -40,23 +40,14 @@ func (b *BaseApi) WsSsh(c *gin.Context) {
|
|||||||
if wshandleError(wsConn, errors.WithMessage(err, "invalid param rows in request")) {
|
if wshandleError(wsConn, errors.WithMessage(err, "invalid param rows in request")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
host, err := hostService.GetHostInfo(uint(id))
|
|
||||||
if wshandleError(wsConn, errors.WithMessage(err, "load host info by id failed")) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var connInfo ssh.ConnInfo
|
|
||||||
_ = copier.Copy(&connInfo, &host)
|
|
||||||
connInfo.PrivateKey = []byte(host.PrivateKey)
|
|
||||||
if len(host.PassPhrase) != 0 {
|
|
||||||
connInfo.PassPhrase = []byte(host.PassPhrase)
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := connInfo.NewClient()
|
client, err := loadLocalConn()
|
||||||
if wshandleError(wsConn, errors.WithMessage(err, "failed to set up the connection. Please check the host information")) {
|
if wshandleError(wsConn, errors.WithMessage(err, "failed to set up the connection. Please check the host information")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
sws, err := terminal.NewLogicSshWsSession(cols, rows, true, connInfo.Client, wsConn)
|
command := c.DefaultQuery("command", "")
|
||||||
|
sws, err := terminal.NewLogicSshWsSession(cols, rows, client.Client, wsConn, command)
|
||||||
if wshandleError(wsConn, err) {
|
if wshandleError(wsConn, err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -80,7 +71,7 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
defer wsConn.Close()
|
defer wsConn.Close()
|
||||||
|
|
||||||
if global.CONF.System.IsDemo {
|
if global.CONF.Base.IsDemo {
|
||||||
if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) {
|
if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -98,8 +89,8 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
|
|||||||
var containerID string
|
var containerID string
|
||||||
var initCmd []string
|
var initCmd []string
|
||||||
switch source {
|
switch source {
|
||||||
case "redis":
|
case "redis", "redis-cluster":
|
||||||
containerID, initCmd, err = loadRedisInitCmd(c)
|
containerID, initCmd, err = loadRedisInitCmd(c, source)
|
||||||
case "ollama":
|
case "ollama":
|
||||||
containerID, initCmd, err = loadOllamaInitCmd(c)
|
containerID, initCmd, err = loadOllamaInitCmd(c)
|
||||||
case "container":
|
case "container":
|
||||||
@@ -113,7 +104,7 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
pidMap := loadMapFromDockerTop(containerID)
|
pidMap := loadMapFromDockerTop(containerID)
|
||||||
slave, err := terminal.NewCommand(initCmd)
|
slave, err := terminal.NewCommand("docker", initCmd...)
|
||||||
if wshandleError(wsConn, err) {
|
if wshandleError(wsConn, err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -134,10 +125,9 @@ func (b *BaseApi) ContainerWsSSH(c *gin.Context) {
|
|||||||
global.LOG.Info("websocket finished")
|
global.LOG.Info("websocket finished")
|
||||||
dt := time.Now().Add(time.Second)
|
dt := time.Now().Add(time.Second)
|
||||||
_ = wsConn.WriteControl(websocket.CloseMessage, nil, dt)
|
_ = wsConn.WriteControl(websocket.CloseMessage, nil, dt)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadRedisInitCmd(c *gin.Context) (string, []string, error) {
|
func loadRedisInitCmd(c *gin.Context, redisType string) (string, []string, error) {
|
||||||
name := c.Query("name")
|
name := c.Query("name")
|
||||||
from := c.Query("from")
|
from := c.Query("from")
|
||||||
commands := []string{"exec", "-it"}
|
commands := []string{"exec", "-it"}
|
||||||
@@ -146,7 +136,7 @@ func loadRedisInitCmd(c *gin.Context) (string, []string, error) {
|
|||||||
return "", nil, fmt.Errorf("no such database in db, err: %v", err)
|
return "", nil, fmt.Errorf("no such database in db, err: %v", err)
|
||||||
}
|
}
|
||||||
if from == "local" {
|
if from == "local" {
|
||||||
redisInfo, err := appInstallService.LoadConnInfo(dto.OperationWithNameAndType{Name: name, Type: "redis"})
|
redisInfo, err := appInstallService.LoadConnInfo(dto.OperationWithNameAndType{Name: name, Type: redisType})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, fmt.Errorf("no such app in db, err: %v", err)
|
return "", nil, fmt.Errorf("no such app in db, err: %v", err)
|
||||||
}
|
}
|
||||||
@@ -220,7 +210,7 @@ func loadMapFromDockerTop(containerID string) map[string]string {
|
|||||||
pidMap := make(map[string]string)
|
pidMap := make(map[string]string)
|
||||||
sudo := cmd.SudoHandleCmd()
|
sudo := cmd.SudoHandleCmd()
|
||||||
|
|
||||||
stdout, err := cmd.Execf("%s docker top %s -eo pid,command ", sudo, containerID)
|
stdout, err := cmd.RunDefaultWithStdoutBashCf("%s docker top %s -eo pid,command ", sudo, containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return pidMap
|
return pidMap
|
||||||
}
|
}
|
||||||
@@ -247,7 +237,7 @@ func killBash(containerID, comm string, pidMap map[string]string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !isOld && command == comm {
|
if !isOld && command == comm {
|
||||||
_, _ = cmd.Execf("%s kill -9 %s", sudo, pid)
|
_, _ = cmd.RunDefaultWithStdoutBashCf("%s kill -9 %s", sudo, pid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,7 +22,7 @@ func (b *BaseApi) PageWebsite(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
total, websites, err := websiteService.PageWebsite(req)
|
total, websites, err := websiteService.PageWebsite(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -43,7 +40,7 @@ func (b *BaseApi) PageWebsite(c *gin.Context) {
|
|||||||
func (b *BaseApi) GetWebsites(c *gin.Context) {
|
func (b *BaseApi) GetWebsites(c *gin.Context) {
|
||||||
websites, err := websiteService.GetWebsites()
|
websites, err := websiteService.GetWebsites()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, websites)
|
helper.SuccessWithData(c, websites)
|
||||||
@@ -54,11 +51,15 @@ func (b *BaseApi) GetWebsites(c *gin.Context) {
|
|||||||
// @Success 200 {array} response.WebsiteOption
|
// @Success 200 {array} response.WebsiteOption
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/options [get]
|
// @Router /websites/options [post]
|
||||||
func (b *BaseApi) GetWebsiteOptions(c *gin.Context) {
|
func (b *BaseApi) GetWebsiteOptions(c *gin.Context) {
|
||||||
websites, err := websiteService.GetWebsiteOptions()
|
var req request.WebsiteOptionReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
websites, err := websiteService.GetWebsiteOptions(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, websites)
|
helper.SuccessWithData(c, websites)
|
||||||
@@ -78,20 +79,12 @@ func (b *BaseApi) CreateWebsite(c *gin.Context) {
|
|||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(req.FtpPassword) != 0 {
|
|
||||||
pass, err := base64.StdEncoding.DecodeString(req.FtpPassword)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.FtpPassword = string(pass)
|
|
||||||
}
|
|
||||||
err := websiteService.CreateWebsite(req)
|
err := websiteService.CreateWebsite(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -110,10 +103,10 @@ func (b *BaseApi) OpWebsite(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := websiteService.OpWebsite(req)
|
err := websiteService.OpWebsite(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -132,10 +125,10 @@ func (b *BaseApi) DeleteWebsite(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := websiteService.DeleteWebsite(req)
|
err := websiteService.DeleteWebsite(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -153,10 +146,10 @@ func (b *BaseApi) UpdateWebsite(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateWebsite(req); err != nil {
|
if err := websiteService.UpdateWebsite(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -166,16 +159,16 @@ func (b *BaseApi) UpdateWebsite(c *gin.Context) {
|
|||||||
// @Success 200 {object} response.WebsiteDTO
|
// @Success 200 {object} response.WebsiteDTO
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/{id} [get]
|
// @Router /websites/:id [get]
|
||||||
func (b *BaseApi) GetWebsite(c *gin.Context) {
|
func (b *BaseApi) GetWebsite(c *gin.Context) {
|
||||||
id, err := helper.GetParamID(c)
|
id, err := helper.GetParamID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
website, err := websiteService.GetWebsite(id)
|
website, err := websiteService.GetWebsite(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, website)
|
helper.SuccessWithData(c, website)
|
||||||
@@ -185,22 +178,21 @@ func (b *BaseApi) GetWebsite(c *gin.Context) {
|
|||||||
// @Summary Search website nginx by id
|
// @Summary Search website nginx by id
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param id path integer true "request"
|
// @Param id path integer true "request"
|
||||||
// @Param type path string true "type"
|
|
||||||
// @Success 200 {object} response.FileInfo
|
// @Success 200 {object} response.FileInfo
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/{id}/config/{type} [get]
|
// @Router /websites/:id/config/:type [get]
|
||||||
func (b *BaseApi) GetWebsiteNginx(c *gin.Context) {
|
func (b *BaseApi) GetWebsiteNginx(c *gin.Context) {
|
||||||
id, err := helper.GetParamID(c)
|
id, err := helper.GetParamID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
configType := c.Param("type")
|
configType := c.Param("type")
|
||||||
|
|
||||||
fileInfo, err := websiteService.GetWebsiteNginxConfig(id, configType)
|
fileInfo, err := websiteService.GetWebsiteNginxConfig(id, configType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, fileInfo)
|
helper.SuccessWithData(c, fileInfo)
|
||||||
@@ -221,7 +213,7 @@ func (b *BaseApi) GetNginxConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
config, err := websiteService.GetNginxConfigByScope(req)
|
config, err := websiteService.GetNginxConfigByScope(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, config)
|
helper.SuccessWithData(c, config)
|
||||||
@@ -242,10 +234,10 @@ func (b *BaseApi) UpdateNginxConfig(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateNginxConfigByScope(req); err != nil {
|
if err := websiteService.UpdateNginxConfigByScope(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website HTTPS
|
// @Tags Website HTTPS
|
||||||
@@ -255,16 +247,16 @@ func (b *BaseApi) UpdateNginxConfig(c *gin.Context) {
|
|||||||
// @Success 200 {object} response.WebsiteHTTPS
|
// @Success 200 {object} response.WebsiteHTTPS
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/{id}/https [get]
|
// @Router /websites/:id/https [get]
|
||||||
func (b *BaseApi) GetHTTPSConfig(c *gin.Context) {
|
func (b *BaseApi) GetHTTPSConfig(c *gin.Context) {
|
||||||
id, err := helper.GetParamID(c)
|
id, err := helper.GetParamID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res, err := websiteService.GetWebsiteHTTPS(id)
|
res, err := websiteService.GetWebsiteHTTPS(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -273,12 +265,11 @@ func (b *BaseApi) GetHTTPSConfig(c *gin.Context) {
|
|||||||
// @Tags Website HTTPS
|
// @Tags Website HTTPS
|
||||||
// @Summary Update https conf
|
// @Summary Update https conf
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param id path integer true "request"
|
|
||||||
// @Param request body request.WebsiteHTTPSOp true "request"
|
// @Param request body request.WebsiteHTTPSOp true "request"
|
||||||
// @Success 200 {object} response.WebsiteHTTPS
|
// @Success 200 {object} response.WebsiteHTTPS
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/{id}/https [post]
|
// @Router /websites/:id/https [post]
|
||||||
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] https 配置","formatEN":"Update website https [domain] conf"}
|
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"更新网站 [domain] https 配置","formatEN":"Update website https [domain] conf"}
|
||||||
func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
|
func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
|
||||||
var req request.WebsiteHTTPSOp
|
var req request.WebsiteHTTPSOp
|
||||||
@@ -289,7 +280,7 @@ func (b *BaseApi) UpdateHTTPSConfig(c *gin.Context) {
|
|||||||
res, err := websiteService.OpWebsiteHTTPS(ctx, req)
|
res, err := websiteService.OpWebsiteHTTPS(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
@@ -311,7 +302,7 @@ func (b *BaseApi) CreateWebsiteCheck(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
data, err := websiteService.PreInstallCheck(req)
|
data, err := websiteService.PreInstallCheck(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, data)
|
helper.SuccessWithData(c, data)
|
||||||
@@ -332,10 +323,10 @@ func (b *BaseApi) UpdateWebsiteNginxConfig(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateNginxConfigFile(req); err != nil {
|
if err := websiteService.UpdateNginxConfigFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -354,7 +345,7 @@ func (b *BaseApi) OpWebsiteLog(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteService.OpWebsiteLog(req)
|
res, err := websiteService.OpWebsiteLog(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -375,74 +366,10 @@ func (b *BaseApi) ChangeDefaultServer(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.ChangeDefaultServer(req.ID); err != nil {
|
if err := websiteService.ChangeDefaultServer(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Website
|
|
||||||
// @Summary Load website php conf
|
|
||||||
// @Accept json
|
|
||||||
// @Param id path integer true "request"
|
|
||||||
// @Success 200 {object} response.PHPConfig
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /websites/php/config/{id} [get]
|
|
||||||
func (b *BaseApi) GetWebsitePHPConfig(c *gin.Context) {
|
|
||||||
id, err := helper.GetParamID(c)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := websiteService.GetPHPConfig(id)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Website PHP
|
|
||||||
// @Summary Update website php conf
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body request.WebsitePHPConfigUpdate true "request"
|
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /websites/php/config [post]
|
|
||||||
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] PHP 配置修改","formatEN":"[domain] PHP conf update"}
|
|
||||||
func (b *BaseApi) UpdateWebsitePHPConfig(c *gin.Context) {
|
|
||||||
var req request.WebsitePHPConfigUpdate
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := websiteService.UpdatePHPConfig(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Website PHP
|
|
||||||
// @Summary Update php conf
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body request.WebsitePHPFileUpdate true "request"
|
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /websites/php/update [post]
|
|
||||||
// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 配置修改 [domain]","formatEN":"Nginx conf update [domain]"}
|
|
||||||
func (b *BaseApi) UpdatePHPFile(c *gin.Context) {
|
|
||||||
var req request.WebsitePHPFileUpdate
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := websiteService.UpdatePHPConfigFile(req); err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithData(c, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website PHP
|
// @Tags Website PHP
|
||||||
@@ -460,10 +387,10 @@ func (b *BaseApi) ChangePHPVersion(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.ChangePHPVersion(req); err != nil {
|
if err := websiteService.ChangePHPVersion(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -481,7 +408,7 @@ func (b *BaseApi) GetRewriteConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteService.GetRewriteConfig(req)
|
res, err := websiteService.GetRewriteConfig(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -502,10 +429,10 @@ func (b *BaseApi) UpdateRewriteConfig(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateRewriteConfig(req); err != nil {
|
if err := websiteService.UpdateRewriteConfig(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -523,10 +450,10 @@ func (b *BaseApi) UpdateSiteDir(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateSiteDir(req); err != nil {
|
if err := websiteService.UpdateSiteDir(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -544,10 +471,10 @@ func (b *BaseApi) UpdateSiteDirPermission(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateSitePermission(req); err != nil {
|
if err := websiteService.UpdateSitePermission(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -565,34 +492,12 @@ func (b *BaseApi) GetProxyConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteService.GetProxies(req.ID)
|
res, err := websiteService.GetProxies(req.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
|
||||||
// @Summary Delete proxy conf
|
|
||||||
// @Accept json
|
|
||||||
// @Param request body request.WebsiteProxyDel true "request"
|
|
||||||
// @Success 200
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
// @Security Timestamp
|
|
||||||
// @Router /websites/proxies/del [post]
|
|
||||||
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"删除网站 [domain] 反向代理配置","formatEN":"Delete domain [domain] proxy config"}
|
|
||||||
func (b *BaseApi) DeleteProxyConfig(c *gin.Context) {
|
|
||||||
var req request.WebsiteProxyDel
|
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := websiteService.DeleteProxy(req)
|
|
||||||
if err != nil {
|
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
helper.SuccessWithOutData(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
// @Summary Update proxy conf
|
// @Summary Update proxy conf
|
||||||
// @Accept json
|
// @Accept json
|
||||||
@@ -609,10 +514,10 @@ func (b *BaseApi) UpdateProxyConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := websiteService.OperateProxy(req)
|
err := websiteService.OperateProxy(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -630,10 +535,10 @@ func (b *BaseApi) UpdateProxyConfigFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateProxyFile(req); err != nil {
|
if err := websiteService.UpdateProxyFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -651,7 +556,7 @@ func (b *BaseApi) GetAuthConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteService.GetAuthBasics(req)
|
res, err := websiteService.GetAuthBasics(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -671,10 +576,51 @@ func (b *BaseApi) UpdateAuthConfig(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateAuthBasic(req); err != nil {
|
if err := websiteService.UpdateAuthBasic(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Get AuthBasic conf
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NginxAuthReq true "request"
|
||||||
|
// @Success 200 {object} response.NginxPathAuthRes
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/auths/path [post]
|
||||||
|
func (b *BaseApi) GetPathAuthConfig(c *gin.Context) {
|
||||||
|
var req request.NginxAuthReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := websiteService.GetPathAuthBasics(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Get AuthBasic conf
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NginxPathAuthUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/auths/path/update [post]
|
||||||
|
func (b *BaseApi) UpdatePathAuthConfig(c *gin.Context) {
|
||||||
|
var req request.NginxPathAuthUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.UpdatePathAuthBasic(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -692,14 +638,14 @@ func (b *BaseApi) GetAntiLeech(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteService.GetAntiLeech(req.WebsiteID)
|
res, err := websiteService.GetAntiLeech(req.WebsiteID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
// @Summary Update AntiLeech conf
|
// @Summary Update AntiLeech
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.NginxAntiLeechUpdate true "request"
|
// @Param request body request.NginxAntiLeechUpdate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -712,10 +658,10 @@ func (b *BaseApi) UpdateAntiLeech(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateAntiLeech(req); err != nil {
|
if err := websiteService.UpdateAntiLeech(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -734,10 +680,10 @@ func (b *BaseApi) UpdateRedirectConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
err := websiteService.OperateRedirect(req)
|
err := websiteService.OperateRedirect(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -755,7 +701,7 @@ func (b *BaseApi) GetRedirectConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteService.GetRedirect(req.WebsiteID)
|
res, err := websiteService.GetRedirect(req.WebsiteID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -776,10 +722,10 @@ func (b *BaseApi) UpdateRedirectConfigFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateRedirectFile(req); err != nil {
|
if err := websiteService.UpdateRedirectFile(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website
|
// @Tags Website
|
||||||
@@ -797,7 +743,7 @@ func (b *BaseApi) GetDirConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteService.LoadWebsiteDirConfig(req)
|
res, err := websiteService.LoadWebsiteDirConfig(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -806,20 +752,19 @@ func (b *BaseApi) GetDirConfig(c *gin.Context) {
|
|||||||
// @Tags Website
|
// @Tags Website
|
||||||
// @Summary Get default html
|
// @Summary Get default html
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param type path string true "type"
|
|
||||||
// @Success 200 {object} response.WebsiteHtmlRes
|
// @Success 200 {object} response.WebsiteHtmlRes
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/default/html/{type} [get]
|
// @Router /websites/default/html/:type [get]
|
||||||
func (b *BaseApi) GetDefaultHtml(c *gin.Context) {
|
func (b *BaseApi) GetDefaultHtml(c *gin.Context) {
|
||||||
resourceType, err := helper.GetStrParamByKey(c, "type")
|
resourceType, err := helper.GetStrParamByKey(c, "type")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fileInfo, err := websiteService.GetDefaultHtml(resourceType)
|
fileInfo, err := websiteService.GetDefaultHtml(resourceType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, fileInfo)
|
helper.SuccessWithData(c, fileInfo)
|
||||||
@@ -840,8 +785,339 @@ func (b *BaseApi) UpdateDefaultHtml(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.UpdateDefaultHtml(req); err != nil {
|
if err := websiteService.UpdateDefaultHtml(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Get website upstreams
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.WebsiteCommonReq true "request"
|
||||||
|
// @Success 200 {array} dto.NginxUpstream
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/lbs [get]
|
||||||
|
func (b *BaseApi) GetLoadBalances(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := websiteService.GetLoadBalances(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Create website upstream
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.WebsiteLBCreate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/lbs/create [post]
|
||||||
|
func (b *BaseApi) CreateLoadBalance(c *gin.Context) {
|
||||||
|
var req request.WebsiteLBCreate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.CreateLoadBalance(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Delete website upstream
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.WebsiteLBDelete true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/lbs/delete [post]
|
||||||
|
func (b *BaseApi) DeleteLoadBalance(c *gin.Context) {
|
||||||
|
var req request.WebsiteLBDelete
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.DeleteLoadBalance(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Update website upstream
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.WebsiteLBUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/lbs/update [post]
|
||||||
|
func (b *BaseApi) UpdateLoadBalance(c *gin.Context) {
|
||||||
|
var req request.WebsiteLBUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.UpdateLoadBalance(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Update website upstream file
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.WebsiteLBUpdateFile true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/lbs/file [post]
|
||||||
|
func (b *BaseApi) UpdateLoadBalanceFile(c *gin.Context) {
|
||||||
|
var req request.WebsiteLBUpdateFile
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.UpdateLoadBalanceFile(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BaseApi) ChangeWebsiteGroup(c *gin.Context) {
|
||||||
|
var req dto.UpdateGroup
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.ChangeGroup(req.Group, req.NewGroup); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary update website proxy cache config
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.NginxProxyCacheUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/proxy/config [post]
|
||||||
|
func (b *BaseApi) UpdateProxyCache(c *gin.Context) {
|
||||||
|
var req request.NginxProxyCacheUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.UpdateProxyCache(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary Get website proxy cache config
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path int true "id"
|
||||||
|
// @Success 200 {object} response.NginxProxyCache
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/proxy/config/{id} [get]
|
||||||
|
func (b *BaseApi) GetProxyCache(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := websiteService.GetProxyCache(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Set Real IP
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.WebsiteRealIP true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/realip [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"修改 [domain] 网站真实IP配置 ","formatEN":"Modify the real IP configuration of [domain] website"}
|
||||||
|
func (b *BaseApi) SetRealIPConfig(c *gin.Context) {
|
||||||
|
var req request.WebsiteRealIP
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.SetRealIPConfig(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Get Real IP Config
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path int true "id"
|
||||||
|
// @Success 200 {object} response.WebsiteRealIP
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/realip/config/{id} [get]
|
||||||
|
func (b *BaseApi) GetRealIPConfig(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := websiteService.GetRealIPConfig(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Get website resource
|
||||||
|
// @Accept json
|
||||||
|
// @Param id path int true "id"
|
||||||
|
// @Success 200 {object} response.Resource
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/resource/{id} [get]
|
||||||
|
func (b *BaseApi) GetWebsiteResource(c *gin.Context) {
|
||||||
|
id, err := helper.GetParamID(c)
|
||||||
|
if err != nil {
|
||||||
|
helper.BadRequest(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := websiteService.GetWebsiteResource(id)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Get databases
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200 {object} response.Database
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/databases [get]
|
||||||
|
func (b *BaseApi) GetWebsiteDatabase(c *gin.Context) {
|
||||||
|
res, err := websiteService.ListDatabases()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Change website database
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.ChangeDatabase true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/databases [post]
|
||||||
|
func (b *BaseApi) ChangeWebsiteDatabase(c *gin.Context) {
|
||||||
|
var req request.ChangeDatabase
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.ChangeDatabase(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Operate custom rewrite
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.CustomRewriteOperate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/rewrite/custom [post]
|
||||||
|
func (b *BaseApi) OperateCustomRewrite(c *gin.Context) {
|
||||||
|
var req request.CustomRewriteOperate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.OperateCustomRewrite(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary List custom rewrite
|
||||||
|
// @Accept json
|
||||||
|
// @Success 200 {array} string
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/rewrite/custom [get]
|
||||||
|
func (b *BaseApi) ListCustomRewrite(c *gin.Context) {
|
||||||
|
res, err := websiteService.ListCustomRewrite()
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Clear Website proxy cache
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/proxy/clear [post]
|
||||||
|
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理 Openresty 代理缓存","formatEN":"Clear nginx proxy cache"}
|
||||||
|
func (b *BaseApi) ClearProxyCache(c *gin.Context) {
|
||||||
|
var req request.NginxCommonReq
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.ClearProxyCache(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website
|
||||||
|
// @Summary Operate Cross Site Access
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.CrossSiteAccessOp true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/crosssite [post]
|
||||||
|
func (b *BaseApi) OperateCrossSiteAccess(c *gin.Context) {
|
||||||
|
var req request.CrossSiteAccessOp
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.OperateCrossSiteAccess(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
+30
-9
@@ -1,10 +1,9 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ func (b *BaseApi) PageWebsiteAcmeAccount(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
total, accounts, err := websiteAcmeAccountService.Page(req)
|
total, accounts, err := websiteAcmeAccountService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -48,7 +47,7 @@ func (b *BaseApi) CreateWebsiteAcmeAccount(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteAcmeAccountService.Create(req)
|
res, err := websiteAcmeAccountService.Create(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -69,8 +68,30 @@ func (b *BaseApi) DeleteWebsiteAcmeAccount(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteAcmeAccountService.Delete(req.ID); err != nil {
|
if err := websiteAcmeAccountService.Delete(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Tags Website Acme
|
||||||
|
// @Summary Update website acme account
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.WebsiteAcmeAccountUpdate true "request"
|
||||||
|
// @Success 200 {object} response.WebsiteAcmeAccountDTO
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/acme/update [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_acme_accounts","output_column":"email","output_value":"email"}],"formatZH":"更新 acme [email]","formatEN":"Update acme [email]"}
|
||||||
|
func (b *BaseApi) UpdateWebsiteAcmeAccount(c *gin.Context) {
|
||||||
|
var req request.WebsiteAcmeAccountUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res, err := websiteAcmeAccountService.Update(req)
|
||||||
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.SuccessWithData(c, res)
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Tags Website CA
|
// @Tags Website CA
|
||||||
@@ -26,7 +26,7 @@ func (b *BaseApi) PageWebsiteCA(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
total, cas, err := websiteCAService.Page(req)
|
total, cas, err := websiteCAService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -51,7 +51,7 @@ func (b *BaseApi) CreateWebsiteCA(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteCAService.Create(req)
|
res, err := websiteCAService.Create(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -72,7 +72,7 @@ func (b *BaseApi) GetWebsiteCA(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteCAService.GetCA(id)
|
res, err := websiteCAService.GetCA(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -93,10 +93,10 @@ func (b *BaseApi) DeleteWebsiteCA(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteCAService.Delete(req.ID); err != nil {
|
if err := websiteCAService.Delete(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website CA
|
// @Tags Website CA
|
||||||
@@ -113,15 +113,16 @@ func (b *BaseApi) ObtainWebsiteCA(c *gin.Context) {
|
|||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, err := websiteCAService.ObtainSSL(req); err != nil {
|
res, err := websiteCAService.ObtainSSL(req)
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
if err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.SuccessWithData(c, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website CA
|
// @Tags Website CA
|
||||||
// @Summary Renew Obtain SSL
|
// @Summary Obtain SSL
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.WebsiteCAObtain true "request"
|
// @Param request body request.WebsiteCAObtain true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -140,10 +141,10 @@ func (b *BaseApi) RenewWebsiteCA(c *gin.Context) {
|
|||||||
Unit: "year",
|
Unit: "year",
|
||||||
Time: 1,
|
Time: 1,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website CA
|
// @Tags Website CA
|
||||||
@@ -162,13 +163,13 @@ func (b *BaseApi) DownloadCAFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
file, err := websiteCAService.DownloadFile(req.ID)
|
file, err := websiteCAService.DownloadFile(req.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
info, err := file.Stat()
|
info, err := file.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Header("Content-Length", strconv.FormatInt(info.Size(), 10))
|
c.Header("Content-Length", strconv.FormatInt(info.Size(), 10))
|
||||||
+11
-12
@@ -1,10 +1,9 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ func (b *BaseApi) PageWebsiteDnsAccount(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
total, accounts, err := websiteDnsAccountService.Page(req)
|
total, accounts, err := websiteDnsAccountService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -47,10 +46,10 @@ func (b *BaseApi) CreateWebsiteDnsAccount(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, err := websiteDnsAccountService.Create(req); err != nil {
|
if _, err := websiteDnsAccountService.Create(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website DNS
|
// @Tags Website DNS
|
||||||
@@ -68,10 +67,10 @@ func (b *BaseApi) UpdateWebsiteDnsAccount(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, err := websiteDnsAccountService.Update(req); err != nil {
|
if _, err := websiteDnsAccountService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website DNS
|
// @Tags Website DNS
|
||||||
@@ -89,8 +88,8 @@ func (b *BaseApi) DeleteWebsiteDnsAccount(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteDnsAccountService.Delete(req.ID); err != nil {
|
if err := websiteDnsAccountService.Delete(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -22,17 +21,17 @@ func (b *BaseApi) DeleteWebDomain(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteService.DeleteWebsiteDomain(req.ID); err != nil {
|
if err := websiteService.DeleteWebsiteDomain(req.ID); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website Domain
|
// @Tags Website Domain
|
||||||
// @Summary Create website domain
|
// @Summary Create website domain
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.WebsiteDomainCreate true "request"
|
// @Param request body request.WebsiteDomainCreate true "request"
|
||||||
// @Success 200 {array} model.WebsiteDomain
|
// @Success 200 {object} model.WebsiteDomain
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/domains [post]
|
// @Router /websites/domains [post]
|
||||||
@@ -44,7 +43,7 @@ func (b *BaseApi) CreateWebDomain(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
domain, err := websiteService.CreateWebsiteDomain(req)
|
domain, err := websiteService.CreateWebsiteDomain(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, domain)
|
helper.SuccessWithData(c, domain)
|
||||||
@@ -57,17 +56,38 @@ func (b *BaseApi) CreateWebDomain(c *gin.Context) {
|
|||||||
// @Success 200 {array} model.WebsiteDomain
|
// @Success 200 {array} model.WebsiteDomain
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/domains/{websiteId} [get]
|
// @Router /websites/domains/:websiteId [get]
|
||||||
func (b *BaseApi) GetWebDomains(c *gin.Context) {
|
func (b *BaseApi) GetWebDomains(c *gin.Context) {
|
||||||
websiteId, err := helper.GetIntParamByKey(c, "websiteId")
|
websiteId, err := helper.GetIntParamByKey(c, "websiteId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
list, err := websiteService.GetWebsiteDomain(websiteId)
|
list, err := websiteService.GetWebsiteDomain(websiteId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Tags Website Domain
|
||||||
|
// @Summary Update website domain
|
||||||
|
// @Accept json
|
||||||
|
// @Param request body request.WebsiteDomainUpdate true "request"
|
||||||
|
// @Success 200
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Security Timestamp
|
||||||
|
// @Router /websites/domains/update [post]
|
||||||
|
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"website_domains","output_column":"domain","output_value":"domain"}],"formatZH":"更新域名 [domain]","formatEN":"Update domain [domain]"}
|
||||||
|
func (b *BaseApi) UpdateWebDomain(c *gin.Context) {
|
||||||
|
var req request.WebsiteDomainUpdate
|
||||||
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := websiteService.UpdateWebsiteDomain(req); err != nil {
|
||||||
|
helper.InternalServer(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
helper.Success(c)
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package v1
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -6,10 +6,9 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ func (b *BaseApi) PageWebsiteSSL(c *gin.Context) {
|
|||||||
if !reflect.DeepEqual(req.PageInfo, dto.PageInfo{}) {
|
if !reflect.DeepEqual(req.PageInfo, dto.PageInfo{}) {
|
||||||
total, accounts, err := websiteSSLService.Page(req)
|
total, accounts, err := websiteSSLService.Page(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, dto.PageResult{
|
helper.SuccessWithData(c, dto.PageResult{
|
||||||
@@ -39,7 +38,7 @@ func (b *BaseApi) PageWebsiteSSL(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
list, err := websiteSSLService.Search(req)
|
list, err := websiteSSLService.Search(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, list)
|
helper.SuccessWithData(c, list)
|
||||||
@@ -62,7 +61,7 @@ func (b *BaseApi) CreateWebsiteSSL(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteSSLService.Create(req)
|
res, err := websiteSSLService.Create(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -83,10 +82,10 @@ func (b *BaseApi) ApplyWebsiteSSL(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteSSLService.ObtainSSL(req); err != nil {
|
if err := websiteSSLService.ObtainSSL(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithOutData(c)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website SSL
|
// @Tags Website SSL
|
||||||
@@ -104,7 +103,7 @@ func (b *BaseApi) GetDNSResolve(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
res, err := websiteSSLService.GetDNSResolve(req)
|
res, err := websiteSSLService.GetDNSResolve(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, res)
|
helper.SuccessWithData(c, res)
|
||||||
@@ -125,10 +124,10 @@ func (b *BaseApi) DeleteWebsiteSSL(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteSSLService.Delete(req.IDs); err != nil {
|
if err := websiteSSLService.Delete(req.IDs); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website SSL
|
// @Tags Website SSL
|
||||||
@@ -138,16 +137,16 @@ func (b *BaseApi) DeleteWebsiteSSL(c *gin.Context) {
|
|||||||
// @Success 200 {object} response.WebsiteSSLDTO
|
// @Success 200 {object} response.WebsiteSSLDTO
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/ssl/website/{websiteId} [get]
|
// @Router /websites/ssl/website/:websiteId [get]
|
||||||
func (b *BaseApi) GetWebsiteSSLByWebsiteId(c *gin.Context) {
|
func (b *BaseApi) GetWebsiteSSLByWebsiteId(c *gin.Context) {
|
||||||
websiteId, err := helper.GetIntParamByKey(c, "websiteId")
|
websiteId, err := helper.GetIntParamByKey(c, "websiteId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
websiteSSL, err := websiteSSLService.GetWebsiteSSL(websiteId)
|
websiteSSL, err := websiteSSLService.GetWebsiteSSL(websiteId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, websiteSSL)
|
helper.SuccessWithData(c, websiteSSL)
|
||||||
@@ -160,23 +159,23 @@ func (b *BaseApi) GetWebsiteSSLByWebsiteId(c *gin.Context) {
|
|||||||
// @Success 200 {object} response.WebsiteSSLDTO
|
// @Success 200 {object} response.WebsiteSSLDTO
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Security Timestamp
|
// @Security Timestamp
|
||||||
// @Router /websites/ssl/{id} [get]
|
// @Router /websites/ssl/:id [get]
|
||||||
func (b *BaseApi) GetWebsiteSSLById(c *gin.Context) {
|
func (b *BaseApi) GetWebsiteSSLById(c *gin.Context) {
|
||||||
id, err := helper.GetParamID(c)
|
id, err := helper.GetParamID(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
helper.BadRequest(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
websiteSSL, err := websiteSSLService.GetSSL(id)
|
websiteSSL, err := websiteSSLService.GetSSL(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, websiteSSL)
|
helper.SuccessWithData(c, websiteSSL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website SSL
|
// @Tags Website SSL
|
||||||
// @Summary Update Website ssl
|
// @Summary Update ssl
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.WebsiteSSLUpdate true "request"
|
// @Param request body request.WebsiteSSLUpdate true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -190,14 +189,14 @@ func (b *BaseApi) UpdateWebsiteSSL(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteSSLService.Update(req); err != nil {
|
if err := websiteSSLService.Update(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website SSL
|
// @Tags Website SSL
|
||||||
// @Summary Upload Website ssl
|
// @Summary Upload ssl
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.WebsiteSSLUpload true "request"
|
// @Param request body request.WebsiteSSLUpload true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -211,14 +210,14 @@ func (b *BaseApi) UploadWebsiteSSL(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := websiteSSLService.Upload(req); err != nil {
|
if err := websiteSSLService.Upload(req); err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
helper.SuccessWithData(c, nil)
|
helper.Success(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags Website SSL
|
// @Tags Website SSL
|
||||||
// @Summary Download SSL file
|
// @Summary Download SSL file
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param request body request.WebsiteResourceReq true "request"
|
// @Param request body request.WebsiteResourceReq true "request"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
@@ -233,13 +232,13 @@ func (b *BaseApi) DownloadWebsiteSSL(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
file, err := websiteSSLService.DownloadFile(req.ID)
|
file, err := websiteSSLService.DownloadFile(req.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
info, err := file.Stat()
|
info, err := file.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
helper.InternalServer(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Header("Content-Length", strconv.FormatInt(info.Size(), 10))
|
c.Header("Content-Length", strconv.FormatInt(info.Size(), 10))
|
||||||
@@ -20,7 +20,8 @@ type OllamaModelDropList struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type OllamaModelName struct {
|
type OllamaModelName struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OllamaBindDomain struct {
|
type OllamaBindDomain struct {
|
||||||
@@ -38,8 +39,8 @@ type OllamaBindDomainReq struct {
|
|||||||
type OllamaBindDomainRes struct {
|
type OllamaBindDomainRes struct {
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
SSLID uint `json:"sslID"`
|
SSLID uint `json:"sslID"`
|
||||||
AcmeAccountID uint `json:"acmeAccountID"`
|
|
||||||
AllowIPs []string `json:"allowIPs"`
|
AllowIPs []string `json:"allowIPs"`
|
||||||
WebsiteID uint `json:"websiteID"`
|
WebsiteID uint `json:"websiteID"`
|
||||||
ConnUrl string `json:"connUrl"`
|
ConnUrl string `json:"connUrl"`
|
||||||
|
AcmeAccountID uint `json:"acmeAccountID"`
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,327 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateOrUpdateAlert struct {
|
||||||
|
AlertTitle string `json:"alertTitle"`
|
||||||
|
AlertType string `json:"alertType"`
|
||||||
|
AlertMethod string `json:"alertMethod"`
|
||||||
|
AlertCount uint `json:"alertCount"`
|
||||||
|
EntryID uint `json:"entryID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertBase struct {
|
||||||
|
AlertType string `json:"alertType"`
|
||||||
|
EntryID uint `json:"entryID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushAlert struct {
|
||||||
|
TaskName string `json:"taskName"`
|
||||||
|
AlertType string `json:"alertType"`
|
||||||
|
EntryID uint `json:"entryID"`
|
||||||
|
Param string `json:"param"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertSearch struct {
|
||||||
|
PageInfo
|
||||||
|
OrderBy string `json:"orderBy" validate:"required,oneof=created_at"`
|
||||||
|
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertDTO struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Cycle uint `json:"cycle"`
|
||||||
|
Count uint `json:"count"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Project string `json:"project"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
SendCount uint `json:"sendCount"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertCreate struct {
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
Cycle uint `json:"cycle"`
|
||||||
|
Count uint `json:"count"`
|
||||||
|
Method string `json:"method" validate:"required"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Project string `json:"project"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
SendCount uint `json:"sendCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertUpdate struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Cycle uint `json:"cycle"`
|
||||||
|
Count uint `json:"count"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Project string `json:"project"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
SendCount uint `json:"sendCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteRequest struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertUpdateStatus struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
Status string `json:"status" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DiskDTO struct {
|
||||||
|
Path string `json:"path"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Device string `json:"device"`
|
||||||
|
Total uint64 `json:"total"`
|
||||||
|
Free uint64 `json:"free"`
|
||||||
|
Used uint64 `json:"used"`
|
||||||
|
UsedPercent float64 `json:"usedPercent"`
|
||||||
|
|
||||||
|
InodesTotal uint64 `json:"inodesTotal"`
|
||||||
|
InodesUsed uint64 `json:"inodesUsed"`
|
||||||
|
InodesFree uint64 `json:"inodesFree"`
|
||||||
|
InodesUsedPercent float64 `json:"inodesUsedPercent"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertLogSearch struct {
|
||||||
|
PageInfo
|
||||||
|
Count uint `json:"count"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertLogDTO struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Count uint `json:"count"`
|
||||||
|
AlertId uint `json:"alertId"`
|
||||||
|
AlertDetail AlertDetail `json:"alertDetail"`
|
||||||
|
AlertRule AlertRule `json:"alertRule"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertLogCreate struct {
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
Count uint `json:"count" validate:"required"`
|
||||||
|
AlertId uint `json:"alertId" validate:"required"`
|
||||||
|
AlertDetail string `json:"alertDetail" validate:"required"`
|
||||||
|
AlertRule string `json:"alertRule" validate:"required"`
|
||||||
|
Status string `json:"status" validate:"required"`
|
||||||
|
Method string `json:"method" validate:"required"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
RecordId uint `json:"recordId"`
|
||||||
|
LicenseId string `json:"licenseId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertLog struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertDetail struct {
|
||||||
|
LicenseId string `json:"licenseId"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
SubType string `json:"subType"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
LicenseCode string `json:"licenseCode"`
|
||||||
|
DeviceId string `json:"deviceId"`
|
||||||
|
Project string `json:"project"`
|
||||||
|
Params []Param `json:"params"`
|
||||||
|
Phone string `json:"phone"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertRule struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Cycle uint `json:"cycle"`
|
||||||
|
Count uint `json:"count"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Project string `json:"project"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
SendCount uint `json:"sendCount"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Param struct {
|
||||||
|
Index string `json:"index"`
|
||||||
|
Key string `json:"key"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClamDTO struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Path string `json:"path"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronJobDTO struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronJobReq struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpgradeInfo struct {
|
||||||
|
TestVersion string `json:"testVersion"`
|
||||||
|
NewVersion string `json:"newVersion"`
|
||||||
|
LatestVersion string `json:"latestVersion"`
|
||||||
|
ReleaseNote string `json:"releaseNote"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertDiskInfo struct {
|
||||||
|
Type string
|
||||||
|
Mount string
|
||||||
|
Device string
|
||||||
|
}
|
||||||
|
|
||||||
|
type SyncResult struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
LicenseID string `json:"licenseId"`
|
||||||
|
SendStatus string `json:"sendStatus"`
|
||||||
|
CreateTime string `json:"createTime"`
|
||||||
|
UpdateTime string `json:"updateTime"`
|
||||||
|
Remarks string `json:"remarks"`
|
||||||
|
MsgCount int `json:"msgCount"`
|
||||||
|
MsgCountMax int `json:"msgCountMax"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type QueryRequest struct {
|
||||||
|
QueryIds []uint `json:"queryIds"`
|
||||||
|
LicenseId string `json:"licenseId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertResponse struct {
|
||||||
|
Result bool `json:"result"`
|
||||||
|
Data json.RawMessage `json:"data"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushResult struct {
|
||||||
|
RecordId uint `json:"recordId"`
|
||||||
|
LicenseId string `json:"licenseId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateOfflineAlertLog struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
RecordId uint `json:"recordId"`
|
||||||
|
LicenseId string `json:"licenseId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SyncOfflineAlertLogDTO struct {
|
||||||
|
QueryRequest string `json:"queryRequest"`
|
||||||
|
Ids []uint `json:"ids"`
|
||||||
|
AlertLogs []model.AlertLog `json:"alertLogs"`
|
||||||
|
LicenseId string `json:"licenseId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OfflineAlertResponse struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
RemoteErr error `json:"remoteErr"`
|
||||||
|
ResponseStruct AlertResponse `json:"responseStruct"`
|
||||||
|
AlertLogs []model.AlertLog `json:"alertLogs"`
|
||||||
|
Ids []uint `json:"ids"`
|
||||||
|
LicenseId string `json:"licenseId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OfflineAlertLogDTO struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Count uint `json:"count"`
|
||||||
|
AlertId uint `json:"alertId"`
|
||||||
|
AlertDetail string `json:"alertDetail"`
|
||||||
|
AlertRule string `json:"alertRule"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Method string `json:"method"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
RecordId uint `json:"recordId"`
|
||||||
|
LicenseId string `json:"licenseId"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OfflineQueryRequest struct {
|
||||||
|
Ids []uint `json:"ids"`
|
||||||
|
QueryIds []uint `json:"queryIds"`
|
||||||
|
LicenseId string `json:"licenseId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertConfigUpdate struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Config string `json:"config"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertConfigTest struct {
|
||||||
|
Host string `json:"host"`
|
||||||
|
Port int `json:"port"`
|
||||||
|
Sender string `json:"sender"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
DisplayName string `json:"displayName"`
|
||||||
|
Encryption string `json:"encryption"` // "ssl" / "tls" / "none"
|
||||||
|
Recipient string `json:"recipient"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertSendTimeRange struct {
|
||||||
|
NoticeAlert struct {
|
||||||
|
SendTimeRange string `json:"sendTimeRange"`
|
||||||
|
Type []string `json:"type"`
|
||||||
|
} `json:"noticeAlert"`
|
||||||
|
ResourceAlert struct {
|
||||||
|
SendTimeRange string `json:"sendTimeRange"`
|
||||||
|
Type []string `json:"type"`
|
||||||
|
} `json:"resourceAlert"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertCommonConfig struct {
|
||||||
|
IsOffline string `json:"isOffline"`
|
||||||
|
AlertSendTimeRange AlertSendTimeRange `json:"alertSendTimeRange"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertSmsConfig struct {
|
||||||
|
Phone string `json:"phone"`
|
||||||
|
AlertDailyNum uint `json:"alertDailyNum"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AlertEmailConfig struct {
|
||||||
|
Host string `json:"host"`
|
||||||
|
Port int `json:"port"`
|
||||||
|
Sender string `json:"sender"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
DisplayName string `json:"displayName"`
|
||||||
|
Encryption string `json:"encryption"` // "ssl" / "tls" / "none"
|
||||||
|
Recipient string `json:"recipient"`
|
||||||
|
}
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/task"
|
||||||
|
)
|
||||||
|
|
||||||
type AppDatabase struct {
|
type AppDatabase struct {
|
||||||
ServiceName string `json:"PANEL_DB_HOST"`
|
ServiceName string `json:"PANEL_DB_HOST"`
|
||||||
DbName string `json:"PANEL_DB_NAME"`
|
DbName string `json:"PANEL_DB_NAME"`
|
||||||
DbUser string `json:"PANEL_DB_USER"`
|
DbUser string `json:"PANEL_DB_USER"`
|
||||||
Password string `json:"PANEL_DB_USER_PASSWORD"`
|
Password string `json:"PANEL_DB_USER_PASSWORD"`
|
||||||
|
DatabaseName string `json:"DATABASE_NAME"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthParam struct {
|
type AuthParam struct {
|
||||||
@@ -89,8 +96,11 @@ type AppProperty struct {
|
|||||||
Website string `json:"website"`
|
Website string `json:"website"`
|
||||||
Github string `json:"github"`
|
Github string `json:"github"`
|
||||||
Document string `json:"document"`
|
Document string `json:"document"`
|
||||||
Version float64 `json:"version"`
|
Architectures []string `json:"architectures"`
|
||||||
|
MemoryRequired int `json:"memoryRequired"`
|
||||||
GpuSupport bool `json:"gpuSupport"`
|
GpuSupport bool `json:"gpuSupport"`
|
||||||
|
Version float64 `json:"version"`
|
||||||
|
Deprecated float64 `json:"deprecated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppConfigVersion struct {
|
type AppConfigVersion struct {
|
||||||
@@ -117,6 +127,7 @@ type Locale struct {
|
|||||||
ZhHant string `json:"zh-hant" yaml:"zh-hant"`
|
ZhHant string `json:"zh-hant" yaml:"zh-hant"`
|
||||||
Zh string `json:"zh"`
|
Zh string `json:"zh"`
|
||||||
Ko string `json:"ko"`
|
Ko string `json:"ko"`
|
||||||
|
Tr string `json:"tr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppForm struct {
|
type AppForm struct {
|
||||||
@@ -125,19 +136,20 @@ type AppForm struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AppFormFields struct {
|
type AppFormFields struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
LabelZh string `json:"labelZh"`
|
LabelZh string `json:"labelZh"`
|
||||||
LabelEn string `json:"labelEn"`
|
LabelEn string `json:"labelEn"`
|
||||||
Label Locale `json:"label"`
|
Label Locale `json:"label"`
|
||||||
Required bool `json:"required"`
|
Description Locale `json:"description"`
|
||||||
Default interface{} `json:"default"`
|
Required bool `json:"required"`
|
||||||
EnvKey string `json:"envKey"`
|
Default interface{} `json:"default"`
|
||||||
Disabled bool `json:"disabled"`
|
EnvKey string `json:"envKey"`
|
||||||
Edit bool `json:"edit"`
|
Disabled bool `json:"disabled"`
|
||||||
Rule string `json:"rule"`
|
Edit bool `json:"edit"`
|
||||||
Multiple bool `json:"multiple"`
|
Rule string `json:"rule"`
|
||||||
Child interface{} `json:"child"`
|
Multiple bool `json:"multiple"`
|
||||||
Values []AppFormValue `json:"values"`
|
Child interface{} `json:"child"`
|
||||||
|
Values []AppFormValue `json:"values"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppFormValue struct {
|
type AppFormValue struct {
|
||||||
@@ -160,3 +172,16 @@ type AppInstallInfo struct {
|
|||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DelAppLink struct {
|
||||||
|
Ctx context.Context
|
||||||
|
Task *task.Task
|
||||||
|
Install *model.AppInstall
|
||||||
|
ForceDelete bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type PHPForm struct {
|
||||||
|
AdditionalProperties struct {
|
||||||
|
FormFields []interface{} `yaml:"formFields"`
|
||||||
|
} `yaml:"additionalProperties"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BackupOperate struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
IsPublic bool `json:"isPublic"`
|
||||||
|
Bucket string `json:"bucket"`
|
||||||
|
AccessKey string `json:"accessKey"`
|
||||||
|
Credential string `json:"credential"`
|
||||||
|
BackupPath string `json:"backupPath"`
|
||||||
|
Vars string `json:"vars" validate:"required"`
|
||||||
|
|
||||||
|
RememberAuth bool `json:"rememberAuth"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BackupInfo struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
IsPublic bool `json:"isPublic"`
|
||||||
|
Bucket string `json:"bucket"`
|
||||||
|
AccessKey string `json:"accessKey"`
|
||||||
|
Credential string `json:"credential"`
|
||||||
|
BackupPath string `json:"backupPath"`
|
||||||
|
Vars string `json:"vars"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
|
||||||
|
RememberAuth bool `json:"rememberAuth"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ForBuckets struct {
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
AccessKey string `json:"accessKey"`
|
||||||
|
Credential string `json:"credential" validate:"required"`
|
||||||
|
Vars string `json:"vars" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SyncFromMaster struct {
|
||||||
|
Name string `json:"name" validate:"required"`
|
||||||
|
Operation string `json:"operation" validate:"required,oneof=create delete update"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BackupOption struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
IsPublic bool `json:"isPublic"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CommonBackup struct {
|
||||||
|
Type string `json:"type" validate:"required,oneof=app mysql mariadb redis website postgresql mysql-cluster postgresql-cluster redis-cluster"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
DetailName string `json:"detailName"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
|
FileName string `json:"fileName"`
|
||||||
|
|
||||||
|
Description string `json:"description"`
|
||||||
|
}
|
||||||
|
type CommonRecover struct {
|
||||||
|
DownloadAccountID uint `json:"downloadAccountID" validate:"required"`
|
||||||
|
Type string `json:"type" validate:"required,oneof=app mysql mariadb redis website postgresql mysql-cluster postgresql-cluster redis-cluster"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
DetailName string `json:"detailName"`
|
||||||
|
File string `json:"file"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
|
BackupRecordID uint `json:"backupRecordID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RecordSearch struct {
|
||||||
|
PageInfo
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
DetailName string `json:"detailName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RecordSearchByCronjob struct {
|
||||||
|
PageInfo
|
||||||
|
CronjobID uint `json:"cronjobID" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BackupRecords struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
AccountType string `json:"accountType"`
|
||||||
|
AccountName string `json:"accountName"`
|
||||||
|
DownloadAccountID uint `json:"downloadAccountID"`
|
||||||
|
FileDir string `json:"fileDir"`
|
||||||
|
FileName string `json:"fileName"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DownloadRecord struct {
|
||||||
|
DownloadAccountID uint `json:"downloadAccountID" validate:"required"`
|
||||||
|
FileDir string `json:"fileDir" validate:"required"`
|
||||||
|
FileName string `json:"fileName" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchForSize struct {
|
||||||
|
PageInfo
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
DetailName string `json:"detailName"`
|
||||||
|
Info string `json:"info"`
|
||||||
|
CronjobID uint `json:"cronjobID"`
|
||||||
|
OrderBy string `json:"orderBy"`
|
||||||
|
Order string `json:"order"`
|
||||||
|
}
|
||||||
|
type RecordFileSize struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Size int64 `json:"size"`
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
type SearchClamWithPage struct {
|
type SearchClamWithPage struct {
|
||||||
PageInfo
|
PageInfo
|
||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
OrderBy string `json:"orderBy" validate:"required,oneof=name status created_at"`
|
OrderBy string `json:"orderBy" validate:"required,oneof=name status createdAt"`
|
||||||
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ type ClamInfo struct {
|
|||||||
Spec string `json:"spec"`
|
Spec string `json:"spec"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
AlertCount uint `json:"alertCount"`
|
AlertCount uint `json:"alertCount"`
|
||||||
|
AlertMethod string `json:"alertMethod"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClamLogSearch struct {
|
type ClamLogSearch struct {
|
||||||
@@ -74,6 +75,7 @@ type ClamCreate struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
AlertCount uint `json:"alertCount"`
|
AlertCount uint `json:"alertCount"`
|
||||||
AlertTitle string `json:"alertTitle"`
|
AlertTitle string `json:"alertTitle"`
|
||||||
|
AlertMethod string `json:"alertMethod"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClamUpdate struct {
|
type ClamUpdate struct {
|
||||||
@@ -87,6 +89,7 @@ type ClamUpdate struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
AlertCount uint `json:"alertCount"`
|
AlertCount uint `json:"alertCount"`
|
||||||
AlertTitle string `json:"alertTitle"`
|
AlertTitle string `json:"alertTitle"`
|
||||||
|
AlertMethod string `json:"alertMethod"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClamUpdateStatus struct {
|
type ClamUpdateStatus struct {
|
||||||
@@ -2,7 +2,7 @@ package dto
|
|||||||
|
|
||||||
type SearchCommandWithPage struct {
|
type SearchCommandWithPage struct {
|
||||||
PageInfo
|
PageInfo
|
||||||
OrderBy string `json:"orderBy" validate:"required,oneof=name command created_at"`
|
OrderBy string `json:"orderBy" validate:"required,oneof=name command createdAt"`
|
||||||
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
||||||
GroupID uint `json:"groupID"`
|
GroupID uint `json:"groupID"`
|
||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
@@ -5,6 +5,12 @@ type SearchWithPage struct {
|
|||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SearchPageWithType struct {
|
||||||
|
PageInfo
|
||||||
|
Info string `json:"info"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
type PageInfo struct {
|
type PageInfo struct {
|
||||||
Page int `json:"page" validate:"required,number"`
|
Page int `json:"page" validate:"required,number"`
|
||||||
PageSize int `json:"pageSize" validate:"required,number"`
|
PageSize int `json:"pageSize" validate:"required,number"`
|
||||||
@@ -22,11 +28,18 @@ type OperationWithName struct {
|
|||||||
type OperateByID struct {
|
type OperateByID struct {
|
||||||
ID uint `json:"id" validate:"required"`
|
ID uint `json:"id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
type OperateByIDs struct {
|
||||||
|
IDs []uint `json:"ids"`
|
||||||
|
}
|
||||||
|
|
||||||
type Operate struct {
|
type Operate struct {
|
||||||
Operation string `json:"operation" validate:"required"`
|
Operation string `json:"operation" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SearchByFilter struct {
|
||||||
|
Filter string `json:"filter"`
|
||||||
|
}
|
||||||
|
|
||||||
type BatchDeleteReq struct {
|
type BatchDeleteReq struct {
|
||||||
Ids []uint `json:"ids" validate:"required"`
|
Ids []uint `json:"ids" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -53,7 +66,21 @@ type OperationWithNameAndType struct {
|
|||||||
Type string `json:"type" validate:"required"`
|
Type string `json:"type" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UpdateGroup struct {
|
||||||
|
Group uint `json:"group"`
|
||||||
|
NewGroup uint `json:"newGroup"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OperateWithTask struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
|
}
|
||||||
|
|
||||||
type ForceDelete struct {
|
type ForceDelete struct {
|
||||||
IDs []uint `json:"ids"`
|
IDs []uint `json:"ids"`
|
||||||
ForceDelete bool `json:"forceDelete"`
|
ForceDelete bool `json:"forceDelete"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChangeGroup struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
GroupID uint `json:"groupID" validate:"required"`
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ type PageContainer struct {
|
|||||||
PageInfo
|
PageInfo
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
State string `json:"state" validate:"required,oneof=all created running paused restarting removing exited dead"`
|
State string `json:"state" validate:"required,oneof=all created running paused restarting removing exited dead"`
|
||||||
OrderBy string `json:"orderBy" validate:"required,oneof=name state created_at"`
|
OrderBy string `json:"orderBy" validate:"required,oneof=name createdAt state"`
|
||||||
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
||||||
Filters string `json:"filters"`
|
Filters string `json:"filters"`
|
||||||
ExcludeAppStore bool `json:"excludeAppStore"`
|
ExcludeAppStore bool `json:"excludeAppStore"`
|
||||||
@@ -39,23 +39,55 @@ type ContainerInfo struct {
|
|||||||
Websites []string `json:"websites"`
|
Websites []string `json:"websites"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ContainerOptions struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
State string `json:"state"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContainerStatus struct {
|
||||||
|
All uint `json:"all"`
|
||||||
|
Created uint `json:"created"`
|
||||||
|
Running uint `json:"running"`
|
||||||
|
Paused uint `json:"paused"`
|
||||||
|
Restarting uint `json:"restarting"`
|
||||||
|
Removing uint `json:"removing"`
|
||||||
|
Exited uint `json:"exited"`
|
||||||
|
Dead uint `json:"dead"`
|
||||||
|
|
||||||
|
ContainerCount int `json:"containerCount"`
|
||||||
|
ComposeCount int `json:"composeCount"`
|
||||||
|
ComposeTemplateCount int `json:"composeTemplateCount"`
|
||||||
|
ImageCount int `json:"imageCount"`
|
||||||
|
NetworkCount int `json:"networkCount"`
|
||||||
|
VolumeCount int `json:"volumeCount"`
|
||||||
|
RepoCount int `json:"repoCount"`
|
||||||
|
|
||||||
|
ImageSize uint64 `json:"imageSize"`
|
||||||
|
}
|
||||||
type ResourceLimit struct {
|
type ResourceLimit struct {
|
||||||
CPU int `json:"cpu"`
|
CPU int `json:"cpu"`
|
||||||
Memory uint64 `json:"memory"`
|
Memory uint64 `json:"memory"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerOperate struct {
|
type ContainerOperate struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
ContainerID string `json:"containerID"`
|
ContainerID string `json:"containerID"`
|
||||||
ForcePull bool `json:"forcePull"`
|
ForcePull bool `json:"forcePull"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Image string `json:"image" validate:"required"`
|
Image string `json:"image" validate:"required"`
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
DomainName string `json:"domainName"`
|
||||||
|
MacAddr string `json:"macAddr"`
|
||||||
|
DNS []string `json:"dns"`
|
||||||
Ipv4 string `json:"ipv4"`
|
Ipv4 string `json:"ipv4"`
|
||||||
Ipv6 string `json:"ipv6"`
|
Ipv6 string `json:"ipv6"`
|
||||||
PublishAllPorts bool `json:"publishAllPorts"`
|
PublishAllPorts bool `json:"publishAllPorts"`
|
||||||
ExposedPorts []PortHelper `json:"exposedPorts"`
|
ExposedPorts []PortHelper `json:"exposedPorts"`
|
||||||
Tty bool `json:"tty"`
|
Tty bool `json:"tty"`
|
||||||
OpenStdin bool `json:"openStdin"`
|
OpenStdin bool `json:"openStdin"`
|
||||||
|
WorkingDir string `json:"workingDir"`
|
||||||
|
User string `json:"user"`
|
||||||
Cmd []string `json:"cmd"`
|
Cmd []string `json:"cmd"`
|
||||||
Entrypoint []string `json:"entrypoint"`
|
Entrypoint []string `json:"entrypoint"`
|
||||||
CPUShares int64 `json:"cpuShares"`
|
CPUShares int64 `json:"cpuShares"`
|
||||||
@@ -69,7 +101,13 @@ type ContainerOperate struct {
|
|||||||
RestartPolicy string `json:"restartPolicy"`
|
RestartPolicy string `json:"restartPolicy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ContainerCreateByCommand struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
|
Command string `json:"command"`
|
||||||
|
}
|
||||||
|
|
||||||
type ContainerUpgrade struct {
|
type ContainerUpgrade struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Image string `json:"image" validate:"required"`
|
Image string `json:"image" validate:"required"`
|
||||||
ForcePull bool `json:"forcePull"`
|
ForcePull bool `json:"forcePull"`
|
||||||
@@ -131,18 +169,16 @@ type ContainerCommit struct {
|
|||||||
Comment string `json:"comment"`
|
Comment string `json:"comment"`
|
||||||
Author string `json:"author"`
|
Author string `json:"author"`
|
||||||
Pause bool `json:"pause"`
|
Pause bool `json:"pause"`
|
||||||
|
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerPrune struct {
|
type ContainerPrune struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
PruneType string `json:"pruneType" validate:"required,oneof=container image volume network buildcache"`
|
PruneType string `json:"pruneType" validate:"required,oneof=container image volume network buildcache"`
|
||||||
WithTagAll bool `json:"withTagAll"`
|
WithTagAll bool `json:"withTagAll"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerPruneReport struct {
|
|
||||||
DeletedNumber int `json:"deletedNumber"`
|
|
||||||
SpaceReclaimed int `json:"spaceReclaimed"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Network struct {
|
type Network struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@@ -187,8 +223,9 @@ type VolumeCreate struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BatchDelete struct {
|
type BatchDelete struct {
|
||||||
Force bool `json:"force"`
|
TaskID string `json:"taskID"`
|
||||||
Names []string `json:"names" validate:"required"`
|
Force bool `json:"force"`
|
||||||
|
Names []string `json:"names" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ComposeInfo struct {
|
type ComposeInfo struct {
|
||||||
@@ -209,6 +246,7 @@ type ComposeContainer struct {
|
|||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
}
|
}
|
||||||
type ComposeCreate struct {
|
type ComposeCreate struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
From string `json:"from" validate:"required,oneof=edit path template"`
|
From string `json:"from" validate:"required,oneof=edit path template"`
|
||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
@@ -235,3 +273,12 @@ type ContainerLog struct {
|
|||||||
Tail uint `json:"tail"`
|
Tail uint `json:"tail"`
|
||||||
ContainerType string `json:"containerType"`
|
ContainerType string `json:"containerType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StreamLog struct {
|
||||||
|
Compose string
|
||||||
|
Container string
|
||||||
|
Since string
|
||||||
|
Follow bool
|
||||||
|
Tail string
|
||||||
|
Type string
|
||||||
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PageCronjob struct {
|
||||||
|
PageInfo
|
||||||
|
Info string `json:"info"`
|
||||||
|
GroupIDs []uint `json:"groupIDs"`
|
||||||
|
OrderBy string `json:"orderBy" validate:"required,oneof=name status createdAt"`
|
||||||
|
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronjobSpec struct {
|
||||||
|
Spec string `json:"spec" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronjobOperate struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name" validate:"required"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
GroupID uint `json:"groupID"`
|
||||||
|
SpecCustom bool `json:"specCustom"`
|
||||||
|
Spec string `json:"spec" validate:"required"`
|
||||||
|
|
||||||
|
Executor string `json:"executor"`
|
||||||
|
ScriptMode string `json:"scriptMode"`
|
||||||
|
Script string `json:"script"`
|
||||||
|
Command string `json:"command"`
|
||||||
|
ContainerName string `json:"containerName"`
|
||||||
|
User string `json:"user"`
|
||||||
|
|
||||||
|
ScriptID uint `json:"scriptID"`
|
||||||
|
AppID string `json:"appID"`
|
||||||
|
Website string `json:"website"`
|
||||||
|
ExclusionRules string `json:"exclusionRules"`
|
||||||
|
DBType string `json:"dbType"`
|
||||||
|
DBName string `json:"dbName"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
IsDir bool `json:"isDir"`
|
||||||
|
SourceDir string `json:"sourceDir"`
|
||||||
|
SnapshotRule SnapshotRule `json:"snapshotRule"`
|
||||||
|
|
||||||
|
SourceAccountIDs string `json:"sourceAccountIDs"`
|
||||||
|
DownloadAccountID uint `json:"downloadAccountID"`
|
||||||
|
RetainCopies int `json:"retainCopies" validate:"number,min=1"`
|
||||||
|
RetryTimes int `json:"retryTimes" validate:"number,min=0"`
|
||||||
|
Timeout uint `json:"timeout" validate:"number,min=1"`
|
||||||
|
IgnoreErr bool `json:"ignoreErr"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
|
||||||
|
AlertCount uint `json:"alertCount"`
|
||||||
|
AlertTitle string `json:"alertTitle"`
|
||||||
|
AlertMethod string `json:"alertMethod"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SnapshotRule struct {
|
||||||
|
WithImage bool `json:"withImage"`
|
||||||
|
IgnoreAppIDs []uint `json:"ignoreAppIDs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronjobUpdateStatus struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
Status string `json:"status" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronjobDownload struct {
|
||||||
|
RecordID uint `json:"recordID" validate:"required"`
|
||||||
|
BackupAccountID uint `json:"backupAccountID" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronjobClean struct {
|
||||||
|
IsDelete bool `json:"isDelete"`
|
||||||
|
CleanData bool `json:"cleanData"`
|
||||||
|
CronjobID uint `json:"cronjobID" validate:"required"`
|
||||||
|
CleanRemoteData bool `json:"cleanRemoteData"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronjobBatchDelete struct {
|
||||||
|
CleanData bool `json:"cleanData"`
|
||||||
|
CleanRemoteData bool `json:"cleanRemoteData"`
|
||||||
|
IDs []uint `json:"ids" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronjobInfo struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
GroupID uint `json:"groupID"`
|
||||||
|
SpecCustom bool `json:"specCustom"`
|
||||||
|
Spec string `json:"spec"`
|
||||||
|
|
||||||
|
Executor string `json:"executor"`
|
||||||
|
ScriptMode string `json:"scriptMode"`
|
||||||
|
Script string `json:"script"`
|
||||||
|
Command string `json:"command"`
|
||||||
|
ContainerName string `json:"containerName"`
|
||||||
|
User string `json:"user"`
|
||||||
|
|
||||||
|
ScriptID uint `json:"scriptID"`
|
||||||
|
AppID string `json:"appID"`
|
||||||
|
Website string `json:"website"`
|
||||||
|
ExclusionRules string `json:"exclusionRules"`
|
||||||
|
DBType string `json:"dbType"`
|
||||||
|
DBName string `json:"dbName"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
IsDir bool `json:"isDir"`
|
||||||
|
SourceDir string `json:"sourceDir"`
|
||||||
|
RetainCopies int `json:"retainCopies"`
|
||||||
|
RetryTimes int `json:"retryTimes"`
|
||||||
|
Timeout uint `json:"timeout"`
|
||||||
|
IgnoreErr bool `json:"ignoreErr"`
|
||||||
|
SnapshotRule SnapshotRule `json:"snapshotRule"`
|
||||||
|
|
||||||
|
SourceAccounts []string `json:"sourceAccounts"`
|
||||||
|
DownloadAccount string `json:"downloadAccount"`
|
||||||
|
SourceAccountIDs string `json:"sourceAccountIDs"`
|
||||||
|
DownloadAccountID uint `json:"downloadAccountID"`
|
||||||
|
|
||||||
|
LastRecordStatus string `json:"lastRecordStatus"`
|
||||||
|
LastRecordTime string `json:"lastRecordTime"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
|
||||||
|
AlertCount uint `json:"alertCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronjobImport struct {
|
||||||
|
Cronjobs []CronjobTrans `json:"cronjobs"`
|
||||||
|
}
|
||||||
|
type CronjobTrans struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
GroupID uint `json:"groupID"`
|
||||||
|
SpecCustom bool `json:"specCustom"`
|
||||||
|
Spec string `json:"spec"`
|
||||||
|
|
||||||
|
Executor string `json:"executor"`
|
||||||
|
ScriptMode string `json:"scriptMode"`
|
||||||
|
Script string `json:"script"`
|
||||||
|
Command string `json:"command"`
|
||||||
|
ContainerName string `json:"containerName"`
|
||||||
|
User string `json:"user"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
|
||||||
|
ScriptName string `json:"scriptName"`
|
||||||
|
Apps []TransHelper `json:"apps"`
|
||||||
|
Websites []string `json:"websites"`
|
||||||
|
DBType string `json:"dbType"`
|
||||||
|
DBNames []TransHelper `json:"dbName"`
|
||||||
|
|
||||||
|
ExclusionRules string `json:"exclusionRules"`
|
||||||
|
|
||||||
|
IsDir bool `json:"isDir"`
|
||||||
|
SourceDir string `json:"sourceDir"`
|
||||||
|
|
||||||
|
RetainCopies uint64 `json:"retainCopies"`
|
||||||
|
RetryTimes uint `json:"retryTimes"`
|
||||||
|
Timeout uint `json:"timeout"`
|
||||||
|
IgnoreErr bool `json:"ignoreErr"`
|
||||||
|
SnapshotRule SnapshotTransHelper `json:"snapshotRule"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
|
||||||
|
SourceAccounts []string `json:"sourceAccounts"`
|
||||||
|
DownloadAccount string `json:"downloadAccount"`
|
||||||
|
|
||||||
|
AlertCount uint `json:"alertCount"`
|
||||||
|
AlertTitle string `json:"alertTitle"`
|
||||||
|
AlertMethod string `json:"alertMethod"`
|
||||||
|
}
|
||||||
|
type TransHelper struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
DetailName string `json:"detailName"`
|
||||||
|
}
|
||||||
|
type SnapshotTransHelper struct {
|
||||||
|
WithImage bool `json:"withImage"`
|
||||||
|
IgnoreApps []TransHelper `json:"ignoreApps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ScriptOptions struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SearchRecord struct {
|
||||||
|
PageInfo
|
||||||
|
CronjobID int `json:"cronjobID"`
|
||||||
|
StartTime time.Time `json:"startTime"`
|
||||||
|
EndTime time.Time `json:"endTime"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Record struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
|
StartTime string `json:"startTime"`
|
||||||
|
Records string `json:"records"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
TargetPath string `json:"targetPath"`
|
||||||
|
Interval int `json:"interval"`
|
||||||
|
File string `json:"file"`
|
||||||
|
}
|
||||||
@@ -16,11 +16,12 @@ type DashboardBase struct {
|
|||||||
KernelArch string `json:"kernelArch"`
|
KernelArch string `json:"kernelArch"`
|
||||||
KernelVersion string `json:"kernelVersion"`
|
KernelVersion string `json:"kernelVersion"`
|
||||||
VirtualizationSystem string `json:"virtualizationSystem"`
|
VirtualizationSystem string `json:"virtualizationSystem"`
|
||||||
IpV4Addr string `json:"ipv4Addr"`
|
IpV4Addr string `json:"ipV4Addr"`
|
||||||
SystemProxy string `json:"SystemProxy"`
|
SystemProxy string `json:"systemProxy"`
|
||||||
CPUCores int `json:"cpuCores"`
|
|
||||||
CPULogicalCores int `json:"cpuLogicalCores"`
|
CPUCores int `json:"cpuCores"`
|
||||||
CPUModelName string `json:"cpuModelName"`
|
CPULogicalCores int `json:"cpuLogicalCores"`
|
||||||
|
CPUModelName string `json:"cpuModelName"`
|
||||||
|
|
||||||
CurrentInfo DashboardCurrent `json:"currentInfo"`
|
CurrentInfo DashboardCurrent `json:"currentInfo"`
|
||||||
}
|
}
|
||||||
@@ -35,10 +36,25 @@ type OsInfo struct {
|
|||||||
DiskSize int64 `json:"diskSize"`
|
DiskSize int64 `json:"diskSize"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DashboardReq struct {
|
type NodeCurrent struct {
|
||||||
Scope string `json:"scope"`
|
Load1 float64 `json:"load1"`
|
||||||
IoOption string `json:"ioOption"`
|
Load5 float64 `json:"load5"`
|
||||||
NetOption string `json:"netOption"`
|
Load15 float64 `json:"load15"`
|
||||||
|
LoadUsagePercent float64 `json:"loadUsagePercent"`
|
||||||
|
|
||||||
|
CPUUsedPercent float64 `json:"cpuUsedPercent"`
|
||||||
|
CPUUsed float64 `json:"cpuUsed"`
|
||||||
|
CPUTotal int `json:"cpuTotal"`
|
||||||
|
|
||||||
|
MemoryTotal uint64 `json:"memoryTotal"`
|
||||||
|
MemoryAvailable uint64 `json:"memoryAvailable"`
|
||||||
|
MemoryUsed uint64 `json:"memoryUsed"`
|
||||||
|
MemoryUsedPercent float64 `json:"memoryUsedPercent"`
|
||||||
|
|
||||||
|
SwapMemoryTotal uint64 `json:"swapMemoryTotal"`
|
||||||
|
SwapMemoryAvailable uint64 `json:"swapMemoryAvailable"`
|
||||||
|
SwapMemoryUsed uint64 `json:"swapMemoryUsed"`
|
||||||
|
SwapMemoryUsedPercent float64 `json:"swapMemoryUsedPercent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DashboardCurrent struct {
|
type DashboardCurrent struct {
|
||||||
@@ -58,8 +74,11 @@ type DashboardCurrent struct {
|
|||||||
CPUTotal int `json:"cpuTotal"`
|
CPUTotal int `json:"cpuTotal"`
|
||||||
|
|
||||||
MemoryTotal uint64 `json:"memoryTotal"`
|
MemoryTotal uint64 `json:"memoryTotal"`
|
||||||
MemoryAvailable uint64 `json:"memoryAvailable"`
|
|
||||||
MemoryUsed uint64 `json:"memoryUsed"`
|
MemoryUsed uint64 `json:"memoryUsed"`
|
||||||
|
MemoryFree uint64 `json:"memoryFree"`
|
||||||
|
MemoryShard uint64 `json:"memoryShard"`
|
||||||
|
MemoryCache uint64 `json:"memoryCache"`
|
||||||
|
MemoryAvailable uint64 `json:"memoryAvailable"`
|
||||||
MemoryUsedPercent float64 `json:"memoryUsedPercent"`
|
MemoryUsedPercent float64 `json:"memoryUsedPercent"`
|
||||||
|
|
||||||
SwapMemoryTotal uint64 `json:"swapMemoryTotal"`
|
SwapMemoryTotal uint64 `json:"swapMemoryTotal"`
|
||||||
@@ -84,6 +103,10 @@ type DashboardCurrent struct {
|
|||||||
ShotTime time.Time `json:"shotTime"`
|
ShotTime time.Time `json:"shotTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AppLauncherSync struct {
|
||||||
|
Keys []string `json:"keys"`
|
||||||
|
}
|
||||||
|
|
||||||
type DiskInfo struct {
|
type DiskInfo struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
@@ -114,6 +137,37 @@ type GPUInfo struct {
|
|||||||
FanSpeed string `json:"fanSpeed"`
|
FanSpeed string `json:"fanSpeed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AppLauncher struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Icon string `json:"icon"`
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Recommend int `json:"recommend"`
|
||||||
|
|
||||||
|
IsInstall bool `json:"isInstall"`
|
||||||
|
IsRecommend bool `json:"isRecommend"`
|
||||||
|
Detail []InstallDetail `json:"detail"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type InstallDetail struct {
|
||||||
|
InstallID uint `json:"installID"`
|
||||||
|
DetailID uint `json:"detailID"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
Path string `json:"path"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
WebUI string `json:"webUI"`
|
||||||
|
HttpPort int `json:"httpPort"`
|
||||||
|
HttpsPort int `json:"httpsPort"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LauncherOption struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
IsShow bool `json:"isShow"`
|
||||||
|
}
|
||||||
|
|
||||||
type XPUInfo struct {
|
type XPUInfo struct {
|
||||||
DeviceID int `json:"deviceID"`
|
DeviceID int `json:"deviceID"`
|
||||||
DeviceName string `json:"deviceName"`
|
DeviceName string `json:"deviceName"`
|
||||||
@@ -4,14 +4,14 @@ import "time"
|
|||||||
|
|
||||||
// common
|
// common
|
||||||
type DBConfUpdateByFile struct {
|
type DBConfUpdateByFile struct {
|
||||||
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql redis"`
|
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql redis mysql-cluster postgresql-cluster redis-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
}
|
}
|
||||||
type ChangeDBInfo struct {
|
type ChangeDBInfo struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
From string `json:"from" validate:"required,oneof=local remote"`
|
From string `json:"from" validate:"required,oneof=local remote"`
|
||||||
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql"`
|
Type string `json:"type" validate:"required,oneof=mysql mariadb postgresql redis mysql-cluster postgresql-cluster redis-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
Value string `json:"value" validate:"required"`
|
Value string `json:"value" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ type MysqlDBSearch struct {
|
|||||||
PageInfo
|
PageInfo
|
||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
OrderBy string `json:"orderBy" validate:"required,oneof=name created_at"`
|
OrderBy string `json:"orderBy" validate:"required,oneof=name createdAt"`
|
||||||
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,19 +74,19 @@ type BindUser struct {
|
|||||||
|
|
||||||
type MysqlLoadDB struct {
|
type MysqlLoadDB struct {
|
||||||
From string `json:"from" validate:"required,oneof=local remote"`
|
From string `json:"from" validate:"required,oneof=local remote"`
|
||||||
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
|
Type string `json:"type" validate:"required,oneof=mysql mariadb mysql-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MysqlDBDeleteCheck struct {
|
type MysqlDBDeleteCheck struct {
|
||||||
ID uint `json:"id" validate:"required"`
|
ID uint `json:"id" validate:"required"`
|
||||||
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
|
Type string `json:"type" validate:"required,oneof=mysql mariadb mysql-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MysqlDBDelete struct {
|
type MysqlDBDelete struct {
|
||||||
ID uint `json:"id" validate:"required"`
|
ID uint `json:"id" validate:"required"`
|
||||||
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
|
Type string `json:"type" validate:"required,oneof=mysql mariadb mysql-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
ForceDelete bool `json:"forceDelete"`
|
ForceDelete bool `json:"forceDelete"`
|
||||||
DeleteBackup bool `json:"deleteBackup"`
|
DeleteBackup bool `json:"deleteBackup"`
|
||||||
@@ -153,7 +153,7 @@ type MysqlVariables struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MysqlVariablesUpdate struct {
|
type MysqlVariablesUpdate struct {
|
||||||
Type string `json:"type" validate:"required,oneof=mysql mariadb"`
|
Type string `json:"type" validate:"required,oneof=mysql mariadb mysql-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
Variables []MysqlVariablesUpdateHelper `json:"variables"`
|
Variables []MysqlVariablesUpdateHelper `json:"variables"`
|
||||||
}
|
}
|
||||||
@@ -174,6 +174,7 @@ type RedisConfUpdate struct {
|
|||||||
Timeout string `json:"timeout"`
|
Timeout string `json:"timeout"`
|
||||||
Maxclients string `json:"maxclients"`
|
Maxclients string `json:"maxclients"`
|
||||||
Maxmemory string `json:"maxmemory"`
|
Maxmemory string `json:"maxmemory"`
|
||||||
|
DBType string `json:"dbType" validate:"required,oneof=redis redis-cluster"`
|
||||||
}
|
}
|
||||||
type RedisConfPersistenceUpdate struct {
|
type RedisConfPersistenceUpdate struct {
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
@@ -181,6 +182,7 @@ type RedisConfPersistenceUpdate struct {
|
|||||||
Appendonly string `json:"appendonly"`
|
Appendonly string `json:"appendonly"`
|
||||||
Appendfsync string `json:"appendfsync"`
|
Appendfsync string `json:"appendfsync"`
|
||||||
Save string `json:"save"`
|
Save string `json:"save"`
|
||||||
|
DBType string `json:"dbType" validate:"required,oneof=redis redis-cluster"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedisConf struct {
|
type RedisConf struct {
|
||||||
@@ -236,7 +238,7 @@ type DatabaseSearch struct {
|
|||||||
PageInfo
|
PageInfo
|
||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
OrderBy string `json:"orderBy" validate:"required,oneof=name created_at"`
|
OrderBy string `json:"orderBy" validate:"required,oneof=name createdAt"`
|
||||||
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,6 +260,7 @@ type DatabaseInfo struct {
|
|||||||
ClientCert string `json:"clientCert"`
|
ClientCert string `json:"clientCert"`
|
||||||
SkipVerify bool `json:"skipVerify"`
|
SkipVerify bool `json:"skipVerify"`
|
||||||
|
|
||||||
|
Timeout uint `json:"timeout"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,6 +296,7 @@ type DatabaseCreate struct {
|
|||||||
ClientCert string `json:"clientCert"`
|
ClientCert string `json:"clientCert"`
|
||||||
SkipVerify bool `json:"skipVerify"`
|
SkipVerify bool `json:"skipVerify"`
|
||||||
|
|
||||||
|
Timeout uint `json:"timeout"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +315,7 @@ type DatabaseUpdate struct {
|
|||||||
ClientCert string `json:"clientCert"`
|
ClientCert string `json:"clientCert"`
|
||||||
SkipVerify bool `json:"skipVerify"`
|
SkipVerify bool `json:"skipVerify"`
|
||||||
|
|
||||||
|
Timeout uint `json:"timeout"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,3 +324,8 @@ type DatabaseDelete struct {
|
|||||||
ForceDelete bool `json:"forceDelete"`
|
ForceDelete bool `json:"forceDelete"`
|
||||||
DeleteBackup bool `json:"deleteBackup"`
|
DeleteBackup bool `json:"deleteBackup"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LoadRedisStatus struct {
|
||||||
|
Name string `json:"name" validate:"required"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ type PostgresqlDBSearch struct {
|
|||||||
PageInfo
|
PageInfo
|
||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
OrderBy string `json:"orderBy" validate:"required,oneof=name created_at"`
|
OrderBy string `json:"orderBy" validate:"required,oneof=name createdAt"`
|
||||||
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
Order string `json:"order" validate:"required,oneof=null ascending descending"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,26 +60,20 @@ type PostgresqlPrivileges struct {
|
|||||||
|
|
||||||
type PostgresqlLoadDB struct {
|
type PostgresqlLoadDB struct {
|
||||||
From string `json:"from" validate:"required,oneof=local remote"`
|
From string `json:"from" validate:"required,oneof=local remote"`
|
||||||
Type string `json:"type" validate:"required,oneof=postgresql"`
|
Type string `json:"type" validate:"required,oneof=postgresql postgresql-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostgresqlDBDeleteCheck struct {
|
type PostgresqlDBDeleteCheck struct {
|
||||||
ID uint `json:"id" validate:"required"`
|
ID uint `json:"id" validate:"required"`
|
||||||
Type string `json:"type" validate:"required,oneof=postgresql"`
|
Type string `json:"type" validate:"required,oneof=postgresql postgresql-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostgresqlDBDelete struct {
|
type PostgresqlDBDelete struct {
|
||||||
ID uint `json:"id" validate:"required"`
|
ID uint `json:"id" validate:"required"`
|
||||||
Type string `json:"type" validate:"required,oneof=postgresql"`
|
Type string `json:"type" validate:"required,oneof=postgresql postgresql-cluster"`
|
||||||
Database string `json:"database" validate:"required"`
|
Database string `json:"database" validate:"required"`
|
||||||
ForceDelete bool `json:"forceDelete"`
|
ForceDelete bool `json:"forceDelete"`
|
||||||
DeleteBackup bool `json:"deleteBackup"`
|
DeleteBackup bool `json:"deleteBackup"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostgresqlConfUpdateByFile struct {
|
|
||||||
Type string `json:"type" validate:"required,oneof=postgresql mariadb"`
|
|
||||||
Database string `json:"database" validate:"required"`
|
|
||||||
File string `json:"file"`
|
|
||||||
}
|
|
||||||
@@ -4,9 +4,13 @@ type DaemonJsonUpdateByFile struct {
|
|||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DockerStatus struct {
|
||||||
|
IsActive bool `json:"isActive"`
|
||||||
|
IsExist bool `json:"isExist"`
|
||||||
|
}
|
||||||
|
|
||||||
type DaemonJsonConf struct {
|
type DaemonJsonConf struct {
|
||||||
IsSwarm bool `json:"isSwarm"`
|
IsSwarm bool `json:"isSwarm"`
|
||||||
Status string `json:"status"`
|
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Mirrors []string `json:"registryMirrors"`
|
Mirrors []string `json:"registryMirrors"`
|
||||||
Registries []string `json:"insecureRegistries"`
|
Registries []string `json:"insecureRegistries"`
|
||||||
@@ -19,7 +19,7 @@ type Fail2BanSearch struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Fail2BanUpdate struct {
|
type Fail2BanUpdate struct {
|
||||||
Key string `json:"key" validate:"required,oneof=port bantime findtime maxretry banaction logpath"`
|
Key string `json:"key" validate:"required,oneof=port bantime findtime maxretry banaction logpath port"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,7 +2,8 @@ package dto
|
|||||||
|
|
||||||
type FirewallBaseInfo struct {
|
type FirewallBaseInfo struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Status string `json:"status"`
|
IsExist bool `json:"isExist"`
|
||||||
|
IsActive bool `json:"isActive"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
PingStatus string `json:"pingStatus"`
|
PingStatus string `json:"pingStatus"`
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
type GroupCreate struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name" validate:"required"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupSearch struct {
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupUpdate struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type" validate:"required"`
|
||||||
|
IsDefault bool `json:"isDefault"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupInfo struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
IsDefault bool `json:"isDefault"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OperateByType struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ type ImageLoad struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ImageBuild struct {
|
type ImageBuild struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
From string `json:"from" validate:"required"`
|
From string `json:"from" validate:"required"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Dockerfile string `json:"dockerfile" validate:"required"`
|
Dockerfile string `json:"dockerfile" validate:"required"`
|
||||||
@@ -22,6 +23,7 @@ type ImageBuild struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ImagePull struct {
|
type ImagePull struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
RepoID uint `json:"repoID"`
|
RepoID uint `json:"repoID"`
|
||||||
ImageName string `json:"imageName" validate:"required"`
|
ImageName string `json:"imageName" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -32,6 +34,7 @@ type ImageTag struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ImagePush struct {
|
type ImagePush struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
RepoID uint `json:"repoID" validate:"required"`
|
RepoID uint `json:"repoID" validate:"required"`
|
||||||
TagName string `json:"tagName" validate:"required"`
|
TagName string `json:"tagName" validate:"required"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SearchTaskLogReq struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
PageInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type TaskDTO struct {
|
||||||
|
model.Task
|
||||||
|
}
|
||||||
@@ -14,3 +14,15 @@ type MonitorData struct {
|
|||||||
Date []time.Time `json:"date"`
|
Date []time.Time `json:"date"`
|
||||||
Value []interface{} `json:"value"`
|
Value []interface{} `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MonitorSetting struct {
|
||||||
|
MonitorStatus string `json:"monitorStatus"`
|
||||||
|
MonitorStoreDays string `json:"monitorStoreDays"`
|
||||||
|
MonitorInterval string `json:"monitorInterval"`
|
||||||
|
DefaultNetwork string `json:"defaultNetwork"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MonitorSettingUpdate struct {
|
||||||
|
Key string `json:"key" validate:"required,oneof=MonitorStatus MonitorStoreDays MonitorInterval DefaultNetwork"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/nginx/components"
|
"github.com/1Panel-dev/1Panel/agent/utils/nginx/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NginxFull struct {
|
type NginxFull struct {
|
||||||
@@ -33,6 +33,13 @@ type NginxAuth struct {
|
|||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NginxPathAuth struct {
|
||||||
|
Username string `json:"username"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
Path string `json:"path"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
type NginxKey string
|
type NginxKey string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -57,3 +64,31 @@ var StaticFileKeyMap = map[NginxKey]struct {
|
|||||||
CACHE: {},
|
CACHE: {},
|
||||||
ProxyCache: {},
|
ProxyCache: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NginxUpstream struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Algorithm string `json:"algorithm"`
|
||||||
|
Servers []NginxUpstreamServer `json:"servers"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NginxUpstreamServer struct {
|
||||||
|
Server string `json:"server"`
|
||||||
|
Weight int `json:"weight"`
|
||||||
|
FailTimeout string `json:"failTimeout"`
|
||||||
|
MaxFails int `json:"maxFails"`
|
||||||
|
MaxConns int `json:"maxConns"`
|
||||||
|
Flag string `json:"flag"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var LBAlgorithms = map[string]struct{}{"ip_hash": {}, "least_conn": {}}
|
||||||
|
|
||||||
|
var RealIPKeys = map[string]struct{}{"X-Forwarded-For": {}, "X-Real-IP": {}, "CF-Connecting-IP": {}}
|
||||||
|
|
||||||
|
type NginxModule struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Script string `json:"script"`
|
||||||
|
Packages []string `json:"packages"`
|
||||||
|
Params string `json:"params"`
|
||||||
|
Enable bool `json:"enable"`
|
||||||
|
}
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
package request
|
package request
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AppSearch struct {
|
type AppSearch struct {
|
||||||
dto.PageInfo
|
dto.PageInfo
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Recommend bool `json:"recommend"`
|
Recommend bool `json:"recommend"`
|
||||||
Resource string `json:"resource"`
|
Resource string `json:"resource"`
|
||||||
|
ShowCurrentArch bool `json:"showCurrentArch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppInstallCreate struct {
|
type AppInstallCreate struct {
|
||||||
@@ -19,6 +21,7 @@ type AppInstallCreate struct {
|
|||||||
Params map[string]interface{} `json:"params"`
|
Params map[string]interface{} `json:"params"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Services map[string]string `json:"services"`
|
Services map[string]string `json:"services"`
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
AppContainerConfig
|
AppContainerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +37,9 @@ type AppContainerConfig struct {
|
|||||||
HostMode bool `json:"hostMode"`
|
HostMode bool `json:"hostMode"`
|
||||||
PullImage bool `json:"pullImage"`
|
PullImage bool `json:"pullImage"`
|
||||||
GpuConfig bool `json:"gpuConfig"`
|
GpuConfig bool `json:"gpuConfig"`
|
||||||
|
WebUI string `json:"webUI"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
SpecifyIP string `json:"specifyIP"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppInstalledSearch struct {
|
type AppInstalledSearch struct {
|
||||||
@@ -72,6 +78,9 @@ type AppInstalledOperate struct {
|
|||||||
Backup bool `json:"backup"`
|
Backup bool `json:"backup"`
|
||||||
PullImage bool `json:"pullImage"`
|
PullImage bool `json:"pullImage"`
|
||||||
DockerCompose string `json:"dockerCompose"`
|
DockerCompose string `json:"dockerCompose"`
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
|
DeleteImage bool `json:"deleteImage"`
|
||||||
|
Favorite bool `json:"favorite"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppInstallUpgrade struct {
|
type AppInstallUpgrade struct {
|
||||||
@@ -80,6 +89,16 @@ type AppInstallUpgrade struct {
|
|||||||
Backup bool `json:"backup"`
|
Backup bool `json:"backup"`
|
||||||
PullImage bool `json:"pullImage"`
|
PullImage bool `json:"pullImage"`
|
||||||
DockerCompose string `json:"dockerCompose"`
|
DockerCompose string `json:"dockerCompose"`
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AppInstallDelete struct {
|
||||||
|
Install model.AppInstall
|
||||||
|
DeleteBackup bool `json:"deleteBackup"`
|
||||||
|
ForceDelete bool `json:"forceDelete"`
|
||||||
|
DeleteDB bool `json:"deleteDB"`
|
||||||
|
DeleteImage bool `json:"deleteImage"`
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppInstalledUpdate struct {
|
type AppInstalledUpdate struct {
|
||||||
@@ -88,6 +107,11 @@ type AppInstalledUpdate struct {
|
|||||||
AppContainerConfig
|
AppContainerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AppConfigUpdate struct {
|
||||||
|
InstallID uint `json:"installID" validate:"required"`
|
||||||
|
WebUI string `json:"webUI"`
|
||||||
|
}
|
||||||
|
|
||||||
type AppInstalledIgnoreUpgrade struct {
|
type AppInstalledIgnoreUpgrade struct {
|
||||||
DetailID uint `json:"detailID" validate:"required"`
|
DetailID uint `json:"detailID" validate:"required"`
|
||||||
Operate string `json:"operate" validate:"required,oneof=cancel ignore"`
|
Operate string `json:"operate" validate:"required,oneof=cancel ignore"`
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
type AppIgnoreUpgradeReq struct {
|
||||||
|
AppID uint `json:"appID" validate:"required"`
|
||||||
|
AppDetailID uint `json:"appDetailID"`
|
||||||
|
Scope string `json:"scope" validate:"required,oneof=all version"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package request
|
||||||
|
|
||||||
|
type ReqWithID struct {
|
||||||
|
ID uint `json:"id" validate:"required"`
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package request
|
package request
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
"github.com/1Panel-dev/1Panel/agent/utils/files"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileOption struct {
|
type FileOption struct {
|
||||||
@@ -134,6 +134,14 @@ type FileReadByLineReq struct {
|
|||||||
ID uint `json:"ID"`
|
ID uint `json:"ID"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Latest bool `json:"latest"`
|
Latest bool `json:"latest"`
|
||||||
|
TaskReq
|
||||||
|
}
|
||||||
|
|
||||||
|
type TaskReq struct {
|
||||||
|
TaskID string `json:"taskID"`
|
||||||
|
TaskType string `json:"taskType"`
|
||||||
|
TaskOperate string `json:"taskOperate"`
|
||||||
|
ResourceID uint `json:"resourceID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileExistReq struct {
|
type FileExistReq struct {
|
||||||
@@ -26,13 +26,16 @@ type HostToolConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SupervisorProcessConfig struct {
|
type SupervisorProcessConfig struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Operate string `json:"operate"`
|
Operate string `json:"operate"`
|
||||||
Command string `json:"command"`
|
Command string `json:"command"`
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
Dir string `json:"dir"`
|
Dir string `json:"dir"`
|
||||||
Numprocs string `json:"numprocs"`
|
Numprocs string `json:"numprocs"`
|
||||||
|
AutoRestart string `json:"autoRestart"`
|
||||||
|
AutoStart string `json:"autoStart"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SupervisorProcessFileReq struct {
|
type SupervisorProcessFileReq struct {
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Operate string `json:"operate" validate:"required,oneof=get clear update" `
|
Operate string `json:"operate" validate:"required,oneof=get clear update" `
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package request
|
package request
|
||||||
|
|
||||||
import "github.com/1Panel-dev/1Panel/backend/app/dto"
|
import "github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
|
||||||
type McpServerSearch struct {
|
type McpServerSearch struct {
|
||||||
dto.PageInfo
|
dto.PageInfo
|
||||||
@@ -9,15 +9,17 @@ type McpServerSearch struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type McpServerCreate struct {
|
type McpServerCreate struct {
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Command string `json:"command" validate:"required"`
|
Command string `json:"command" validate:"required"`
|
||||||
Environments []Environment `json:"environments"`
|
Environments []Environment `json:"environments"`
|
||||||
Volumes []Volume `json:"volumes"`
|
Volumes []Volume `json:"volumes"`
|
||||||
Port int `json:"port" validate:"required"`
|
Port int `json:"port" validate:"required"`
|
||||||
ContainerName string `json:"containerName"`
|
ContainerName string `json:"containerName"`
|
||||||
BaseURL string `json:"baseUrl"`
|
BaseURL string `json:"baseUrl"`
|
||||||
SsePath string `json:"ssePath"`
|
SsePath string `json:"ssePath"`
|
||||||
HostIP string `json:"hostIP"`
|
HostIP string `json:"hostIP"`
|
||||||
|
StreamableHttpPath string `json:"streamableHttpPath"`
|
||||||
|
OutputTransport string `json:"outputTransport" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type McpServerUpdate struct {
|
type McpServerUpdate struct {
|
||||||
@@ -25,16 +27,6 @@ type McpServerUpdate struct {
|
|||||||
McpServerCreate
|
McpServerCreate
|
||||||
}
|
}
|
||||||
|
|
||||||
type Environment struct {
|
|
||||||
Key string `json:"key"`
|
|
||||||
Value string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Volume struct {
|
|
||||||
Source string `json:"source"`
|
|
||||||
Target string `json:"target"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type McpServerDelete struct {
|
type McpServerDelete struct {
|
||||||
ID uint `json:"id" validate:"required"`
|
ID uint `json:"id" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package request
|
package request
|
||||||
|
|
||||||
import "github.com/1Panel-dev/1Panel/backend/app/dto"
|
import "github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
|
||||||
type NginxConfigFileUpdate struct {
|
type NginxConfigFileUpdate struct {
|
||||||
Content string `json:"content" validate:"required"`
|
Content string `json:"content" validate:"required"`
|
||||||
@@ -24,6 +24,12 @@ type NginxRewriteReq struct {
|
|||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CustomRewriteOperate struct {
|
||||||
|
Operate string `json:"operate" validate:"required,oneof=create delete"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
type NginxRewriteUpdate struct {
|
type NginxRewriteUpdate struct {
|
||||||
WebsiteID uint `json:"websiteId" validate:"required"`
|
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
@@ -36,6 +42,17 @@ type NginxProxyUpdate struct {
|
|||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NginxProxyCacheUpdate struct {
|
||||||
|
WebsiteID uint `json:"websiteID" validate:"required"`
|
||||||
|
Open bool `json:"open"`
|
||||||
|
CacheLimit int `json:"cacheLimit" validate:"required"`
|
||||||
|
CacheLimitUnit string `json:"cacheLimitUnit" validate:"required"`
|
||||||
|
ShareCache int `json:"shareCache" validate:"required"`
|
||||||
|
ShareCacheUnit string `json:"shareCacheUnit" validate:"required"`
|
||||||
|
CacheExpire int `json:"cacheExpire" validate:"required"`
|
||||||
|
CacheExpireUnit string `json:"cacheExpireUnit" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
type NginxAuthUpdate struct {
|
type NginxAuthUpdate struct {
|
||||||
WebsiteID uint `json:"websiteID" validate:"required"`
|
WebsiteID uint `json:"websiteID" validate:"required"`
|
||||||
Operate string `json:"operate" validate:"required"`
|
Operate string `json:"operate" validate:"required"`
|
||||||
@@ -44,6 +61,16 @@ type NginxAuthUpdate struct {
|
|||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NginxPathAuthUpdate struct {
|
||||||
|
WebsiteID uint `json:"websiteID" validate:"required"`
|
||||||
|
Operate string `json:"operate" validate:"required"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Path string `json:"path"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
}
|
||||||
|
|
||||||
type NginxAuthReq struct {
|
type NginxAuthReq struct {
|
||||||
WebsiteID uint `json:"websiteID" validate:"required"`
|
WebsiteID uint `json:"websiteID" validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -85,3 +112,21 @@ type NginxRedirectUpdate struct {
|
|||||||
Content string `json:"content" validate:"required"`
|
Content string `json:"content" validate:"required"`
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NginxBuildReq struct {
|
||||||
|
TaskID string `json:"taskID" validate:"required"`
|
||||||
|
Mirror string `json:"mirror" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NginxModuleUpdate struct {
|
||||||
|
Operate string `json:"operate" validate:"required,oneof=create delete update"`
|
||||||
|
Name string `json:"name" validate:"required"`
|
||||||
|
Script string `json:"script"`
|
||||||
|
Packages string `json:"packages"`
|
||||||
|
Enable bool `json:"enable"`
|
||||||
|
Params string `json:"params"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NginxOperateReq struct {
|
||||||
|
Operate string `json:"operate" validate:"required,oneof=enable disable"`
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package request
|
package request
|
||||||
|
|
||||||
import "github.com/1Panel-dev/1Panel/backend/app/dto"
|
import "github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
|
|
||||||
type PHPExtensionsSearch struct {
|
type PHPExtensionsSearch struct {
|
||||||
dto.PageInfo
|
dto.PageInfo
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user