Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-qywx-self
Overview
Overview
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
haoban3.0
gic-qywx-self
Commits
1afa87f7
Commit
1afa87f7
authored
May 06, 2023
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
出口ip
parent
c506be8c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
17 deletions
+22
-17
HttpClient.java
src/main/java/com/gic/qywx/self/HttpClient.java
+0
-0
QywxController.java
src/main/java/com/gic/qywx/self/QywxController.java
+22
-17
No files found.
src/main/java/com/gic/qywx/self/HttpClient.java
View file @
1afa87f7
This diff is collapsed.
Click to expand it.
src/main/java/com/gic/qywx/self/QywxController.java
View file @
1afa87f7
package
com
.
gic
.
qywx
.
self
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -15,6 +12,7 @@ import org.apache.http.entity.mime.content.ByteArrayBody;
import
org.apache.http.entity.mime.content.ContentBody
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -28,41 +26,38 @@ public class QywxController {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QywxController
.
class
);
@RequestMapping
(
"self-post"
)
public
Object
selfPost
(
String
url
,
String
json
)
{
public
Object
selfPost
(
String
url
,
String
json
,
String
ip
)
{
logger
.
info
(
"自建post,url={},json={}"
,
url
,
json
);
Map
<
String
,
Object
>
map
=
HttpClient
.
getWinxinResByJson
(
url
,
json
);
Map
<
String
,
Object
>
map
=
HttpClient
.
getWinxinResByJson
(
url
,
json
,
getIp
(
ip
)
);
return
map
;
}
@RequestMapping
(
"self-post-json"
)
public
Object
selfPostJson
(
String
url
,
@RequestBody
String
json
)
{
public
Object
selfPostJson
(
String
url
,
@RequestBody
String
json
,
String
ip
)
{
logger
.
info
(
"自建post json,url={},json={}"
,
url
,
json
);
Map
<
String
,
Object
>
map
=
HttpClient
.
getWinxinResByJson
(
url
,
json
);
Map
<
String
,
Object
>
map
=
HttpClient
.
getWinxinResByJson
(
url
,
json
,
getIp
(
ip
)
);
return
map
;
}
@RequestMapping
(
"self-get"
)
public
Object
selfGet
(
String
url
)
{
public
Object
selfGet
(
String
url
,
String
ip
)
{
logger
.
info
(
"自建get,url={}"
,
url
);
Map
<
String
,
Object
>
map
=
HttpClient
.
getHttpByGet
(
url
);
Map
<
String
,
Object
>
map
=
HttpClient
.
getHttpByGet
(
url
,
getIp
(
ip
)
);
return
map
;
}
@RequestMapping
(
"self-upload"
)
public
Object
selfUpload
(
String
url
,
String
fileUrl
,
String
fileName
)
{
public
Object
selfUpload
(
String
url
,
String
fileUrl
,
String
fileName
,
String
ip
)
{
logger
.
info
(
"自建upload,url={}"
,
url
);
byte
[]
data
=
CommonUtil
.
getFileByte
(
fileUrl
);
Map
<
String
,
ContentBody
>
paramsMap
=
new
HashMap
<
String
,
ContentBody
>();
paramsMap
.
put
(
"media"
,
new
ByteArrayBody
(
data
,
ContentType
.
DEFAULT_BINARY
,
fileName
));
Map
<
String
,
Object
>
map
=
HttpClient
.
getWinxinResByFile
(
url
,
paramsMap
);
Map
<
String
,
Object
>
map
=
HttpClient
.
getWinxinResByFile
(
url
,
paramsMap
,
getIp
(
ip
)
);
return
map
;
}
@RequestMapping
(
"self-upload-data"
)
public
Object
selfImage
(
String
url
,
String
fileName
,
HttpServletRequest
request
)
throws
IOException
{
public
Object
selfImage
(
String
url
,
String
fileName
,
HttpServletRequest
request
,
String
ip
)
throws
IOException
{
logger
.
info
(
"自建upload-data,url={}"
,
url
);
MultipartHttpServletRequest
multiRequest
=
(
MultipartHttpServletRequest
)
request
;
List
<
MultipartFile
>
list
=
multiRequest
.
getMultiFileMap
().
get
(
"media"
);
...
...
@@ -70,8 +65,18 @@ public class QywxController {
byte
[]
data
=
mf
.
getBytes
();
Map
<
String
,
ContentBody
>
paramsMap
=
new
HashMap
<
String
,
ContentBody
>();
paramsMap
.
put
(
"media"
,
new
ByteArrayBody
(
data
,
ContentType
.
DEFAULT_BINARY
,
fileName
));
Map
<
String
,
Object
>
map
=
HttpClient
.
getWinxinResByFile
(
url
,
paramsMap
);
Map
<
String
,
Object
>
map
=
HttpClient
.
getWinxinResByFile
(
url
,
paramsMap
,
getIp
(
ip
)
);
return
map
;
}
// 必须是内网ip
private
byte
[]
getIp
(
String
ip
)
{
logger
.
info
(
"ip={}"
,
ip
);
if
(
StringUtils
.
isEmpty
(
ip
))
{
return
null
;
}
String
[]
arr
=
ip
.
split
(
"\\."
);
byte
[]
b
=
new
byte
[]
{
Integer
.
valueOf
(
arr
[
0
]).
byteValue
(),
Integer
.
valueOf
(
arr
[
1
]).
byteValue
(),
Integer
.
valueOf
(
arr
[
2
]).
byteValue
(),
Integer
.
valueOf
(
arr
[
3
]).
byteValue
()};
return
b
;
}
}
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