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
5e695942
Commit
5e695942
authored
Jun 07, 2024
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
企微托管账号
parent
2c87140f
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
139 additions
and
14 deletions
+139
-14
QwOpenStepEnum.java
.../java/com/gic/haoban/manage/api/enums/QwOpenStepEnum.java
+33
-0
OpenStaffApiService.java
...om/gic/haoban/manage/api/service/OpenStaffApiService.java
+15
-2
QywxCallbackController.java
.../haoban/manage/web/controller/QywxCallbackController.java
+7
-2
OpenStaffMapper.java
...gic/haoban/manage/service/dao/mapper/OpenStaffMapper.java
+7
-0
OpenStaffApiServiceImpl.java
...age/service/service/out/impl/OpenStaffApiServiceImpl.java
+54
-5
OpenUtils.java
...in/java/com/gic/haoban/manage/service/util/OpenUtils.java
+12
-5
OpenStaffMapper.xml
...ge3-service/src/main/resources/mapper/OpenStaffMapper.xml
+11
-0
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/enums/QwOpenStepEnum.java
0 → 100644
View file @
5e695942
package
com
.
gic
.
haoban
.
manage
.
api
.
enums
;
public
enum
QwOpenStepEnum
{
step1
(
1
,
"用户已扫码"
),
step2
(
2
,
"取消登录"
),
step3
(
3
,
"超时未扫码"
)
,
step4
(
4
,
"验证码正确"
)
;
QwOpenStepEnum
(
Integer
step
,
String
desc
){
this
.
step
=
step
;
this
.
desc
=
desc
;
}
private
int
step
;
private
String
desc
;
public
int
getStep
()
{
return
step
;
}
public
void
setStep
(
int
step
)
{
this
.
step
=
step
;
}
public
String
getDesc
()
{
return
desc
;
}
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
}
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/OpenStaffApiService.java
View file @
5e695942
...
@@ -35,6 +35,19 @@ public interface OpenStaffApiService {
...
@@ -35,6 +35,19 @@ public interface OpenStaffApiService {
*/
*/
public
ServiceResponse
<
Void
>
updateValiFlag
(
String
uuid
)
;
public
ServiceResponse
<
Void
>
updateValiFlag
(
String
uuid
)
;
/**
* 设置需要二次验证扫码
* @param uuid
* @return
*/
public
ServiceResponse
<
Void
>
update2QrcodeFlag
(
String
uuid
)
;
/**
* 获取二次验证码
* @param id
* @return
*/
public
ServiceResponse
<
OpenStaffDTO
>
get2Qrcode
(
long
id
)
;
/**
/**
* 登录成功
* 登录成功
...
@@ -57,9 +70,9 @@ public interface OpenStaffApiService {
...
@@ -57,9 +70,9 @@ public interface OpenStaffApiService {
/**
/**
*
*
* @param uuid
* @param uuid
* @param
loginStatus
* @param
step
* @return
* @return
*/
*/
public
ServiceResponse
<
Void
>
updateLoginSt
atus
(
String
uuid
,
int
loginStatus
)
;
public
ServiceResponse
<
Void
>
updateLoginSt
ep
(
String
uuid
,
int
step
)
;
}
}
haoban-manage3-operation-web/src/main/java/com/gic/haoban/manage/web/controller/QywxCallbackController.java
View file @
5e695942
...
@@ -5,6 +5,7 @@ import com.gic.authcenter.commons.util.IgnoreLogin;
...
@@ -5,6 +5,7 @@ import com.gic.authcenter.commons.util.IgnoreLogin;
import
com.gic.commons.util.GlobalVar
;
import
com.gic.commons.util.GlobalVar
;
import
com.gic.commons.util.HttpClient
;
import
com.gic.commons.util.HttpClient
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.enums.QwOpenStepEnum
;
import
com.gic.haoban.manage.api.service.OpenStaffApiService
;
import
com.gic.haoban.manage.api.service.OpenStaffApiService
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -31,7 +32,7 @@ public class QywxCallbackController extends WebBaseController {
...
@@ -31,7 +32,7 @@ public class QywxCallbackController extends WebBaseController {
@RequestMapping
(
"qywx-msg-notice"
)
@RequestMapping
(
"qywx-msg-notice"
)
@IgnoreLogin
@IgnoreLogin
public
Object
callback
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
Object
callback
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
try
{
String
body
=
IOUtils
.
toString
(
request
.
getInputStream
())
;
String
body
=
IOUtils
.
toString
(
request
.
getInputStream
())
;
logger
.
info
(
"企微消息下发={}"
,
body
);
logger
.
info
(
"企微消息下发={}"
,
body
);
...
@@ -82,13 +83,15 @@ public class QywxCallbackController extends WebBaseController {
...
@@ -82,13 +83,15 @@ public class QywxCallbackController extends WebBaseController {
}
}
private
void
v100012
(
String
uuid
,
JSONObject
json
)
{
private
void
v100012
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"需要二次扫码"
);
logger
.
info
(
"需要二次扫码"
);
this
.
openStaffApiService
.
update2QrcodeFlag
(
uuid
)
;
}
}
private
void
v100009
(
String
uuid
,
JSONObject
json
)
{
private
void
v100009
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"超时未扫码关闭"
);
logger
.
info
(
"超时未扫码关闭"
);
this
.
openStaffApiService
.
updateLoginStep
(
uuid
,
QwOpenStepEnum
.
step3
.
getStep
())
;
}
}
private
void
v100001
(
String
uuid
,
JSONObject
json
)
{
private
void
v100001
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"用户扫码={}"
,
uuid
);
logger
.
info
(
"用户扫码={}"
,
uuid
);
this
.
openStaffApiService
.
updateLoginStep
(
uuid
,
QwOpenStepEnum
.
step1
.
getStep
())
;
}
}
private
void
v100004
(
String
uuid
,
JSONObject
json
)
{
private
void
v100004
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"需要输入验证码校验={}"
,
uuid
);
logger
.
info
(
"需要输入验证码校验={}"
,
uuid
);
...
@@ -96,6 +99,7 @@ public class QywxCallbackController extends WebBaseController {
...
@@ -96,6 +99,7 @@ public class QywxCallbackController extends WebBaseController {
}
}
private
void
v100002
(
String
uuid
,
JSONObject
json
)
{
private
void
v100002
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"验证码校验成功返回={}"
,
uuid
);
logger
.
info
(
"验证码校验成功返回={}"
,
uuid
);
this
.
openStaffApiService
.
updateLoginStep
(
uuid
,
QwOpenStepEnum
.
step4
.
getStep
())
;
}
}
private
void
loginSuccess
(
String
uuid
,
JSONObject
json
)
{
private
void
loginSuccess
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"登录成功={}"
,
uuid
);
logger
.
info
(
"登录成功={}"
,
uuid
);
...
@@ -110,6 +114,7 @@ public class QywxCallbackController extends WebBaseController {
...
@@ -110,6 +114,7 @@ public class QywxCallbackController extends WebBaseController {
}
}
private
void
v100003
(
String
uuid
,
JSONObject
json
)
{
private
void
v100003
(
String
uuid
,
JSONObject
json
)
{
logger
.
info
(
"取消登录={}"
,
uuid
);
logger
.
info
(
"取消登录={}"
,
uuid
);
this
.
openStaffApiService
.
updateLoginStep
(
uuid
,
QwOpenStepEnum
.
step2
.
getStep
())
;
}
}
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/OpenStaffMapper.java
View file @
5e695942
...
@@ -25,4 +25,10 @@ public interface OpenStaffMapper {
...
@@ -25,4 +25,10 @@ public interface OpenStaffMapper {
void
updateValiFlag
(
@Param
(
"uuid"
)
String
uuid
);
void
updateValiFlag
(
@Param
(
"uuid"
)
String
uuid
);
TabOpenStaff
getById
(
Long
openStaffId
);
TabOpenStaff
getById
(
Long
openStaffId
);
void
update2QrcodeFlag
(
@Param
(
"id"
)
Long
openStaffId
);
void
update2Qrcode
(
@Param
(
"id"
)
Long
id
,
@Param
(
"qrcode"
)
String
qrcode
,
@Param
(
"key"
)
String
key
)
;
void
updateLoginStep
(
@Param
(
"id"
)
Long
openStaffId
,
@Param
(
"step"
)
int
step
);
}
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/OpenStaffApiServiceImpl.java
View file @
5e695942
...
@@ -51,7 +51,44 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
...
@@ -51,7 +51,44 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
}
}
@Override
@Override
public
ServiceResponse
<
Void
>
updateLoginStatus
(
String
uuid
,
int
loginStatus
)
{
public
ServiceResponse
<
Void
>
update2QrcodeFlag
(
String
uuid
)
{
TabOpenStaff
openStaff
=
this
.
openStaffMapper
.
getByUUID
(
uuid
)
;
if
(
null
==
openStaff
)
{
log
.
info
(
"通过uuid查不到={}"
,
uuid
);
return
ServiceResponse
.
failure
(
"9999"
,
"登录错误"
)
;
}
this
.
openStaffMapper
.
update2QrcodeFlag
(
openStaff
.
getOpenStaffId
());
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
OpenStaffDTO
>
get2Qrcode
(
long
id
)
{
TabOpenStaff
openStaff
=
this
.
openStaffMapper
.
getById
(
id
)
;
if
(
null
==
openStaff
)
{
return
ServiceResponse
.
failure
(
"9999"
,
"登录错误"
)
;
}
ServiceResponse
<
QwOpenResultInitBO
>
resp
=
OpenUtils
.
getQrcode
(
openStaff
.
getUuid
(),
null
,
2
)
;
if
(
resp
.
isSuccess
())
{
String
qrcode
=
resp
.
getResult
().
getQrcode
()
;
String
key
=
resp
.
getResult
().
getKey
()
;
this
.
openStaffMapper
.
update2Qrcode
(
openStaff
.
getOpenStaffId
(),
qrcode
,
key
);
openStaff
.
setQrCode2
(
qrcode
);
}
else
{
return
ServiceResponse
.
failure
(
"9999"
,
resp
.
getMessage
())
;
}
OpenStaffDTO
dto
=
EntityUtil
.
changeEntityByJSON
(
OpenStaffDTO
.
class
,
openStaff
)
;
return
ServiceResponse
.
success
(
dto
);
}
@Override
public
ServiceResponse
<
Void
>
updateLoginStep
(
String
uuid
,
int
step
)
{
TabOpenStaff
openStaff
=
this
.
openStaffMapper
.
getByUUID
(
uuid
)
;
if
(
null
==
openStaff
)
{
log
.
info
(
"通过uuid查不到={}"
,
uuid
);
OpenUtils
.
logout
(
uuid
);
return
ServiceResponse
.
failure
(
"9999"
,
"登录错误"
)
;
}
this
.
openStaffMapper
.
updateLoginStep
(
openStaff
.
getOpenStaffId
(),
step
)
;
return
ServiceResponse
.
success
();
return
ServiceResponse
.
success
();
}
}
...
@@ -83,6 +120,15 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
...
@@ -83,6 +120,15 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
@Override
@Override
public
ServiceResponse
<
Void
>
logout
(
String
uuid
)
{
public
ServiceResponse
<
Void
>
logout
(
String
uuid
)
{
TabOpenStaff
openStaff
=
this
.
openStaffMapper
.
getByUUID
(
uuid
)
;
if
(
null
==
openStaff
)
{
log
.
info
(
"通过uuid查不到={}"
,
uuid
);
OpenUtils
.
logout
(
uuid
);
return
ServiceResponse
.
failure
(
"9999"
,
"登录错误"
)
;
}
openStaff
.
setStep
(
0
);
openStaff
.
setStatusFlag
(
2
);
this
.
openStaffMapper
.
update
(
openStaff
)
;
return
ServiceResponse
.
success
();
return
ServiceResponse
.
success
();
}
}
...
@@ -116,22 +162,25 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
...
@@ -116,22 +162,25 @@ public class OpenStaffApiServiceImpl implements OpenStaffApiService {
try
{
try
{
RedisUtil
.
lock
(
lockKey
,
3L
);
RedisUtil
.
lock
(
lockKey
,
3L
);
TabOpenStaff
openStaff
=
this
.
openStaffMapper
.
getByStaffId
(
staffId
)
;
TabOpenStaff
openStaff
=
this
.
openStaffMapper
.
getByStaffId
(
staffId
)
;
Long
qwUserId
=
null
;
if
(
null
!=
openStaff
)
{
qwUserId
=
openStaff
.
getQwUserId
()
;
log
.
info
(
"重新初始化,退出登录"
);
OpenUtils
.
logout
(
openStaff
.
getUuid
());
}
if
(
null
==
openStaff
)
{
if
(
null
==
openStaff
)
{
openStaff
=
new
TabOpenStaff
()
;
openStaff
=
new
TabOpenStaff
()
;
openStaff
.
setStaffId
(
staffId
);
openStaff
.
setStaffId
(
staffId
);
openStaff
.
setWxEnterpriseId
(
qdto
.
getWxEnterpriseId
());
openStaff
.
setWxEnterpriseId
(
qdto
.
getWxEnterpriseId
());
openStaff
.
setEnterpriseId
(
qdto
.
getEnterpriseId
());
openStaff
.
setEnterpriseId
(
qdto
.
getEnterpriseId
());
}
}
Long
qwUserId
=
null
;
if
(
null
!=
openStaff
)
{
qwUserId
=
openStaff
.
getQwUserId
()
;
}
ServiceResponse
<
QwOpenResultInitBO
>
resp
=
OpenUtils
.
init
(
qwUserId
)
;
ServiceResponse
<
QwOpenResultInitBO
>
resp
=
OpenUtils
.
init
(
qwUserId
)
;
log
.
info
(
"resp={}"
,
JSONObject
.
toJSONString
(
resp
));
log
.
info
(
"resp={}"
,
JSONObject
.
toJSONString
(
resp
));
QwOpenResultInitBO
init
=
resp
.
getResult
()
;
QwOpenResultInitBO
init
=
resp
.
getResult
()
;
openStaff
.
setUuid
(
init
.
getUuid
());
openStaff
.
setUuid
(
init
.
getUuid
());
openStaff
.
setQrCode1
(
init
.
getQrcode
());
openStaff
.
setQrCode1
(
init
.
getQrcode
());
openStaff
.
setKey1
(
init
.
getKey
());
openStaff
.
setKey1
(
init
.
getKey
());
openStaff
.
setStep
(
0
);
openStaff
=
this
.
openStaffService
.
save
(
openStaff
);
openStaff
=
this
.
openStaffService
.
save
(
openStaff
);
return
ServiceResponse
.
success
(
openStaff
.
getOpenStaffId
())
;
return
ServiceResponse
.
success
(
openStaff
.
getOpenStaffId
())
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/util/OpenUtils.java
View file @
5e695942
...
@@ -36,7 +36,7 @@ public class OpenUtils {
...
@@ -36,7 +36,7 @@ public class OpenUtils {
// 设置回调
// 设置回调
setCallback
(
uuid
);
setCallback
(
uuid
);
// 获取二维码
// 获取二维码
ServiceResponse
<
QwOpenResultInitBO
>
response
=
getQrcode
(
uuid
,
initBO
)
;
ServiceResponse
<
QwOpenResultInitBO
>
response
=
getQrcode
(
uuid
,
initBO
,
1
)
;
if
(!
response
.
isSuccess
())
{
if
(!
response
.
isSuccess
())
{
return
response
;
return
response
;
}
}
...
@@ -72,19 +72,26 @@ public class OpenUtils {
...
@@ -72,19 +72,26 @@ public class OpenUtils {
logger
.
info
(
"设置回调={},uuid={}"
,
backJson
,
uuid
);
logger
.
info
(
"设置回调={},uuid={}"
,
backJson
,
uuid
);
}
}
private
static
ServiceResponse
<
QwOpenResultInitBO
>
getQrcode
(
String
uuid
,
QwOpenResultInitBO
initBO
)
{
public
static
ServiceResponse
<
QwOpenResultInitBO
>
getQrcode
(
String
uuid
,
QwOpenResultInitBO
initBO
,
int
times
)
{
String
req
=
"getQrCode"
;
if
(
times
==
2
)
{
req
=
"SecondaryValidation"
;
}
JSONObject
json
=
new
JSONObject
()
;
JSONObject
json
=
new
JSONObject
()
;
json
.
put
(
"uuid"
,
uuid
)
;
json
.
put
(
"uuid"
,
uuid
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
"getQrCode"
),
json
.
toJSONString
(),
"utf-8"
)
;
String
backJson
=
HttpClient
.
sendPostJSON
(
String
.
format
(
openHost
,
req
),
json
.
toJSONString
(),
"utf-8"
)
;
logger
.
info
(
"获取qrcode={},uuid={}
"
,
backJson
,
uuid
);
logger
.
info
(
"获取qrcode={},uuid={}
,times={}"
,
backJson
,
uuid
,
times
);
QwOpenResultBO
initResult
=
result
(
backJson
)
;
QwOpenResultBO
initResult
=
result
(
backJson
)
;
if
(!
initResult
.
isOk
())
{
if
(!
initResult
.
isOk
())
{
return
ServiceResponse
.
failure
(
"9999"
,
initResult
.
getErrmsg
())
;
return
ServiceResponse
.
failure
(
"9999"
,
initResult
.
getErrmsg
())
;
}
}
QwOpenResultInitBO
backBO
=
JSONObject
.
parseObject
(
initResult
.
getData
().
toString
(),
QwOpenResultInitBO
.
class
)
;
QwOpenResultInitBO
backBO
=
JSONObject
.
parseObject
(
initResult
.
getData
().
toString
(),
QwOpenResultInitBO
.
class
)
;
if
(
null
==
initBO
)
{
return
ServiceResponse
.
success
(
backBO
)
;
}
initBO
.
setQrcode
(
backBO
.
getQrcode
());
initBO
.
setQrcode
(
backBO
.
getQrcode
());
initBO
.
setKey
(
backBO
.
getKey
());
initBO
.
setKey
(
backBO
.
getKey
());
return
ServiceResponse
.
success
()
;
return
ServiceResponse
.
success
(
initBO
)
;
}
}
private
static
QwOpenResultBO
result
(
String
json
)
{
private
static
QwOpenResultBO
result
(
String
json
)
{
...
...
haoban-manage3-service/src/main/resources/mapper/OpenStaffMapper.xml
View file @
5e695942
...
@@ -66,6 +66,17 @@
...
@@ -66,6 +66,17 @@
update tab_haoban_open_staff set valid_flag = 1 where uuid = #{uuid}
update tab_haoban_open_staff set valid_flag = 1 where uuid = #{uuid}
</update>
</update>
<update
id=
"update2QrcodeFlag"
>
update tab_haoban_open_staff set valid_qrcode_flag = 1 where id = #{id}
</update>
<update
id=
"update2Qrcode"
>
update tab_haoban_open_staff set qr_code_2 = #{qrCode} , key_2 = #{key} where id = #{id}
</update>
<update
id=
"updateLoginStep"
>
update tab_haoban_open_staff set step = #{step} where open_staff_id = #{id}
</update>
<delete
id=
"deleteByPrimaryKey"
>
<delete
id=
"deleteByPrimaryKey"
>
update tab_haoban_open_staff set delete_flag = 1 , update_time =now() where open_staff_id = #{id}
update tab_haoban_open_staff set delete_flag = 1 , update_time =now() where open_staff_id = #{id}
</delete>
</delete>
...
...
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