调整请求方式
Showing
4 changed files
with
130 additions
and
14 deletions
| ... | @@ -64,10 +64,6 @@ | ... | @@ -64,10 +64,6 @@ |
| 64 | <groupId>org.springframework.boot</groupId> | 64 | <groupId>org.springframework.boot</groupId> |
| 65 | <artifactId>spring-boot-maven-plugin</artifactId> | 65 | <artifactId>spring-boot-maven-plugin</artifactId> |
| 66 | <version>${spring-boot.version}</version> | 66 | <version>${spring-boot.version}</version> |
| 67 | <configuration> | ||
| 68 | <mainClass>com.topdraw.dockingapi.DockingApiApplication</mainClass> | ||
| 69 | <skip>true</skip> | ||
| 70 | </configuration> | ||
| 71 | <executions> | 67 | <executions> |
| 72 | <execution> | 68 | <execution> |
| 73 | <id>repackage</id> | 69 | <id>repackage</id> | ... | ... |
| ... | @@ -7,7 +7,8 @@ import com.digital.szzz.gateway.sdk.bean.GatewayResponse; | ... | @@ -7,7 +7,8 @@ import com.digital.szzz.gateway.sdk.bean.GatewayResponse; |
| 7 | import com.topdraw.dockingapi.config.EnvConfiguration; | 7 | import com.topdraw.dockingapi.config.EnvConfiguration; |
| 8 | import lombok.RequiredArgsConstructor; | 8 | import lombok.RequiredArgsConstructor; |
| 9 | import lombok.extern.slf4j.Slf4j; | 9 | import lombok.extern.slf4j.Slf4j; |
| 10 | import org.springframework.web.bind.annotation.GetMapping; | 10 | import org.springframework.web.bind.annotation.PostMapping; |
| 11 | import org.springframework.web.bind.annotation.RequestBody; | ||
| 11 | import org.springframework.web.bind.annotation.RequestMapping; | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
| 12 | import org.springframework.web.bind.annotation.RestController; | 13 | import org.springframework.web.bind.annotation.RestController; |
| 13 | 14 | ||
| ... | @@ -51,8 +52,9 @@ public class ApiController { | ... | @@ -51,8 +52,9 @@ public class ApiController { |
| 51 | * 获取jsToken | 52 | * 获取jsToken |
| 52 | * @return token信息 | 53 | * @return token信息 |
| 53 | */ | 54 | */ |
| 54 | @GetMapping("/js/token") | 55 | @PostMapping("/js/token") |
| 55 | public GatewayResponse getJsApiToken() { | 56 | public GatewayResponse getJsApiToken() { |
| 57 | String authCode = ""; | ||
| 56 | String method = "ykb.app.jsapi.getToken"; | 58 | String method = "ykb.app.jsapi.getToken"; |
| 57 | JSONObject param = new JSONObject(); | 59 | JSONObject param = new JSONObject(); |
| 58 | param.put("appId", appId); | 60 | param.put("appId", appId); |
| ... | @@ -62,14 +64,15 @@ public class ApiController { | ... | @@ -62,14 +64,15 @@ public class ApiController { |
| 62 | 64 | ||
| 63 | /** | 65 | /** |
| 64 | * 获取authCode | 66 | * 获取authCode |
| 65 | * @param userId 用户id | 67 | * @param data 用户id |
| 66 | * @return authCode信息 | 68 | * @return authCode信息 |
| 67 | */ | 69 | */ |
| 68 | @GetMapping("/auth/code") | 70 | @PostMapping("/auth/code") |
| 69 | public GatewayResponse getAuthCodeByUserId(String userId) { | 71 | public GatewayResponse getAuthCodeByUserId(@RequestBody JSONObject data) { |
| 70 | String method = "app.ykb.uc.oauth.get"; | 72 | String method = "app.ykb.uc.oauth.get"; |
| 71 | JSONObject param = new JSONObject(); | 73 | JSONObject param = new JSONObject(); |
| 72 | param.put("appId", appId); | 74 | param.put("appId", appId); |
| 75 | String userId = data.getString("userId"); | ||
| 73 | param.put("userId", userId); | 76 | param.put("userId", userId); |
| 74 | param.put("forceScopes", new JSONArray().fluentAdd("ykb_user_info").fluentAdd("ykb_divide")); | 77 | param.put("forceScopes", new JSONArray().fluentAdd("ykb_user_info").fluentAdd("ykb_divide")); |
| 75 | Map<String, String> headerMap = new HashMap<>(); | 78 | Map<String, String> headerMap = new HashMap<>(); |
| ... | @@ -78,14 +81,14 @@ public class ApiController { | ... | @@ -78,14 +81,14 @@ public class ApiController { |
| 78 | 81 | ||
| 79 | /** | 82 | /** |
| 80 | * 获取用户脱敏信息 | 83 | * 获取用户脱敏信息 |
| 81 | * @param authCode 认证code | 84 | * @param data 认证code |
| 82 | * @return 用户信息 | 85 | * @return 用户信息 |
| 83 | */ | 86 | */ |
| 84 | @GetMapping("/user/info") | 87 | @PostMapping("/user/info") |
| 85 | public GatewayResponse getUserInfoByAuthCode(String authCode) { | 88 | public GatewayResponse getUserInfoByAuthCode(@RequestBody JSONObject data) { |
| 86 | String method = "app.ykb.uc.oauth.userInfo"; | 89 | String method = "app.ykb.uc.oauth.userInfo"; |
| 87 | JSONObject param = new JSONObject(); | 90 | JSONObject param = new JSONObject(); |
| 88 | param.put("authCode", authCode); | 91 | param.put("authCode", data.getString("authCode")); |
| 89 | Map<String, String> headerMap = new HashMap<>(); | 92 | Map<String, String> headerMap = new HashMap<>(); |
| 90 | return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout); | 93 | return GatewaySender.send(url, appId, method, iv, appKey, appSecretKey, param, authCode, headerMap, readTimeout, connTimeout); |
| 91 | } | 94 | } | ... | ... |
src/main/resources/publish.sh
0 → 100644
| 1 | #!/usr/bin/env bash | ||
| 2 | |||
| 3 | pid= #进程pid | ||
| 4 | # 启动jar包的名字 | ||
| 5 | packageName=docking-api-0.0.1-SNAPSHOT.jar | ||
| 6 | |||
| 7 | counter=0 | ||
| 8 | |||
| 9 | max_attempts=10 | ||
| 10 | |||
| 11 | #检测pid | ||
| 12 | function getPid() | ||
| 13 | { | ||
| 14 | echo "检测状态---------------------------------------------" | ||
| 15 | pid=$(ps -ef | grep -n ${packageName} | grep -v grep | awk '{print $2}') | ||
| 16 | if [ -n "${pid}" ] | ||
| 17 | then | ||
| 18 | echo "运行pid:${pid}" | ||
| 19 | else | ||
| 20 | echo "未运行" | ||
| 21 | fi | ||
| 22 | } | ||
| 23 | |||
| 24 | #停止程序 | ||
| 25 | function stop() | ||
| 26 | { | ||
| 27 | getPid | ||
| 28 | if [ -n "${pid}" ] | ||
| 29 | then | ||
| 30 | echo "停止程序---------------------------------------------" | ||
| 31 | kill -15 ${pid} | ||
| 32 | while [ $counter -lt $max_attempts ]; do | ||
| 33 | getPid | ||
| 34 | if [ ${pid} ] | ||
| 35 | then | ||
| 36 | #stop | ||
| 37 | sleep 1 | ||
| 38 | else | ||
| 39 | echo "停止成功,尝试${counter}次" | ||
| 40 | break | ||
| 41 | fi | ||
| 42 | ((counter++)) | ||
| 43 | done | ||
| 44 | getPid | ||
| 45 | if [ ${pid} ] | ||
| 46 | then | ||
| 47 | #stop | ||
| 48 | echo "停止失败" | ||
| 49 | else | ||
| 50 | echo "停止完成" | ||
| 51 | fi | ||
| 52 | fi | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | #启动程序 | ||
| 58 | function start() | ||
| 59 | { | ||
| 60 | #启动前,先停止之前的 | ||
| 61 | stop | ||
| 62 | if [ -n "${pid}" ] | ||
| 63 | then | ||
| 64 | echo "停止程序失败,无法启动" | ||
| 65 | else | ||
| 66 | echo "启动程序---------------------------------------------" | ||
| 67 | # 删除out输出文件 | ||
| 68 | rm -rf ./console.out | ||
| 69 | nohup java -Xms500m -Xmx800m -jar ./$packageName --spring.profiles.active=prod >./console.out 2>&1 & | ||
| 70 | #查询是否有启动进程 | ||
| 71 | getPid | ||
| 72 | if [ ${pid} ] | ||
| 73 | then | ||
| 74 | echo "已启动" | ||
| 75 | #nohup日志 | ||
| 76 | tail -n 50 -f ./console.out | ||
| 77 | else | ||
| 78 | echo "启动失败" | ||
| 79 | fi | ||
| 80 | fi | ||
| 81 | } | ||
| 82 | |||
| 83 | #启动时带参数,根据参数执行 | ||
| 84 | if [ ${#} -ge 1 ] | ||
| 85 | then | ||
| 86 | case ${1} in | ||
| 87 | "start") | ||
| 88 | start | ||
| 89 | ;; | ||
| 90 | "restart") | ||
| 91 | start | ||
| 92 | ;; | ||
| 93 | "stop") | ||
| 94 | stop | ||
| 95 | ;; | ||
| 96 | *) | ||
| 97 | echo "${1}无任何操作" | ||
| 98 | ;; | ||
| 99 | esac | ||
| 100 | else | ||
| 101 | echo " | ||
| 102 | command如下命令: | ||
| 103 | start:启动 | ||
| 104 | stop:停止进程 | ||
| 105 | restart:重启 | ||
| 106 | 示例命令如:./publish start | ||
| 107 | " | ||
| 108 | fi |
| 1 | <html> | 1 | <html lang="zh" xmlns=""> |
| 2 | <body> | 2 | <body> |
| 3 | <h1>hello word!!!</h1> | 3 | <h1>hello word!!!</h1> |
| 4 | <p>this is a html page</p> | 4 | <p>this is a html page</p> |
| 5 | <div > | ||
| 6 | test | ||
| 7 | <div> | ||
| 8 | test | ||
| 9 | <table> | ||
| 10 | <li>1</li> | ||
| 11 | </table> | ||
| 12 | </div> | ||
| 13 | </div> | ||
| 5 | </body> | 14 | </body> |
| 6 | </html> | 15 | </html> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment