Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
仟微科技
Link Wechat
提交
91032f33
Link Wechat
项目概览
仟微科技
/
Link Wechat
通知
48
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Link Wechat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
91032f33
编写于
5月 27, 2021
作者:
1
1539136324@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化提取任务宝与群裂变相关运行参数。
上级
5eeba376
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
69 addition
and
39 deletion
+69
-39
linkwe-admin/src/main/resources/application.yml
linkwe-admin/src/main/resources/application.yml
+0
-6
linkwe-common/src/main/java/com/linkwechat/common/core/domain/entity/WeCorpAccount.java
...m/linkwechat/common/core/domain/entity/WeCorpAccount.java
+17
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/interceptor/WeiXinAccessTokenInterceptor.java
...echat/wecom/interceptor/WeiXinAccessTokenInterceptor.java
+28
-14
linkwe-wecom/src/main/java/com/linkwechat/wecom/interceptor/WeiXinAuthInterceptor.java
...m/linkwechat/wecom/interceptor/WeiXinAuthInterceptor.java
+17
-9
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTaskFissionServiceImpl.java
...nkwechat/wecom/service/impl/WeTaskFissionServiceImpl.java
+7
-10
未找到文件。
linkwe-admin/src/main/resources/application.yml
浏览文件 @
91032f33
...
...
@@ -88,12 +88,6 @@ logging:
path
:
log
:
./logs
#H5地址路径
H5
:
url
:
http://h5.linkwechat.cn/index.html
fissionUrl
:
http://h5.linkwechat.cn/index.html
fissionGroupUrl
:
http://h5.linkwechat.cn/fission.html
# Spring配置
spring
:
# 资源信息
...
...
linkwe-common/src/main/java/com/linkwechat/common/core/domain/entity/WeCorpAccount.java
浏览文件 @
91032f33
...
...
@@ -98,4 +98,21 @@ public class WeCorpAccount extends BaseEntity
@ApiModelProperty
(
"微信公众号APPID"
)
private
String
appid
;
@ApiModelProperty
(
"微信公众号密钥"
)
private
String
secret
;
@ApiModelProperty
(
"任务宝H5访问地址"
)
private
String
fissionUrl
;
@ApiModelProperty
(
"群裂变H5访问地址"
)
private
String
fissionGroupUrl
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/interceptor/WeiXinAccessTokenInterceptor.java
浏览文件 @
91032f33
package
com.linkwechat.wecom.interceptor
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dtflys.forest.exceptions.ForestRuntimeException
;
...
...
@@ -8,14 +9,16 @@ import com.dtflys.forest.http.ForestResponse;
import
com.dtflys.forest.interceptor.Interceptor
;
import
com.dtflys.forest.utils.ForestDataType
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.domain.model.LoginUser
;
import
com.linkwechat.common.core.redis.RedisCache
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.domain.weixin.dto.WxBaseResultDto
;
import
com.linkwechat.wecom.domain.weixin.dto.WxTokenDto
;
import
com.linkwechat.wecom.wxclient.WxCommonClient
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -28,11 +31,9 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public
class
WeiXinAccessTokenInterceptor
implements
Interceptor
{
//暂时写到配置文件,之后写入数据库
@Value
(
"${weixin.appid}"
)
private
String
appId
;
@Value
(
"${weixin.secret}"
)
private
String
secret
;
private
final
String
grantType
=
"client_credential"
;
@Autowired
...
...
@@ -51,16 +52,29 @@ public class WeiXinAccessTokenInterceptor implements Interceptor {
private
String
findAccessToken
(){
//获取用户token
String
accessToken
=
redisCache
.
getCacheObject
(
WeConstans
.
WX_ACCESS_TOKEN
);
if
(
StringUtils
.
isEmpty
(
accessToken
)){
//当用户token失效,重新获取token
WxTokenDto
wxTokenDto
=
wxCommonClient
.
getToken
(
grantType
,
appId
,
secret
);
if
(
wxTokenDto
!=
null
&&
StringUtils
.
isNotEmpty
(
wxTokenDto
.
getAccessToken
())){
redisCache
.
setCacheObject
(
WeConstans
.
WX_AUTH_ACCESS_TOKEN
,
wxTokenDto
.
getAccessToken
(),
wxTokenDto
.
getExpiresIn
(),
TimeUnit
.
SECONDS
);
accessToken
=
wxTokenDto
.
getAccessToken
();
String
accessToken
=
null
;
LoginUser
loginUser
=
SecurityUtils
.
getLoginUser
();
if
(
null
!=
loginUser
&&
null
!=
loginUser
.
getUser
()
&&
null
!=
loginUser
.
getUser
().
getWeCorpAccount
()){
WeCorpAccount
weCorpAccount
=
loginUser
.
getUser
().
getWeCorpAccount
();
if
(
StrUtil
.
isEmpty
(
weCorpAccount
.
getAppid
())
&&
StrUtil
.
isEmpty
(
weCorpAccount
.
getSecret
())){
//获取用户token
accessToken
=
redisCache
.
getCacheObject
(
WeConstans
.
WX_ACCESS_TOKEN
);
if
(
StringUtils
.
isEmpty
(
accessToken
)){
//当用户token失效,重新获取token
WxTokenDto
wxTokenDto
=
wxCommonClient
.
getToken
(
grantType
,
weCorpAccount
.
getAppid
(),
weCorpAccount
.
getSecret
());
if
(
wxTokenDto
!=
null
&&
StringUtils
.
isNotEmpty
(
wxTokenDto
.
getAccessToken
())){
redisCache
.
setCacheObject
(
WeConstans
.
WX_AUTH_ACCESS_TOKEN
,
wxTokenDto
.
getAccessToken
(),
wxTokenDto
.
getExpiresIn
(),
TimeUnit
.
SECONDS
);
accessToken
=
wxTokenDto
.
getAccessToken
();
}
}
}
else
{
throw
new
ForestRuntimeException
(
"公众号appid或者secret不可为空"
);
}
}
return
accessToken
;
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/interceptor/WeiXinAuthInterceptor.java
浏览文件 @
91032f33
package
com.linkwechat.wecom.interceptor
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dtflys.forest.exceptions.ForestRuntimeException
;
...
...
@@ -8,8 +9,12 @@ import com.dtflys.forest.http.ForestResponse;
import
com.dtflys.forest.interceptor.Interceptor
;
import
com.dtflys.forest.utils.ForestDataType
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.domain.model.LoginUser
;
import
com.linkwechat.common.core.redis.RedisCache
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.ServletUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.domain.weixin.dto.WxTokenDto
;
import
com.linkwechat.wecom.domain.weixin.dto.WxBaseResultDto
;
...
...
@@ -26,15 +31,11 @@ import java.util.concurrent.TimeUnit;
* @description 微信授权拦截器
* @date 2021/4/5 15:28
**/
@Slf4j
@Component
public
class
WeiXinAuthInterceptor
implements
Interceptor
{
//暂时写到配置文件,之后写入数据库
@Value
(
"${weixin.appid}"
)
private
String
appId
;
@Value
(
"${weixin.secret}"
)
private
String
secret
;
private
final
String
grantType
=
"refresh_token"
;
@Autowired
...
...
@@ -63,9 +64,16 @@ public class WeiXinAuthInterceptor implements Interceptor {
if
(
StringUtils
.
isEmpty
(
refreshToken
)){
throw
new
WeComException
(
1001
,
"token失效,请重新授权"
);
}
else
{
wxTokenDto
=
wxAuthClient
.
refreshToken
(
appId
,
grantType
,
refreshToken
);
if
(
wxTokenDto
!=
null
&&
StringUtils
.
isNotEmpty
(
wxTokenDto
.
getAccessToken
())){
redisCache
.
setCacheObject
(
WeConstans
.
WX_AUTH_ACCESS_TOKEN
+
":"
+
openId
,
wxTokenDto
,
wxTokenDto
.
getExpiresIn
(),
TimeUnit
.
SECONDS
);
LoginUser
loginUser
=
SecurityUtils
.
getLoginUser
();
if
(
null
!=
loginUser
&&
null
!=
loginUser
.
getUser
()
&&
null
!=
loginUser
.
getUser
().
getWeCorpAccount
())
{
WeCorpAccount
weCorpAccount
=
loginUser
.
getUser
().
getWeCorpAccount
();
if
(
StrUtil
.
isEmpty
(
weCorpAccount
.
getAppid
()))
{
wxTokenDto
=
wxAuthClient
.
refreshToken
(
weCorpAccount
.
getAppid
(),
grantType
,
refreshToken
);
if
(
wxTokenDto
!=
null
&&
StringUtils
.
isNotEmpty
(
wxTokenDto
.
getAccessToken
())){
redisCache
.
setCacheObject
(
WeConstans
.
WX_AUTH_ACCESS_TOKEN
+
":"
+
openId
,
wxTokenDto
,
wxTokenDto
.
getExpiresIn
(),
TimeUnit
.
SECONDS
);
}
}
}
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTaskFissionServiceImpl.java
浏览文件 @
91032f33
...
...
@@ -62,16 +62,14 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
private
IWeCustomerMessagePushService
weCustomerMessagePushService
;
@Autowired
private
IWeTaskFissionRecordService
weTaskFissionRecordService
;
@Autowired
private
IWeUserService
weUserService
;
@Autowired
private
WeExternalContactClient
weExternalContactClient
;
@Autowired
private
IWePosterService
wePosterService
;
@Autowired
private
IWeGroupCodeService
weGroupCodeService
;
@Autowired
private
IWeMaterialService
weMaterialService
;
@Autowired
private
IWeCustomerService
weCustomerService
;
@Autowired
...
...
@@ -81,10 +79,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
@Autowired
private
CosConfig
cosConfig
;
@Value
(
"${H5.fissionUrl}"
)
private
String
pageUrl
;
@Value
(
"${H5.fissionGroupUrl}"
)
private
String
pageGroupUrl
;
/**
* 查询任务宝
...
...
@@ -203,7 +198,9 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
//目标员工id
String
fissStaffId
=
weTaskFission
.
getFissionTargetId
();
//H5生成海报页面路径
StringBuilder
pageUrlBuilder
=
new
StringBuilder
(
pageUrl
);
StringBuilder
pageUrlBuilder
=
new
StringBuilder
(
SecurityUtils
.
getLoginUser
().
getUser
().
getWeCorpAccount
().
getFissionUrl
()
);
pageUrlBuilder
.
append
(
"?"
)
.
append
(
"fissionId="
).
append
(
id
)
.
append
(
"&"
)
...
...
@@ -436,7 +433,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
String
qrCode
=
null
;
if
(
weCustomer
!=
null
)
{
String
avatarUrl
=
weCustomer
.
getAvatar
();
StringBuilder
contentBuilder
=
new
StringBuilder
(
pageGroupUrl
);
StringBuilder
contentBuilder
=
new
StringBuilder
(
SecurityUtils
.
getLoginUser
().
getUser
().
getWeCorpAccount
().
getFissionGroupUrl
()
);
contentBuilder
.
append
(
"?"
)
.
append
(
"fissionId="
)
.
append
(
taskFissionId
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录