Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
FrontEndProcessor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CrossProvincialPlatform
FrontEndProcessor
Commits
ffd08ffa
Commit
ffd08ffa
authored
Sep 28, 2023
by
张俊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提取公共方法
parent
e037f7bb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
93 deletions
+19
-93
src/main/java/net/cdkj/gjj/adapter/controller/CacheDemoController.java
.../net/cdkj/gjj/adapter/controller/CacheDemoController.java
+3
-6
src/main/java/net/cdkj/gjj/adapter/controller/ProvidentFundServicesController.java
...j/adapter/controller/ProvidentFundServicesController.java
+3
-2
src/main/java/net/cdkj/gjj/adapter/controller/TokenAcquisitionController.java
...kj/gjj/adapter/controller/TokenAcquisitionController.java
+13
-84
src/main/java/net/cdkj/gjj/adapter/domain/UnitAccountOpeningInformation.java
...dkj/gjj/adapter/domain/UnitAccountOpeningInformation.java
+0
-1
No files found.
src/main/java/net/cdkj/gjj/adapter/controller/CacheDemoController.java
View file @
ffd08ffa
package
net.cdkj.gjj.adapter.controller
;
package
net.cdkj.gjj.adapter.controller
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
net.cdkj.gjj.adapter.domain.Json
;
import
net.cdkj.gjj.adapter.domain.Json
;
import
net.cdkj.gjj.adapter.domain.TimeExpiredPoolCache
;
import
net.cdkj.gjj.adapter.domain.TimeExpiredPoolCache
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
java.io.*
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
/**
/**
* Cache设置token缓存和获取类
* Cache设置token缓存和获取类
...
...
src/main/java/net/cdkj/gjj/adapter/controller/ProvidentFundServicesController.java
View file @
ffd08ffa
...
@@ -11,8 +11,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -11,8 +11,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Properties
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
unzipString
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
unzipString
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
zipString
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
zipString
;
...
...
src/main/java/net/cdkj/gjj/adapter/controller/TokenAcquisitionController.java
View file @
ffd08ffa
...
@@ -2,19 +2,17 @@ package net.cdkj.gjj.adapter.controller;
...
@@ -2,19 +2,17 @@ package net.cdkj.gjj.adapter.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
net.cdkj.gjj.adapter.domain.HttpUtil
;
import
net.cdkj.gjj.adapter.domain.PropertyUtil
;
import
net.cdkj.gjj.adapter.domain.PropertyUtil
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.io.IOException
;
import
java.util.Properties
;
import
java.util.zip.GZIPInputStream
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.*;
import
java.util.Properties
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
unzipString
;
import
static
net
.
cdkj
.
gjj
.
adapter
.
domain
.
GzipUtil
.
zipString
;
/**
/**
...
@@ -29,9 +27,9 @@ public class TokenAcquisitionController {
...
@@ -29,9 +27,9 @@ public class TokenAcquisitionController {
*/
*/
@ResponseBody
@ResponseBody
@PostMapping
(
"test"
)
@PostMapping
(
"test"
)
public
static
void
test
(){
public
static
void
test
()
{
Properties
prop
=
PropertyUtil
.
getConfig
(
"application.properties"
);
Properties
prop
=
PropertyUtil
.
getConfig
(
"application.properties"
);
System
.
out
.
println
(
PropertyUtil
.
getPropValue
(
prop
,
"tokenurl"
));
System
.
out
.
println
(
PropertyUtil
.
getPropValue
(
prop
,
"tokenurl"
));
}
}
/**
/**
...
@@ -51,77 +49,8 @@ public class TokenAcquisitionController {
...
@@ -51,77 +49,8 @@ public class TokenAcquisitionController {
jsonObject
.
put
(
"userid"
,
"gjj"
);
jsonObject
.
put
(
"userid"
,
"gjj"
);
String
str
=
jsonObject
.
toString
();
String
str
=
jsonObject
.
toString
();
System
.
out
.
println
(
"鉴权参数zip压缩处理之前要发送给第三方的报文:"
+
str
);
System
.
out
.
println
(
"鉴权参数zip压缩处理之前要发送给第三方的报文:"
+
str
);
StringBuffer
sb
=
new
StringBuffer
();
String
tokenurl
=
PropertyUtil
.
getPropValue
(
prop
,
"tokenurl"
);
HttpURLConnection
conn
=
null
;
return
HttpUtil
.
sendPost
(
tokenurl
,
str
);
OutputStream
out
=
null
;
try
{
// 创建url 资源
URL
url
=
new
URL
(
PropertyUtil
.
getPropValue
(
prop
,
"tokenurl"
));
//正式环境第三方地址
// URL url = new URL("https://scjg.hubei.gov.cn/sjzt/api/oauth2/token");//测试环境第三方地址
// URL url = new URL("http://127.0.0.1:8080/FrontEndProcessor/FrontEndProcessor/token2");//本地环境模拟第三方地址
// 创建http 连接
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
// 设置允许输出
conn
.
setDoOutput
(
true
);
// 设置允许输入
conn
.
setDoInput
(
true
);
// 设置不使用缓存
conn
.
setUseCaches
(
false
);
// 设置传递方式
conn
.
setRequestMethod
(
"POST"
);
// 设置维持长连接
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"accept"
,
"*/*"
);
conn
.
setRequestProperty
(
"Accept-Encoding"
,
"gzip, deflate, br"
);
// 设置文件类型:
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
// 设置文件字符集:
conn
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
// 转换为字节数组
byte
[]
data
=
(
str
).
getBytes
(
"UTF-8"
);
// 设置文件长度
conn
.
setRequestProperty
(
"Content-Length"
,
String
.
valueOf
(
data
.
length
));
// 开始连接请求
conn
.
connect
();
//创建写入流,写入请求的字符串
out
=
new
DataOutputStream
(
conn
.
getOutputStream
());
out
.
write
(
data
);
// 请求返回的状态
if
(
HttpURLConnection
.
HTTP_OK
==
conn
.
getResponseCode
())
{
// // 请求返回的数据
InputStream
is
=
conn
.
getInputStream
();
// String readLine = new String();
// BufferedReader responseReader = new BufferedReader(new InputStreamReader(is,"UTF-8"));
// while ((readLine = responseReader.readLine()) != null) {
// sb.append(readLine);
// }
GZIPInputStream
gzis
=
new
GZIPInputStream
(
is
);
InputStreamReader
reader
=
new
InputStreamReader
(
gzis
);
BufferedReader
br
=
new
BufferedReader
(
reader
);
String
temp
;
while
((
temp
=
br
.
readLine
())
!=
null
)
{
sb
.
append
(
temp
);
}
System
.
out
.
println
(
"鉴权参数第三方返回的zip解压缩之后的报文:"
+
sb
.
toString
());
return
sb
.
toString
();
}
else
{
System
.
out
.
println
(
"请求失败!!!"
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
out
!=
null
)
{
try
{
out
.
flush
();
out
.
close
();
}
catch
(
IOException
e
)
{
}
}
if
(
conn
!=
null
)
{
conn
.
disconnect
();
}
}
return
null
;
}
}
/**
/**
...
@@ -138,7 +67,7 @@ public class TokenAcquisitionController {
...
@@ -138,7 +67,7 @@ public class TokenAcquisitionController {
jsonObject
.
put
(
"expires_in"
,
7200
);
jsonObject
.
put
(
"expires_in"
,
7200
);
jsonObject
.
put
(
"access_token"
,
"0faca598-787b-47cd-b74e-1f6f294e0250"
);
jsonObject
.
put
(
"access_token"
,
"0faca598-787b-47cd-b74e-1f6f294e0250"
);
String
str
=
jsonObject
.
toString
();
String
str
=
jsonObject
.
toString
();
//压缩处理
//
压缩处理
String
s
=
zipString
(
str
);
String
s
=
zipString
(
str
);
return
s
;
return
s
;
}
}
...
@@ -159,9 +88,9 @@ public class TokenAcquisitionController {
...
@@ -159,9 +88,9 @@ public class TokenAcquisitionController {
jsonObject
.
put
(
"userid"
,
"gjj"
);
jsonObject
.
put
(
"userid"
,
"gjj"
);
String
str
=
jsonObject
.
toString
();
String
str
=
jsonObject
.
toString
();
System
.
out
.
println
(
"未经过压缩处理的json字符串:"
+
str
);
System
.
out
.
println
(
"未经过压缩处理的json字符串:"
+
str
);
String
s
=
zipString
(
str
);
//进行zip压缩
String
s
=
zipString
(
str
);
//
进行zip压缩
System
.
out
.
println
(
"压缩处理之后的json字符串:"
+
s
);
System
.
out
.
println
(
"压缩处理之后的json字符串:"
+
s
);
String
s1
=
unzipString
(
s
);
//进行zip解压缩
String
s1
=
unzipString
(
s
);
//
进行zip解压缩
System
.
out
.
println
(
"解压缩处理之后的json字符串:"
+
s1
);
System
.
out
.
println
(
"解压缩处理之后的json字符串:"
+
s1
);
}
}
}
}
src/main/java/net/cdkj/gjj/adapter/domain/UnitAccountOpeningInformation.java
View file @
ffd08ffa
...
@@ -3,7 +3,6 @@ package net.cdkj.gjj.adapter.domain;
...
@@ -3,7 +3,6 @@ package net.cdkj.gjj.adapter.domain;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Objects
;
/**
/**
* 单位开户信息对象
* 单位开户信息对象
...
...
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