Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-cr20g
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
dsk-cr20g
Commits
27b4ff04
Commit
27b4ff04
authored
May 15, 2023
by
yujicen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加工具类
parent
e1ffc866
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
0 deletions
+133
-0
application-dev.yml
dsk-admin/src/main/resources/application-dev.yml
+5
-0
pom.xml
dsk-common/pom.xml
+15
-0
DskAccClientUtil.java
...main/java/com/dsk/common/utils/http/DskAccClientUtil.java
+113
-0
No files found.
dsk-admin/src/main/resources/application-dev.yml
View file @
27b4ff04
...
...
@@ -188,3 +188,8 @@ xss:
excludes
:
/system/notice
# 匹配链接
urlPatterns
:
/system/*,/monitor/*,/tool/*
dsk-acc
:
open
:
accessKeyId
:
5dat74XI0CMWgoskYW32VkpVCD0MXsC0
accessSecret
:
1a5G4svf71KQHCg13FU3NyoJUrTp8cES
dsk-common/pom.xml
View file @
27b4ff04
...
...
@@ -17,6 +17,17 @@
<dependencies>
<dependency>
<groupId>
com.gitee.dasikong
</groupId>
<artifactId>
dsk-acc-open-sdk-java
</artifactId>
<version>
1.0.4
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
5.7.13
</version>
</dependency>
<!-- Spring框架基本的核心工具 -->
<dependency>
<groupId>
org.springframework
</groupId>
...
...
@@ -125,6 +136,10 @@
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependencies>
...
...
dsk-common/src/main/java/com/dsk/common/utils/http/DskAccClientUtil.java
0 → 100644
View file @
27b4ff04
package
com
.
dsk
.
common
.
utils
.
http
;
import
com.dsk.acc.openapi.api.AccClient
;
import
com.dsk.acc.openapi.client.Config
;
import
com.dsk.acc.openapi.client.util.CommonUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author lc
* @date 2022/2/18 11:41
*/
@Slf4j
@Component
public
class
DskAccClientUtil
{
private
static
String
accessKeyId
;
private
static
String
accessSecret
;
/**
* <b>application/json请求</b>
* @param path 请求路径
* @param bodyMap 参数体
* @return
* */
public
static
Map
<
String
,
Object
>
requestBody
(
String
path
,
Map
<
String
,
Object
>
bodyMap
){
return
request
(
path
,
bodyMap
,
"json"
);
}
/**
* <b>application/x-www-form-urlencoded请求</b>
* @param path 请求路径
* @param bodyMap 参数体
* @return
*/
public
static
Map
<
String
,
Object
>
requestForm
(
String
path
,
Map
<
String
,
Object
>
bodyMap
){
return
request
(
path
,
bodyMap
,
"form"
);
}
/**
* <b>开放平台统一请求</b>
* @param path 请求路径
* @param bodyMap 参数体
* @param reqBodyType 请求格式
* @return
*/
public
static
Map
<
String
,
Object
>
request
(
String
path
,
Map
<
String
,
Object
>
bodyMap
,
String
reqBodyType
){
// try {
//测试沙盒版本
// AccClient.init(new Config(accessKeyId, accessSecret).setEndpoint("sandbox.openapi.jiansheku.com"));
//后期线上版本
AccClient
.
init
(
new
Config
(
accessKeyId
,
accessSecret
));
Map
<
String
,
?>
res
=
AccClient
.
request
(
reqBodyType
,
path
,
bodyMap
);
if
(!
res
.
containsKey
(
"headers"
)
||
!
res
.
containsKey
(
"body"
))
{
throw
new
RuntimeException
(
String
.
format
(
"请求无返回:path=%s"
,
path
));
}
Object
resBody
=
res
.
get
(
"body"
);
if
(
resBody
==
null
)
{
return
null
;
}
return
CommonUtils
.
assertAsMap
(
resBody
);
// } catch (Exception e) {
// log.error("大司空开放平台请求异常 request() ",e);
// throw new RuntimeException(String.format("请求异常:path=%s,err=%s",path,e.getMessage()));
// }
}
public
String
getAccessKeyId
()
{
return
accessKeyId
;
}
@Value
(
"${dsk-acc.open.accessKeyId}"
)
public
void
setAccessKeyId
(
String
accessKeyId
)
{
DskAccClientUtil
.
accessKeyId
=
accessKeyId
;
}
public
String
getAccessSecret
()
{
return
accessSecret
;
}
@Value
(
"${dsk-acc.open.accessSecret}"
)
public
void
setAccessSecret
(
String
accessSecret
)
{
DskAccClientUtil
.
accessSecret
=
accessSecret
;
}
public
static
void
main
(
String
[]
args
)
{
DskAccClientUtil
.
accessKeyId
=
"kUN0ZtZg2H4b1e6z6smXlzo7Enta0bKt"
;
DskAccClientUtil
.
accessSecret
=
"LXmIIEZ9vVkRAqAKFDlYCavtkfveIDPi"
;
// Map<String, Object> map =new HashMap<>();
// map.put("companyId",339447);
Map
<
String
,
Object
>
jsonParam
=
new
HashMap
<
String
,
Object
>();
jsonParam
.
put
(
"companyName"
,
"重庆大司空信息科技有限公司"
);
jsonParam
.
put
(
"creditCode"
,
"91350203MA2YG0RP5A"
);
// Map<String,Object> res = DskAccClientUtil.requestBody(DskAccClientUtil.HTTPURLMAP.get("涉金融领域非法集资企业"), jsonParam);
// Map<String, Object> result = requestForm("/zh/jsk/enterprise/ownership", map);
// System.out.println(JSONUtil.toJsonStr(res));
// List<CompanyInfo> list = multiCriteriaQuery("浙江恒欣设计集团股份有限公司");
// System.out.println(list);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment