Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cms-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
cms-ci-test
Commits
068e04a1
提交
068e04a1
authored
6月 15, 2023
作者:
panda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
删除多余System.out.println
上级
e0d40d30
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
6 行增加
和
24 行删除
+6
-24
BCrypt.java
...ice-user/src/main/java/com/mmc/iuav/user/auth/BCrypt.java
+0
-2
WxServiceImpl.java
...in/java/com/mmc/iuav/user/service/impl/WxServiceImpl.java
+6
-22
没有找到文件。
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/auth/BCrypt.java
浏览文件 @
068e04a1
...
@@ -42,9 +42,7 @@ import java.util.Arrays;
...
@@ -42,9 +42,7 @@ import java.util.Arrays;
* <p>
* <p>
* <code>
* <code>
* if (BCrypt.checkpw(candidate_password, stored_hash))<br />
* if (BCrypt.checkpw(candidate_password, stored_hash))<br />
* System.out.println("It matches");<br />
* else<br />
* else<br />
* System.out.println("It does not match");<br />
* </code>
* </code>
* <p>
* <p>
* The gensalt() method takes an optional parameter (log_rounds)
* The gensalt() method takes an optional parameter (log_rounds)
...
...
csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/service/impl/WxServiceImpl.java
浏览文件 @
068e04a1
...
@@ -15,6 +15,7 @@ import com.mmc.iuav.user.model.vo.WxLoginVO;
...
@@ -15,6 +15,7 @@ import com.mmc.iuav.user.model.vo.WxLoginVO;
import
com.mmc.iuav.user.model.vo.WxMsgVO
;
import
com.mmc.iuav.user.model.vo.WxMsgVO
;
import
com.mmc.iuav.user.service.WxService
;
import
com.mmc.iuav.user.service.WxService
;
import
com.mmc.iuav.user.util.WxApiUtil
;
import
com.mmc.iuav.user.util.WxApiUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
...
@@ -32,6 +33,7 @@ import java.util.concurrent.TimeUnit;
...
@@ -32,6 +33,7 @@ import java.util.concurrent.TimeUnit;
* @Date: 2023/5/16 13:44
* @Date: 2023/5/16 13:44
*/
*/
@Service
@Service
@Slf4j
public
class
WxServiceImpl
implements
WxService
{
public
class
WxServiceImpl
implements
WxService
{
@Autowired
@Autowired
private
UserSystemConstant
userSystemConstant
;
private
UserSystemConstant
userSystemConstant
;
...
@@ -68,7 +70,6 @@ public class WxServiceImpl implements WxService {
...
@@ -68,7 +70,6 @@ public class WxServiceImpl implements WxService {
String
accessTokenMsg
=
HttpsRequestUtil
.
httpsGet
(
getAccessTokenUrl
,
null
);
String
accessTokenMsg
=
HttpsRequestUtil
.
httpsGet
(
getAccessTokenUrl
,
null
);
JSONObject
tokenResult
=
JSONObject
.
parseObject
(
accessTokenMsg
);
JSONObject
tokenResult
=
JSONObject
.
parseObject
(
accessTokenMsg
);
if
(
accessTokenMsg
.
indexOf
(
"access_token"
)
==
-
1
)
{
if
(
accessTokenMsg
.
indexOf
(
"access_token"
)
==
-
1
)
{
System
.
out
.
println
(
"获取小程序access_token有误:"
+
tokenResult
);
return
null
;
return
null
;
}
}
accessToken
=
tokenResult
.
getString
(
"access_token"
);
accessToken
=
tokenResult
.
getString
(
"access_token"
);
...
@@ -90,7 +91,7 @@ public class WxServiceImpl implements WxService {
...
@@ -90,7 +91,7 @@ public class WxServiceImpl implements WxService {
String
accessTokenMsg
=
HttpsRequestUtil
.
httpsGet
(
getAccessTokenUrl
,
null
);
String
accessTokenMsg
=
HttpsRequestUtil
.
httpsGet
(
getAccessTokenUrl
,
null
);
JSONObject
tokenResult
=
JSONObject
.
parseObject
(
accessTokenMsg
);
JSONObject
tokenResult
=
JSONObject
.
parseObject
(
accessTokenMsg
);
if
(
accessTokenMsg
.
indexOf
(
"access_token"
)
==
-
1
)
{
if
(
accessTokenMsg
.
indexOf
(
"access_token"
)
==
-
1
)
{
System
.
out
.
println
(
"获取公众号access_token有误:"
+
tokenResult
);
log
.
info
(
"获取公众号access_token有误:{}"
,
tokenResult
);
return
null
;
return
null
;
}
}
accessToken
=
tokenResult
.
getString
(
"access_token"
);
accessToken
=
tokenResult
.
getString
(
"access_token"
);
...
@@ -112,14 +113,10 @@ public class WxServiceImpl implements WxService {
...
@@ -112,14 +113,10 @@ public class WxServiceImpl implements WxService {
this
.
subScribeUser
(
map
);
this
.
subScribeUser
(
map
);
}
else
if
(
WxConstant
.
unsubscribe
.
equals
(
event
))
{
}
else
if
(
WxConstant
.
unsubscribe
.
equals
(
event
))
{
// 取消关注事件
// 取消关注事件
System
.
out
.
println
(
"############################"
);
System
.
out
.
println
(
"###########取消关注############"
);
System
.
out
.
println
(
"############################"
);
String
openId
=
map
.
get
(
"FromUserName"
);
String
openId
=
map
.
get
(
"FromUserName"
);
userSubInfoDao
.
removeUserSubInfo
(
openId
);
userSubInfoDao
.
removeUserSubInfo
(
openId
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"接收消息异常"
+
e
.
getMessage
());
return
"error"
;
return
"error"
;
}
}
return
"success"
;
return
"success"
;
...
@@ -167,10 +164,6 @@ public class WxServiceImpl implements WxService {
...
@@ -167,10 +164,6 @@ public class WxServiceImpl implements WxService {
// 用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息。
// 用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息。
Integer
subscribe
=
obj
.
getInteger
(
"subscribe"
);
Integer
subscribe
=
obj
.
getInteger
(
"subscribe"
);
if
(
subscribe
!=
null
&&
subscribe
==
1
)
{
if
(
subscribe
!=
null
&&
subscribe
==
1
)
{
System
.
out
.
println
(
"###########access_token##########"
);
System
.
out
.
println
(
accessToken
);
System
.
out
.
println
(
"###########用户信息##########"
);
System
.
out
.
println
(
jsonStr
);
UserSubInfoDO
user
=
new
UserSubInfoDO
();
UserSubInfoDO
user
=
new
UserSubInfoDO
();
user
.
setOpenId
(
openid
);
user
.
setOpenId
(
openid
);
user
.
setUnionId
(
obj
.
getString
(
"unionid"
));
user
.
setUnionId
(
obj
.
getString
(
"unionid"
));
...
@@ -179,7 +172,7 @@ public class WxServiceImpl implements WxService {
...
@@ -179,7 +172,7 @@ public class WxServiceImpl implements WxService {
userSubInfoDao
.
updateUserSubInfo
(
user
);
userSubInfoDao
.
updateUserSubInfo
(
user
);
return
;
return
;
}
else
{
}
else
{
System
.
out
.
println
(
"未订阅公众号,无法拉取信息。"
);
log
.
info
(
"未订阅公众号,无法拉取信息。"
);
return
;
return
;
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
@@ -190,19 +183,14 @@ public class WxServiceImpl implements WxService {
...
@@ -190,19 +183,14 @@ public class WxServiceImpl implements WxService {
@Override
@Override
public
ResultBody
sendSubTemplateMsg
(
WxMsgVO
ws
)
{
public
ResultBody
sendSubTemplateMsg
(
WxMsgVO
ws
)
{
System
.
out
.
println
(
"###########开始发送公众号消息##########"
);
String
accessToken
=
null
;
String
accessToken
=
null
;
try
{
try
{
accessToken
=
this
.
getSubAccessToken
();
accessToken
=
this
.
getSubAccessToken
();
System
.
out
.
println
(
"accesstoken:"
+
accessToken
);
String
url
=
"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="
+
accessToken
;
String
url
=
"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="
+
accessToken
;
String
param
=
ws
.
buildMsgJson
();
String
param
=
ws
.
buildMsgJson
();
System
.
out
.
println
(
"参数:"
+
param
);
String
result
=
HttpHelper
.
httpPost
(
url
,
param
);
String
result
=
HttpHelper
.
httpPost
(
url
,
param
);
System
.
out
.
println
(
"###########结束发送公众号消息##########"
);
System
.
out
.
println
(
result
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"accessToken获取失败:"
+
e
.
getMessage
());
log
.
error
(
"accessToken获取失败:{}"
,
e
.
getMessage
());
return
ResultBody
.
error
(
ResultEnum
.
WX_ACCESS_TOKEN_ERROR
.
getResultCode
(),
return
ResultBody
.
error
(
ResultEnum
.
WX_ACCESS_TOKEN_ERROR
.
getResultCode
(),
ResultEnum
.
WX_ACCESS_TOKEN_ERROR
.
getResultMsg
()
+
e
.
getMessage
());
ResultEnum
.
WX_ACCESS_TOKEN_ERROR
.
getResultMsg
()
+
e
.
getMessage
());
}
}
...
@@ -231,7 +219,6 @@ public class WxServiceImpl implements WxService {
...
@@ -231,7 +219,6 @@ public class WxServiceImpl implements WxService {
@Override
@Override
public
ResultBody
sendAppletMsg
(
AppletMsgVO
appletMsgVO
)
{
public
ResultBody
sendAppletMsg
(
AppletMsgVO
appletMsgVO
)
{
System
.
out
.
println
(
"###########开始发送-小程序-用户端消息##########"
);
String
accessToken
=
this
.
getAccessToken
();
String
accessToken
=
this
.
getAccessToken
();
if
(
StringUtils
.
isBlank
(
accessToken
)){
if
(
StringUtils
.
isBlank
(
accessToken
)){
return
ResultBody
.
error
(
ResultEnum
.
WX_ACCESS_TOKEN_ERROR
.
getResultCode
(),
return
ResultBody
.
error
(
ResultEnum
.
WX_ACCESS_TOKEN_ERROR
.
getResultCode
(),
...
@@ -241,12 +228,10 @@ public class WxServiceImpl implements WxService {
...
@@ -241,12 +228,10 @@ public class WxServiceImpl implements WxService {
String
url
=
"https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="
+
accessToken
;
String
url
=
"https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="
+
accessToken
;
appletMsgVO
.
setData
(
WxApiUtil
.
buildMsgJson
(
appletMsgVO
.
getData
()));
appletMsgVO
.
setData
(
WxApiUtil
.
buildMsgJson
(
appletMsgVO
.
getData
()));
String
param
=
JSONObject
.
toJSONString
(
appletMsgVO
);
String
param
=
JSONObject
.
toJSONString
(
appletMsgVO
);
System
.
out
.
println
(
"参数:"
+
param
);
HttpHelper
.
httpPost
(
url
,
param
);
HttpHelper
.
httpPost
(
url
,
param
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
System
.
out
.
println
(
"系统异常:"
+
e
.
getMessage
());
log
.
error
(
"系统异常:{}"
,
e
.
getMessage
());
}
}
System
.
out
.
println
(
"###########结束发送-小程序-消息##########"
);
return
ResultBody
.
success
();
return
ResultBody
.
success
();
}
}
...
@@ -280,7 +265,6 @@ public class WxServiceImpl implements WxService {
...
@@ -280,7 +265,6 @@ public class WxServiceImpl implements WxService {
String
url
=
"https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="
+
accessToken
;
String
url
=
"https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="
+
accessToken
;
String
res
=
HttpHelper
.
httpPost
(
url
,
param
.
toString
());
String
res
=
HttpHelper
.
httpPost
(
url
,
param
.
toString
());
JSONObject
result
=
JSONObject
.
parseObject
(
res
);
JSONObject
result
=
JSONObject
.
parseObject
(
res
);
System
.
out
.
println
(
"用户授权手机号:"
+
res
);
if
(
result
.
getString
(
"errcode"
).
equals
(
"0"
))
{
if
(
result
.
getString
(
"errcode"
).
equals
(
"0"
))
{
String
phone_info
=
result
.
getString
(
"phone_info"
);
String
phone_info
=
result
.
getString
(
"phone_info"
);
JSONObject
phoneInfoObject
=
JSONObject
.
parseObject
(
phone_info
);
JSONObject
phoneInfoObject
=
JSONObject
.
parseObject
(
phone_info
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论