Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
agent-platform
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
赵啸非
agent-platform
Commits
6d862576
Commit
6d862576
authored
Apr 28, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
82f33892
79a4315b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
40 deletions
+10
-40
agent-manager/src/main/java/com/mortals/xhx/busiz/web/H5LoginController.java
...ain/java/com/mortals/xhx/busiz/web/H5LoginController.java
+10
-39
agent-manager/src/main/java/com/mortals/xhx/common/utils/WeChatUtils.java
...c/main/java/com/mortals/xhx/common/utils/WeChatUtils.java
+0
-1
No files found.
agent-manager/src/main/java/com/mortals/xhx/busiz/web/H5LoginController.java
View file @
6d862576
...
...
@@ -55,44 +55,18 @@ public class H5LoginController extends BaseCRUDJsonBodyMappingController<UserSer
private
IAuthTokenService
authTokenService
;
@Autowired
private
CompanyService
companyService
;
@Autowired
private
ICacheService
cacheService
;
private
static
String
WX_VERIFY_CODE_KEY
=
"login:wx:verify:"
;
/**
* 微信appId
*/
@Value
(
"${WeChat.pc.appID
:wx3490570828df45c8
}"
)
private
static
String
APP_ID
;
@Value
(
"${WeChat.pc.appID}"
)
private
String
APP_ID
;
/**
* 微信appSecret
*/
@Value
(
"${WeChat.pc.appSecret:8654c409f1a18f7ddffc70ee20d05ef1}"
)
private
static
String
APP_SECRET
;
@RequestMapping
(
value
=
{
"getLoginSoleCode"
},
method
=
{
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@UnAuth
public
Rest
<
Object
>
sendSmsVerifyCode
(){
Rest
<
Object
>
ret
=
new
Rest
();
Map
<
String
,
Object
>
model
=
new
HashMap
();
String
busiDesc
=
"获取微信登录验证码"
;
int
code
=
1
;
try
{
String
vCode
=
RandomUtil
.
randomNumbers
(
11
);
cacheService
.
setnx
(
WX_VERIFY_CODE_KEY
+
vCode
,
vCode
,
90
);
model
.
put
(
"data"
,
vCode
);
model
.
put
(
"message_info"
,
busiDesc
+
"成功"
);
}
catch
(
Exception
var9
)
{
code
=
-
1
;
this
.
doException
(
this
.
request
,
busiDesc
,
model
,
var9
);
}
ret
.
setCode
(
code
);
ret
.
setData
(
model
.
get
(
"data"
));
ret
.
setMsg
(
model
.
get
(
"message_info"
)
==
null
?
""
:
model
.
remove
(
"message_info"
).
toString
());
return
ret
;
}
@Value
(
"${WeChat.pc.appSecret}"
)
private
String
APP_SECRET
;
@RequestMapping
(
value
=
{
"bind"
},
method
=
{
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@UnAuth
...
...
@@ -102,22 +76,19 @@ public class H5LoginController extends BaseCRUDJsonBodyMappingController<UserSer
try
{
// 第三方发起微信授权登录请求,微信用户允许授权第三方应用后,微信会拉起应用或重定向到第三方网站,并且带上授权临时票据code参数;
String
loginCode
=
request
.
getParameter
(
"code"
);
//前端扫码登入传来的时间戳
String
loginState
=
request
.
getParameter
(
"state"
);
//用户拒绝授权时code为空,微信也不会请求该接口。为了防止非法请求,若code为空则返回
if
(
StringUtils
.
isEmpty
(
loginCode
))
{
throw
new
AppException
(
"登入请求被拒绝"
);
}
if
(
StringUtils
.
isEmpty
(
loginState
))
{
throw
new
AppException
(
"请求状态异常"
);
}
String
vCode
=
cacheService
.
get
(
WX_VERIFY_CODE_KEY
+
loginState
);
if
(
StringUtils
.
isEmpty
(
vCode
)){
throw
new
AppException
(
"微信登录验证码失效"
);
}
Map
<
String
,
String
>
accessTokenMap
=
WeChatUtils
.
getAccessToken
(
loginCode
,
APP_ID
,
APP_SECRET
);
//String access_token = accessTokenMap.get("access_token");//接口调用凭证,登录后右上角展示数据需要该值去获取
String
openid
=
accessTokenMap
.
get
(
"openid"
);
//授权用户唯一标识
if
(
StringUtils
.
isEmpty
(
openid
)){
log
.
error
(
"bind error "
,
"调用微信接口失败:"
+
JSONObject
.
toJSONString
(
accessTokenMap
));
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
"调用微信接口失败:"
+
JSONObject
.
toJSONString
(
accessTokenMap
));
return
ret
.
toJSONString
();
}
data
.
put
(
"openId"
,
openid
);
ret
.
put
(
KEY_RESULT_DATA
,
data
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
...
...
agent-manager/src/main/java/com/mortals/xhx/common/utils/WeChatUtils.java
View file @
6d862576
...
...
@@ -20,7 +20,6 @@ public class WeChatUtils {
* 获取微信accessToken路径
*/
private
static
final
String
GET_ACCESS_TOKEN_URL
=
"https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code"
;
/**
* 微信appId
*/
...
...
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