Bladeren bron

统一api生成命令编码

Cyrus Zhou 1 jaar geleden
bovenliggende
commit
30219f98e9
1 gewijzigde bestanden met toevoegingen van 38 en 20 verwijderingen
  1. 38 20
      Web/api_build/build.sh

+ 38 - 20
Web/api_build/build.sh

@@ -1,28 +1,46 @@
-#!/bin/sh
+#!/bin/bash
 
-currPath=$(pwd)
-parentPath=$(dirname "$currPath")
-apiServicesPath=${parentPath}/src/api-services/
+dir="$(dirname "$0")"
 
-echo "================================ 生成目录 ${apiServicesPath} ================================"
+moduleName="apiServices"
+apiServicesPath="$dir/../src/api-services/"
+apiUrl="http://localhost:5005/swagger/Default/swagger.json"
 
-# 判断目录是否存在
-if test -d "$apiServicesPath"; then
-  echo "================================ 删除目录 api-services ================================"
-  rm -rf "${apiServicesPath}"
+case "$1" in
+    approvalFlow)
+        moduleName="approvalFlow"
+        apiServicesPath="$dir/../src/api-plugins/approvalFlow/"
+        apiUrl="http://localhost:5005/swagger/ApprovalFlow/swagger.json"
+        ;;
+    dingTalk)
+        moduleName="dingTalk"
+        apiServicesPath="$dir/../src/api-plugins/dingTalk/"
+        apiUrl="http://localhost:5005/swagger/DingTalk/swagger.json"
+        ;;
+    goView)
+        moduleName="goView"
+        apiServicesPath="$dir/../src/api-plugins/goView/"
+        apiUrl="http://localhost:5005/swagger/GoView/swagger.json"
+        ;;
+esac
+
+if [ -d "$apiServicesPath" ]; then
+    echo "================================ 删除目录 $apiServicesPath ================================"
+    rm -rf "$apiServicesPath"
 fi
 
-echo "================================ 开始生成 api-services ================================"
+echo "================================ 开始生成 $moduleName ================================"
 
-java -jar "${currPath}"/swagger-codegen-cli.jar generate -i http://localhost:5005/swagger/All%20Groups/swagger.json -l typescript-axios -o "${apiServicesPath}"
+java -jar "$dir/swagger-codegen-cli.jar" generate -i "$apiUrl" -l typescript-axios -o "$apiServicesPath"
 
-rm -rf "${apiServicesPath}".swagger-codegen
-rm -f "${apiServicesPath}".gitignore
-rm -f "${apiServicesPath}".npmignore
-rm -f "${apiServicesPath}".swagger-codegen-ignore
-rm -f "${apiServicesPath}"git_push.sh
-rm -f "${apiServicesPath}"package.json
-rm -f "${apiServicesPath}"README.md
-rm -f "${apiServicesPath}"tsconfig.json
+# 删除不必要的文件和文件夹
+rm -rf "$apiServicesPath/.swagger-codegen"
+rm -f "$apiServicesPath/.gitignore"
+rm -f "$apiServicesPath/.npmignore"
+rm -f "$apiServicesPath/.swagger-codegen-ignore"
+rm -f "$apiServicesPath/git_push.sh"
+rm -f "$apiServicesPath/package.json"
+rm -f "$apiServicesPath/README.md"
+rm -f "$apiServicesPath/tsconfig.json"
 
-echo "================================ 生成结束 ================================"
+echo "================================ 生成结束 ================================"