Compare commits

...

125 Commits

Author SHA1 Message Date
Dot.L b1b9f49b06 Merge pull request #329 from APIParkLab/feature/liujian-1.8
Fix the issue of failed compilation of ARM images
2025-06-26 20:05:03 +08:00
Liujian 8f2857cf55 Fix the issue of failed compilation of ARM images 2025-06-26 20:03:48 +08:00
Dot.L f149fede71 Merge pull request #328 from APIParkLab/feature/liujian-1.8
Fix the issue of failed compilation of ARM images
2025-06-26 18:27:45 +08:00
Liujian 972f072346 Fix the issue of failed compilation of ARM images 2025-06-26 18:24:06 +08:00
Dot.L 3cab3c1828 Merge pull request #326 from APIParkLab/feature/liujian-1.8
Fix a series of bug
2025-06-26 17:07:59 +08:00
Liujian 88bf7d0244 1. Fix the issue of ineffective interception of routing settings
2. The problem of long loading times for optimizing service lists and API portals
2025-06-26 17:06:03 +08:00
Dot.L a7523c7b54 Merge pull request #322 from APIParkLab/feature/liujian-1.8
fix: The problem of slow retrieval of service lists and API portal se…
2025-06-19 17:02:14 +08:00
Liujian 590f328e07 fix: The problem of slow retrieval of service lists and API portal service lists 2025-06-19 17:00:51 +08:00
Dot.L ca2682fb22 Merge pull request #311 from APIParkLab/feature/liujian-1.8
update docker run.sh
2025-05-26 19:33:51 +08:00
Liujian 2bd1d4a423 update docker run.sh 2025-05-26 19:32:10 +08:00
Dot.L b2baa711c2 Merge pull request #309 from APIParkLab/feature/1.8-cx
chore: Add annotations
2025-05-23 18:31:33 +08:00
ningyv 3d51f96dda chore: Add annotations 2025-05-23 18:29:58 +08:00
Dot.L b55675e5a5 Merge pull request #308 from APIParkLab/feature/liujian-1.8
Feature/liujian 1.8
2025-05-23 18:24:32 +08:00
Liujian 9a33992a0b Merge remote-tracking branch 'github-pro/main' into feature/liujian-1.8
# Conflicts:
#	.gitlab-ci.yml
2025-05-23 18:23:52 +08:00
Liujian 07ae37eb5f update gitlab-ci.yml 2025-05-23 18:21:50 +08:00
Liujian c36726f25f update gitlab-ci.yml 2025-05-23 17:45:57 +08:00
Liujian e2e9abeb4c update gitlab-ci.yml 2025-05-23 16:19:28 +08:00
Liujian 0fcc2215f7 Merge remote-tracking branch 'origin/main' into main-github-pro 2025-05-23 15:42:51 +08:00
刘健 ce559c4643 Update .gitlab-ci.yml file 2025-05-23 15:30:54 +08:00
刘健 8d4b13f633 Update .gitlab-ci.yml file 2025-05-23 15:30:13 +08:00
Liujian 19a3378fa3 Merge branch 'main' into main-github-pro 2025-05-23 15:16:29 +08:00
Liujian cef1250199 Merge tag 'v1.8.0-beta' 2025-05-23 15:16:02 +08:00
刘健 3c85658931 Update .gitlab-ci.yml file 2025-05-23 15:05:39 +08:00
刘健 ba7022bc2d Update .gitlab-ci.yml file 2025-05-23 15:02:52 +08:00
刘健 fb24abc111 Update .gitlab-ci.yml file 2025-05-23 15:02:23 +08:00
刘健 0e3fb84e7c Update .gitlab-ci.yml file 2025-05-23 15:01:47 +08:00
刘健 5d6d949ca4 Update .gitlab-ci.yml file 2025-05-23 15:00:44 +08:00
刘健 3578182343 Update .gitlab-ci.yml file 2025-05-23 14:32:11 +08:00
刘健 28bad2d963 Update .gitlab-ci.yml file 2025-05-23 14:31:31 +08:00
刘健 384bd239fa Update .gitlab-ci.yml file 2025-05-23 14:21:58 +08:00
刘健 98710ad296 Update .gitlab-ci.yml file 2025-05-23 14:12:49 +08:00
刘健 4806e12907 Update .gitlab-ci.yml file 2025-05-23 14:12:09 +08:00
刘健 9097760a0f Update .gitlab-ci.yml file 2025-05-23 14:10:08 +08:00
刘健 a5639bff60 Update .gitlab-ci.yml file 2025-05-23 14:01:10 +08:00
刘健 1d66ed84f3 Update .gitlab-ci.yml file 2025-05-23 13:55:45 +08:00
刘健 249ac3ea1c Update .gitlab-ci.yml file 2025-05-23 13:55:22 +08:00
刘健 b02db8020d Update .gitlab-ci.yml file 2025-05-23 13:55:03 +08:00
刘健 4105540686 Update .gitlab-ci.yml file 2025-05-23 13:54:37 +08:00
刘健 36d10c5cfd Update .gitlab-ci.yml file 2025-05-23 13:54:17 +08:00
lichunxian 5efd19ef7c Merge branch 'feature/1.8-cx' into 'main'
feat: feature/1.8-Improve system observability

See merge request apipark/APIPark!377
2025-05-06 17:58:28 +08:00
lichunxian 28cd4fd91c Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!376
2025-05-06 16:06:16 +08:00
刘健 82f4089f42 Merge branch 'feature/liujian-1.8' into 'main'
update build.sh

See merge request apipark/APIPark!375
2025-05-06 16:02:17 +08:00
刘健 cd33448446 Merge branch 'feature/liujian-1.8' into 'main'
fix bug

See merge request apipark/APIPark!373
2025-05-06 15:31:23 +08:00
lichunxian e5b50a7073 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!374
2025-05-06 14:41:00 +08:00
刘健 10bd352bf4 Merge branch 'feature/liujian-1.8' into 'main'
update data

See merge request apipark/APIPark!372
2025-05-06 14:12:01 +08:00
刘健 e5c6e4fa82 Merge branch 'feature/liujian-1.8' into 'main'
Feature/liujian 1.8

See merge request apipark/APIPark!371
2025-05-06 12:04:47 +08:00
lichunxian 1572e03dd1 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!370
2025-05-06 11:09:42 +08:00
刘健 61025763ed Merge branch 'feature/liujian-1.8' into 'main'
Feature/liujian 1.8

See merge request apipark/APIPark!369
2025-05-06 10:49:33 +08:00
lichunxian 00905e4167 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!368
2025-04-30 19:09:44 +08:00
lichunxian a5a895e42d Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!367
2025-04-30 17:18:00 +08:00
lichunxian ed1d19532b Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!366
2025-04-30 16:33:49 +08:00
刘健 bf990517dc Merge branch 'feature/liujian-1.8' into 'main'
update service logs

See merge request apipark/APIPark!365
2025-04-30 15:53:11 +08:00
lichunxian 83873c8c92 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!364
2025-04-30 15:49:50 +08:00
刘健 a61e6ba67f Merge branch 'feature/liujian-1.8' into 'main'
Optimize chart data

See merge request apipark/APIPark!363
2025-04-30 15:06:24 +08:00
刘健 e081580786 Merge branch 'feature/liujian-1.8' into 'main'
fix:ai token monitor bug

See merge request apipark/APIPark!362
2025-04-30 14:00:22 +08:00
lichunxian 813905ca40 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!361
2025-04-30 10:25:41 +08:00
lichunxian 66be761d18 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!360
2025-04-30 09:46:26 +08:00
lichunxian 6b6fa5bd40 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!359
2025-04-30 09:30:12 +08:00
lichunxian 943ef4f9b0 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!358
2025-04-30 09:20:32 +08:00
lichunxian 78d9a1c23c Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!357
2025-04-30 09:09:26 +08:00
刘健 342d022c43 Merge branch 'feature/liujian-1.8' into 'main'
Feature/liujian 1.8

See merge request apipark/APIPark!356
2025-04-30 00:24:33 +08:00
lichunxian a8c14ee839 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!355
2025-04-29 19:40:30 +08:00
lichunxian 23c40efe0d Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!354
2025-04-29 19:33:43 +08:00
lichunxian a76941ea17 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!353
2025-04-29 19:28:59 +08:00
刘健 0c392d2092 Merge branch 'feature/liujian-1.8' into 'main'
Log information returns the newly added Body

See merge request apipark/APIPark!352
2025-04-29 19:28:04 +08:00
刘健 46caf49f18 Merge branch 'feature/liujian-1.8' into 'main'
fix bug

See merge request apipark/APIPark!351
2025-04-29 19:16:54 +08:00
刘健 74c87ec308 Merge branch 'feature/liujian-1.8' into 'main'
finish service log module

See merge request apipark/APIPark!350
2025-04-29 19:08:43 +08:00
lichunxian 8b318caa0b Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!349
2025-04-29 19:06:52 +08:00
lichunxian 6bad1c3c7c Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!348
2025-04-29 18:24:17 +08:00
刘健 1333d4ed02 Merge branch 'feature/liujian-1.8' into 'main'
finish log list

See merge request apipark/APIPark!347
2025-04-29 17:49:59 +08:00
lichunxian d3e91b04a2 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!346
2025-04-29 17:33:16 +08:00
lichunxian f4400c0130 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!345
2025-04-29 17:27:37 +08:00
lichunxian cc5d677d67 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!344
2025-04-29 11:52:46 +08:00
刘健 e4c3cbc99b Merge branch 'feature/liujian-1.8' into 'main'
update service overview

See merge request apipark/APIPark!343
2025-04-29 10:20:17 +08:00
刘健 5c1db00d7e Merge branch 'feature/liujian-1.8' into 'main'
Feature/liujian 1.8

See merge request apipark/APIPark!342
2025-04-29 00:35:41 +08:00
lichunxian cd91f4bdb9 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!341
2025-04-27 17:44:31 +08:00
lichunxian 79860bc665 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!340
2025-04-27 14:55:12 +08:00
lichunxian 4623ba6fba Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!339
2025-04-27 14:50:59 +08:00
lichunxian 1f4acdc99e Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!338
2025-04-27 14:31:19 +08:00
lichunxian 0307282dbd Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!337
2025-04-27 14:15:29 +08:00
lichunxian 7dbc2a1a78 Merge branch 'feature/1.8-cx' into 'main'
feature/1.8-Improve system observability

See merge request apipark/APIPark!336
2025-04-27 10:53:53 +08:00
lichunxian 12d42c4247 Merge branch 'feature/1.8-cx' into 'main'
Feature/1.8 cx

See merge request apipark/APIPark!335
2025-04-27 10:45:08 +08:00
lichunxian 4eb3368875 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP-analytics-table-optimize

See merge request apipark/APIPark!334
2025-04-16 15:47:13 +08:00
刘健 4478e6823a Merge branch 'feature/1.7-liujian' into 'main'
Fix: Dragging to modify the order of service categories will fail when there...

See merge request apipark/APIPark!333
2025-04-16 15:21:28 +08:00
lichunxian ab5bffea87 Merge branch 'feature/1.7-cxx' into 'main'
Feature/1.7 cxx

See merge request apipark/APIPark!332
2025-04-16 14:36:37 +08:00
刘健 8a48828a76 Merge branch 'feature/1.7-liujian' into 'main'
Fix: Issue of API duplicate publishing when publishing services

See merge request apipark/APIPark!331
2025-04-16 14:34:39 +08:00
刘健 c2b70e23e4 Merge branch 'feature/1.7-liujian' into 'main'
update

See merge request apipark/APIPark!330
2025-04-16 14:12:52 +08:00
lichunxian eb46a4365c Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!329
2025-04-16 14:07:50 +08:00
lichunxian 058a8f7974 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!328
2025-04-16 13:48:41 +08:00
lichunxian b5585f548a Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!327
2025-04-16 13:45:08 +08:00
lichunxian e4a3e1a1a2 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!326
2025-04-16 11:54:13 +08:00
刘健 674a15ef32 Merge branch 'feature/1.7-liujian' into 'main'
update api portal interface

See merge request apipark/APIPark!325
2025-04-16 11:11:14 +08:00
lichunxian d82d665280 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!324
2025-04-16 10:19:11 +08:00
lichunxian 752db42b3b Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!323
2025-04-16 09:53:24 +08:00
lichunxian 10aaf85a26 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!322
2025-04-16 09:47:57 +08:00
lichunxian 5c97ef9416 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!321
2025-04-16 09:18:16 +08:00
刘健 5fc84299f1 Merge branch 'feature/1.7-liujian' into 'main'
update path

See merge request apipark/APIPark!320
2025-04-16 00:01:29 +08:00
刘健 2eeeebf7c2 Merge branch 'feature/1.7-liujian' into 'main'
MCP Server supports multiple languages.

See merge request apipark/APIPark!319
2025-04-15 22:42:51 +08:00
lichunxian 155ad537a9 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!318
2025-04-15 18:58:14 +08:00
lichunxian 4a1430c62a Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP-Breadcrumb

See merge request apipark/APIPark!317
2025-04-14 17:45:58 +08:00
lichunxian 8cc0d038bd Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP-Breadcrumb

See merge request apipark/APIPark!316
2025-04-14 17:33:06 +08:00
lichunxian 165759398e Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!315
2025-04-14 14:09:47 +08:00
lichunxian 1091d4e086 Merge branch 'feature/1.7-cxx' into 'main'
Feature/1.7 cxx

See merge request apipark/APIPark!314
2025-04-14 13:37:01 +08:00
刘健 0523f13dfb Merge branch 'feature/1.7-liujian' into 'main'
Feature/1.7 liujian

See merge request apipark/APIPark!313
2025-04-14 11:57:40 +08:00
lichunxian 256c04f5bb Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!312
2025-04-14 11:33:52 +08:00
lichunxian a9dcc78db6 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!311
2025-04-14 11:12:24 +08:00
刘健 1f6c173e18 Merge branch 'feature/1.7-liujian' into 'main'
Fix: API forwarding header setting failure issue

See merge request apipark/APIPark!310
2025-04-14 10:20:17 +08:00
lichunxian b593e8b57b Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!309
2025-04-14 09:54:30 +08:00
lichunxian 1ec00de03c Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!308
2025-04-11 18:41:00 +08:00
lichunxian bad7fbadda Merge branch 'feature/1.7-cxx' into 'main'
Feature/1.7 cxx

See merge request apipark/APIPark!307
2025-04-11 18:31:30 +08:00
lichunxian 7a506fc15e Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!306
2025-04-11 17:28:46 +08:00
lichunxian dec2c3a23e Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!305
2025-04-11 16:49:06 +08:00
刘健 2093541c37 Merge branch 'feature/1.7-liujian' into 'main'
Add the openapiaddress field to the API portal to obtain detailed service information

See merge request apipark/APIPark!304
2025-04-11 14:43:07 +08:00
lichunxian 40c7ba4305 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!303
2025-04-11 14:18:13 +08:00
刘健 a95bca31e2 Merge branch 'feature/1.7-liujian' into 'main'
service detail add invoke_count

See merge request apipark/APIPark!302
2025-04-11 11:58:33 +08:00
刘健 a541e45a53 Merge branch 'feature/1.7-liujian' into 'main'
Feature/1.7 liujian

See merge request apipark/APIPark!301
2025-04-11 11:04:56 +08:00
lichunxian b20c66b311 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!300
2025-04-11 10:06:06 +08:00
lichunxian 729e1f105c Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!299
2025-04-10 17:48:12 +08:00
lichunxian 6aa96a2ae9 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!298
2025-04-10 16:29:48 +08:00
lichunxian 5093c98656 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!297
2025-04-10 16:22:52 +08:00
lichunxian f4b70d4e71 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!296
2025-04-10 16:11:01 +08:00
刘健 eeb36f43a4 Update .gitlab-ci.yml file 2025-04-10 15:52:44 +08:00
lichunxian 5a59a6d378 Merge branch 'feature/1.7-cxx' into 'main'
feature/1.7-MCP

See merge request apipark/APIPark!295
2025-04-10 15:27:13 +08:00
lichunxian c0045d17e2 Merge branch 'feature/1.7-cxx' into 'main'
Feature/1.7 cxx

See merge request apipark/APIPark!294
2025-04-10 10:47:54 +08:00
刘健 42963d3ee5 Merge branch 'feature/1.7-liujian' into 'main'
Revert "Auxiliary commit to revert individual files from da05525cbbf2510a2cbc37d7eed6bfb8248e448b"

See merge request apipark/APIPark!291
2025-04-10 10:00:30 +08:00
27 changed files with 63425 additions and 60745 deletions
+5
View File
@@ -75,6 +75,11 @@ jobs:
with:
name: frontend-package
path: frontend/dist
# 设置 QEMU 以支持多架构构建
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login Docker #登录docker
uses: docker/login-action@v1
with:
+88
View File
@@ -0,0 +1,88 @@
variables:
PATH: /opt/go-1.23/go/bin/:/opt/node-1.22/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
GOROOT: /opt/go-1.23/go
GOPROXY: https://goproxy.cn
VERSION: $CI_COMMIT_SHORT_SHA
APP: apipark
APP_PRE: ${APP}_${VERSION}
BUILD_DIR: ${APP}-build
DEPLOY_DESC: "DEV 环境"
VIEW_ADDR: http://172.18.166.219:8288
SAVE_DIR: /opt/${APP}
NODE_OPTIONS: --max_old_space_size=8192
stages:
# - notice
- build
- deploy
- webhook
#
#feishu-informer: # 飞书回调
# stage: notice
# variables:
# DIFF_URL: "$CI_MERGE_REQUEST_PROJECT_URL/-/merge_requests/$CI_MERGE_REQUEST_IID/diffs"
# rules:
# - if: $CI_PIPELINE_SOURCE=="merge_request_event" && $CI_COMMIT_BRANCH =~ "main-github-pro"
# script:
# - echo "merge request"
# - |
# curl -X POST -H "Content-Type: application/json" \
# -d "{\"msg_type\":\"text\",\"content\":{\"text\":\"项目:${CI_PROJECT_NAME}\\n提交人:${GITLAB_USER_NAME}\\n提交信息:${CI_MERGE_REQUEST_TITLE}\\n合并分支信息:${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} -> ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}\\n差异性地址:${DIFF_URL}\\n请及时review代码\"}}" \
# ${FEISHU_WEBHOOK}
builder:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == "main-github-pro" || $CI_COMMIT_BRANCH == "main"
script:
- set -e
- |
if [ ! -d "../artifacts" ]; then
mkdir -p ../artifacts
fi
if [ -d "../artifacts/dist" ]; then
cp -r ../artifacts/dist frontend/dist
fi
- |
if [ -n "$(git diff --name-status HEAD~1 HEAD -- frontend)" ]; then
./scripts/build.sh $BUILD_DIR ${VERSION} all ""
else
./scripts/build.sh $BUILD_DIR ${VERSION}
fi
if [ -d "frontend/dist" ]; then
echo "copy frontend/dist to artifacts/dist"
rm -fr ../artifacts/dist
cp -r frontend/dist ../artifacts/dist
fi
cp $BUILD_DIR/${APP_PRE}_linux_amd64.tar.gz ${SAVE_DIR}
deployer:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == "main-github-pro" || $CI_COMMIT_BRANCH == "main"
variables:
APIPARK_GUEST_MODE: allow
APIPARK_GUEST_ID: dklejrfbhjqwdh
script:
- cd ${SAVE_DIR};mkdir -p ${APP_PRE};tar -zxvf ${APP_PRE}_linux_amd64.tar.gz -C ${APP_PRE};cd ${APP_PRE};./install.sh ${SAVE_DIR};./run.sh restart;cd ${SAVE_DIR} && ./clean.sh ${APP_PRE}
when: on_success
success:
stage: webhook
rules:
- if: $CI_COMMIT_BRANCH == "main-github-pro" || $CI_COMMIT_BRANCH == "main"
script:
- |
curl -X POST -H "Content-Type: application/json" \
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"最近一次提交:${CI_COMMIT_TITLE}\\n提交人:${GITLAB_USER_NAME}\\n项目:${CI_PROJECT_NAME}\\n环境:${DEPLOY_DESC}\\n更新部署完成.\\n访问地址:${VIEW_ADDR}\\n工作流地址:${CI_PIPELINE_URL}\"}}" \
${FEISHU_WEBHOOK}
when: on_success
failure:
stage: webhook
rules:
- if: $CI_COMMIT_BRANCH == "main-github-pro" || $CI_COMMIT_BRANCH == "main"
script:
- |
curl -X POST -H "Content-Type: application/json" \
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"最近一次提交:${CI_COMMIT_TITLE}\\n提交人:${GITLAB_USER_NAME}\\n项目:${CI_PROJECT_NAME}\\n环境:${DEPLOY_DESC}\\n更新部署失败,请及时到gitlab上查看\\n工作流地址:${CI_PIPELINE_URL}\"}}" \
${FEISHU_WEBHOOK}
when: on_failure
+62748 -60558
View File
File diff suppressed because it is too large Load Diff
@@ -20,6 +20,10 @@ interface PageListRef {
[key: string]: any;
}
/**
* 排名列表
* @returns
*/
const RankingList = ({ topRankingList, serviceType }: { topRankingList: RankingListData; serviceType: 'aiService' | 'restService' }) => {
/** 全局状态 */
const { state } = useGlobalContext()
+32 -12
View File
@@ -8,6 +8,8 @@ import (
"net/http"
"strings"
service_overview "github.com/APIParkLab/APIPark/service/service-overview"
ai_provider_local "github.com/APIParkLab/APIPark/ai-provider/local"
model_runtime "github.com/APIParkLab/APIPark/ai-provider/model-runtime"
@@ -35,12 +37,13 @@ var (
)
type imlAPIModule struct {
serviceService service.IServiceService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
aiAPIService ai_api.IAPIService `autowired:""`
aiModelService ai_model.IProviderModelService `autowired:""`
apiService api.IAPIService `autowired:""`
transaction store.ITransaction `autowired:""`
serviceService service.IServiceService `autowired:""`
serviceOverviewService service_overview.IOverviewService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
aiAPIService ai_api.IAPIService `autowired:""`
aiModelService ai_model.IProviderModelService `autowired:""`
apiService api.IAPIService `autowired:""`
transaction store.ITransaction `autowired:""`
}
func (i *imlAPIModule) getAPIDoc(ctx context.Context, serviceId string) (*openapi3.T, error) {
@@ -77,9 +80,17 @@ func (i *imlAPIModule) updateAPIDoc(ctx context.Context, serviceId, serviceName,
if err != nil {
return err
}
return i.apiDocService.UpdateDoc(ctx, serviceId, &api_doc.UpdateDoc{
ID: uuid.New().String(),
Content: string(result),
return i.transaction.Transaction(ctx, func(ctx context.Context) error {
count, err := i.apiDocService.UpdateDoc(ctx, serviceId, &api_doc.UpdateDoc{
ID: uuid.New().String(),
Content: string(result),
})
if err != nil {
return fmt.Errorf("update api doc error:%v", err)
}
return i.serviceOverviewService.Update(ctx, serviceId, &service_overview.Update{
ApiCount: &count,
})
})
}
@@ -93,10 +104,19 @@ func (i *imlAPIModule) deleteAPIDoc(ctx context.Context, serviceId string, path
if err != nil {
return err
}
return i.apiDocService.UpdateDoc(ctx, serviceId, &api_doc.UpdateDoc{
ID: uuid.New().String(),
Content: string(result),
return i.transaction.Transaction(ctx, func(ctx context.Context) error {
count, err := i.apiDocService.UpdateDoc(ctx, serviceId, &api_doc.UpdateDoc{
ID: uuid.New().String(),
Content: string(result),
})
if err != nil {
return fmt.Errorf("update api doc error:%v", err)
}
return i.serviceOverviewService.Update(ctx, serviceId, &service_overview.Update{
ApiCount: &count,
})
})
}
func (i *imlAPIModule) Create(ctx context.Context, serviceId string, input *ai_api_dto.CreateAPI) error {
+21 -7
View File
@@ -3,6 +3,11 @@ package api_doc
import (
"context"
"errors"
"fmt"
"github.com/eolinker/go-common/store"
service_overview "github.com/APIParkLab/APIPark/service/service-overview"
api_doc_dto "github.com/APIParkLab/APIPark/module/api-doc/dto"
api_doc "github.com/APIParkLab/APIPark/service/api-doc"
@@ -16,8 +21,10 @@ import (
var _ IAPIDocModule = (*imlAPIDocModule)(nil)
type imlAPIDocModule struct {
apiDocService api_doc.IAPIDocService `autowired:""`
serviceService service.IServiceService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
serviceService service.IServiceService `autowired:""`
serviceOverviewService service_overview.IOverviewService `autowired:""`
transaction store.ITransaction `autowired:""`
}
func (i *imlAPIDocModule) UpdateDoc(ctx context.Context, serviceId string, input *api_doc_dto.UpdateDoc) (*api_doc_dto.ApiDocDetail, error) {
@@ -29,11 +36,18 @@ func (i *imlAPIDocModule) UpdateDoc(ctx context.Context, serviceId string, input
input.Id = uuid.New().String()
}
// 每个API加上前缀
err = i.apiDocService.UpdateDoc(ctx, serviceId, &api_doc.UpdateDoc{
ID: input.Id,
Content: input.Content,
Prefix: info.Prefix,
err = i.transaction.Transaction(ctx, func(ctx context.Context) error {
count, err := i.apiDocService.UpdateDoc(ctx, serviceId, &api_doc.UpdateDoc{
ID: input.Id,
Content: input.Content,
Prefix: info.Prefix,
})
if err != nil {
return fmt.Errorf("update api doc error:%v", err)
}
return i.serviceOverviewService.Update(ctx, serviceId, &service_overview.Update{
ApiCount: &count,
})
})
if err != nil {
return nil, err
+84 -32
View File
@@ -9,6 +9,8 @@ import (
"strings"
"time"
service_overview "github.com/APIParkLab/APIPark/service/service-overview"
mcp_server "github.com/APIParkLab/APIPark/mcp-server"
"github.com/APIParkLab/APIPark/module/monitor/driver"
@@ -58,23 +60,73 @@ var (
)
type imlCatalogueModule struct {
catalogueService catalogue.ICatalogueService `autowired:""`
apiService api.IAPIService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
serviceService service.IServiceService `autowired:""`
serviceTagService service_tag.ITagService `autowired:""`
serviceDocService service_doc.IDocService `autowired:""`
tagService tag.ITagService `autowired:""`
releaseService release.IReleaseService `autowired:""`
subscribeService subscribe.ISubscribeService `autowired:""`
subscribeApplyService subscribe.ISubscribeApplyService `autowired:""`
transaction store.ITransaction `autowired:""`
clusterService cluster.IClusterService `autowired:""`
settingService setting.ISettingService `autowired:""`
monitorService monitor.IMonitorService `autowired:""`
root *Root
catalogueService catalogue.ICatalogueService `autowired:""`
apiService api.IAPIService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
serviceService service.IServiceService `autowired:""`
serviceOverviewService service_overview.IOverviewService `autowired:""`
serviceTagService service_tag.ITagService `autowired:""`
serviceDocService service_doc.IDocService `autowired:""`
tagService tag.ITagService `autowired:""`
releaseService release.IReleaseService `autowired:""`
subscribeService subscribe.ISubscribeService `autowired:""`
subscribeApplyService subscribe.ISubscribeApplyService `autowired:""`
transaction store.ITransaction `autowired:""`
clusterService cluster.IClusterService `autowired:""`
settingService setting.ISettingService `autowired:""`
monitorService monitor.IMonitorService `autowired:""`
root *Root
}
//func (i *imlCatalogueModule) OnInit() {
// register.Handle(func(v server.Server) {
// ctx := context.Background()
// list, err := i.releaseService.GetRunningList(ctx)
// if err != nil {
// log.Errorf("onInit: get running list failed:%s", err.Error())
// return
// }
// if len(list) < 1 || list[0].APICount > 0 {
// return
// }
// serviceMap := make(map[string]*release.Release)
// serviceIds := make([]string, 0, len(list))
// for _, v := range list {
// if _, ok := serviceMap[v.Service]; !ok {
// serviceMap[v.Service] = v
// serviceIds = append(serviceIds, v.Service)
// }
// }
// if len(serviceIds) < 1 {
// return
// }
// commitIds, err := i.releaseService.GetRunningApiDocCommits(ctx, serviceIds...)
// if err != nil {
// log.Errorf("onInit: get running api doc commits failed:%s", err.Error())
// return
// }
// if len(commitIds) < 1 {
// return
// }
// listCommits, err := i.apiDocService.ListDocCommit(ctx, commitIds...)
// if err != nil {
// log.Error("onInit: list doc commit failed:", err.Error())
// return
// }
// for _, v := range listCommits {
// m, ok := serviceMap[v.Target]
// if !ok {
// continue
// }
//
// i.releaseService.UpdateRelease(ctx, m.UUID, &release.Update{
// APICount: &v.Data.APICount,
// })
// }
// })
//
//}
func (i *imlCatalogueModule) DefaultCatalogue(ctx context.Context) (*catalogue_dto.Catalogue, error) {
catalogues, err := i.catalogueService.List(ctx)
if err != nil {
@@ -447,27 +499,26 @@ func (i *imlCatalogueModule) Services(ctx context.Context, keyword string) ([]*c
if err != nil {
return nil, err
}
serviceIds := utils.SliceToSlice(items, func(i *service.Service) string {
return i.Id
}, func(s *service.Service) bool {
// 未发布的不给展示
_, err = i.releaseService.GetRunning(ctx, s.Id)
return err == nil
})
overviewMap, err := i.serviceOverviewService.Map(ctx, serviceIds...)
if err != nil {
return nil, err
}
serviceIds = utils.SliceToSlice(serviceIds, func(s string) string {
return s
}, func(s string) bool {
// 只展示已发布的服务
if info, ok := overviewMap[s]; ok && info.IsReleased {
return true
}
return false
})
if len(serviceIds) < 1 {
return nil, nil
}
commits, err := i.releaseService.GetRunningApiDocCommits(ctx, serviceIds...)
if err != nil {
return nil, err
}
apiCountMap, err := i.apiDocService.LatestAPICountByCommits(ctx, commits...)
if err != nil {
return nil, err
}
subscriberCountMap, err := i.subscribeService.CountMapByService(ctx, subscribe.ApplyStatusSubscribe, serviceIds...)
if err != nil {
return nil, err
@@ -479,8 +530,9 @@ func (i *imlCatalogueModule) Services(ctx context.Context, keyword string) ([]*c
result := make([]*catalogue_dto.ServiceItem, 0, len(items))
for _, v := range items {
apiNum, ok := apiCountMap[v.Id]
if !ok || apiNum < 1 {
ov, ok := overviewMap[v.Id]
if !ok || ov.ReleaseApiCount < 1 {
continue
}
@@ -489,8 +541,8 @@ func (i *imlCatalogueModule) Services(ctx context.Context, keyword string) ([]*c
Name: v.Name,
Tags: auto.List(serviceTagMap[v.Id]),
Catalogue: auto.UUID(v.Catalogue),
ApiNum: apiNum,
SubscriberNum: subscriberCountMap[v.Id],
ApiNum: ov.ReleaseApiCount,
Description: v.Description,
Logo: v.Logo,
EnableMCP: v.EnableMCP,
+149 -87
View File
@@ -7,6 +7,12 @@ import (
"fmt"
"time"
"github.com/eolinker/go-common/server"
"github.com/eolinker/go-common/register"
service_overview "github.com/APIParkLab/APIPark/service/service-overview"
mcp_server "github.com/APIParkLab/APIPark/mcp-server"
api_doc "github.com/APIParkLab/APIPark/service/api-doc"
"github.com/mark3labs/mcp-go/mcp"
@@ -51,22 +57,70 @@ var (
)
type imlPublishModule struct {
projectDiffModule serviceDiff.IServiceDiffModule `autowired:""`
releaseModule releaseModule.IReleaseModule `autowired:""`
publishService publish.IPublishService `autowired:""`
apiService api.IAPIService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
upstreamService upstream.IUpstreamService `autowired:""`
strategyService strategy.IStrategyService `autowired:""`
releaseService release.IReleaseService `autowired:""`
clusterService cluster.IClusterService `autowired:""`
serviceService service.IServiceService `autowired:""`
transaction store.ITransaction `autowired:""`
projectDiffModule serviceDiff.IServiceDiffModule `autowired:""`
releaseModule releaseModule.IReleaseModule `autowired:""`
publishService publish.IPublishService `autowired:""`
apiService api.IAPIService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
upstreamService upstream.IUpstreamService `autowired:""`
strategyService strategy.IStrategyService `autowired:""`
releaseService release.IReleaseService `autowired:""`
clusterService cluster.IClusterService `autowired:""`
serviceService service.IServiceService `autowired:""`
serviceOverviewService service_overview.IOverviewService `autowired:""`
transaction store.ITransaction `autowired:""`
}
func (m *imlPublishModule) initGateway(ctx context.Context, partitionId string, clientDriver gateway.IClientDriver) error {
func (i *imlPublishModule) OnInit() {
register.Handle(func(v server.Server) {
ctx := context.Background()
list, err := i.releaseService.GetRunningList(ctx)
if err != nil {
log.Errorf("onInit: get running list failed:%s", err.Error())
return
}
if len(list) < 1 {
return
}
serviceMap := make(map[string]*release.Release)
serviceIds := make([]string, 0, len(list))
for _, v := range list {
if _, ok := serviceMap[v.Service]; !ok {
serviceMap[v.Service] = v
serviceIds = append(serviceIds, v.Service)
}
}
overviewList, err := i.serviceOverviewService.List(ctx, serviceIds...)
if err != nil {
log.Errorf("onInit: get running list failed:%s", err.Error())
return
}
for _, v := range overviewList {
if v.IsReleased {
return
}
}
listCommits, err := i.apiDocService.ListLatestDocCommit(ctx, serviceIds...)
if err != nil {
log.Errorf("onInit: get running api doc commits failed:%s", err.Error())
return
}
isReleased := true
for _, v := range listCommits {
i.serviceOverviewService.Update(ctx, v.Target, &service_overview.Update{
ApiCount: nil,
ReleaseApiCount: &v.Data.APICount,
IsReleased: &isReleased,
})
}
})
}
func (i *imlPublishModule) initGateway(ctx context.Context, partitionId string, clientDriver gateway.IClientDriver) error {
return nil
//projects, err := m.serviceService.List(ctx)
//projects, err := i.serviceService.List(ctx)
//if err != nil {
// return err
//}
@@ -74,7 +128,7 @@ func (m *imlPublishModule) initGateway(ctx context.Context, partitionId string,
// return p.Id
//})
//for _, projectId := range projectIds {
// releaseInfo, err := m.GetProjectRelease(ctx, projectId, partitionId)
// releaseInfo, err := i.GetProjectRelease(ctx, projectId, partitionId)
// if err != nil {
// return err
// }
@@ -90,8 +144,8 @@ func (m *imlPublishModule) initGateway(ctx context.Context, partitionId string,
//return nil
}
func (m *imlPublishModule) getProjectRelease(ctx context.Context, projectID string, commitId string) (*gateway.ProjectRelease, error) {
commits, err := m.releaseService.GetCommits(ctx, commitId)
func (i *imlPublishModule) getProjectRelease(ctx context.Context, projectID string, commitId string) (*gateway.ProjectRelease, error) {
commits, err := i.releaseService.GetCommits(ctx, commitId)
if err != nil {
return nil, err
}
@@ -110,17 +164,17 @@ func (m *imlPublishModule) getProjectRelease(ctx context.Context, projectID stri
strategyCommitIds = append(strategyCommitIds, c.Commit)
}
}
serviceInfo, err := m.serviceService.Get(ctx, projectID)
serviceInfo, err := i.serviceService.Get(ctx, projectID)
if err != nil {
return nil, err
}
apiInfos, err := m.apiService.ListInfo(ctx, apiIds...)
apiInfos, err := i.apiService.ListInfo(ctx, apiIds...)
if err != nil {
return nil, err
}
proxyCommits, err := m.apiService.ListProxyCommit(ctx, apiProxyCommitIds...)
proxyCommits, err := i.apiService.ListProxyCommit(ctx, apiProxyCommitIds...)
if err != nil {
return nil, err
}
@@ -177,7 +231,7 @@ func (m *imlPublishModule) getProjectRelease(ctx context.Context, projectID stri
r.Apis = apis
var upstreamRelease *gateway.UpstreamRelease
if len(upstreamCommitIds) > 0 {
upstreamCommits, err := m.upstreamService.ListCommit(ctx, upstreamCommitIds...)
upstreamCommits, err := i.upstreamService.ListCommit(ctx, upstreamCommitIds...)
if err != nil {
return nil, err
}
@@ -202,7 +256,7 @@ func (m *imlPublishModule) getProjectRelease(ctx context.Context, projectID stri
r.Upstream = upstreamRelease
}
if len(strategyCommitIds) > 0 {
strategyCommits, err := m.strategyService.ListStrategyCommit(ctx, strategyCommitIds...)
strategyCommits, err := i.strategyService.ListStrategyCommit(ctx, strategyCommitIds...)
if err != nil {
return nil, err
}
@@ -234,9 +288,9 @@ func (m *imlPublishModule) getProjectRelease(ctx context.Context, projectID stri
return r, nil
}
func (m *imlPublishModule) GetProjectRelease(ctx context.Context, projectID string, partitionId string) (*gateway.ProjectRelease, error) {
func (i *imlPublishModule) GetProjectRelease(ctx context.Context, projectID string, partitionId string) (*gateway.ProjectRelease, error) {
releaseInfo, err := m.releaseService.GetRunning(ctx, projectID)
releaseInfo, err := i.releaseService.GetRunning(ctx, projectID)
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
return nil, err
@@ -244,11 +298,11 @@ func (m *imlPublishModule) GetProjectRelease(ctx context.Context, projectID stri
return nil, nil
}
return m.getProjectRelease(ctx, projectID, releaseInfo.UUID)
return i.getProjectRelease(ctx, projectID, releaseInfo.UUID)
}
func (m *imlPublishModule) getReleaseInfo(ctx context.Context, projectID, releaseId, version string, clusterIds []string) (map[string]*gateway.ProjectRelease, error) {
projectRelease, err := m.getProjectRelease(ctx, projectID, releaseId)
func (i *imlPublishModule) getReleaseInfo(ctx context.Context, projectID, releaseId, version string, clusterIds []string) (map[string]*gateway.ProjectRelease, error) {
projectRelease, err := i.getProjectRelease(ctx, projectID, releaseId)
if err != nil {
return nil, err
}
@@ -266,19 +320,19 @@ func (m *imlPublishModule) getReleaseInfo(ctx context.Context, projectID, releas
return projectReleaseMap, nil
}
func (m *imlPublishModule) PublishStatuses(ctx context.Context, serviceId string, id string) ([]*dto.PublishStatus, error) {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) PublishStatuses(ctx context.Context, serviceId string, id string) ([]*dto.PublishStatus, error) {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return nil, err
}
flow, err := m.publishService.Get(ctx, id)
flow, err := i.publishService.Get(ctx, id)
if err != nil {
return nil, err
}
if flow.Service != serviceId {
return nil, errors.New("服务不一致")
}
list, err := m.publishService.GetPublishStatus(ctx, id)
list, err := i.publishService.GetPublishStatus(ctx, id)
if err != nil {
return nil, err
}
@@ -302,18 +356,18 @@ func (m *imlPublishModule) PublishStatuses(ctx context.Context, serviceId string
//
// ctx context.Context, serviceId string, input *dto.ApplyInput
// *dto.Publish, error
func (m *imlPublishModule) Apply(ctx context.Context, serviceId string, input *dto.ApplyInput) (*dto.Publish, error) {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) Apply(ctx context.Context, serviceId string, input *dto.ApplyInput) (*dto.Publish, error) {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return nil, err
}
err = m.checkPublish(ctx, serviceId, input.Release)
err = i.checkPublish(ctx, serviceId, input.Release)
if err != nil {
return nil, err
}
previous := ""
running, err := m.releaseService.GetRunning(ctx, serviceId)
running, err := i.releaseService.GetRunning(ctx, serviceId)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return nil, err
@@ -322,42 +376,42 @@ func (m *imlPublishModule) Apply(ctx context.Context, serviceId string, input *d
previous = running.UUID
}
releaseToPublish, err := m.releaseService.GetRelease(ctx, input.Release)
releaseToPublish, err := i.releaseService.GetRelease(ctx, input.Release)
if err != nil {
// 目标版本不存在
return nil, err
}
newPublishId := uuid.NewString()
diff, ok, err := m.projectDiffModule.DiffForLatest(ctx, serviceId, previous)
diff, ok, err := i.projectDiffModule.DiffForLatest(ctx, serviceId, previous)
if err != nil {
return nil, err
}
if !ok {
return nil, errors.New("latest completeness check failed")
}
err = m.publishService.Create(ctx, newPublishId, serviceId, releaseToPublish.UUID, previous, releaseToPublish.Version, input.Remark, diff)
err = i.publishService.Create(ctx, newPublishId, serviceId, releaseToPublish.UUID, previous, releaseToPublish.Version, input.Remark, diff)
if err != nil {
return nil, err
}
np, err := m.publishService.Get(ctx, newPublishId)
np, err := i.publishService.Get(ctx, newPublishId)
if err != nil {
return nil, err
}
return dto.FromModel(np, releaseToPublish.Remark), nil
}
func (m *imlPublishModule) CheckPublish(ctx context.Context, serviceId string, releaseId string) (*dto.DiffOut, error) {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) CheckPublish(ctx context.Context, serviceId string, releaseId string) (*dto.DiffOut, error) {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return nil, err
}
err = m.checkPublish(ctx, serviceId, releaseId)
err = i.checkPublish(ctx, serviceId, releaseId)
if err != nil {
return nil, err
}
running, err := m.releaseService.GetRunning(ctx, serviceId)
running, err := i.releaseService.GetRunning(ctx, serviceId)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return nil, err
}
@@ -367,30 +421,30 @@ func (m *imlPublishModule) CheckPublish(ctx context.Context, serviceId string, r
}
if releaseId == "" {
// 发布latest 版本
diff, _, err := m.projectDiffModule.DiffForLatest(ctx, serviceId, runningReleaseId)
diff, _, err := i.projectDiffModule.DiffForLatest(ctx, serviceId, runningReleaseId)
if err != nil {
return nil, err
}
return m.projectDiffModule.Out(ctx, diff)
return i.projectDiffModule.Out(ctx, diff)
} else {
// 发布 releaseId 版本, 返回 与当前版本的差异
diff, err := m.projectDiffModule.Diff(ctx, serviceId, runningReleaseId, releaseId)
diff, err := i.projectDiffModule.Diff(ctx, serviceId, runningReleaseId, releaseId)
if err != nil {
return nil, err
}
return m.projectDiffModule.Out(ctx, diff)
return i.projectDiffModule.Out(ctx, diff)
}
}
func (m *imlPublishModule) checkPublish(ctx context.Context, serviceId string, releaseId string) error {
flows, err := m.publishService.ListForStatus(ctx, serviceId, publish.StatusApply, publish.StatusAccept)
func (i *imlPublishModule) checkPublish(ctx context.Context, serviceId string, releaseId string) error {
flows, err := i.publishService.ListForStatus(ctx, serviceId, publish.StatusApply, publish.StatusAccept)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return err
}
if len(flows) > 0 {
return errors.New("正在发布中")
}
running, err := m.releaseService.GetRunning(ctx, serviceId)
running, err := i.releaseService.GetRunning(ctx, serviceId)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return err
}
@@ -403,8 +457,8 @@ func (m *imlPublishModule) checkPublish(ctx context.Context, serviceId string, r
}
return nil
}
func (m *imlPublishModule) Close(ctx context.Context, serviceId, id string) error {
err := m.publishService.SetStatus(ctx, serviceId, id, publish.StatusClose)
func (i *imlPublishModule) Close(ctx context.Context, serviceId, id string) error {
err := i.publishService.SetStatus(ctx, serviceId, id, publish.StatusClose)
if err != nil {
return err
}
@@ -412,12 +466,12 @@ func (m *imlPublishModule) Close(ctx context.Context, serviceId, id string) erro
return nil
}
func (m *imlPublishModule) Stop(ctx context.Context, serviceId string, id string) error {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) Stop(ctx context.Context, serviceId string, id string) error {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return err
}
flow, err := m.publishService.Get(ctx, id)
flow, err := i.publishService.Get(ctx, id)
if err != nil {
return err
}
@@ -432,44 +486,44 @@ func (m *imlPublishModule) Stop(ctx context.Context, serviceId string, id string
if flow.Status == publish.StatusApply {
status = publish.StatusClose
}
return m.publishService.SetStatus(ctx, serviceId, id, status)
return i.publishService.SetStatus(ctx, serviceId, id, status)
}
func (m *imlPublishModule) Refuse(ctx context.Context, serviceId string, id string, commits string) error {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) Refuse(ctx context.Context, serviceId string, id string, commits string) error {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return err
}
return m.publishService.Refuse(ctx, serviceId, id, commits)
return i.publishService.Refuse(ctx, serviceId, id, commits)
}
func (m *imlPublishModule) Accept(ctx context.Context, serviceId string, id string, commits string) error {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) Accept(ctx context.Context, serviceId string, id string, commits string) error {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return err
}
return m.publishService.Accept(ctx, serviceId, id, commits)
return i.publishService.Accept(ctx, serviceId, id, commits)
}
func (m *imlPublishModule) publish(ctx context.Context, id string, clusterId string, projectRelease *gateway.ProjectRelease) error {
func (i *imlPublishModule) publish(ctx context.Context, id string, clusterId string, projectRelease *gateway.ProjectRelease) error {
publishStatus := &publish.Status{
Publish: id,
Status: publish.StatusPublishing,
UpdateAt: time.Now(),
}
err := m.publishService.SetPublishStatus(ctx, publishStatus)
err := i.publishService.SetPublishStatus(ctx, publishStatus)
if err != nil {
return fmt.Errorf("set publishing publishStatus error: %v", err)
}
defer func() {
err := m.publishService.SetPublishStatus(ctx, publishStatus)
err := i.publishService.SetPublishStatus(ctx, publishStatus)
if err != nil {
log.Errorf("set publishing publishStatus error: %v", err)
}
}()
client, err := m.clusterService.GatewayClient(ctx, clusterId)
client, err := i.clusterService.GatewayClient(ctx, clusterId)
if err != nil {
publishStatus.Status = publish.StatusPublishError
publishStatus.Error = err.Error()
@@ -501,12 +555,12 @@ func (m *imlPublishModule) publish(ctx context.Context, id string, clusterId str
return nil
}
func (m *imlPublishModule) Publish(ctx context.Context, serviceId string, id string) error {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) Publish(ctx context.Context, serviceId string, id string) error {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return err
}
flow, err := m.publishService.Get(ctx, id)
flow, err := i.publishService.Get(ctx, id)
if err != nil {
return err
}
@@ -516,7 +570,7 @@ func (m *imlPublishModule) Publish(ctx context.Context, serviceId string, id str
if flow.Status != publish.StatusAccept && flow.Status != publish.StatusDone {
return errors.New("只有通过状态才能发布")
}
clusters, err := m.clusterService.List(ctx)
clusters, err := i.clusterService.List(ctx)
if err != nil {
return err
}
@@ -524,21 +578,21 @@ func (m *imlPublishModule) Publish(ctx context.Context, serviceId string, id str
return i.Uuid
})
projectReleaseMap, err := m.getReleaseInfo(ctx, serviceId, flow.Release, flow.Release, clusterIds)
projectReleaseMap, err := i.getReleaseInfo(ctx, serviceId, flow.Release, flow.Release, clusterIds)
if err != nil {
return err
}
hasError := false
return m.transaction.Transaction(ctx, func(ctx context.Context) error {
return i.transaction.Transaction(ctx, func(ctx context.Context) error {
for _, c := range clusters {
err = m.publish(ctx, flow.Id, c.Uuid, projectReleaseMap[c.Uuid])
err = i.publish(ctx, flow.Id, c.Uuid, projectReleaseMap[c.Uuid])
if err != nil {
hasError = true
log.Error(err)
continue
}
}
err = m.releaseService.SetRunning(ctx, serviceId, flow.Release)
err = i.releaseService.SetRunning(ctx, serviceId, flow.Release)
if err != nil {
return err
}
@@ -547,29 +601,37 @@ func (m *imlPublishModule) Publish(ctx context.Context, serviceId string, id str
status = publish.StatusPublishError
}
if status == publish.StatusDone {
info, err := m.serviceService.Get(ctx, serviceId)
info, err := i.serviceService.Get(ctx, serviceId)
if err != nil {
return err
}
if info.EnableMCP {
err = m.updateMCPServer(ctx, serviceId, info.Name, flow.Version)
err = i.updateMCPServer(ctx, serviceId, info.Name, flow.Version)
if err != nil {
return err
}
}
apidocCommit, err := i.apiDocService.LatestDocCommit(ctx, serviceId)
if err != nil {
return err
}
isReleased := true
i.serviceOverviewService.Update(ctx, serviceId, &service_overview.Update{
ReleaseApiCount: &apidocCommit.Data.APICount,
IsReleased: &isReleased,
})
}
return m.publishService.SetStatus(ctx, serviceId, id, status)
return i.publishService.SetStatus(ctx, serviceId, id, status)
})
}
func (m *imlPublishModule) List(ctx context.Context, serviceId string, page, pageSize int) ([]*dto.Publish, int64, error) {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) List(ctx context.Context, serviceId string, page, pageSize int) ([]*dto.Publish, int64, error) {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return nil, 0, err
}
list, total, err := m.publishService.ListProjectPage(ctx, serviceId, page, pageSize)
list, total, err := i.publishService.ListProjectPage(ctx, serviceId, page, pageSize)
if err != nil {
return nil, 0, err
}
@@ -659,31 +721,31 @@ func (i *imlPublishModule) updateMCPServer(ctx context.Context, sid string, name
return nil
}
func (m *imlPublishModule) Detail(ctx context.Context, serviceId string, id string) (*dto.PublishDetail, error) {
_, err := m.serviceService.Check(ctx, serviceId, asServer)
func (i *imlPublishModule) Detail(ctx context.Context, serviceId string, id string) (*dto.PublishDetail, error) {
_, err := i.serviceService.Check(ctx, serviceId, asServer)
if err != nil {
return nil, err
}
flow, err := m.publishService.Get(ctx, id)
flow, err := i.publishService.Get(ctx, id)
if err != nil {
return nil, err
}
if flow.Service != serviceId {
return nil, errors.New("项目不一致")
}
diff, err := m.publishService.GetDiff(ctx, id)
diff, err := i.publishService.GetDiff(ctx, id)
if err != nil {
return nil, err
}
out, err := m.projectDiffModule.Out(ctx, diff)
out, err := i.projectDiffModule.Out(ctx, diff)
if err != nil {
return nil, err
}
publishStatuses, err := m.PublishStatuses(ctx, serviceId, id)
publishStatuses, err := i.PublishStatuses(ctx, serviceId, id)
if err != nil {
return nil, err
}
releaseInfo, err := m.releaseService.GetRelease(ctx, flow.Release)
releaseInfo, err := i.releaseService.GetRelease(ctx, flow.Release)
if err != nil {
return nil, err
}
-1
View File
@@ -65,7 +65,6 @@ func (m *imlReleaseModule) latestStrategyCommits(ctx context.Context, serviceId
}
func (m *imlReleaseModule) Create(ctx context.Context, serviceId string, input *dto.CreateInput) (string, error) {
proInfo, err := m.projectService.Check(ctx, serviceId, projectRuleMustServer)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
+2 -2
View File
@@ -30,7 +30,7 @@ type Create struct {
MatchRules []Match `json:"match"`
Upstream string `json:"upstream"`
Proxy *InputProxy `json:"proxy"`
Disable bool `json:"disabled"`
Disable bool `json:"disable"`
}
type InputProxy struct {
@@ -70,7 +70,7 @@ type Edit struct {
Methods *[]string `json:"methods"`
Protocols *[]string `json:"protocols"`
MatchRules *[]Match `json:"match"`
Disable *bool `json:"disabled"`
Disable *bool `json:"disable"`
Upstream *string `json:"upstream"`
}
+1 -1
View File
@@ -35,7 +35,7 @@ type Detail struct {
SimpleDetail
Proxy *Proxy `json:"proxy"`
Protocols []string `json:"protocols"`
Disable bool `json:"disabled"`
Disable bool `json:"disable"`
//Doc map[string]interface{} `json:"doc"`
}
+1
View File
@@ -31,6 +31,7 @@ type EditService struct {
Name *string `json:"name"`
Description *string `json:"description"`
ServiceType *string `json:"service_type"`
Prefix *string `json:"prefix"`
Catalogue *string `json:"catalogue"`
Logo *string `json:"logo"`
Tags *[]string `json:"tags"`
+52 -17
View File
@@ -10,6 +10,8 @@ import (
"strings"
"time"
service_overview "github.com/APIParkLab/APIPark/service/service-overview"
"github.com/APIParkLab/APIPark/common"
"github.com/mitchellh/mapstructure"
@@ -83,11 +85,12 @@ type imlServiceModule struct {
tagService tag.ITagService `autowired:""`
localModelService ai_local.ILocalModelService `autowired:""`
serviceTagService service_tag.ITagService `autowired:""`
apiService api.IAPIService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
clusterService cluster.IClusterService `autowired:""`
subscribeServer subscribe.ISubscribeService `autowired:""`
serviceOverviewService service_overview.IOverviewService `autowired:""`
serviceTagService service_tag.ITagService `autowired:""`
apiService api.IAPIService `autowired:""`
apiDocService api_doc.IAPIDocService `autowired:""`
clusterService cluster.IClusterService `autowired:""`
subscribeServer subscribe.ISubscribeService `autowired:""`
releaseService release.IReleaseService `autowired:""`
serviceModelMappingService service_model_mapping.IServiceModelMappingService `autowired:""`
@@ -304,6 +307,7 @@ func (i *imlServiceModule) OnInit() {
log.Error(err)
return
}
for _, s := range services {
err = i.updateMCPServer(ctx, s.Id, s.Name, "1.0")
if err != nil {
@@ -311,6 +315,28 @@ func (i *imlServiceModule) OnInit() {
return
}
}
overviews, err := i.serviceOverviewService.List(ctx)
if err != nil {
log.Error(err)
return
}
if len(overviews) > 0 {
return
}
countMap, err := i.apiDocService.APICountByServices(ctx)
if err != nil {
log.Error(err)
return
}
for k, v := range countMap {
err = i.serviceOverviewService.Update(ctx, k, &service_overview.Update{
ApiCount: &v,
})
if err != nil {
log.Error(err)
return
}
}
})
}
@@ -510,7 +536,14 @@ func (i *imlServiceModule) SearchMyServices(ctx context.Context, teamId string,
serviceIds := utils.SliceToSlice(services, func(p *service.Service) string {
return p.Id
})
apiCountMap, err := i.apiDocService.APICountByServices(ctx, serviceIds...)
//apiCountMap, err := i.apiDocService.APICountByServices(ctx, serviceIds...)
//if err != nil {
// return nil, err
//}
//serviceIds := utils.SliceToSlice(services, func(s *service.Service) string {
// return s.Id
//})
overviewMap, err := i.serviceOverviewService.Map(ctx, serviceIds...)
if err != nil {
return nil, err
}
@@ -520,10 +553,12 @@ func (i *imlServiceModule) SearchMyServices(ctx context.Context, teamId string,
if teamId != "" && model.Team != teamId {
continue
}
apiCount := apiCountMap[model.Id]
item := toServiceItem(model)
item.ApiNum = apiCount
item.CanDelete = apiCount == 0
if ov, ok := overviewMap[model.Id]; ok {
item.ApiNum = ov.ApiCount
item.CanDelete = ov.ApiCount == 0
}
items = append(items, item)
}
@@ -629,22 +664,21 @@ func (i *imlServiceModule) Search(ctx context.Context, teamID string, keyword st
if err != nil {
return nil, err
}
serviceIds := utils.SliceToSlice(list, func(s *service.Service) string {
return s.Id
})
apiCountMap, err := i.apiDocService.APICountByServices(ctx, serviceIds...)
overviewMap, err := i.serviceOverviewService.Map(ctx, serviceIds...)
if err != nil {
return nil, err
}
items := make([]*service_dto.ServiceItem, 0, len(list))
for _, model := range list {
apiCount := apiCountMap[model.Id]
item := toServiceItem(model)
item.ApiNum = apiCount
item.CanDelete = apiCount == 0
if v, ok := overviewMap[model.Id]; ok {
item.ApiNum = v.ApiCount
item.CanDelete = v.ApiCount == 0
}
items = append(items, item)
}
return items, nil
@@ -734,7 +768,7 @@ func (i *imlServiceModule) Create(ctx context.Context, teamID string, input *ser
mo.AsServer = *input.AsServer
}
input.Prefix = strings.Trim(strings.Trim(input.Prefix, " "), "/")
//input.Prefix = strings.Trim(strings.Trim(input.Prefix, " "), "/")
err := i.transaction.Transaction(ctx, func(ctx context.Context) error {
if input.Tags != nil {
tags, err := i.getTagUuids(ctx, input.Tags)
@@ -839,6 +873,7 @@ func (i *imlServiceModule) Edit(ctx context.Context, id string, input *service_d
ServiceType: serviceType,
Catalogue: input.Catalogue,
AdditionalConfig: &info.AdditionalConfig,
Prefix: input.Prefix,
ApprovalType: &approvalType,
EnableMCP: input.EnableMCP,
}
+3 -1
View File
@@ -29,9 +29,11 @@ VERSION=$(gen_version)
SYS_ARCH=$(arch)
echo "SYS_ARCH: ${SYS_ARCH}"
echo "ARCH: ${ARCH}"
if [[ (${SYS_ARCH} == "aarch64" || ${SYS_ARCH} == "arm64") && $ARCH == "amd64" ]];then
OPTIONS="--platform=linux/amd64"
elif [[ ${SYS_ARCH} == "amd64" && $ARCH == "arm64" ]];then
elif [[ (${SYS_ARCH} == "amd64" || ${SYS_ARCH} == "x86_64") && $ARCH == "arm64" ]];then
OPTIONS="--platform=linux/arm64"
fi
+15 -15
View File
@@ -47,22 +47,22 @@ if [[ ${Init} == "true" ]];then
r=$(is_init)
if [[ $r == "true" ]];then
echo "Already initialized, skipping initialization."
exit 0
else
wait_for_influxdb
wait_for_apinto
set_cluster
wait_for_influxdb
set_influxdb
set_loki
set_nsq
set_openapi_config
# 重启apipark
kill -9 $(pgrep apipark)
nohup ./apipark >> run.log 2>&1 &
fi
wait_for_influxdb
wait_for_apinto
set_cluster
wait_for_influxdb
set_influxdb
set_loki
set_nsq
set_openapi_config
# 重启apipark
kill -9 $(pgrep apipark)
nohup ./apipark >> run.log 2>&1 &
fi
tail -F run.log
+14 -10
View File
@@ -5,6 +5,8 @@ import (
"errors"
"time"
"github.com/eolinker/eosc/log"
"github.com/APIParkLab/APIPark/service/universally/commit"
"github.com/APIParkLab/APIPark/stores/api"
"github.com/eolinker/go-common/utils"
@@ -59,7 +61,9 @@ func (i *imlAPIDocService) APICountByServices(ctx context.Context, serviceIds ..
if len(serviceIds) > 0 {
w["service"] = serviceIds
}
now := time.Now()
list, err := i.store.List(ctx, w)
log.Infof("search api doc count by services, serviceIds: %v, cost: %v", serviceIds, time.Since(now))
if err != nil {
return nil, err
}
@@ -68,35 +72,35 @@ func (i *imlAPIDocService) APICountByServices(ctx context.Context, serviceIds ..
}), nil
}
func (i *imlAPIDocService) UpdateDoc(ctx context.Context, serviceId string, input *UpdateDoc) error {
func (i *imlAPIDocService) UpdateDoc(ctx context.Context, serviceId string, input *UpdateDoc) (int64, error) {
doc, err := NewDocLoader(input.Content)
if err != nil {
return err
return 0, err
}
if err := doc.Valid(); err != nil {
return err
return 0, err
}
if input.Prefix != "" {
err = doc.AddPrefixInAll(input.Prefix)
if err != nil {
return err
return 0, err
}
}
data, err := doc.Marshal()
if err != nil {
return err
return 0, err
}
input.Content = string(data)
operator := utils.UserId(ctx)
info, err := i.store.First(ctx, map[string]interface{}{
"service": serviceId,
})
operator := utils.UserId(ctx)
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
return err
return 0, err
}
return i.store.Insert(ctx, &api.Doc{
return doc.APICount(), i.store.Insert(ctx, &api.Doc{
UUID: input.ID,
Service: serviceId,
Content: input.Content,
@@ -109,7 +113,7 @@ func (i *imlAPIDocService) UpdateDoc(ctx context.Context, serviceId string, inpu
info.Updater = operator
info.UpdateAt = time.Now()
info.APICount = doc.APICount()
return i.store.Save(ctx, info)
return doc.APICount(), i.store.Save(ctx, info)
}
func (i *imlAPIDocService) GetDoc(ctx context.Context, serviceId string) (*Doc, error) {
+1 -1
View File
@@ -15,7 +15,7 @@ import (
type IAPIDocService interface {
// UpdateDoc 更新文档
UpdateDoc(ctx context.Context, serviceId string, input *UpdateDoc) error
UpdateDoc(ctx context.Context, serviceId string, input *UpdateDoc) (int64, error)
// GetDoc 获取文档
GetDoc(ctx context.Context, serviceId string) (*Doc, error)
+37
View File
@@ -28,6 +28,43 @@ type imlReleaseService struct {
releaseRuntime release.IReleaseRuntime `autowired:""`
}
func (s *imlReleaseService) UpdateRelease(ctx context.Context, id string, update *Update) error {
info, err := s.releaseStore.GetByUUID(ctx, id)
if err != nil {
return err
}
if update.Version != nil {
info.Name = *update.Version
}
if update.Remark != nil {
info.Remark = *update.Remark
}
_, err = s.releaseStore.Update(ctx, info)
return err
}
func (s *imlReleaseService) GetRunningList(ctx context.Context, serviceId ...string) ([]*Release, error) {
w := make(map[string]interface{})
if len(serviceId) > 0 {
w["service"] = serviceId
}
list, err := s.releaseRuntime.List(ctx, w)
if err != nil {
return nil, err
}
if len(list) == 0 {
return nil, nil
}
commitIds := utils.SliceToSlice(list, func(o *release.Runtime) string {
return o.Release
})
commits, err := s.releaseStore.List(ctx, map[string]interface{}{
"uuid": commitIds,
})
return utils.SliceToSlice(commits, FromEntity), err
}
func (s *imlReleaseService) GetRunningApiDocCommits(ctx context.Context, serviceIds ...string) ([]string, error) {
w := make(map[string]interface{})
if len(serviceIds) > 0 {
+6
View File
@@ -26,6 +26,12 @@ func FromEntity(e *release.Release) *Release {
}
}
type Update struct {
Version *string
Remark *string
APICount *int64 // API数量
}
type APICommit struct {
Release string
API string
+5 -1
View File
@@ -15,12 +15,15 @@ type IReleaseService interface {
GetRelease(ctx context.Context, id string) (*Release, error)
// CreateRelease 创建发布
CreateRelease(ctx context.Context, service, version, remark string, apiRequestCommit, apisProxyCommits map[string]string, apiDocCommits, serviceDocCommits string, upstreams map[string]map[string]string, strategies map[string]string) (*Release, error)
UpdateRelease(ctx context.Context, id string, update *Update) error
// DeleteRelease 删除发布
DeleteRelease(ctx context.Context, id string) error
GetRunningApiDocCommits(ctx context.Context, serviceIds ...string) ([]string, error)
List(ctx context.Context, service string) ([]*Release, error)
GetReleaseInfos(ctx context.Context, id string) ([]*APICommit, []*APICommit, *APICommit, []*UpstreamCommit, *ServiceCommit, error)
GetCommits(ctx context.Context, id string) ([]*ProjectCommits, error)
GetRunningApiDocCommits(ctx context.Context, serviceIds ...string) ([]string, error)
//GetRunningApiDocCommits(ctx context.Context, serviceIds ...string) ([]string, error)
GetRunningApiProxyCommit(ctx context.Context, service string, apiUUID string) (string, error)
Completeness(partitions []string, apis []string, requestCommits []*commit.Commit[api.Request], proxyCommits []*commit.Commit[api.Proxy], upstreamCommits []*commit.Commit[upstream.Config]) bool
@@ -30,6 +33,7 @@ type IReleaseService interface {
// service: the service name
// Return type(s): *Release, error
GetRunning(ctx context.Context, service string) (*Release, error)
GetRunningList(ctx context.Context, serviceId ...string) ([]*Release, error)
SetRunning(ctx context.Context, service string, id string) error
CheckNewVersion(ctx context.Context, service string, version string) (bool, error)
+81
View File
@@ -0,0 +1,81 @@
package service_overview
import (
"context"
"errors"
"gorm.io/gorm"
"github.com/eolinker/go-common/utils"
"github.com/APIParkLab/APIPark/stores/service"
)
var _ IOverviewService = (*imlOverviewService)(nil)
type imlOverviewService struct {
store service.IOverviewStore `autowired:""`
}
func genUpdateFields(info *service.Overview, update *Update) {
if update.ApiCount != nil {
info.ApiCount = *update.ApiCount
}
if update.ReleaseApiCount != nil {
info.ReleaseApiCount = *update.ReleaseApiCount
}
if update.IsReleased != nil {
info.IsReleased = *update.IsReleased
}
return
}
func (i imlOverviewService) Update(ctx context.Context, serviceId string, update *Update) error {
if update == nil {
return nil
}
info, err := i.store.First(ctx, map[string]interface{}{
"service": serviceId,
})
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
return err
}
info = &service.Overview{
Service: serviceId,
}
genUpdateFields(info, update)
return i.store.Insert(ctx, info)
}
genUpdateFields(info, update)
_, err = i.store.Update(ctx, info)
if err != nil {
return err
}
return nil
}
func (i imlOverviewService) List(ctx context.Context, serviceIds ...string) ([]*Overview, error) {
w := make(map[string]interface{})
if len(serviceIds) > 0 {
w = map[string]interface{}{
"service": serviceIds,
}
}
list, err := i.store.List(ctx, w)
if err != nil {
return nil, err
}
return utils.SliceToSlice(list, FromEntity), nil
}
func (i imlOverviewService) Map(ctx context.Context, serviceIds ...string) (map[string]*Overview, error) {
list, err := i.List(ctx, serviceIds...)
if err != nil {
return nil, err
}
return utils.SliceToMap(list, func(i *Overview) string {
return i.Service
}), nil
}
+27
View File
@@ -0,0 +1,27 @@
package service_overview
import (
"github.com/APIParkLab/APIPark/stores/service"
)
type Overview struct {
Service string
ApiCount int64
ReleaseApiCount int64
IsReleased bool
}
func FromEntity(e *service.Overview) *Overview {
return &Overview{
Service: e.Service,
ApiCount: e.ApiCount,
ReleaseApiCount: e.ReleaseApiCount,
IsReleased: e.IsReleased,
}
}
type Update struct {
ApiCount *int64
ReleaseApiCount *int64
IsReleased *bool
}
+20
View File
@@ -0,0 +1,20 @@
package service_overview
import (
"context"
"reflect"
"github.com/eolinker/go-common/autowire"
)
type IOverviewService interface {
Update(ctx context.Context, serviceId string, update *Update) error
List(ctx context.Context, serviceIds ...string) ([]*Overview, error)
Map(ctx context.Context, serviceIds ...string) (map[string]*Overview, error)
}
func init() {
autowire.Auto[IOverviewService](func() reflect.Value {
return reflect.ValueOf(new(imlOverviewService))
})
}
+3
View File
@@ -229,5 +229,8 @@ func updateHandler(e *service.Service, i *Edit) {
if i.EnableMCP != nil {
e.EnableMCP = *i.EnableMCP
}
//if i.Prefix != nil {
// e.Prefix = *i.Prefix
//}
e.UpdateAt = time.Now()
}
+1
View File
@@ -182,6 +182,7 @@ type Edit struct {
AdditionalConfig *map[string]string
State *int
ApprovalType *ApprovalType
Prefix *string
EnableMCP *bool
}
+16
View File
@@ -35,6 +35,22 @@ func (p *Service) TableName() string {
return "service"
}
type Overview struct {
Id int64 `gorm:"type:BIGINT(20);size:20;not null;auto_increment;primary_key;column:id;comment:主键ID;"`
Service string `gorm:"size:255;not null;column:service;comment:服务ID"`
ApiCount int64 `gorm:"type:BIGINT(20);not null;column:api_count;comment:接口数量"`
ReleaseApiCount int64 `gorm:"type:BIGINT(20);not null;column:release_api_count;comment:已发布接口数量"`
IsReleased bool `gorm:"type:tinyint(1);not null;column:is_released;comment:是否已发布"`
}
func (o *Overview) IdValue() int64 {
return o.Id
}
func (o *Overview) TableName() string {
return "service_overview"
}
type Authorization struct {
Id int64 `gorm:"type:BIGINT(20);size:20;not null;auto_increment;primary_key;column:id;comment:主键ID;"`
UUID string `gorm:"size:36;not null;column:uuid;uniqueIndex:uuid;comment:UUID;"`
+9
View File
@@ -13,6 +13,12 @@ type IServiceStore interface {
type imlServiceStore struct {
store.SearchStore[Service]
}
type IOverviewStore interface {
store.IBaseStore[Overview]
}
type imlOverviewStore struct {
store.Store[Overview]
}
type IServiceTagStore interface {
store.IBaseStore[Tag]
@@ -61,6 +67,9 @@ func init() {
return reflect.ValueOf(new(imlServiceDocStore))
})
autowire.Auto[IOverviewStore](func() reflect.Value {
return reflect.ValueOf(new(imlOverviewStore))
})
autowire.Auto[IServiceModelMappingStore](func() reflect.Value {
return reflect.ValueOf(new(imlServiceModelMappingStore))
})