feat: 新增admin-center的poa api-docs 的部署镜像
diff --git a/poa-api-docs/Dockerfile b/poa-api-docs/Dockerfile
new file mode 100644
index 0000000..bcb710c
--- /dev/null
+++ b/poa-api-docs/Dockerfile
@@ -0,0 +1,18 @@
+FROM alpine:latest
+
+# 安装toolkit
+RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
+RUN apk add --update curl && rm -rf /var/cache/apk/*
+
+RUN mkdir -p /root/poa-api-docs
+
+COPY api-docs/ /root/poa-api-docs/
+
+COPY exec.sh /root/poa-api-docs/
+RUN chmod +x /root/poa-api-docs/exec.sh
+
+COPY docker-entrypoint.sh /root/poa-api-docs/
+RUN chmod +x /root/poa-api-docs/docker-entrypoint.sh
+
+ENTRYPOINT ["/root/poa-api-docs/docker-entrypoint.sh"]
+CMD ["app"]
diff --git a/poa-api-docs/api-docs/admin-center-poa.v1.yaml b/poa-api-docs/api-docs/admin-center-poa.v1.yaml
new file mode 100644
index 0000000..d44c849
--- /dev/null
+++ b/poa-api-docs/api-docs/admin-center-poa.v1.yaml
@@ -0,0 +1,475 @@
+# admin-center-poa.v1.yaml
+#
+# 1. 创建服务
+# curl -i -s -X POST 'https://poa-sa.dev.supwisdom.com/v1/services' -H 'Content-Type: application/json' -d '{"id": "admincenter", "origin": "http://admin-center-poa-svc.admin-center.svc.cluster.local:8080", "name": "管理中心", "description": "管理中心"}'
+#
+# 2. 创建版本
+# curl -i -s -X POST 'https://poa-sa.dev.supwisdom.com/v1/services/admincenter/apiVersions/v1'
+#
+# 3. 上传OAS Yaml
+# curl -i -s -X POST 'https://poa-sa.dev.supwisdom.com/v1/services/admincenter/apiVersions/v1/apiSpecs' -H 'Content-Type: application/yaml' --data-binary @admin-center-poa.v1.yaml
+#
+# 4. 发布版本
+# curl -i -s -X POST 'https://poa-sa.dev.supwisdom.com/v1/services/admincenter/apiVersions/v1/publish'
+#
+openapi: 3.0.2
+info:
+ title: Admin Center Platform Open APIs
+ version: v1
+ description: '管理中心 - 平台开放接口'
+servers:
+ - url: '${POA_SERVER_URL}/apis/admincenter/v1'
+ description: '正式环境'
+tags:
+ - name: Menu
+ description: '管理中心菜单'
+ - name: Permission
+ description: '云平台权限'
+paths:
+
+ '/menus/accountName/{accountName}/menus':
+ get:
+ summary: 获取用户帐号可访问的菜单
+ description: 获取用户帐号可访问的菜单
+ operationId: loadAccountMenus
+ tags:
+ - Menu
+ security:
+ - oauth2:
+ - "admincenter:v1:readMenu"
+ parameters:
+ - name: accountName
+ in: path
+ required: true
+ description: 用户名
+ schema:
+ type: string
+ # - name: applicationId
+ # in: query
+ # required: true
+ # description: 应用标识
+ # schema:
+ # type: string
+ responses:
+ '200':
+ description: 菜单列表
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/GrantedMenusResponse'
+ default:
+ $ref: '#/components/responses/DefaultErrorResponse'
+
+
+ '/permissions/accountName/{accountName}/permissions':
+ get:
+ summary: 获取用户帐号拥有的权限
+ description: 获取用户帐号拥有的权限
+ operationId: loadAccountPermissions
+ tags:
+ - Permission
+ security:
+ - oauth2:
+ - "admincenter:v1:readAdminCenterPermission"
+ parameters:
+ - name: accountName
+ in: path
+ required: true
+ description: 用户名
+ schema:
+ type: string
+ - name: applicationId
+ in: query
+ required: false
+ description: 应用标识
+ schema:
+ type: string
+ responses:
+ '200':
+ description: 权限(菜单、操作、资源)列表
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/GrantedPermissionsResponse'
+ default:
+ $ref: '#/components/responses/DefaultErrorResponse'
+
+
+ '/permissions/accountName/{accountName}/menus':
+ get:
+ summary: 获取用户帐号拥有的菜单
+ description: 获取用户帐号拥有的菜单
+ operationId: loadAccountPermissionMenus
+ tags:
+ - Permission
+ security:
+ - oauth2:
+ - "admincenter:v1:readAdminCenterPermission"
+ parameters:
+ - name: accountName
+ in: path
+ required: true
+ description: 用户名
+ schema:
+ type: string
+ - name: applicationId
+ in: query
+ required: false
+ description: 应用标识
+ schema:
+ type: string
+ responses:
+ '200':
+ description: 权限(菜单)列表
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/GrantedMenusResponse'
+ default:
+ $ref: '#/components/responses/DefaultErrorResponse'
+
+ '/permissions/accountName/{accountName}/operations':
+ get:
+ summary: 获取用户帐号拥有的操作
+ description: 获取用户帐号拥有的操作
+ operationId: loadAccountPermissionOperations
+ tags:
+ - Permission
+ security:
+ - oauth2:
+ - "admincenter:v1:readAdminCenterPermission"
+ parameters:
+ - name: accountName
+ in: path
+ required: true
+ description: 用户名
+ schema:
+ type: string
+ - name: applicationId
+ in: query
+ required: false
+ description: 应用标识
+ schema:
+ type: string
+ responses:
+ '200':
+ description: 权限(操作)列表
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/GrantedOperationsResponse'
+ default:
+ $ref: '#/components/responses/DefaultErrorResponse'
+
+ '/permissions/accountName/{accountName}/resources':
+ get:
+ summary: 获取用户帐号拥有的资源
+ description: 获取用户帐号拥有的资源
+ operationId: loadAccountPermissionResources
+ tags:
+ - Permission
+ security:
+ - oauth2:
+ - "admincenter:v1:readAdminCenterPermission"
+ parameters:
+ - name: accountName
+ in: path
+ required: true
+ description: 用户名
+ schema:
+ type: string
+ - name: applicationId
+ in: query
+ required: false
+ description: 应用标识
+ schema:
+ type: string
+ responses:
+ '200':
+ description: 菜单列表
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/GrantedResourcesResponse'
+ default:
+ $ref: '#/components/responses/DefaultErrorResponse'
+
+
+components:
+
+ # Security Schemes
+
+ securitySchemes:
+ oauth2:
+ type: oauth2
+ flows:
+ clientCredentials:
+ tokenUrl: ${POA_SERVER_URL}/oauth2/token
+ scopes:
+ "admincenter:v1:readMenu": "读取后台菜单"
+ "admincenter:v1:readAdminCenterPermission": "读取权限"
+
+ responses:
+ 'ErrorResponse400':
+ description: unexpected error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorResponse'
+
+ DefaultErrorResponse:
+ description: unexpected error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/ErrorResponse'
+
+ schemas:
+
+ # Error
+
+ ErrorResponse:
+ title: '异常响应'
+ required:
+ - code
+ - message
+ properties:
+ code:
+ title: 异常代码
+ type: integer
+ format: int32
+ default: -1
+ message:
+ title: 异常信息
+ type: string
+ default: "未知错误"
+
+ # DTO
+
+ GrantedMenu:
+ title: DTO - 菜单数据
+ type: object
+ properties:
+ id:
+ title: ID
+ type: string
+ code:
+ title: 代码
+ type: string
+ name:
+ title: 名称
+ type: string
+ memo:
+ title: 备注
+ type: string
+ status:
+ title: 状态(1 启用,0 停用)
+ type: string
+ applicationId:
+ title: 系统ID
+ type: string
+ parentId:
+ title: 父级ID
+ type: string
+ icon:
+ title: 菜单图标
+ type: string
+ origin:
+ title: 来源系统
+ type: string
+ url:
+ title: URL地址
+ type: string
+ order:
+ title: 排序
+ type: integer
+ format: int32
+
+ GrantedOperation:
+ title: DTO - 操作数据
+ type: object
+ properties:
+ id:
+ title: ID
+ type: string
+ code:
+ title: 代码
+ type: string
+ name:
+ title: 名称
+ type: string
+ memo:
+ title: 备注
+ type: string
+ status:
+ title: 状态(1 启用,0 停用)
+ type: string
+ applicationId:
+ title: 系统ID
+ type: string
+ parentId:
+ title: 父级ID
+ type: string
+ order:
+ title: 排序
+ type: integer
+ format: int32
+
+ GrantedResource:
+ title: DTO - 资源数据
+ type: object
+ properties:
+ id:
+ title: ID
+ type: string
+ code:
+ title: 代码
+ type: string
+ name:
+ title: 名称
+ type: string
+ memo:
+ title: 备注
+ type: string
+ status:
+ title: 状态(1 启用,0 停用)
+ type: string
+ applicationId:
+ title: 系统ID
+ type: string
+ origin:
+ title: 来源系统
+ type: string
+ method:
+ title: 请求方式(GET、POST、PUT、DELETE 等)
+ type: string
+ path:
+ title: 请求路径
+ type: string
+ access:
+ title: 访问规则(匿名访问anonymous、认证访问authenticate、授权访问authorize、允许所有permitAll、拒绝所有denyAll)
+ type: string
+
+
+ # Request VO
+
+
+ # Response Data
+
+ GrantedMenusResponseData:
+ title: 响应数据 - 菜单列表
+ type: object
+ properties:
+ menus:
+ title: 菜单列表
+ type: array
+ items:
+ $ref: '#/components/schemas/GrantedMenu'
+
+ GrantedOperationsResponseData:
+ title: 响应数据 - 操作列表
+ type: object
+ properties:
+ operations:
+ title: 操作列表
+ type: array
+ items:
+ $ref: '#/components/schemas/GrantedOperation'
+
+ GrantedResourcesResponseData:
+ title: 响应数据 - 资源列表
+ type: object
+ properties:
+ resource:
+ title: 资源列表
+ type: array
+ items:
+ $ref: '#/components/schemas/GrantedResource'
+
+ GrantedPermissionsResponseData:
+ title: 响应数据 - 权限列表
+ type: object
+ properties:
+ menus:
+ title: 菜单列表
+ type: array
+ items:
+ $ref: '#/components/schemas/GrantedMenu'
+ operations:
+ title: 操作列表
+ type: array
+ items:
+ $ref: '#/components/schemas/GrantedOperation'
+ resource:
+ title: 资源列表
+ type: array
+ items:
+ $ref: '#/components/schemas/GrantedResource'
+
+
+ # Response VO
+
+ ApiDataResponse:
+ title: 响应
+ properties:
+ code:
+ title: 响应代码
+ type: integer
+ format: int32
+ default: 0
+ message:
+ title: 响应信息
+ type: string
+ data:
+ title: 响应数据
+ type: object
+
+ DefaultApiDataResponse:
+ allOf:
+ - $ref: '#/components/schemas/ApiDataResponse'
+ - type: object
+ title: 响应
+ properties:
+ data:
+ title: 响应数据
+ type: object
+
+ GrantedMenusResponse:
+ allOf:
+ - $ref: '#/components/schemas/DefaultApiDataResponse'
+ - type: object
+ title: 响应
+ properties:
+ data:
+ allOf:
+ - $ref: '#/components/schemas/GrantedMenusResponseData'
+
+ GrantedOperationsResponse:
+ allOf:
+ - $ref: '#/components/schemas/DefaultApiDataResponse'
+ - type: object
+ title: 响应
+ properties:
+ data:
+ allOf:
+ - $ref: '#/components/schemas/GrantedOperationsResponseData'
+
+ GrantedResourcesResponse:
+ allOf:
+ - $ref: '#/components/schemas/DefaultApiDataResponse'
+ - type: object
+ title: 响应
+ properties:
+ data:
+ allOf:
+ - $ref: '#/components/schemas/GrantedResourcesResponseData'
+
+ GrantedPermissionsResponse:
+ allOf:
+ - $ref: '#/components/schemas/DefaultApiDataResponse'
+ - type: object
+ title: 响应
+ properties:
+ data:
+ allOf:
+ - $ref: '#/components/schemas/GrantedPermissionsResponseData'
diff --git a/poa-api-docs/docker-build.sh b/poa-api-docs/docker-build.sh
new file mode 100755
index 0000000..d4a7865
--- /dev/null
+++ b/poa-api-docs/docker-build.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+CMD_NAME=`basename $0`
+COMMAND=$1
+
+IMAGE_SERVER="harbor.supwisdom.com"
+IMAGE_PREFIX="admin-center"
+
+NAME="poa-api-docs-installer"
+VERSION="1.1.0-SNAPSHOT"
+
+
+function build
+{
+ local variant=$1
+ if [ -z "$variant" ]; then
+ local variant_suffix=""
+ else
+ local variant_suffix="-$variant"
+ fi
+
+ docker build --force-rm --squash --pull -t ${IMAGE_SERVER}/${IMAGE_PREFIX}/${NAME}:${VERSION}$variant_suffix --file Dockerfile .;
+}
+
+function push
+{
+ local variant=$1
+ if [ -z "$variant" ]; then
+ local variant_suffix=""
+ else
+ local variant_suffix="-$variant"
+ fi
+ docker push ${IMAGE_SERVER}/${IMAGE_PREFIX}/${NAME}:${VERSION}$variant_suffix;
+}
+
+function usage
+{
+ echo "Usage: ${CMD_NAME} build|push [variant: DEV | TEST | STAGING | RELEASE]"
+}
+
+case $COMMAND in
+ 'build')
+ build
+ ;;
+ 'push')
+ push
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+esac
+
+exit 0
\ No newline at end of file
diff --git a/poa-api-docs/docker-entrypoint.sh b/poa-api-docs/docker-entrypoint.sh
new file mode 100644
index 0000000..5eabe41
--- /dev/null
+++ b/poa-api-docs/docker-entrypoint.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+replace_file() {
+ local file="$1"
+ local key="$2"
+ local value="$3"
+ sed -i "s;\${$key};$value;" $file
+}
+
+# 如果第一个参数是app,那么就启动执行nginx
+if [ "$1" = 'app' ]; then
+
+ if [ -n "$POA_SERVER_URL" ]; then
+ replace_file "/root/poa-api-docs/admin-center-poa.v1.yaml" "POA_SERVER_URL" "$POA_SERVER_URL"
+ fi
+
+ set -ex;
+ exec /root/poa-api-docs/exec.sh
+else
+ set -ex;
+ exec "$@"
+fi
\ No newline at end of file
diff --git a/poa-api-docs/exec.sh b/poa-api-docs/exec.sh
new file mode 100644
index 0000000..1e48985
--- /dev/null
+++ b/poa-api-docs/exec.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+cd /root/poa-api-docs
+
+ls -al
+
+
+# admin-center-poa.v1.yaml
+
+curl -i -s -X DELETE 'http://poa-sa-svc.poa.svc.cluster.local:8443/v1/services/admincenter'
+
+# 1. 创建服务
+curl -i -s -X POST 'http://poa-sa-svc.poa.svc.cluster.local:8443/v1/services' -H 'Content-Type: application/json' -d '{"id": "admincenter", "origin": "http://admin-center-poa-svc.admin-center.svc.cluster.local:8080", "name": "管理中心", "description": "管理中心"}'
+
+# 2. 创建版本
+curl -i -s -X POST 'http://poa-sa-svc.poa.svc.cluster.local:8443/v1/services/admincenter/apiVersions/v1'
+
+# 3. 上传OAS Yaml
+curl -i -s -X POST 'http://poa-sa-svc.poa.svc.cluster.local:8443/v1/services/admincenter/apiVersions/v1/apiSpecs' -H 'Content-Type: application/yaml' --data-binary @admin-center-poa.v1.yaml
+
+# 4. 发布版本
+curl -i -s -X POST 'http://poa-sa-svc.poa.svc.cluster.local:8443/v1/services/admincenter/apiVersions/v1/publish'