Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
1
Merge Requests
1
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
haoban-manage3.0
Commits
36549189
Commit
36549189
authored
May 22, 2024
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
441629e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
QywxCallbackController.java
.../haoban/manage/web/controller/QywxCallbackController.java
+84
-0
No files found.
haoban-manage3-operation-web/src/main/java/com/gic/haoban/manage/web/controller/QywxCallbackController.java
View file @
36549189
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.authcenter.commons.util.IgnoreLogin
;
import
com.gic.commons.util.HttpClient
;
import
org.apache.commons.io.IOUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -10,22 +12,104 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
@Controller
public
class
QywxCallbackController
extends
WebBaseController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QywxCallbackController
.
class
);
private
static
final
String
url
=
"http://47.94.7.218:8083/wxwork/%s"
;
@RequestMapping
(
"qywx-msg-notice"
)
@IgnoreLogin
public
Object
callback
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
try
{
String
body
=
IOUtils
.
toString
(
request
.
getInputStream
())
;
logger
.
info
(
"企微消息下发={}"
,
body
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
body
)
;
int
type
=
jsonObject
.
getIntValue
(
"type"
)
;
String
uuid
=
jsonObject
.
getString
(
"uuid"
)
;
JSONObject
json
=
jsonObject
.
getJSONObject
(
"json"
)
;
this
.
post
(
type
,
uuid
,
json
);
Map
<
String
,
String
>
map
=
new
HashMap
<>()
;
map
.
put
(
"errcode"
,
"0"
)
;
map
.
put
(
"errmsg"
,
"ok"
)
;
return
map
;
}
catch
(
Exception
e
)
{
logger
.
info
(
"异常"
,
e
);
}
return
"ok"
;
}
private
void
post
(
int
type
,
String
uuid
,
JSONObject
json
)
{
switch
(
type
)
{
case
100001
:
this
.
v100001
(
uuid
,
json
)
;
break
;
case
100002
:
this
.
v100002
(
uuid
,
json
)
;
break
;
case
100003
:
this
.
v100003
(
uuid
,
json
)
;
break
;
case
100004
:
this
.
v100004
(
uuid
,
json
)
;
break
;
case
100005
:
this
.
close
(
uuid
,
json
)
;
break
;
case
104001
:
this
.
loginSuccess
(
uuid
,
json
)
;
break
;
case
100012
:
this
.
v100012
(
uuid
,
json
)
;
break
;
default
:
break
;
}
}
private
void
v100012
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"需要二次扫码"
);
}
private
void
v100001
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"用户扫码={}"
,
uuid
);
}
private
void
v100004
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"需要输入验证码校验={}"
,
uuid
);
}
private
void
v100002
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"验证码校验成功返回={}"
,
uuid
);
}
private
void
loginSuccess
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"登录成功={}"
,
uuid
);
}
private
void
close
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"退出={}"
,
uuid
);
}
private
void
v100003
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"取消登录={}"
,
uuid
);
}
@RequestMapping
(
"qywx-msg-notice"
)
@IgnoreLogin
public
Object
init
(
Object
object
)
{
String
callbackUrl
=
"https://www.gicdev.com/haoban-manage3-operation-web/qywx-msg-notice"
;
Map
<
String
,
Object
>
map1
=
HttpClient
.
getWinxinResByJson
(
String
.
format
(
url
,
"init"
)
,
"{}"
)
;
JSONObject
json
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
map1
.
get
(
"data"
)))
;
String
uuid
=
json
.
getString
(
"uuid"
)
;
JSONObject
setCallbackUrl
=
new
JSONObject
()
;
setCallbackUrl
.
put
(
"uuid"
,
uuid
)
;
setCallbackUrl
.
put
(
"url"
,
callbackUrl
)
;
Map
<
String
,
Object
>
map2
=
HttpClient
.
getWinxinResByJson
(
String
.
format
(
url
,
"SetCallbackUrl"
),
setCallbackUrl
.
toJSONString
())
;
Map
<
String
,
Object
>
map3
=
HttpClient
.
getWinxinResByJson
(
String
.
format
(
url
,
"getQrCode"
),
setCallbackUrl
.
toJSONString
())
;
Map
<
String
,
Object
>
retMap
=
new
HashMap
<>()
;
retMap
.
put
(
"map1"
,
map1
);
retMap
.
put
(
"map2"
,
map2
)
;
retMap
.
put
(
"map3"
,
map3
)
;
return
retMap
;
}
}
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