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
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
haoban-manage3.0
Commits
377f8a69
Commit
377f8a69
authored
Jun 24, 2024
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
企微托管
parent
a0617652
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
51 deletions
+70
-51
OpenUtils.java
...in/java/com/gic/haoban/manage/service/util/OpenUtils.java
+70
-51
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/util/OpenUtils.java
View file @
377f8a69
...
...
@@ -16,87 +16,106 @@ public class OpenUtils {
private
static
Logger
logger
=
LogManager
.
getLogger
(
OpenUtils
.
class
);
private
static
final
String
gicCallbackHost
=
GlobalVar
.
ctxPropertiesMap
.
get
(
"haoban_service_host"
)+
"/haoban-manage3-operation-web/qywx-msg-notice"
;
private
static
final
String
gicCallbackHost
=
GlobalVar
.
ctxPropertiesMap
.
get
(
"haoban_service_host"
)
+
"/haoban-manage3-operation-web/qywx-msg-notice"
;
private
static
final
String
openHost
=
"http://47.94.7.218:8089/wxwork/%s"
;
private
static
final
String
openHost
=
"http://47.94.7.218:8089/wxwork/%s"
;
public
static
ServiceResponse
<
QwOpenResultInitBO
>
init
(
Long
qwUserId
)
{
JSONObject
initJson
=
new
JSONObject
()
;
if
(
null
!=
qwUserId
)
{
initJson
.
put
(
"vid"
,
qwUserId
)
;
JSONObject
initJson
=
new
JSONObject
();
if
(
null
!=
qwUserId
)
{
initJson
.
put
(
"vid"
,
qwUserId
)
;
}
String
initStr
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"init"
)
,
initJson
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"init={}"
,
initStr
);
QwOpenResultBO
initResult
=
result
(
initStr
)
;
if
(!
initResult
.
isOk
())
{
return
ServiceResponse
.
failure
(
"9999"
,
initResult
.
getErrmsg
())
;
String
initStr
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"init"
),
initJson
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"init={}"
,
initStr
);
QwOpenResultBO
initResult
=
result
(
initStr
);
if
(!
initResult
.
isOk
())
{
return
ServiceResponse
.
failure
(
"9999"
,
initResult
.
getErrmsg
())
;
}
QwOpenResultInitBO
initBO
=
JSONObject
.
parseObject
(
initResult
.
getData
().
toString
(),
QwOpenResultInitBO
.
class
)
;
String
uuid
=
initBO
.
getUuid
()
;
QwOpenResultInitBO
initBO
=
JSONObject
.
parseObject
(
initResult
.
getData
().
toString
(),
QwOpenResultInitBO
.
class
);
String
uuid
=
initBO
.
getUuid
();
// 设置回调
setCallback
(
uuid
);
// 获取二维码
ServiceResponse
<
QwOpenResultInitBO
>
response
=
getQrcode
(
uuid
,
initBO
,
1
)
;
if
(!
response
.
isSuccess
())
{
return
response
;
ServiceResponse
<
QwOpenResultInitBO
>
response
=
getQrcode
(
uuid
,
initBO
,
1
)
;
if
(!
response
.
isSuccess
())
{
return
response
;
}
return
ServiceResponse
.
success
(
initBO
)
;
return
ServiceResponse
.
success
(
initBO
);
}
public
static
ServiceResponse
<
Void
>
checkCode
(
String
uuid
,
String
qrcodeKey
,
String
validCode
)
{
JSONObject
json
=
new
JSONObject
()
;
json
.
put
(
"uuid"
,
uuid
)
;
json
.
put
(
"qrcodeKey"
,
qrcodeKey
)
;
json
.
put
(
"code"
,
validCode
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"CheckCode"
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"校验验证码={},uuid={}"
,
backJson
,
uuid
);
QwOpenResultBO
bo
=
result
(
backJson
)
;
if
(!
bo
.
isOk
())
{
return
ServiceResponse
.
failure
(
"9999"
,
bo
.
getErrmsg
())
;
public
static
ServiceResponse
<
Void
>
checkCode
(
String
uuid
,
String
qrcodeKey
,
String
validCode
)
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"uuid"
,
uuid
)
;
json
.
put
(
"qrcodeKey"
,
qrcodeKey
)
;
json
.
put
(
"code"
,
validCode
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"CheckCode"
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"校验验证码={},uuid={}"
,
backJson
,
uuid
);
QwOpenResultBO
bo
=
result
(
backJson
);
if
(!
bo
.
isOk
())
{
return
ServiceResponse
.
failure
(
"9999"
,
bo
.
getErrmsg
())
;
}
return
ServiceResponse
.
success
()
;
return
ServiceResponse
.
success
();
}
public
static
void
logout
(
String
uuid
)
{
JSONObject
json
=
new
JSONObject
()
;
json
.
put
(
"uuid"
,
uuid
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"LoginOut"
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"退出={},uuid={}"
,
backJson
,
uuid
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"uuid"
,
uuid
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"LoginOut"
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"退出={},uuid={}"
,
backJson
,
uuid
);
}
private
static
void
setCallback
(
String
uuid
)
{
JSONObject
json
=
new
JSONObject
()
;
json
.
put
(
"uuid"
,
uuid
)
;
json
.
put
(
"url"
,
gicCallbackHost
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"SetCallbackUrl"
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"设置回调={},uuid={}"
,
backJson
,
uuid
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"uuid"
,
uuid
)
;
json
.
put
(
"url"
,
gicCallbackHost
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"SetCallbackUrl"
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"设置回调={},uuid={}"
,
backJson
,
uuid
);
}
public
static
ServiceResponse
<
QwOpenResultInitBO
>
getQrcode
(
String
uuid
,
QwOpenResultInitBO
initBO
,
int
times
)
{
String
req
=
"getQrCode"
;
if
(
times
==
2
)
{
req
=
"SecondaryValidation"
;
public
static
ServiceResponse
<
QwOpenResultInitBO
>
getQrcode
(
String
uuid
,
QwOpenResultInitBO
initBO
,
int
times
)
{
String
req
=
"getQrCode"
;
if
(
times
==
2
)
{
req
=
"SecondaryValidation"
;
}
JSONObject
json
=
new
JSONObject
()
;
json
.
put
(
"uuid"
,
uuid
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
req
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"获取qrcode={},uuid={},times={}"
,
backJson
,
uuid
,
times
);
QwOpenResultBO
initResult
=
result
(
backJson
)
;
if
(!
initResult
.
isOk
())
{
return
ServiceResponse
.
failure
(
"9999"
,
initResult
.
getErrmsg
())
;
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"uuid"
,
uuid
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
req
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"获取qrcode={},uuid={},times={}"
,
backJson
,
uuid
,
times
);
QwOpenResultBO
initResult
=
result
(
backJson
);
if
(!
initResult
.
isOk
())
{
return
ServiceResponse
.
failure
(
"9999"
,
initResult
.
getErrmsg
())
;
}
QwOpenResultInitBO
backBO
=
JSONObject
.
parseObject
(
initResult
.
getData
().
toString
(),
QwOpenResultInitBO
.
class
)
;
if
(
null
==
initBO
)
{
return
ServiceResponse
.
success
(
backBO
)
;
QwOpenResultInitBO
backBO
=
JSONObject
.
parseObject
(
initResult
.
getData
().
toString
(),
QwOpenResultInitBO
.
class
);
if
(
null
==
initBO
)
{
return
ServiceResponse
.
success
(
backBO
);
}
initBO
.
setQrcode
(
backBO
.
getQrcode
());
initBO
.
setKey
(
backBO
.
getKey
());
initBO
.
setQrcode_data
(
backBO
.
getQrcode_data
());
return
ServiceResponse
.
success
(
initBO
)
;
return
ServiceResponse
.
success
(
initBO
);
}
private
static
QwOpenResultBO
result
(
String
json
)
{
QwOpenResultBO
bo
=
JSONObject
.
parseObject
(
json
,
QwOpenResultBO
.
class
);
return
bo
;
}
/**
* 判断账号是否登录中
*
* @param uuid
* @return
*/
private
static
boolean
isLogin
(
String
uuid
)
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"uuid"
,
uuid
);
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"GetProfile"
),
json
.
toJSONString
(),
"utf-8"
);
logger
.
info
(
"获取当前账号详情={},uuid={}"
,
backJson
,
uuid
);
JSONObject
resultJson
=
JSONObject
.
parseObject
(
backJson
);
int
errcode
=
resultJson
.
getIntValue
(
"errcode"
);
if
(
errcode
==
500
&&
resultJson
.
getString
(
"errmsg"
).
contains
(
"实例不存在"
))
{
return
false
;
}
return
true
;
}
}
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