Commit 1dc8d32c by leejoker

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

2 parents 32f4584e 7821b81f
......@@ -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");
......
......@@ -44,7 +44,7 @@ public class WeTagGroupController extends BaseController
public TableDataInfo list(WeTagGroup weTagGroup)
{
startPage();
synchWeTags();
//synchWeTags();
return getDataTable(
weTagGroupService.selectWeTagGroupList(weTagGroup)
);
......
......@@ -209,9 +209,9 @@ wecome:
- /message/send
#企微回调通知配置
callBack:
appIdOrCorpId: ww38152475d1bca752
token: uEyhhuTKfpS
encodingAesKey: diTFQ6B4IW14UN2JplADuhMZsBZHjvuBG24kHFrr4Px
appIdOrCorpId: ww24262ce93851488f
token: jtQ1aGHgSmH2UHNBIndUtUe6B6EwfR
encodingAesKey: Vga4HWv7nFbRDYK8iAaQbxmkuecpo2BAfmXAyWwcXMO
#腾讯云对象存储
cos:
secretId: AKIDQRCizIeUGl13vakkDQMH0VkjhPr1rBBv
......
......@@ -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
*/
......
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());
}
}
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
.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)
......
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);
/**
* 应用推送消息
......
......@@ -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;
......
......@@ -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("拉黑/删除好友");
......
......@@ -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
......
......@@ -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;
}
//批量提交插入记录
......
......@@ -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());
......
......@@ -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>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!