Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibznotify
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibznotify
提交
b49932c5
提交
b49932c5
编写于
8月 12, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
钉钉、微信、阿里消息集成
上级
b523a3c9
变更
7
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
491 行增加
和
2 行删除
+491
-2
pom.xml
ibznotify-core/pom.xml
+19
-0
RefreshTokenAspect.java
...cn/ibizlab/core/extensions/aspect/RefreshTokenAspect.java
+55
-0
RedisConfig.java
...n/java/cn/ibizlab/core/extensions/config/RedisConfig.java
+19
-0
NotifyCoreService.java
...cn/ibizlab/core/extensions/service/NotifyCoreService.java
+275
-0
RefreshTokenService.java
.../ibizlab/core/extensions/service/RefreshTokenService.java
+54
-0
pom.xml
ibznotify-dependencies/pom.xml
+26
-2
NotifyCoreResource.java
...va/cn/ibizlab/api/rest/extensions/NotifyCoreResource.java
+43
-0
未找到文件。
ibznotify-core/pom.xml
浏览文件 @
b49932c5
...
...
@@ -98,6 +98,25 @@
<artifactId>
jobs-spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
alibaba-dingtalk-service-sdk
</artifactId>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-ecs
</artifactId>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-dm
</artifactId>
</dependency>
</dependencies>
...
...
ibznotify-core/src/main/java/cn/ibizlab/core/extensions/aspect/RefreshTokenAspect.java
0 → 100644
浏览文件 @
b49932c5
package
cn
.
ibizlab
.
core
.
extensions
.
aspect
;
import
cn.ibizlab.core.extensions.service.NotifyCoreService
;
import
cn.ibizlab.core.notify.domain.MsgOpenAccess
;
import
cn.ibizlab.core.notify.service.IMsgOpenAccessService
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
/**
* 新建或更新时刷新token
*/
@Aspect
@Order
(
0
)
@Component
public
class
RefreshTokenAspect
{
@Autowired
@Lazy
IMsgOpenAccessService
smsConfigService
;
@Autowired
@Lazy
NotifyCoreService
notifyCoreService
;
@Before
(
value
=
"execution(* cn.ibizlab.core.notify.service.IMsgOpenAccessService.create*(..))"
)
public
void
afterCreate
(
JoinPoint
point
)
throws
Exception
{
refreshToken
(
point
);
}
@Before
(
value
=
"execution(* cn.ibizlab.core.notify.service.IMsgOpenAccessService.update*(..))"
)
public
void
afterUpdate
(
JoinPoint
point
)
throws
Exception
{
refreshToken
(
point
);
}
/**
* 刷新token
* @param point
*/
private
void
refreshToken
(
JoinPoint
point
){
Object
[]
args
=
point
.
getArgs
();
if
(
args
.
length
>
0
)
{
MsgOpenAccess
msgOpenAccess
=
(
MsgOpenAccess
)
args
[
0
];
if
(
msgOpenAccess
.
getOpenType
().
equals
(
"wechat"
)
||
msgOpenAccess
.
getOpenType
().
equals
(
"dingtalk"
)){
notifyCoreService
.
refreshToken
(
msgOpenAccess
);
}
}
}
}
ibznotify-core/src/main/java/cn/ibizlab/core/extensions/config/RedisConfig.java
0 → 100644
浏览文件 @
b49932c5
package
cn
.
ibizlab
.
core
.
extensions
.
config
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.cloud.client.loadbalancer.LoadBalanced
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.client.RestTemplate
;
@Configuration
public
class
RedisConfig
{
@Bean
// @LoadBalanced
@ConditionalOnMissingBean
public
RestTemplate
restTemplate
()
{
return
new
RestTemplate
();
}
}
\ No newline at end of file
ibznotify-core/src/main/java/cn/ibizlab/core/extensions/service/NotifyCoreService.java
0 → 100644
浏览文件 @
b49932c5
此差异已折叠。
点击以展开。
ibznotify-core/src/main/java/cn/ibizlab/core/extensions/service/RefreshTokenService.java
0 → 100644
浏览文件 @
b49932c5
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.notify.domain.MsgOpenAccess
;
import
cn.ibizlab.core.notify.service.IMsgOpenAccessService
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* 定时刷新token
*/
@Service
@Slf4j
public
class
RefreshTokenService
{
@Autowired
IMsgOpenAccessService
smsConfigService
;
@Autowired
NotifyCoreService
notifyCoreService
;
@Scheduled
(
fixedRate
=
1800000
)
public
void
refreshToken
()
{
QueryWrapper
<
MsgOpenAccess
>
qw
=
new
QueryWrapper
();
qw
.
eq
(
"disabled"
,
0
).
isNotNull
(
"access_key"
).
isNotNull
(
"secret_key"
).
and
(
i
->
i
.
eq
(
"open_type"
,
"wechat"
).
or
().
eq
(
"open_type"
,
"dingtalk"
));
List
<
MsgOpenAccess
>
accessList
=
smsConfigService
.
list
(
qw
);
if
(
accessList
.
size
()==
0
)
return
;
List
<
MsgOpenAccess
>
refreshAccessList
=
new
ArrayList
<>();
for
(
MsgOpenAccess
openAccess
:
accessList
){
String
accessToken
=
openAccess
.
getAccessToken
();
Timestamp
expiresTime
=
openAccess
.
getExpiresTime
();
if
(
StringUtils
.
isEmpty
(
accessToken
)){
notifyCoreService
.
refreshToken
(
openAccess
);
refreshAccessList
.
add
(
openAccess
);
}
else
{
if
(
expiresTime
!=
null
&&
expiresTime
.
before
(
new
Timestamp
(
new
Date
().
getTime
()))){
notifyCoreService
.
refreshToken
(
openAccess
);
refreshAccessList
.
add
(
openAccess
);
}
}
}
if
(
refreshAccessList
.
size
()>
0
)
smsConfigService
.
updateBatch
(
refreshAccessList
);
}
}
\ No newline at end of file
ibznotify-dependencies/pom.xml
浏览文件 @
b49932c5
...
...
@@ -89,6 +89,10 @@
<oracle.version>
11.2.0.3
</oracle.version>
<postgresql.version>
42.2.6
</postgresql.version>
<alibaba-dingtalk.version>
1.0.1
</alibaba-dingtalk.version>
<aliyun-sdk-core.version>
4.5.4
</aliyun-sdk-core.version>
<aliyun-sdk-ecs.version>
4.19.6
</aliyun-sdk-ecs.version>
<aliyun-sdk-dm.version>
3.3.1
</aliyun-sdk-dm.version>
</properties>
<dependencyManagement>
...
...
@@ -270,6 +274,28 @@
<version>
${baomidou-jobs.version}
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
alibaba-dingtalk-service-sdk
</artifactId>
<version>
${alibaba-dingtalk.version}
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
${aliyun-sdk-core.version}
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-ecs
</artifactId>
<version>
${aliyun-sdk-ecs.version}
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-dm
</artifactId>
<version>
${aliyun-sdk-dm.version}
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
@@ -349,8 +375,6 @@
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
</dependencies>
</project>
ibznotify-provider/ibznotify-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/NotifyCoreResource.java
0 → 100644
浏览文件 @
b49932c5
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.core.extensions.service.NotifyCoreService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
public
class
NotifyCoreResource
{
@Autowired
NotifyCoreService
notifyCoreService
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/sendDingTalkMsg"
)
public
ResponseEntity
<
Boolean
>
sendDingTalkMsg
(
@Validated
@RequestParam
String
tid
,
@RequestParam
String
userId
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
sendDingTalkMsg
(
tid
,
userId
));
// return ResponseEntity.status(HttpStatus.OK).body(notifyCoreService.sendDingTalkMsg("6c2e3779dd159ceba3e70e7502f4cf6f","760fd9aae5bb9475cb4e18b80d689ea7"));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/sendWeChatMsg"
)
public
ResponseEntity
<
Boolean
>
sendWeChatMsg
(
@Validated
@RequestParam
String
tid
,
@RequestParam
String
userId
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
sendWeChatMsg
(
tid
,
userId
));
// return ResponseEntity.status(HttpStatus.OK).body(notifyCoreService.sendWeChatMsg("8ddcea1f2a9743f159bd765133443684","760fd9aae5bb9475cb4e18b80d689ea7"));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/sendAliEMail"
)
public
ResponseEntity
<
Boolean
>
sendAliEMail
(
@Validated
@RequestParam
String
tid
,
@RequestParam
String
userId
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
sendAliEMail
(
tid
,
userId
));
// return ResponseEntity.status(HttpStatus.OK).body(notifyCoreService.sendAliEMail("5f4c72e0eb1eb3cf5b57c319a021d5b9","760fd9aae5bb9475cb4e18b80d689ea7"));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/SendAliSms"
)
public
ResponseEntity
<
Boolean
>
SendAliSms
(
@Validated
@RequestParam
String
tid
,
@RequestParam
String
userId
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
notifyCoreService
.
SendAliSms
(
tid
,
userId
));
// return ResponseEntity.status(HttpStatus.OK).body(notifyCoreService.SendAliSms("Vufzr1HEvhntkIOK8HkT_poUTLAmpwSbjzK0ncOkSuw","18677074230"));
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录