Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
文鑫
/
docking-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
83a04ac2
...
83a04ac2e0ef3ebd9a8daf8a3a041311979041a5
authored
2024-05-10 14:22:17 +0800
by
文鑫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整请求方式
1 parent
68a0764c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
15 deletions
pom.xml
src/main/java/com/topdraw/dockingapi/controller/ApiController.java
src/main/resources/publish.sh
src/main/resources/static/index.html
pom.xml
View file @
83a04ac
...
...
@@ -64,10 +64,6 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
${spring-boot.version}
</version>
<configuration>
<mainClass>
com.topdraw.dockingapi.DockingApiApplication
</mainClass>
<skip>
true
</skip>
</configuration>
<executions>
<execution>
<id>
repackage
</id>
...
...
src/main/java/com/topdraw/dockingapi/controller/ApiController.java
View file @
83a04ac
...
...
@@ -7,7 +7,8 @@ import com.digital.szzz.gateway.sdk.bean.GatewayResponse;
import
com.topdraw.dockingapi.config.EnvConfiguration
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -51,25 +52,27 @@ public class ApiController {
* 获取jsToken
* @return token信息
*/
@
Ge
tMapping
(
"/js/token"
)
@
Pos
tMapping
(
"/js/token"
)
public
GatewayResponse
getJsApiToken
()
{
String
authCode
=
""
;
String
method
=
"ykb.app.jsapi.getToken"
;
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"appId"
,
appId
);
Map
<
String
,
String
>
headerMap
=
new
HashMap
<>();
return
GatewaySender
.
send
(
url
,
appId
,
method
,
iv
,
appKey
,
appSecretKey
,
param
,
authCode
,
headerMap
,
readTimeout
,
connTimeout
);
return
GatewaySender
.
send
(
url
,
appId
,
method
,
iv
,
appKey
,
appSecretKey
,
param
,
authCode
,
headerMap
,
readTimeout
,
connTimeout
);
}
/**
* 获取authCode
* @param
userId
用户id
* @param
data
用户id
* @return authCode信息
*/
@
Ge
tMapping
(
"/auth/code"
)
public
GatewayResponse
getAuthCodeByUserId
(
String
userId
)
{
@
Pos
tMapping
(
"/auth/code"
)
public
GatewayResponse
getAuthCodeByUserId
(
@RequestBody
JSONObject
data
)
{
String
method
=
"app.ykb.uc.oauth.get"
;
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"appId"
,
appId
);
String
userId
=
data
.
getString
(
"userId"
);
param
.
put
(
"userId"
,
userId
);
param
.
put
(
"forceScopes"
,
new
JSONArray
().
fluentAdd
(
"ykb_user_info"
).
fluentAdd
(
"ykb_divide"
));
Map
<
String
,
String
>
headerMap
=
new
HashMap
<>();
...
...
@@ -78,14 +81,14 @@ public class ApiController {
/**
* 获取用户脱敏信息
* @param
authCode
认证code
* @param
data
认证code
* @return 用户信息
*/
@
Ge
tMapping
(
"/user/info"
)
public
GatewayResponse
getUserInfoByAuthCode
(
String
authCode
)
{
@
Pos
tMapping
(
"/user/info"
)
public
GatewayResponse
getUserInfoByAuthCode
(
@RequestBody
JSONObject
data
)
{
String
method
=
"app.ykb.uc.oauth.userInfo"
;
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"authCode"
,
authCode
);
param
.
put
(
"authCode"
,
data
.
getString
(
"authCode"
)
);
Map
<
String
,
String
>
headerMap
=
new
HashMap
<>();
return
GatewaySender
.
send
(
url
,
appId
,
method
,
iv
,
appKey
,
appSecretKey
,
param
,
authCode
,
headerMap
,
readTimeout
,
connTimeout
);
}
...
...
src/main/resources/publish.sh
0 → 100644
View file @
83a04ac
#!/usr/bin/env bash
pid
=
#进程pid
# 启动jar包的名字
packageName
=
docking-api-0.0.1-SNAPSHOT.jar
counter
=
0
max_attempts
=
10
#检测pid
function
getPid
()
{
echo
"检测状态---------------------------------------------"
pid
=
$(
ps -ef | grep -n
${
packageName
}
| grep -v grep | awk
'{print $2}'
)
if
[
-n
"
${
pid
}
"
]
then
echo
"运行pid:
${
pid
}
"
else
echo
"未运行"
fi
}
#停止程序
function
stop
()
{
getPid
if
[
-n
"
${
pid
}
"
]
then
echo
"停止程序---------------------------------------------"
kill
-15
${
pid
}
while
[
$counter
-lt
$max_attempts
]
;
do
getPid
if
[
${
pid
}
]
then
#stop
sleep 1
else
echo
"停止成功,尝试
${
counter
}
次"
break
fi
((
counter++
))
done
getPid
if
[
${
pid
}
]
then
#stop
echo
"停止失败"
else
echo
"停止完成"
fi
fi
}
#启动程序
function
start
()
{
#启动前,先停止之前的
stop
if
[
-n
"
${
pid
}
"
]
then
echo
"停止程序失败,无法启动"
else
echo
"启动程序---------------------------------------------"
# 删除out输出文件
rm -rf ./console.out
nohup java -Xms500m -Xmx800m -jar ./
$packageName
--spring.profiles.active
=
prod >./console.out 2>&1 &
#查询是否有启动进程
getPid
if
[
${
pid
}
]
then
echo
"已启动"
#nohup日志
tail -n 50 -f ./console.out
else
echo
"启动失败"
fi
fi
}
#启动时带参数,根据参数执行
if
[
${#}
-ge 1
]
then
case
${
1
}
in
"start"
)
start
;;
"restart"
)
start
;;
"stop"
)
stop
;;
*
)
echo
"
${
1
}
无任何操作"
;;
esac
else
echo
"
command如下命令:
start:启动
stop:停止进程
restart:重启
示例命令如:./publish start
"
fi
src/main/resources/static/index.html
View file @
83a04ac
<html>
<html
lang=
"zh"
xmlns=
""
>
<body>
<h1>
hello word!!!
</h1>
<p>
this is a html page
</p>
<div
>
test
<div>
test
<table>
<li>
1
</li>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment