Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c791a352
authored
Feb 09, 2021
by
leejoker
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/back_end_dev' into back_end_dev
2 parents
273e13c7
a7519b02
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
93 additions
and
14 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCallBackController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java
linkwe-admin/src/main/resources/application.yml
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
linkwe-framework/src/main/java/com/linkwechat/framework/config/RedisConfig.java
linkwe-framework/src/main/java/com/linkwechat/framework/listener/EmpleCodeExpiredListener.java
linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMessagePushClient.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeUser.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/factory/impl/customer/WeCallBackDelFollowUserImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeEmpleCodeServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeSensitiveServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/strategy/SendMessageToUserStrategy.java
linkwe-wecom/src/main/resources/mapper/wecom/WeUserMapper.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCallBackController.java
View file @
c791a35
...
...
@@ -37,7 +37,7 @@ public class WeCallBackController extends CommonController {
@Value
(
"${wecome.callBack.encodingAesKey}"
)
private
String
encodingAesKey
;
@PostMapping
(
value
=
"/recive"
,
produces
=
{
"application/xml;charset=UTF-8"
}
)
@PostMapping
(
value
=
"/recive"
)
public
String
recive
(
@RequestBody
String
msg
,
@RequestParam
(
name
=
"msg_signature"
)
String
signature
,
String
timestamp
,
String
nonce
)
{
WxCryptUtil
wxCryptUtil
=
new
WxCryptUtil
(
token
,
encodingAesKey
,
appIdOrCorpId
);
...
...
@@ -61,7 +61,7 @@ public class WeCallBackController extends CommonController {
}
}
@GetMapping
(
value
=
"/recive"
,
produces
=
{
"application/xml;charset=UTF-8"
}
)
@GetMapping
(
value
=
"/recive"
)
public
String
recive
(
HttpServletRequest
request
)
{
// 微信加密签名
String
sVerifyMsgSig
=
request
.
getParameter
(
"msg_signature"
);
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java
View file @
c791a35
...
...
@@ -44,7 +44,7 @@ public class WeTagGroupController extends BaseController
public
TableDataInfo
list
(
WeTagGroup
weTagGroup
)
{
startPage
();
synchWeTags
();
//
synchWeTags();
return
getDataTable
(
weTagGroupService
.
selectWeTagGroupList
(
weTagGroup
)
);
...
...
linkwe-admin/src/main/resources/application.yml
View file @
c791a35
...
...
@@ -209,9 +209,9 @@ wecome:
-
/message/send
#企微回调通知配置
callBack
:
appIdOrCorpId
:
ww
38152475d1bca752
token
:
uEyhhuTKfpS
encodingAesKey
:
diTFQ6B4IW14UN2JplADuhMZsBZHjvuBG24kHFrr4Px
appIdOrCorpId
:
ww
24262ce93851488f
token
:
jtQ1aGHgSmH2UHNBIndUtUe6B6EwfR
encodingAesKey
:
Vga4HWv7nFbRDYK8iAaQbxmkuecpo2BAfmXAyWwcXMO
#腾讯云对象存储
cos
:
secretId
:
AKIDQRCizIeUGl13vakkDQMH0VkjhPr1rBBv
...
...
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
View file @
c791a35
...
...
@@ -44,6 +44,11 @@ public class WeConstans {
*/
public
static
final
String
WE_AGENT_ACCESS_TOKEN
=
"we_agent_access_token"
;
public
static
final
String
WE_EMPLE_CODE_KEY
=
"we_emple_code_key"
;
/**
* 企业微信接口返回成功code
*/
...
...
linkwe-framework/src/main/java/com/linkwechat/framework/config/RedisConfig.java
View file @
c791a35
package
com
.
linkwechat
.
framework
.
config
;
import
com.linkwechat.framework.listener.EmpleCodeExpiredListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CachingConfigurerSupport
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.listener.PatternTopic
;
import
org.springframework.data.redis.listener.RedisMessageListenerContainer
;
import
org.springframework.data.redis.listener.adapter.MessageListenerAdapter
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
...
...
@@ -20,6 +25,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@EnableCaching
public
class
RedisConfig
extends
CachingConfigurerSupport
{
@Autowired
private
RedisConnectionFactory
redisConnectionFactory
;
@Bean
@SuppressWarnings
(
value
=
{
"unchecked"
,
"rawtypes"
})
public
RedisTemplate
<
Object
,
Object
>
redisTemplate
(
RedisConnectionFactory
connectionFactory
)
...
...
@@ -40,4 +49,18 @@ public class RedisConfig extends CachingConfigurerSupport
template
.
afterPropertiesSet
();
return
template
;
}
@Bean
public
RedisMessageListenerContainer
redisMessageListenerContainer
()
{
RedisMessageListenerContainer
redisMessageListenerContainer
=
new
RedisMessageListenerContainer
();
redisMessageListenerContainer
.
setConnectionFactory
(
redisConnectionFactory
);
return
redisMessageListenerContainer
;
}
@Bean
public
EmpleCodeExpiredListener
codeExpiredListener
()
{
return
new
EmpleCodeExpiredListener
(
this
.
redisMessageListenerContainer
());
}
}
linkwe-framework/src/main/java/com/linkwechat/framework/listener/EmpleCodeExpiredListener.java
0 → 100644
View file @
c791a35
package
com
.
linkwechat
.
framework
.
listener
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.wecom.client.WeExternalContactClient
;
import
com.linkwechat.wecom.domain.WeEmpleCode
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.Message
;
import
org.springframework.data.redis.listener.KeyExpirationEventMessageListener
;
import
org.springframework.data.redis.listener.RedisMessageListenerContainer
;
import
java.nio.charset.StandardCharsets
;
/**
* @author danmo
* @description redis 键值过期监听
* @date 2021/2/8 17:24
**/
public
class
EmpleCodeExpiredListener
extends
KeyExpirationEventMessageListener
{
@Autowired
private
WeExternalContactClient
weExternalContactClient
;
public
EmpleCodeExpiredListener
(
RedisMessageListenerContainer
listenerContainer
)
{
super
(
listenerContainer
);
}
@Override
public
void
onMessage
(
Message
message
,
byte
[]
pattern
)
{
System
.
out
.
println
(
"过期key:"
+
message
.
toString
());
if
(
message
.
toString
().
contains
(
WeConstans
.
WE_EMPLE_CODE_KEY
)){
weExternalContactClient
.
delContactWay
(
message
.
toString
().
split
(
":"
)[
1
]);
}
}
}
linkwe-framework/src/main/java/com/linkwechat/framework/web/service/UserDetailsServiceImpl.java
View file @
c791a35
...
...
@@ -72,7 +72,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
.
userType
(
Constants
.
USER_TYPE_WECOME
)
.
email
(
weUser
.
getEmail
())
.
phonenumber
(
weUser
.
getMobile
())
.
sex
(
weUser
.
getGender
().
toString
())
.
sex
(
weUser
.
getGender
()
==
0
?
"1"
:
weUser
.
getGender
()
.
toString
())
.
avatar
(
weUser
.
getAvatarMediaid
())
.
roleIds
(
ArrayUtil
.
toArray
(
roleMapper
.
selectRoleList
(
SysRole
.
builder
()
.
roleKey
(
Constants
.
DEFAULT_WECOME_ROLE_KEY
)
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/client/WeMessagePushClient.java
View file @
c791a35
package
com
.
linkwechat
.
wecom
.
client
;
import
com.dtflys.forest.annotation.DataObject
;
import
com.dtflys.forest.annotation.Header
;
import
com.dtflys.forest.annotation.Request
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushGroupDto
;
...
...
@@ -20,7 +21,7 @@ public interface WeMessagePushClient {
@Request
(
url
=
"/message/send"
,
type
=
"POST"
)
WeMessagePushResultDto
sendMessageToUser
(
@DataObject
WeMessagePushDto
weMessagePushDto
);
WeMessagePushResultDto
sendMessageToUser
(
@DataObject
WeMessagePushDto
weMessagePushDto
,
@Header
(
"agentId"
)
String
agentId
);
/**
* 应用推送消息
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeUser.java
View file @
c791a35
...
...
@@ -57,7 +57,7 @@ public class WeUser
private
String
userId
;
/** 性别。1表示男性,2表示女性 */
private
Integer
gender
=
new
Integer
(
1
)
;
private
Integer
gender
;
/** 手机号 */
@NotBlank
(
message
=
"手机号不可为空"
)
...
...
@@ -102,7 +102,8 @@ public class WeUser
private
Date
birthday
;
/** 是否激活(1:是;2:否)该字段主要表示当前信息是否同步微信 */
private
Integer
isActivate
=
new
Integer
(
2
);
/** 激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业,6=删除 */
private
Integer
isActivate
;
/** 离职是否分配(1:已分配;0:未分配;) */
private
Integer
isAllocate
;
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/factory/impl/customer/WeCallBackDelFollowUserImpl.java
View file @
c791a35
...
...
@@ -58,7 +58,7 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
Optional
.
ofNullable
(
validWeCorpAccount
).
map
(
WeCorpAccount:
:
getAgentId
).
ifPresent
(
agentId
->
{
weMessagePushDto
.
setAgentid
(
Integer
.
valueOf
(
agentId
));
});
weMessagePushClient
.
sendMessageToUser
(
weMessagePushDto
);
weMessagePushClient
.
sendMessageToUser
(
weMessagePushDto
,
weMessagePushDto
.
getAgentid
().
toString
()
);
//增加敏感行为记录,客户删除员工
WeSensitiveAct
weSensitiveAct
=
weSensitiveActHitService
.
getSensitiveActType
(
"拉黑/删除好友"
);
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeEmpleCodeServiceImpl.java
View file @
c791a35
...
...
@@ -3,6 +3,7 @@ package com.linkwechat.wecom.service.impl;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.redis.RedisCache
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.StringUtils
;
...
...
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -47,6 +49,9 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
@Autowired
private
IWeMaterialService
materialService
;
@Autowired
private
RedisCache
redisCache
;
/**
* 查询员工活码
*
...
...
@@ -237,7 +242,10 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
Long
[]
departmentIdArr
=
Arrays
.
stream
(
departmentIds
.
split
(
","
))
.
filter
(
StringUtils:
:
isNotEmpty
)
.
map
(
Long:
:
new
).
toArray
(
Long
[]::
new
);
return
getQrcode
(
userIdArr
,
departmentIdArr
);
WeExternalContactDto
qrcode
=
getQrcode
(
userIdArr
,
departmentIdArr
);
//设置24小时过期
redisCache
.
setCacheObject
(
WeConstans
.
WE_EMPLE_CODE_KEY
+
":"
+
qrcode
.
getConfig_id
(),
qrcode
.
getConfig_id
(),
24
,
TimeUnit
.
HOURS
);
return
qrcode
;
}
@Override
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeSensitiveServiceImpl.java
View file @
c791a35
...
...
@@ -13,6 +13,7 @@ import com.linkwechat.common.utils.DateUtils;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.client.WeMessagePushClient
;
import
com.linkwechat.wecom.domain.WeCorpAccount
;
import
com.linkwechat.wecom.domain.WeSensitive
;
import
com.linkwechat.wecom.domain.WeSensitiveAuditScope
;
import
com.linkwechat.wecom.domain.WeUser
;
...
...
@@ -20,6 +21,7 @@ import com.linkwechat.wecom.domain.dto.WeMessagePushDto;
import
com.linkwechat.wecom.domain.dto.message.TextMessageDto
;
import
com.linkwechat.wecom.domain.query.WeSensitiveHitQuery
;
import
com.linkwechat.wecom.mapper.WeSensitiveMapper
;
import
com.linkwechat.wecom.service.IWeCorpAccountService
;
import
com.linkwechat.wecom.service.IWeSensitiveAuditScopeService
;
import
com.linkwechat.wecom.service.IWeSensitiveService
;
import
com.linkwechat.wecom.service.IWeUserService
;
...
...
@@ -65,6 +67,9 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService {
@Autowired
private
WeMessagePushClient
weMessagePushClient
;
@Autowired
private
IWeCorpAccountService
weCorpAccountService
;
/**
* 查询敏感词设置
*
...
...
@@ -254,6 +259,7 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService {
boolean
sendMessage
=
false
;
if
(
weSensitive
.
getAlertFlag
().
equals
(
1
))
{
//发送消息通知给相应的审计人
WeCorpAccount
weCorpAccount
=
weCorpAccountService
.
findValidWeCorpAccount
();
String
auditUserId
=
weSensitive
.
getAuditUserId
();
String
content
=
"有消息触发敏感词,请登录系统及时处理!"
;
TextMessageDto
textMessageDto
=
new
TextMessageDto
();
...
...
@@ -262,7 +268,7 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService {
pushDto
.
setTouser
(
auditUserId
);
pushDto
.
setMsgtype
(
MessageType
.
TEXT
.
getMessageType
());
pushDto
.
setText
(
textMessageDto
);
weMessagePushClient
.
sendMessageToUser
(
pushDto
);
weMessagePushClient
.
sendMessageToUser
(
pushDto
,
weCorpAccount
.
getAgentId
()
);
sendMessage
=
true
;
}
//批量提交插入记录
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/strategy/SendMessageToUserStrategy.java
View file @
c791a35
...
...
@@ -68,7 +68,7 @@ public class SendMessageToUserStrategy implements Strategy {
//动态添加微信消息体属性和属性值信息
WeMessagePushDto
target
=
(
WeMessagePushDto
)
ReflectUtil
.
getTarget
(
weMessagePushDto
,
map
);
WeMessagePushResultDto
weMessagePushResultDto
=
weMessagePushClient
.
sendMessageToUser
(
target
);
WeMessagePushResultDto
weMessagePushResultDto
=
weMessagePushClient
.
sendMessageToUser
(
target
,
target
.
getAgentid
().
toString
()
);
if
(
weMessagePushResultDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
))
{
weMessagePush
.
setCreateTime
(
DateUtils
.
getNowDate
());
...
...
linkwe-wecom/src/main/resources/mapper/wecom/WeUserMapper.xml
View file @
c791a35
...
...
@@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"name != null and name != ''"
>
and user_name like concat('%', #{name}, '%')
</if>
<if
test=
"alias != null and alias != ''"
>
and alias = #{alias}
</if>
<if
test=
"userId != null and userId != ''"
>
and user_id = #{userId}
</if>
<if
test=
"isActivate != null"
>
and is_activate = #{isActivate}
</if>
<if
test=
"gender != null "
>
and gender = #{gender}
</if>
<if
test=
"mobile != null and mobile != ''"
>
and mobile = #{mobile}
</if>
<if
test=
"email != null and email != ''"
>
and email = #{email}
</if>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment