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
2c871b2e
...
2c871b2ea9695bcc00282fd265ea66ba8123c463
authored
2024-07-19 10:02:38 +0800
by
文鑫
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
更换网关开放平台地址
1 parent
2c1550de
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
10 deletions
src/main/java/com/topdraw/dockingapi/controller/ApiController.java
src/main/java/com/topdraw/dockingapi/entity/DecodeBody.java
src/main/java/com/topdraw/dockingapi/http/UserService.java
src/main/resources/application-prod.yml
src/test/java/com/topdraw/dockingapi/DockingApiApplicationTests.java
src/main/java/com/topdraw/dockingapi/controller/ApiController.java
View file @
2c871b2
...
...
@@ -109,7 +109,7 @@ public class ApiController {
.
map
(
t
->
t
.
getJSONObject
(
"userInfo"
))
.
map
(
t
->
t
.
getString
(
"phone"
))
.
filter
(
StrUtil:
:
isNotBlank
)
.
orElse
Throw
(()
->
new
RuntimeException
(
"获取手机号失败"
)
);
.
orElse
(
""
);
}
...
...
@@ -121,9 +121,12 @@ public class ApiController {
* @return 用户信息
*/
@PostMapping
(
"/user/info"
)
public
DecodeBody
<
Object
>
getUserInfoByAuthCode
(
@RequestBody
JSONObject
data
)
{
public
Object
getUserInfoByAuthCode
(
@RequestBody
JSONObject
data
)
{
//通过authCode获取用户手机号
String
phone
=
getPhone
(
data
.
getString
(
"authCode"
));
if
(
StrUtil
.
isBlank
(
phone
))
{
return
DecodeBody
.
fail
(
"-1"
,
"获取手机号失败"
);
}
//判断手机号是否已经注册
DecodeBody
<
JSONObject
>
register
=
userService
.
checkIsRegisterByPhoneNum
(
MapBuilder
.<
String
,
String
>
create
()
.
put
(
"phoneNum"
,
phone
).
build
());
...
...
src/main/java/com/topdraw/dockingapi/entity/DecodeBody.java
View file @
2c871b2
...
...
@@ -15,4 +15,12 @@ public class DecodeBody<T> {
private
String
errmsg
;
private
T
data
;
public
static
<
T
>
DecodeBody
<
T
>
fail
(
String
errcode
,
String
mesg
)
{
DecodeBody
<
T
>
body
=
new
DecodeBody
<>();
body
.
setErrcode
(
"-1"
);
body
.
setErrmsg
(
mesg
);
return
body
;
}
}
...
...
src/main/java/com/topdraw/dockingapi/http/UserService.java
View file @
2c871b2
...
...
@@ -66,8 +66,7 @@ public interface UserService {
*/
@Post
(
"/cpc-ms-service-user/login/yk/privateLogin"
)
@Encode
(
"${key}"
)
@Decode
(
"${key}"
)
DecodeBody
<
Object
>
privateLogin
(
@EncodeBody
Map
<
String
,
?>
body
);
JSONObject
privateLogin
(
@EncodeBody
Map
<
String
,
?>
body
);
}
...
...
src/main/resources/application-prod.yml
View file @
2c871b2
...
...
@@ -4,7 +4,7 @@ interface:
appIv
:
kfalxHTE3Np6PbQbbZhLnA==
appKey
:
Rd+oZa5bYfhiNK9O0dc0ng==
appSecret
:
x6en8WE3
url
:
http
://23.210.52.243:44207
/gateway/open/api/do
url
:
http
s://open-platform-zw.cqdcg.com
/gateway/open/api/do
forest
:
variables
:
...
...
src/test/java/com/topdraw/dockingapi/DockingApiApplicationTests.java
View file @
2c871b2
...
...
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.digital.szzz.gateway.sdk.bean.GatewayResponse
;
import
com.topdraw.dockingapi.controller.ApiController
;
import
com.topdraw.dockingapi.entity.DecodeBody
;
import
com.topdraw.dockingapi.http.UserService
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
@@ -22,22 +21,22 @@ class DockingApiApplicationTests {
@Test
void
contextLoads
()
{
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"phoneNum"
,
"15636524584"
);
param
.
put
(
"phoneNum"
,
"15636524584"
);
System
.
out
.
println
(
userService
.
checkIsRegisterByPhoneNum
(
param
));
}
@Test
void
testApi
()
{
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"userId"
,
"8798981653125"
);
param
.
put
(
"userId"
,
"8798981653125"
);
GatewayResponse
authCodeByUserId
=
apiController
.
getAuthCodeByUserId
(
param
);
String
data
=
authCodeByUserId
.
getData
();
JSONObject
j
=
JSON
.
parseObject
(
data
,
JSONObject
.
class
);
String
string
=
j
.
getJSONObject
(
"data"
)
.
getString
(
"authCode"
);
JSONObject
p
=
new
JSONObject
();
p
.
put
(
"authCode"
,
string
);
DecodeBody
<
Object
>
userInfoByAuthCode
=
apiController
.
getUserInfoByAuthCode
(
p
);
p
.
put
(
"authCode"
,
string
);
Object
userInfoByAuthCode
=
apiController
.
getUserInfoByAuthCode
(
p
);
System
.
out
.
println
(
"----------------------------------------------------"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
userInfoByAuthCode
));
...
...
Please
register
or
sign in
to post a comment