Commit c791a352 by leejoker

Merge remote-tracking branch 'origin/back_end_dev' into back_end_dev

2 parents 273e13c7 a7519b02
...@@ -37,7 +37,7 @@ public class WeCallBackController extends CommonController { ...@@ -37,7 +37,7 @@ public class WeCallBackController extends CommonController {
@Value("${wecome.callBack.encodingAesKey}") @Value("${wecome.callBack.encodingAesKey}")
private String 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, public String recive(@RequestBody String msg, @RequestParam(name = "msg_signature") String signature,
String timestamp, String nonce) { String timestamp, String nonce) {
WxCryptUtil wxCryptUtil = new WxCryptUtil(token, encodingAesKey, appIdOrCorpId); WxCryptUtil wxCryptUtil = new WxCryptUtil(token, encodingAesKey, appIdOrCorpId);
...@@ -61,7 +61,7 @@ public class WeCallBackController extends CommonController { ...@@ -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) { public String recive(HttpServletRequest request) {
// 微信加密签名 // 微信加密签名
String sVerifyMsgSig = request.getParameter("msg_signature"); String sVerifyMsgSig = request.getParameter("msg_signature");
......
...@@ -44,7 +44,7 @@ public class WeTagGroupController extends BaseController ...@@ -44,7 +44,7 @@ public class WeTagGroupController extends BaseController
public TableDataInfo list(WeTagGroup weTagGroup) public TableDataInfo list(WeTagGroup weTagGroup)
{ {
startPage(); startPage();
synchWeTags(); //synchWeTags();
return getDataTable( return getDataTable(
weTagGroupService.selectWeTagGroupList(weTagGroup) weTagGroupService.selectWeTagGroupList(weTagGroup)
); );
......
...@@ -209,9 +209,9 @@ wecome: ...@@ -209,9 +209,9 @@ wecome:
- /message/send - /message/send
#企微回调通知配置 #企微回调通知配置
callBack: callBack:
appIdOrCorpId: ww38152475d1bca752 appIdOrCorpId: ww24262ce93851488f
token: uEyhhuTKfpS token: jtQ1aGHgSmH2UHNBIndUtUe6B6EwfR
encodingAesKey: diTFQ6B4IW14UN2JplADuhMZsBZHjvuBG24kHFrr4Px encodingAesKey: Vga4HWv7nFbRDYK8iAaQbxmkuecpo2BAfmXAyWwcXMO
#腾讯云对象存储 #腾讯云对象存储
cos: cos:
secretId: AKIDQRCizIeUGl13vakkDQMH0VkjhPr1rBBv secretId: AKIDQRCizIeUGl13vakkDQMH0VkjhPr1rBBv
......
...@@ -44,6 +44,11 @@ public class WeConstans { ...@@ -44,6 +44,11 @@ public class WeConstans {
*/ */
public static final String WE_AGENT_ACCESS_TOKEN = "we_agent_access_token"; 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 * 企业微信接口返回成功code
*/ */
......
package com.linkwechat.framework.config; 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.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; 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 org.springframework.data.redis.serializer.StringRedisSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.annotation.PropertyAccessor;
...@@ -20,6 +25,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -20,6 +25,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@EnableCaching @EnableCaching
public class RedisConfig extends CachingConfigurerSupport public class RedisConfig extends CachingConfigurerSupport
{ {
@Autowired
private RedisConnectionFactory redisConnectionFactory;
@Bean @Bean
@SuppressWarnings(value = { "unchecked", "rawtypes" }) @SuppressWarnings(value = { "unchecked", "rawtypes" })
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
...@@ -40,4 +49,18 @@ public class RedisConfig extends CachingConfigurerSupport ...@@ -40,4 +49,18 @@ public class RedisConfig extends CachingConfigurerSupport
template.afterPropertiesSet(); template.afterPropertiesSet();
return template; return template;
} }
@Bean
public RedisMessageListenerContainer redisMessageListenerContainer() {
RedisMessageListenerContainer redisMessageListenerContainer = new RedisMessageListenerContainer();
redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory);
return redisMessageListenerContainer;
}
@Bean
public EmpleCodeExpiredListener codeExpiredListener() {
return new EmpleCodeExpiredListener(this.redisMessageListenerContainer());
}
} }
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]);
}
}
}
...@@ -72,7 +72,7 @@ public class UserDetailsServiceImpl implements UserDetailsService ...@@ -72,7 +72,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
.userType(Constants.USER_TYPE_WECOME) .userType(Constants.USER_TYPE_WECOME)
.email(weUser.getEmail()) .email(weUser.getEmail())
.phonenumber(weUser.getMobile()) .phonenumber(weUser.getMobile())
.sex(weUser.getGender().toString()) .sex(weUser.getGender() ==0 ? "1": weUser.getGender() .toString())
.avatar(weUser.getAvatarMediaid()) .avatar(weUser.getAvatarMediaid())
.roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder() .roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder()
.roleKey(Constants.DEFAULT_WECOME_ROLE_KEY) .roleKey(Constants.DEFAULT_WECOME_ROLE_KEY)
......
package com.linkwechat.wecom.client; package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.DataObject; import com.dtflys.forest.annotation.DataObject;
import com.dtflys.forest.annotation.Header;
import com.dtflys.forest.annotation.Request; import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.dto.WeMessagePushDto; import com.linkwechat.wecom.domain.dto.WeMessagePushDto;
import com.linkwechat.wecom.domain.dto.WeMessagePushGroupDto; import com.linkwechat.wecom.domain.dto.WeMessagePushGroupDto;
...@@ -20,7 +21,7 @@ public interface WeMessagePushClient { ...@@ -20,7 +21,7 @@ public interface WeMessagePushClient {
@Request(url = "/message/send", @Request(url = "/message/send",
type = "POST" type = "POST"
) )
WeMessagePushResultDto sendMessageToUser(@DataObject WeMessagePushDto weMessagePushDto); WeMessagePushResultDto sendMessageToUser(@DataObject WeMessagePushDto weMessagePushDto,@Header("agentId") String agentId);
/** /**
* 应用推送消息 * 应用推送消息
......
...@@ -57,7 +57,7 @@ public class WeUser ...@@ -57,7 +57,7 @@ public class WeUser
private String userId; private String userId;
/** 性别。1表示男性,2表示女性 */ /** 性别。1表示男性,2表示女性 */
private Integer gender=new Integer(1); private Integer gender;
/** 手机号 */ /** 手机号 */
@NotBlank(message = "手机号不可为空") @NotBlank(message = "手机号不可为空")
...@@ -102,7 +102,8 @@ public class WeUser ...@@ -102,7 +102,8 @@ public class WeUser
private Date birthday; private Date birthday;
/** 是否激活(1:是;2:否)该字段主要表示当前信息是否同步微信 */ /** 是否激活(1:是;2:否)该字段主要表示当前信息是否同步微信 */
private Integer isActivate=new Integer(2); /** 激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业,6=删除 */
private Integer isActivate;
/** 离职是否分配(1:已分配;0:未分配;) */ /** 离职是否分配(1:已分配;0:未分配;) */
private Integer isAllocate; private Integer isAllocate;
......
...@@ -58,7 +58,7 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy { ...@@ -58,7 +58,7 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
Optional.ofNullable(validWeCorpAccount).map(WeCorpAccount::getAgentId).ifPresent(agentId -> { Optional.ofNullable(validWeCorpAccount).map(WeCorpAccount::getAgentId).ifPresent(agentId -> {
weMessagePushDto.setAgentid(Integer.valueOf(agentId)); weMessagePushDto.setAgentid(Integer.valueOf(agentId));
}); });
weMessagePushClient.sendMessageToUser(weMessagePushDto); weMessagePushClient.sendMessageToUser(weMessagePushDto,weMessagePushDto.getAgentid().toString());
//增加敏感行为记录,客户删除员工 //增加敏感行为记录,客户删除员工
WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友"); WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友");
......
...@@ -3,6 +3,7 @@ package com.linkwechat.wecom.service.impl; ...@@ -3,6 +3,7 @@ package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.utils.SecurityUtils; import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
...@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service; ...@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -47,6 +49,9 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp ...@@ -47,6 +49,9 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
@Autowired @Autowired
private IWeMaterialService materialService; private IWeMaterialService materialService;
@Autowired
private RedisCache redisCache;
/** /**
* 查询员工活码 * 查询员工活码
* *
...@@ -237,7 +242,10 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp ...@@ -237,7 +242,10 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
Long[] departmentIdArr = Arrays.stream(departmentIds.split(",")) Long[] departmentIdArr = Arrays.stream(departmentIds.split(","))
.filter(StringUtils::isNotEmpty) .filter(StringUtils::isNotEmpty)
.map(Long::new).toArray(Long[]::new); .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 @Override
......
...@@ -13,6 +13,7 @@ import com.linkwechat.common.utils.DateUtils; ...@@ -13,6 +13,7 @@ import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SecurityUtils; import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeMessagePushClient; import com.linkwechat.wecom.client.WeMessagePushClient;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.wecom.domain.WeSensitive; import com.linkwechat.wecom.domain.WeSensitive;
import com.linkwechat.wecom.domain.WeSensitiveAuditScope; import com.linkwechat.wecom.domain.WeSensitiveAuditScope;
import com.linkwechat.wecom.domain.WeUser; import com.linkwechat.wecom.domain.WeUser;
...@@ -20,6 +21,7 @@ import com.linkwechat.wecom.domain.dto.WeMessagePushDto; ...@@ -20,6 +21,7 @@ import com.linkwechat.wecom.domain.dto.WeMessagePushDto;
import com.linkwechat.wecom.domain.dto.message.TextMessageDto; import com.linkwechat.wecom.domain.dto.message.TextMessageDto;
import com.linkwechat.wecom.domain.query.WeSensitiveHitQuery; import com.linkwechat.wecom.domain.query.WeSensitiveHitQuery;
import com.linkwechat.wecom.mapper.WeSensitiveMapper; import com.linkwechat.wecom.mapper.WeSensitiveMapper;
import com.linkwechat.wecom.service.IWeCorpAccountService;
import com.linkwechat.wecom.service.IWeSensitiveAuditScopeService; import com.linkwechat.wecom.service.IWeSensitiveAuditScopeService;
import com.linkwechat.wecom.service.IWeSensitiveService; import com.linkwechat.wecom.service.IWeSensitiveService;
import com.linkwechat.wecom.service.IWeUserService; import com.linkwechat.wecom.service.IWeUserService;
...@@ -65,6 +67,9 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService { ...@@ -65,6 +67,9 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService {
@Autowired @Autowired
private WeMessagePushClient weMessagePushClient; private WeMessagePushClient weMessagePushClient;
@Autowired
private IWeCorpAccountService weCorpAccountService;
/** /**
* 查询敏感词设置 * 查询敏感词设置
* *
...@@ -254,6 +259,7 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService { ...@@ -254,6 +259,7 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService {
boolean sendMessage = false; boolean sendMessage = false;
if (weSensitive.getAlertFlag().equals(1)) { if (weSensitive.getAlertFlag().equals(1)) {
//发送消息通知给相应的审计人 //发送消息通知给相应的审计人
WeCorpAccount weCorpAccount = weCorpAccountService.findValidWeCorpAccount();
String auditUserId = weSensitive.getAuditUserId(); String auditUserId = weSensitive.getAuditUserId();
String content = "有消息触发敏感词,请登录系统及时处理!"; String content = "有消息触发敏感词,请登录系统及时处理!";
TextMessageDto textMessageDto = new TextMessageDto(); TextMessageDto textMessageDto = new TextMessageDto();
...@@ -262,7 +268,7 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService { ...@@ -262,7 +268,7 @@ public class WeSensitiveServiceImpl implements IWeSensitiveService {
pushDto.setTouser(auditUserId); pushDto.setTouser(auditUserId);
pushDto.setMsgtype(MessageType.TEXT.getMessageType()); pushDto.setMsgtype(MessageType.TEXT.getMessageType());
pushDto.setText(textMessageDto); pushDto.setText(textMessageDto);
weMessagePushClient.sendMessageToUser(pushDto); weMessagePushClient.sendMessageToUser(pushDto,weCorpAccount.getAgentId());
sendMessage = true; sendMessage = true;
} }
//批量提交插入记录 //批量提交插入记录
......
...@@ -68,7 +68,7 @@ public class SendMessageToUserStrategy implements Strategy { ...@@ -68,7 +68,7 @@ public class SendMessageToUserStrategy implements Strategy {
//动态添加微信消息体属性和属性值信息 //动态添加微信消息体属性和属性值信息
WeMessagePushDto target = (WeMessagePushDto) ReflectUtil.getTarget(weMessagePushDto, map); 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)) { if (weMessagePushResultDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)) {
weMessagePush.setCreateTime(DateUtils.getNowDate()); weMessagePush.setCreateTime(DateUtils.getNowDate());
......
...@@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -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="name != null and name != ''"> and user_name like concat('%', #{name}, '%')</if>
<if test="alias != null and alias != ''"> and alias = #{alias}</if> <if test="alias != null and alias != ''"> and alias = #{alias}</if>
<if test="userId != null and userId != ''"> and user_id = #{userId}</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="gender != null "> and gender = #{gender}</if>
<if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if> <if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if>
<if test="email != null and email != ''"> and email = #{email}</if> <if test="email != null and email != ''"> and email = #{email}</if>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!