Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
仟微科技
Link Wechat
提交
b06a1a36
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,发现更多精彩内容 >>
提交
b06a1a36
编写于
11月 04, 2020
作者:
X
xinlaa
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://gitee.com/LinkWeChat/link-wechat
into master
上级
288662a7
d76d3c34
变更
24
展开全部
显示空白变更内容
内联
并排
Showing
24 changed file
with
1515 addition
and
93 deletion
+1515
-93
linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysLoginController.java
.../linkwechat/web/controller/system/SysLoginController.java
+26
-16
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMessagePushController.java
...kwechat/web/controller/wecom/WeMessagePushController.java
+81
-0
linkwe-common/pom.xml
linkwe-common/pom.xml
+13
-3
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
.../main/java/com/linkwechat/common/constant/WeConstans.java
+15
-20
linkwe-common/src/main/java/com/linkwechat/common/enums/MediaType.java
.../src/main/java/com/linkwechat/common/enums/MediaType.java
+2
-2
linkwe-common/src/main/java/com/linkwechat/common/enums/MessageType.java
...rc/main/java/com/linkwechat/common/enums/MessageType.java
+86
-0
linkwe-common/src/main/java/com/linkwechat/common/enums/PushType.java
...n/src/main/java/com/linkwechat/common/enums/PushType.java
+33
-0
linkwe-common/src/main/java/com/linkwechat/common/utils/ReflectUtil.java
...rc/main/java/com/linkwechat/common/utils/ReflectUtil.java
+126
-0
linkwe-framework/src/main/java/com/linkwechat/framework/config/SecurityConfig.java
.../java/com/linkwechat/framework/config/SecurityConfig.java
+1
-1
linkwe-framework/src/main/java/com/linkwechat/framework/web/service/SysLoginService.java
...com/linkwechat/framework/web/service/SysLoginService.java
+23
-0
linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java
...kwechat/framework/web/service/UserDetailsServiceImpl.java
+16
-19
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMessagePushClient.java
...java/com/linkwechat/wecom/client/WeMessagePushClient.java
+33
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCorpAccount.java
.../main/java/com/linkwechat/wecom/domain/WeCorpAccount.java
+4
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeMessagePush.java
.../main/java/com/linkwechat/wecom/domain/WeMessagePush.java
+85
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeMessagePushDto.java
...ava/com/linkwechat/wecom/domain/dto/WeMessagePushDto.java
+63
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeMessagePushGroupDto.java
...om/linkwechat/wecom/domain/dto/WeMessagePushGroupDto.java
+28
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeMessagePushResultDto.java
...m/linkwechat/wecom/domain/dto/WeMessagePushResultDto.java
+37
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeMessagePushMapper.java
...java/com/linkwechat/wecom/mapper/WeMessagePushMapper.java
+13
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeMessagePushService.java
...a/com/linkwechat/wecom/service/IWeMessagePushService.java
+53
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCategoryServiceImpl.java
.../linkwechat/wecom/service/impl/WeCategoryServiceImpl.java
+5
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMaterialServiceImpl.java
.../linkwechat/wecom/service/impl/WeMaterialServiceImpl.java
+5
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMessagePushServiceImpl.java
...nkwechat/wecom/service/impl/WeMessagePushServiceImpl.java
+157
-0
linkwe-wecom/src/main/resources/mapper/wecom/WeMessagePushMapper.xml
...m/src/main/resources/mapper/wecom/WeMessagePushMapper.xml
+6
-0
sql/link-wechat.sql
sql/link-wechat.sql
+604
-32
未找到文件。
linkwe-admin/src/main/java/com/linkwechat/web/controller/system/SysLoginController.java
浏览文件 @
b06a1a36
package
com.linkwechat.web.controller.system
;
package
com.linkwechat.web.controller.system
;
import
java.util.List
;
import
java.util.Set
;
import
com.linkwechat.wecom.client.WeAccessTokenClient
;
import
com.linkwechat.wecom.domain.WeCorpAccount
;
import
com.linkwechat.wecom.domain.dto.WeLoginUserInfoDto
;
import
com.linkwechat.wecom.service.IWeAccessTokenService
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.domain.entity.SysMenu
;
import
com.linkwechat.common.core.domain.entity.SysMenu
;
...
@@ -24,6 +11,18 @@ import com.linkwechat.framework.web.service.SysLoginService;
...
@@ -24,6 +11,18 @@ import com.linkwechat.framework.web.service.SysLoginService;
import
com.linkwechat.framework.web.service.SysPermissionService
;
import
com.linkwechat.framework.web.service.SysPermissionService
;
import
com.linkwechat.framework.web.service.TokenService
;
import
com.linkwechat.framework.web.service.TokenService
;
import
com.linkwechat.system.service.ISysMenuService
;
import
com.linkwechat.system.service.ISysMenuService
;
import
com.linkwechat.wecom.client.WeAccessTokenClient
;
import
com.linkwechat.wecom.domain.WeCorpAccount
;
import
com.linkwechat.wecom.domain.dto.WeLoginUserInfoDto
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* 登录验证
* 登录验证
...
@@ -53,6 +52,8 @@ public class SysLoginController
...
@@ -53,6 +52,8 @@ public class SysLoginController
@Autowired
@Autowired
private
WeAccessTokenClient
weAccessTokenClient
;
private
WeAccessTokenClient
weAccessTokenClient
;
/**
/**
* 登录方法
* 登录方法
*
*
...
@@ -118,7 +119,7 @@ public class SysLoginController
...
@@ -118,7 +119,7 @@ public class SysLoginController
* 获取企业扫码登录相关参数
* 获取企业扫码登录相关参数
* @return
* @return
*/
*/
@GetMapping
(
"/find
QrLoginParm
"
)
@GetMapping
(
"/find
WxQrLoginInfo
"
)
public
AjaxResult
findQrLoginParm
(){
public
AjaxResult
findQrLoginParm
(){
WeCorpAccount
validWeCorpAccount
WeCorpAccount
validWeCorpAccount
...
@@ -142,10 +143,19 @@ public class SysLoginController
...
@@ -142,10 +143,19 @@ public class SysLoginController
@GetMapping
(
"/wxQrLogin"
)
@GetMapping
(
"/wxQrLogin"
)
public
AjaxResult
wxQrLogin
(
String
auth_code
){
public
AjaxResult
wxQrLogin
(
String
auth_code
){
AjaxResult
ajax
=
AjaxResult
.
success
();
WeLoginUserInfoDto
loginInfo
=
weAccessTokenClient
.
getLoginInfo
(
auth_code
);
WeLoginUserInfoDto
loginInfo
=
weAccessTokenClient
.
getLoginInfo
(
auth_code
);
if
(
null
!=
loginInfo
.
getUser_info
()){
String
token
=
loginService
.
noPwdLogin
(
loginInfo
.
getUser_info
().
getUserid
());
ajax
.
put
(
Constants
.
TOKEN
,
token
);
}
System
.
out
.
println
(
auth_code
)
;
return
ajax
;
return
AjaxResult
.
success
();
}
}
}
}
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMessagePushController.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.web.controller.wecom
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.utils.poi.ExcelUtil
;
import
com.linkwechat.wecom.domain.WeMessagePush
;
import
com.linkwechat.wecom.service.IWeMessagePushService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 消息发送的Controller
*
* @author ruoyi
* @date 2020-10-28
*/
@RestController
@RequestMapping
(
"/system/push"
)
public
class
WeMessagePushController
extends
BaseController
{
@Autowired
private
IWeMessagePushService
weMessagePushService
;
/**
* 查询消息发送的列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:push:list')"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
WeMessagePush
weMessagePush
)
{
startPage
();
List
<
WeMessagePush
>
list
=
weMessagePushService
.
selectWeMessagePushList
(
weMessagePush
);
return
getDataTable
(
list
);
}
/**
* 导出消息发送的列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:push:export')"
)
@Log
(
title
=
"消息发送的"
,
businessType
=
BusinessType
.
EXPORT
)
@GetMapping
(
"/export"
)
public
AjaxResult
export
(
WeMessagePush
weMessagePush
)
{
List
<
WeMessagePush
>
list
=
weMessagePushService
.
selectWeMessagePushList
(
weMessagePush
);
ExcelUtil
<
WeMessagePush
>
util
=
new
ExcelUtil
<
WeMessagePush
>(
WeMessagePush
.
class
);
return
util
.
exportExcel
(
list
,
"push"
);
}
/**
* 获取消息发送的详细信息
*/
@PreAuthorize
(
"@ss.hasPermi('system:push:query')"
)
@GetMapping
(
value
=
"/{messagePushId}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"messagePushId"
)
Long
messagePushId
)
{
return
AjaxResult
.
success
(
weMessagePushService
.
selectWeMessagePushById
(
messagePushId
));
}
/**
* 新增消息发送的
*/
@PreAuthorize
(
"@ss.hasPermi('system:push:add')"
)
@Log
(
title
=
"消息发送的"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
value
=
"add"
)
public
AjaxResult
add
(
@RequestBody
WeMessagePush
weMessagePush
)
{
return
toAjax
(
weMessagePushService
.
insertWeMessagePush
(
weMessagePush
));
}
/**
* 删除消息发送的
*/
@PreAuthorize
(
"@ss.hasPermi('system:push:remove')"
)
@Log
(
title
=
"消息发送的"
,
businessType
=
BusinessType
.
DELETE
)
@DeleteMapping
(
"/{messagePushIds}"
)
public
AjaxResult
remove
(
@PathVariable
Long
[]
messagePushIds
)
{
return
toAjax
(
weMessagePushService
.
deleteWeMessagePushByIds
(
messagePushIds
));
}
}
linkwe-common/pom.xml
浏览文件 @
b06a1a36
...
@@ -178,11 +178,21 @@
...
@@ -178,11 +178,21 @@
<dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
</dependency>
</dependency>
<!--动态添加属性和方法开始-->
<dependency>
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils
</artifactId>
<version>
1.9.3
</version>
</dependency>
<dependency>
<groupId>
cglib
</groupId>
<artifactId>
cglib-nodep
</artifactId>
<version>
3.2.4
</version>
</dependency>
<!--动态添加属性和方法结束-->
</dependencies>
</dependencies>
...
...
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
浏览文件 @
b06a1a36
...
@@ -61,8 +61,6 @@ public class WeConstans {
...
@@ -61,8 +61,6 @@ public class WeConstans {
public
static
final
Integer
LEAVE_NO_ALLOCATE_STATE
=
0
;
public
static
final
Integer
LEAVE_NO_ALLOCATE_STATE
=
0
;
/**
/**
* 离职已分配分配
* 离职已分配分配
*/
*/
...
@@ -72,28 +70,25 @@ public class WeConstans {
...
@@ -72,28 +70,25 @@ public class WeConstans {
/**
/**
* 已激活
* 已激活
*/
*/
public
static
final
Integer
WE_USER_IS_ACTIVATE
=
1
;
public
static
final
Integer
WE_USER_IS_ACTIVATE
=
1
;
/**
/**
* 已禁用
* 已禁用
*/
*/
public
static
final
Integer
WE_USER_IS_FORBIDDEN
=
2
;
public
static
final
Integer
WE_USER_IS_FORBIDDEN
=
2
;
/**
/**
* 已离职
* 已离职
*/
*/
public
static
final
Integer
WE_USER_IS_LEAVE
=
6
;
public
static
final
Integer
WE_USER_IS_LEAVE
=
6
;
/**
/**
* 未激活
* 未激活
*/
*/
public
static
final
Integer
WE_USER_IS_NO_ACTIVATE
=
4
;
public
static
final
Integer
WE_USER_IS_NO_ACTIVATE
=
4
;
/**
/**
...
@@ -123,57 +118,57 @@ public class WeConstans {
...
@@ -123,57 +118,57 @@ public class WeConstans {
/**
/**
* 在小程序中联系场景
* 在小程序中联系场景
*/
*/
public
static
final
Integer
SMALL_ROUTINE_EMPLE_CODE_SCENE
=
1
;
public
static
final
Integer
SMALL_ROUTINE_EMPLE_CODE_SCENE
=
1
;
/**
/**
* 通过二维码联系场景
* 通过二维码联系场景
*/
*/
public
static
final
Integer
QR_CODE_EMPLE_CODE_SCENE
=
2
;
public
static
final
Integer
QR_CODE_EMPLE_CODE_SCENE
=
2
;
/**
/**
* 微信接口相应端错误字段
* 微信接口相应端错误字段
*/
*/
public
static
final
String
WE_ERROR_FIELD
=
"errcode"
;
public
static
final
String
WE_ERROR_FIELD
=
"errcode"
;
/**
/**
* 递归
* 递归
*/
*/
public
static
final
Integer
YES_IS_RECURSION
=
0
;
public
static
final
Integer
YES_IS_RECURSION
=
0
;
/**
/**
* 获取所有子部门数据
* 获取所有子部门数据
*/
*/
public
static
final
Integer
DEPARTMENT_SUB_WEUSER
=
1
;
public
static
final
Integer
DEPARTMENT_SUB_WEUSER
=
1
;
/**
/**
* 获取当前部门
* 获取当前部门
*/
*/
public
static
final
Integer
DEPARTMENT_CURRENT_WEUSER
=
0
;
public
static
final
Integer
DEPARTMENT_CURRENT_WEUSER
=
0
;
/**
/**
* 通讯录用户激活
* 通讯录用户激活
*/
*/
public
static
final
Integer
YES_IS_ACTIVATE
=
1
;
public
static
final
Integer
YES_IS_ACTIVATE
=
1
;
/**
/**
* 通讯录用户未激活
* 通讯录用户未激活
*/
*/
public
static
final
Integer
NO_IS_ACTIVATE
=
2
;
public
static
final
Integer
NO_IS_ACTIVATE
=
2
;
/**
/**
* 不存在外部联系人的关系
* 不存在外部联系人的关系
*/
*/
public
static
final
Integer
NOT_EXIST_CONTACT
=
84061
;
public
static
final
Integer
NOT_EXIST_CONTACT
=
84061
;
public
static
final
String
COMMA
=
","
;
}
}
linkwe-common/src/main/java/com/linkwechat/common/enums/MediaType.java
浏览文件 @
b06a1a36
...
@@ -32,7 +32,7 @@ public enum MediaType {
...
@@ -32,7 +32,7 @@ public enum MediaType {
this
.
mediaType
=
mediaType
;
this
.
mediaType
=
mediaType
;
}
}
public
static
Optional
<
MediaType
>
of
(
String
type
){
public
static
Optional
<
MediaType
>
of
(
String
type
)
{
return
Stream
.
of
(
values
()).
filter
(
s
->
s
.
type
.
equals
(
type
)).
findFirst
();
return
Stream
.
of
(
values
()).
filter
(
s
->
s
.
type
.
equals
(
type
)).
findFirst
();
}
}
}
}
linkwe-common/src/main/java/com/linkwechat/common/enums/MessageType.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.common.enums
;
import
lombok.Getter
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
/**
* 应用支持推送文本、图片、视频、文件、图文等类型
*/
@SuppressWarnings
(
"all"
)
@Getter
public
enum
MessageType
{
/**
* 文本消息
*/
TEXT
(
"0"
,
"text"
),
/**
* 图片消息
*/
IMAGE
(
"1"
,
"image"
),
/**
* 语音消息
*/
VOICE
(
"2"
,
"voice"
),
/**
* 视频消息
*/
VIDEO
(
"3"
,
"video"
),
/**
* 文件消息
*/
FILE
(
"4"
,
"file"
),
/**
* 文本卡片消息
*/
TEXTCARD
(
"5"
,
"textcard"
),
/**
* 图文消息
*/
NEWS
(
"6"
,
"news"
),
/**
* 图文消息(mpnews)
*/
MPNEWS
(
"7"
,
"mpnews"
),
/**
* markdown消息
*/
MARKDOWN
(
"8"
,
"markdown"
),
/**
* 小程序通知消息
*/
MINIPROGRAM_NOTICE
(
"9"
,
"miniprogram_notice"
),
/**
* 任务卡片消息
*/
TASKCARD
(
"10"
,
"taskcard"
),
;
/**
* 媒体类型
*/
String
messageType
;
/**
* 数据值
*/
String
type
;
MessageType
(
String
type
,
String
messageType
)
{
this
.
type
=
type
;
this
.
messageType
=
messageType
;
}
public
static
Optional
<
MessageType
>
of
(
String
type
)
{
return
Stream
.
of
(
values
()).
filter
(
s
->
s
.
type
.
equals
(
type
)).
findFirst
();
}
}
linkwe-common/src/main/java/com/linkwechat/common/enums/PushType.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.common.enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
/**
* 群发类型 0 发给客户 1 发给客户群
*/
@NoArgsConstructor
@Getter
public
enum
PushType
{
/**
* 发给客户
*/
SEND_TO_USER
(
0
,
"发给客户"
),
/**
* 发给客户群
*/
SENT_TO_USER_GROUP
(
1
,
"发给客户群"
);
private
String
name
;
private
Integer
type
;
PushType
(
Integer
type
,
String
name
)
{
this
.
name
=
name
;
this
.
type
=
type
;
}
}
linkwe-common/src/main/java/com/linkwechat/common/utils/ReflectUtil.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.common.utils
;
import
com.google.common.collect.Maps
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.beanutils.PropertyUtilsBean
;
import
org.springframework.cglib.beans.BeanGenerator
;
import
org.springframework.cglib.beans.BeanMap
;
import
java.beans.PropertyDescriptor
;
import
java.util.Map
;
/**
* 动态添加属性和属性值
*/
@Slf4j
public
class
ReflectUtil
{
/**
* 动态添加属性
*
* @param dest 原对象
* @param addProperties 新加属性的信息
* @return {@link Object} 新增属性和属性值之后的对象
*/
public
static
Object
getTarget
(
Object
dest
,
Map
<
String
,
Object
>
addProperties
)
{
// get property map
PropertyUtilsBean
propertyUtilsBean
=
new
PropertyUtilsBean
();
PropertyDescriptor
[]
descriptors
=
propertyUtilsBean
.
getPropertyDescriptors
(
dest
);
Map
<
String
,
Class
>
propertyMap
=
Maps
.
newHashMap
();
for
(
PropertyDescriptor
d
:
descriptors
)
{
if
(!
"class"
.
equalsIgnoreCase
(
d
.
getName
()))
{
propertyMap
.
put
(
d
.
getName
(),
d
.
getPropertyType
());
}
}
// add extra properties
addProperties
.
forEach
((
k
,
v
)
->
propertyMap
.
put
(
k
,
v
.
getClass
()));
// new dynamic bean
DynamicBean
dynamicBean
=
new
DynamicBean
(
dest
.
getClass
(),
propertyMap
);
// add old value
propertyMap
.
forEach
((
k
,
v
)
->
{
try
{
// filter extra properties
if
(!
addProperties
.
containsKey
(
k
))
{
dynamicBean
.
setValue
(
k
,
propertyUtilsBean
.
getNestedProperty
(
dest
,
k
));
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
});
// add extra value
addProperties
.
forEach
((
k
,
v
)
->
{
try
{
dynamicBean
.
setValue
(
k
,
v
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
});
Object
target
=
dynamicBean
.
getTarget
();
return
target
;
}
public
static
class
DynamicBean
{
/**
* 目标对象
*/
private
Object
target
;
/**
* 属性集合
*/
private
BeanMap
beanMap
;
public
DynamicBean
(
Class
superclass
,
Map
<
String
,
Class
>
propertyMap
)
{
this
.
target
=
generateBean
(
superclass
,
propertyMap
);
this
.
beanMap
=
BeanMap
.
create
(
this
.
target
);
}
/**
* bean 添加属性和值
*
* @param property
* @param value
*/
public
void
setValue
(
String
property
,
Object
value
)
{
beanMap
.
put
(
property
,
value
);
}
/**
* 获取属性值
*
* @param property
* @return
*/
public
Object
getValue
(
String
property
)
{
return
beanMap
.
get
(
property
);
}
/**
* 获取对象
*
* @return
*/
public
Object
getTarget
()
{
return
this
.
target
;
}
/**
* 根据属性生成对象
*
* @param superclass
* @param propertyMap
* @return
*/
private
Object
generateBean
(
Class
superclass
,
Map
<
String
,
Class
>
propertyMap
)
{
BeanGenerator
generator
=
new
BeanGenerator
();
if
(
null
!=
superclass
)
{
generator
.
setSuperclass
(
superclass
);
}
BeanGenerator
.
addProperties
(
generator
,
propertyMap
);
return
generator
.
create
();
}
}
}
linkwe-framework/src/main/java/com/linkwechat/framework/config/SecurityConfig.java
浏览文件 @
b06a1a36
...
@@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
...
@@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求
// 过滤请求
.
authorizeRequests
()
.
authorizeRequests
()
// 对于登录login 验证码captchaImage 允许匿名访问
// 对于登录login 验证码captchaImage 允许匿名访问
.
antMatchers
(
"/login"
,
"/captchaImage"
,
"/find
QrLoginParm
"
,
"/wxQrLogin"
).
anonymous
()
.
antMatchers
(
"/login"
,
"/captchaImage"
,
"/find
WxQrLoginInfo
"
,
"/wxQrLogin"
).
anonymous
()
.
antMatchers
(
.
antMatchers
(
HttpMethod
.
GET
,
HttpMethod
.
GET
,
"/*.html"
,
"/*.html"
,
...
...
linkwe-framework/src/main/java/com/linkwechat/framework/web/service/SysLoginService.java
浏览文件 @
b06a1a36
...
@@ -6,6 +6,8 @@ import org.springframework.security.authentication.AuthenticationManager;
...
@@ -6,6 +6,8 @@ import org.springframework.security.authentication.AuthenticationManager;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.core.domain.model.LoginUser
;
import
com.linkwechat.common.core.domain.model.LoginUser
;
...
@@ -35,6 +37,9 @@ public class SysLoginService
...
@@ -35,6 +37,9 @@ public class SysLoginService
@Autowired
@Autowired
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
@Autowired
private
UserDetailsService
userDetailsService
;
/**
/**
* 登录验证
* 登录验证
*
*
...
@@ -46,6 +51,7 @@ public class SysLoginService
...
@@ -46,6 +51,7 @@ public class SysLoginService
*/
*/
public
String
login
(
String
username
,
String
password
,
String
code
,
String
uuid
)
public
String
login
(
String
username
,
String
password
,
String
code
,
String
uuid
)
{
{
String
verifyKey
=
Constants
.
CAPTCHA_CODE_KEY
+
uuid
;
String
verifyKey
=
Constants
.
CAPTCHA_CODE_KEY
+
uuid
;
String
captcha
=
redisCache
.
getCacheObject
(
verifyKey
);
String
captcha
=
redisCache
.
getCacheObject
(
verifyKey
);
redisCache
.
deleteObject
(
verifyKey
);
redisCache
.
deleteObject
(
verifyKey
);
...
@@ -59,6 +65,7 @@ public class SysLoginService
...
@@ -59,6 +65,7 @@ public class SysLoginService
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.jcaptcha.error"
)));
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.jcaptcha.error"
)));
throw
new
CaptchaException
();
throw
new
CaptchaException
();
}
}
// 用户验证
// 用户验证
Authentication
authentication
=
null
;
Authentication
authentication
=
null
;
try
try
...
@@ -85,4 +92,20 @@ public class SysLoginService
...
@@ -85,4 +92,20 @@ public class SysLoginService
// 生成token
// 生成token
return
tokenService
.
createToken
(
loginUser
);
return
tokenService
.
createToken
(
loginUser
);
}
}
/**
* 无密码登录
* @param userName
* @return
*/
public
String
noPwdLogin
(
String
userName
){
LoginUser
loginUser
=
(
LoginUser
)
userDetailsService
.
loadUserByUsername
(
userName
);
return
tokenService
.
createToken
(
loginUser
);
}
}
}
linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java
浏览文件 @
b06a1a36
...
@@ -4,12 +4,15 @@ import cn.hutool.core.util.ArrayUtil;
...
@@ -4,12 +4,15 @@ import cn.hutool.core.util.ArrayUtil;
import
com.linkwechat.common.config.RuoYiConfig
;
import
com.linkwechat.common.config.RuoYiConfig
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.core.domain.entity.SysRole
;
import
com.linkwechat.common.core.domain.entity.SysRole
;
import
com.linkwechat.common.core.domain.entity.SysUser
;
import
com.linkwechat.common.core.domain.model.LoginUser
;
import
com.linkwechat.common.enums.UserStatus
;
import
com.linkwechat.common.exception.BaseException
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.system.mapper.SysRoleMapper
;
import
com.linkwechat.system.mapper.SysRoleMapper
;
import
com.linkwechat.system.service.ISysRoleService
;
import
com.linkwechat.system.service.ISysUserService
;
import
com.linkwechat.wecom.domain.WeCorpAccount
;
import
com.linkwechat.wecom.domain.WeUser
;
import
com.linkwechat.wecom.domain.WeUser
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
com.linkwechat.wecom.service.IWeUserService
;
import
com.linkwechat.wecom.service.IWeUserService
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -18,14 +21,7 @@ import org.springframework.security.core.userdetails.UserDetails;
...
@@ -18,14 +21,7 @@ import org.springframework.security.core.userdetails.UserDetails;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.linkwechat.common.core.domain.entity.SysUser
;
import
com.linkwechat.common.core.domain.model.LoginUser
;
import
com.linkwechat.common.enums.UserStatus
;
import
com.linkwechat.common.exception.BaseException
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.system.service.ISysUserService
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -100,11 +96,12 @@ public class UserDetailsServiceImpl implements UserDetailsService
...
@@ -100,11 +96,12 @@ public class UserDetailsServiceImpl implements UserDetailsService
}
}
return
createLoginUser
(
user
);
return
createLoginUser
(
user
);
}
}
public
UserDetails
createLoginUser
(
SysUser
user
)
public
UserDetails
createLoginUser
(
SysUser
user
)
{
{
return
new
LoginUser
(
user
,
permissionService
.
getMenuPermission
(
user
));
return
new
LoginUser
(
user
,
permissionService
.
getMenuPermission
(
user
));
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMessagePushClient.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.client
;
import
com.dtflys.forest.annotation.DataObject
;
import
com.dtflys.forest.annotation.Request
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushGroupDto
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushResultDto
;
/**
* @description: 消息推送
* @author: KeWen
* @create: 2020-10-17 22:41
**/
@SuppressWarnings
(
"all"
)
public
interface
WeMessagePushClient
{
/**
* 发送应用消息
*/
@Request
(
url
=
"/message/send"
,
type
=
"POST"
)
WeMessagePushResultDto
sendMessageToUser
(
@DataObject
WeMessagePushDto
weMessagePushDto
);
/**
* 应用推送消息
*/
@Request
(
url
=
"/appchat/send"
,
type
=
"POST"
)
WeMessagePushResultDto
sendMessageToUserGroup
(
@DataObject
WeMessagePushGroupDto
weMessagePushGroupDto
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCorpAccount.java
浏览文件 @
b06a1a36
...
@@ -66,4 +66,8 @@ public class WeCorpAccount extends BaseEntity
...
@@ -66,4 +66,8 @@ public class WeCorpAccount extends BaseEntity
private
String
providerSecret
;
private
String
providerSecret
;
@ApiModelProperty
(
"企业微信扫码登陆回调地址"
)
private
String
wxQrLoginRedirectUri
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeMessagePush.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.domain
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
lombok.Data
;
/**
* 消息发送的对象 we_message_push
*
* @author KeWen
* @date 2020-10-28
*/
@Data
public
class
WeMessagePush
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键id
*/
private
Long
messagePushId
;
/**
* 群发类型 0 发给客户 1 发给客户群
*/
private
Integer
pushType
;
/**
* 消息类型 0 文本消息 1 图片消息 2 语音消息 3 视频消息 4 文件消息 5 文本卡片消息 6 图文消息
* 7 图文消息(mpnews) 8 markdown消息 9 小程序通知消息 10 任务卡片消息
*/
private
String
messageType
;
/**
* 消息体
*/
private
String
messageJson
;
/**
* 消息范围 0 全部客户 1 指定客户
*/
private
String
pushRange
;
/**
* 0 未删除 1 已删除
*/
private
Integer
delFlag
;
/**
* 无效用户
*/
private
String
invaliduser
;
/**
* 无效单位
*/
private
String
invalidparty
;
/**
* 无效标签
*/
private
String
invalidtag
;
/**
* 指定接收消息的成员
*/
private
String
toUser
;
/**
* 指定接收消息的部门
*/
private
String
toParty
;
/**
* 指定接收消息的标签
*/
private
String
toTag
;
/**
* 群聊id
*/
private
String
chatId
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeMessagePushDto.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.domain.dto
;
import
lombok.Data
;
@SuppressWarnings
(
"all"
)
@Data
public
class
WeMessagePushDto
{
/**
* 指定接收消息的成员,成员ID列表(多个接收者用‘|’分隔,最多支持1000个)。
* 特殊情况:指定为”@all”,则向该企业应用的全部成员发送
*/
private
String
touser
;
/**
* 指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。
* 当touser为”@all”时忽略本参数
*/
private
String
toparty
;
/**
* 指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。
* 当touser为”@all”时忽略本参数
*/
private
String
totag
;
/**
* 消息类型,此时固定为:text
*/
private
String
msgtype
;
/**
* 企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口
* <a href="https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E6%8E%88%E6%9D%83%E4%BF%A1%E6%81%AF">获取企业授权信息</a> 获取该参数值
*/
private
Integer
agentid
;
/**
* 表示是否是保密消息,0表示否,1表示是,默认0
*/
private
Integer
safe
;
/**
* 表示是否开启id转译,0表示否,1表示是,默认0
*/
private
Integer
enable_id_trans
;
/**
* 表示是否开启重复消息检查,0表示否,1表示是,默认0
*/
private
Integer
enable_duplicate_check
;
/**
* 表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时
*/
private
Long
duplicate_check_interval
;
/**
* 根据msgtype的值不同添加一个属性和对应的属性值
*/
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeMessagePushGroupDto.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.domain.dto
;
import
lombok.Data
;
@SuppressWarnings
(
"all"
)
@Data
public
class
WeMessagePushGroupDto
{
/**
* 群聊id
*/
private
String
chatid
;
/**
* 消息类型
*/
private
String
msgtype
;
/**
* 表示是否是保密消息,0表示否,1表示是,默认0
*/
private
Integer
safe
;
/**
* 根据msgtype的值不同添加一个属性和对应的属性值
*/
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeMessagePushResultDto.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.domain.dto
;
import
cn.hutool.json.JSONObject
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.Maps
;
import
com.linkwechat.common.enums.MessageType
;
import
com.linkwechat.common.utils.ReflectUtil
;
import
lombok.Data
;
import
java.util.HashMap
;
import
java.util.Optional
;
/**
* @description: 发送应用消息响应应用结果
* @author: KeWen
* @create: 2020-10-27 22:46
**/
@Data
public
class
WeMessagePushResultDto
extends
WeResultDto
{
/**
* 无效用户
*/
private
String
invaliduser
;
/**
* 无效单位
*/
private
String
invalidparty
;
/**
* 无效标签
*/
private
String
invalidtag
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeMessagePushMapper.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.linkwechat.wecom.domain.WeMessagePush
;
/**
* 消息发送的对象 we_message_push
*
* @author KeWen
* @date 2020-10-28
*/
public
interface
WeMessagePushMapper
extends
BaseMapper
<
WeMessagePush
>
{
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeMessagePushService.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.service
;
import
com.linkwechat.wecom.domain.WeMessagePush
;
import
java.util.List
;
/**
* 消息发送的Service接口
*
* @author KeWen
* @date 2020-10-28
*/
public
interface
IWeMessagePushService
{
/**
* 查询消息发送的
*
* @param messagePushId 消息发送的ID
* @return 消息发送的
*/
public
WeMessagePush
selectWeMessagePushById
(
Long
messagePushId
);
/**
* 查询消息发送的列表
*
* @param weMessagePush 消息发送的
* @return 消息发送的集合
*/
public
List
<
WeMessagePush
>
selectWeMessagePushList
(
WeMessagePush
weMessagePush
);
/**
* 新增消息发送的
*
* @param weMessagePush 消息发送的
* @return 结果
*/
public
int
insertWeMessagePush
(
WeMessagePush
weMessagePush
);
/**
* 批量删除消息发送的
*
* @param messagePushIds 需要删除的消息发送的ID
* @return 结果
*/
public
int
deleteWeMessagePushByIds
(
Long
[]
messagePushIds
);
/**
* 删除消息发送的信息
*
* @param messagePushId 消息发送的ID
* @return 结果
*/
public
int
deleteWeMessagePushById
(
Long
messagePushId
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCategoryServiceImpl.java
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.service.impl
;
package
com.linkwechat.wecom.service.impl
;
import
cn.hutool.core.date.DateUtil
;
import
com.linkwechat.common.core.domain.Tree
;
import
com.linkwechat.common.core.domain.Tree
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.TreeUtil
;
import
com.linkwechat.common.utils.TreeUtil
;
import
com.linkwechat.wecom.domain.WeCategory
;
import
com.linkwechat.wecom.domain.WeCategory
;
import
com.linkwechat.wecom.domain.vo.WeCategoryVo
;
import
com.linkwechat.wecom.domain.vo.WeCategoryVo
;
...
@@ -28,6 +30,8 @@ public class WeCategoryServiceImpl implements IWeCategoryService {
...
@@ -28,6 +30,8 @@ public class WeCategoryServiceImpl implements IWeCategoryService {
if
(
null
!=
weCategory
)
{
if
(
null
!=
weCategory
)
{
throw
new
WeComException
(
"名称已存在!"
);
throw
new
WeComException
(
"名称已存在!"
);
}
}
category
.
setCreateTime
(
DateUtil
.
date
());
category
.
setId
(
SnowFlakeUtil
.
nextId
());
return
weCategoryMapper
.
insertWeCategory
(
category
);
return
weCategoryMapper
.
insertWeCategory
(
category
);
}
}
...
@@ -38,6 +42,7 @@ public class WeCategoryServiceImpl implements IWeCategoryService {
...
@@ -38,6 +42,7 @@ public class WeCategoryServiceImpl implements IWeCategoryService {
if
(
null
!=
weCategory
)
{
if
(
null
!=
weCategory
)
{
throw
new
WeComException
(
"名称已存在!"
);
throw
new
WeComException
(
"名称已存在!"
);
}
}
category
.
setUpdateTime
(
DateUtil
.
date
());
return
weCategoryMapper
.
updateWeCategory
(
category
);
return
weCategoryMapper
.
updateWeCategory
(
category
);
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMaterialServiceImpl.java
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.service.impl
;
package
com.linkwechat.wecom.service.impl
;
import
cn.hutool.core.date.DateUtil
;
import
com.linkwechat.common.config.RuoYiConfig
;
import
com.linkwechat.common.config.RuoYiConfig
;
import
com.linkwechat.common.config.ServerConfig
;
import
com.linkwechat.common.config.ServerConfig
;
import
com.linkwechat.common.enums.MediaType
;
import
com.linkwechat.common.enums.MediaType
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.file.FileUploadUtils
;
import
com.linkwechat.common.utils.file.FileUploadUtils
;
import
com.linkwechat.wecom.domain.WeMaterial
;
import
com.linkwechat.wecom.domain.WeMaterial
;
import
com.linkwechat.wecom.domain.vo.WeMaterialFileVO
;
import
com.linkwechat.wecom.domain.vo.WeMaterialFileVO
;
...
@@ -60,6 +62,8 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
...
@@ -60,6 +62,8 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
@Override
@Override
public
int
insertWeMaterial
(
WeMaterial
weMaterial
)
{
public
int
insertWeMaterial
(
WeMaterial
weMaterial
)
{
weMaterial
.
setCreateTime
(
DateUtil
.
date
());
weMaterial
.
setId
(
SnowFlakeUtil
.
nextId
());
return
weMaterialMapper
.
insertWeMaterial
(
weMaterial
);
return
weMaterialMapper
.
insertWeMaterial
(
weMaterial
);
}
}
...
@@ -75,6 +79,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
...
@@ -75,6 +79,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
@Override
@Override
public
int
updateWeMaterial
(
WeMaterial
weMaterial
)
{
public
int
updateWeMaterial
(
WeMaterial
weMaterial
)
{
weMaterial
.
setCreateTime
(
DateUtil
.
date
());
return
weMaterialMapper
.
updateWeMaterial
(
weMaterial
);
return
weMaterialMapper
.
updateWeMaterial
(
weMaterial
);
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMessagePushServiceImpl.java
0 → 100644
浏览文件 @
b06a1a36
package
com.linkwechat.wecom.service.impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.json.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.enums.MessageType
;
import
com.linkwechat.common.enums.PushType
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.ReflectUtil
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.client.WeMessagePushClient
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.WeMessagePush
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushGroupDto
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushResultDto
;
import
com.linkwechat.wecom.mapper.WeMessagePushMapper
;
import
com.linkwechat.wecom.service.IWeGroupService
;
import
com.linkwechat.wecom.service.IWeMessagePushService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
* 消息发送的Service接口
*
* @author KeWen
* @date 2020-10-28
*/
@Service
public
class
WeMessagePushServiceImpl
implements
IWeMessagePushService
{
@Autowired
private
WeMessagePushMapper
weMessagePushMapper
;
@Autowired
private
WeMessagePushClient
weMessagePushClient
;
@Autowired
private
IWeGroupService
weGroupService
;
@Override
public
WeMessagePush
selectWeMessagePushById
(
Long
messagePushId
)
{
return
weMessagePushMapper
.
selectById
(
messagePushId
);
}
@Override
public
List
<
WeMessagePush
>
selectWeMessagePushList
(
WeMessagePush
weMessagePush
)
{
return
weMessagePushMapper
.
selectList
(
new
QueryWrapper
<>());
}
@Override
public
int
insertWeMessagePush
(
WeMessagePush
weMessagePush
)
{
HashMap
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
JSONObject
jsonObject
=
new
JSONObject
(
weMessagePush
.
getMessageJson
());
Optional
<
MessageType
>
of
=
MessageType
.
of
(
weMessagePush
.
getMessageType
());
of
.
ifPresent
(
messageType
->
map
.
put
(
messageType
.
getMessageType
(),
jsonObject
));
if
(
weMessagePush
.
getPushType
()
!=
null
&&
weMessagePush
.
getPushType
().
equals
(
PushType
.
SEND_TO_USER
.
getType
()))
{
//发送消息
WeMessagePushDto
weMessagePushDto
=
new
WeMessagePushDto
();
weMessagePushDto
.
setTouser
(
weMessagePush
.
getToUser
());
weMessagePushDto
.
setToparty
(
weMessagePush
.
getToParty
());
weMessagePushDto
.
setTotag
(
weMessagePush
.
getToTag
());
weMessagePushDto
.
setMsgtype
(
weMessagePush
.
getMessageType
());
//这个先写在配置文件中
weMessagePushDto
.
setAgentid
(
1000003
);
weMessagePushDto
.
setSafe
(
0
);
weMessagePushDto
.
setEnable_id_trans
(
0
);
weMessagePushDto
.
setEnable_duplicate_check
(
0
);
weMessagePushDto
.
setDuplicate_check_interval
(
1800L
);
//动态添加微信消息体属性和属性值信息
WeMessagePushDto
target
=
(
WeMessagePushDto
)
ReflectUtil
.
getTarget
(
weMessagePushDto
,
map
);
WeMessagePushResultDto
weMessagePushResultDto
=
weMessagePushClient
.
sendMessageToUser
(
target
);
if
(
weMessagePushResultDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
))
{
weMessagePush
.
setCreateTime
(
DateUtils
.
getNowDate
());
weMessagePush
.
setDelFlag
(
0
);
weMessagePush
.
setMessagePushId
(
SnowFlakeUtil
.
nextId
());
//存储返回结果信息
weMessagePush
.
setInvaliduser
(
weMessagePushResultDto
.
getInvaliduser
());
weMessagePush
.
setInvalidparty
(
weMessagePushResultDto
.
getInvalidparty
());
weMessagePush
.
setInvalidtag
(
weMessagePushResultDto
.
getInvalidtag
());
}
}
if
(
weMessagePush
.
getPushType
()
!=
null
&&
weMessagePush
.
getPushType
().
equals
(
PushType
.
SENT_TO_USER_GROUP
.
getType
()))
{
//根据员工id列表查询所有的群信息
List
<
String
>
strings
=
Arrays
.
asList
(
StringUtils
.
splitByWholeSeparatorPreserveAllTokens
(
weMessagePush
.
getToUser
(),
WeConstans
.
COMMA
));
List
<
String
>
chatIds
=
Lists
.
newArrayList
();
strings
.
forEach
(
s
->
{
List
<
WeGroup
>
groups
=
weGroupService
.
list
(
new
LambdaQueryWrapper
<
WeGroup
>().
eq
(
WeGroup:
:
getOwner
,
s
));
//发送消息到群聊
if
(
CollectionUtil
.
isNotEmpty
(
groups
))
{
groups
.
forEach
(
d
->
{
WeMessagePushGroupDto
weMessagePushGroupDto
=
new
WeMessagePushGroupDto
();
weMessagePushGroupDto
.
setChatid
(
d
.
getChatId
());
weMessagePushGroupDto
.
setMsgtype
(
weMessagePush
.
getMessageType
());
weMessagePushGroupDto
.
setSafe
(
0
);
//动态添加微信消息体属性和属性值信息
WeMessagePushGroupDto
target
=
(
WeMessagePushGroupDto
)
ReflectUtil
.
getTarget
(
weMessagePushGroupDto
,
map
);
WeMessagePushResultDto
weMessagePushResultDto
=
weMessagePushClient
.
sendMessageToUserGroup
(
target
);
if
(
weMessagePushResultDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
))
{
//保存发送的群消息
chatIds
.
add
(
d
.
getChatId
());
}
});
}
});
weMessagePush
.
setCreateTime
(
DateUtils
.
getNowDate
());
weMessagePush
.
setDelFlag
(
0
);
weMessagePush
.
setMessagePushId
(
SnowFlakeUtil
.
nextId
());
weMessagePush
.
setChatId
(
CollectionUtil
.
isNotEmpty
(
chatIds
)
?
String
.
join
(
","
,
chatIds
)
:
null
);
}
return
weMessagePushMapper
.
insert
(
weMessagePush
);
}
@Override
public
int
deleteWeMessagePushByIds
(
Long
[]
messagePushIds
)
{
return
weMessagePushMapper
.
deleteBatchIds
(
Arrays
.
asList
(
messagePushIds
));
}
@Override
public
int
deleteWeMessagePushById
(
Long
messagePushId
)
{
return
weMessagePushMapper
.
deleteById
(
messagePushId
);
}
}
linkwe-wecom/src/main/resources/mapper/wecom/WeMessagePushMapper.xml
0 → 100644
浏览文件 @
b06a1a36
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ruoyi.system.mapper.WeMessagePushMapper"
>
</mapper>
\ No newline at end of file
sql/link-wechat.sql
浏览文件 @
b06a1a36
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录