注册事件发送消息
This commit is contained in:
parent
1d0d07ed9c
commit
ee045eea03
@ -99,6 +99,16 @@
|
||||
<artifactId>msg-center-dal</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.retry</groupId>
|
||||
<artifactId>spring-retry</artifactId>
|
||||
<version>1.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,40 @@
|
||||
package cn.axzo.msg.center.inside.notices.event;
|
||||
|
||||
import cn.axzo.msg.center.domain.dto.PlatDeptLogDto;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分包机构创建事件对象
|
||||
*
|
||||
* @author: wangli
|
||||
* @date: 2021/10/28 14:06
|
||||
*/
|
||||
public class PlatDepLogEvent extends ApplicationEvent {
|
||||
|
||||
private List<PlatDeptLogDto> datas;
|
||||
|
||||
private Long acctId;
|
||||
|
||||
public PlatDepLogEvent(Object o, List<PlatDeptLogDto> datas, Long acctId) {
|
||||
super(o);
|
||||
this.datas = datas;
|
||||
this.acctId = acctId;
|
||||
}
|
||||
|
||||
public List<PlatDeptLogDto> getDatas(){
|
||||
|
||||
if(datas==null){
|
||||
this.datas = Lists.newArrayList();
|
||||
}
|
||||
|
||||
return this.datas;
|
||||
}
|
||||
|
||||
public Long getAcctId(){
|
||||
return this.acctId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.axzo.msg.center.inside.notices.event;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* @author: wangli
|
||||
* @date: 2022/1/25 18:28
|
||||
*/
|
||||
public class PlatUserCreateEvent extends ApplicationEvent {
|
||||
|
||||
private final String phone;
|
||||
|
||||
private final String pwd;
|
||||
|
||||
public PlatUserCreateEvent(String phone, String pwd) {
|
||||
super(AgencyChangeEvent.OBJECT);
|
||||
this.phone = phone;
|
||||
this.pwd = pwd;
|
||||
}
|
||||
|
||||
public String getPwd() {
|
||||
return pwd;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlatUserCreateEvent{" +
|
||||
"phone='" + phone + '\'' +
|
||||
", pwd='" + pwd + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package cn.axzo.msg.center.inside.notices.listener;
|
||||
|
||||
|
||||
import cn.axzo.msg.center.inside.notices.event.PlatUserCreateEvent;
|
||||
import cn.axzo.msg.center.inside.notices.utils.DingTalkUtilWangli;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
|
||||
/**
|
||||
* @author: wangli
|
||||
* @date: 2022/1/25 18:32
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PlatUserCreateListener {
|
||||
|
||||
@Autowired
|
||||
private DingTalkUtilWangli util;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String active;
|
||||
|
||||
@TransactionalEventListener(classes = PlatUserCreateEvent.class)
|
||||
public void onEvent(PlatUserCreateEvent event) {
|
||||
log.info("监听到平台用户创建的事件: {}", event);
|
||||
String mobile = event.getPhone();
|
||||
String acme = "";
|
||||
|
||||
switch (active) {
|
||||
case "dev":
|
||||
acme = "dev-";
|
||||
break;
|
||||
case "test":
|
||||
acme = "test-";
|
||||
break;
|
||||
case "test1":
|
||||
acme = "test1-";
|
||||
break;
|
||||
case "pre":
|
||||
acme = "pre-";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
util.sendMsg(mobile,
|
||||
"已为您分配OMS账号\r账号: " + mobile + "\r密码: " + event.getPwd() + "\rOMS地址: " + String.format(
|
||||
"https://%soms.axzo.cn/", acme));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package cn.axzo.msg.center.inside.notices.listener;
|
||||
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.dal.MessageRecordDao;
|
||||
import cn.axzo.msg.center.domain.dto.MsgBody4GuestDTO;
|
||||
import cn.axzo.msg.center.domain.entity.MessageRecord;
|
||||
import cn.axzo.msg.center.inside.notices.event.SendMessageEvent;
|
||||
import cn.axzo.msg.center.inside.notices.service.NewImService;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
import cn.azxo.framework.common.utils.LogUtil.ErrorLevel;
|
||||
import cn.azxo.framework.common.utils.LogUtil.ErrorType;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Recover;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @ClassName SendMessageListener
|
||||
* @Description TODO
|
||||
* @Author zhangran
|
||||
* @Date 2022/4/8 11:44
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SendMessageListener {
|
||||
|
||||
@Resource
|
||||
private NewImService imService;
|
||||
@Resource
|
||||
private MessageRecordDao messageRecordDao;
|
||||
@Resource
|
||||
private SendMessageListener sendMessageListener;
|
||||
|
||||
@EventListener(classes = SendMessageEvent.class)
|
||||
public void sendMessage(SendMessageEvent event) {
|
||||
log.info("sendMessage event:{}", event);
|
||||
sendMessageListener.send(event);
|
||||
|
||||
MessageRecord messageRecord = new MessageRecord();
|
||||
messageRecord.setId(event.getMsgId());
|
||||
messageRecord.setRetryCount(event.getRetryCounting().get());
|
||||
messageRecord.setFailCause(event.getErrMsg());
|
||||
if (event.getIsSend().get()) {
|
||||
messageRecord.setState(MsgStateEnum.HAS_BEEN_SENT);
|
||||
messageRecord.setEventSource("");
|
||||
} else {
|
||||
messageRecord.setState(MsgStateEnum.UNSENT);
|
||||
messageRecord.setEventSource(JSON.toJSONString(event.getMessage()));
|
||||
}
|
||||
messageRecordDao.updateById(messageRecord);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息推送,默认重试三次
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Retryable(value = ServiceException.class, backoff = @Backoff(delay = 1000L, multiplier = 1))
|
||||
public void send(SendMessageEvent event) {
|
||||
try {
|
||||
MsgBody4GuestDTO dto = new MsgBody4GuestDTO();
|
||||
BeanUtils.copyProperties(event.getMessage(), dto);
|
||||
imService.syncSendImMessage(dto);
|
||||
} catch (ServiceException e) {
|
||||
event.getRetryCounting().getAndIncrement();
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试失败,默认恢复方法 用户打印日志和记录最后一次错误信息
|
||||
*
|
||||
* @param e
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
@Recover
|
||||
public void recover(ServiceException e, SendMessageEvent event) {
|
||||
event.setErrMsg(e.getMessage());
|
||||
event.getIsSend().compareAndSet(true, false);
|
||||
LogUtil.error(ErrorLevel.P1, ErrorType.ERROR_INNER_SERVICE, "发送消息失败", event.getMsgId(),
|
||||
e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,216 @@
|
||||
package cn.axzo.msg.center.inside.notices.redis;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* jedis 管理
|
||||
* @author Smile
|
||||
*/
|
||||
@Service
|
||||
public class AxzoJedisManager implements IAxzoJedisManager {
|
||||
|
||||
/**
|
||||
* redis 工具
|
||||
*/
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
@Autowired
|
||||
public void setRedisTemplate (RedisTemplate redisTemplate) {
|
||||
JSON.DEFAULT_GENERATE_FEATURE = SerializerFeature.config(
|
||||
JSON.DEFAULT_GENERATE_FEATURE, SerializerFeature.SkipTransientField, false);
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
GenericFastJsonRedisSerializer fastJsonRedisSerializer = new GenericFastJsonRedisSerializer();
|
||||
// GenericFastJsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
// jackson2JsonRedisSerializer.setObjectMapper();
|
||||
redisTemplate.setKeySerializer(stringRedisSerializer);
|
||||
redisTemplate.setValueSerializer(fastJsonRedisSerializer);
|
||||
redisTemplate.setHashKeySerializer(stringRedisSerializer);
|
||||
redisTemplate.setHashValueSerializer(fastJsonRedisSerializer);
|
||||
redisTemplate.afterPropertiesSet();
|
||||
this.redisTemplate = redisTemplate;
|
||||
}
|
||||
/**
|
||||
* 设置
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean set(final String key, Object value) {
|
||||
return set(key, value, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(String key, Object value, long time) {
|
||||
try {
|
||||
if (time > 0) {
|
||||
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
|
||||
} else {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setIfPresent(String key, Object value, long time) {
|
||||
try {
|
||||
if (time > 0) {
|
||||
redisTemplate.opsForValue().setIfPresent(key, value, time, TimeUnit.SECONDS);
|
||||
} else {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(String key, INullValueHandler<T> handler, long time) {
|
||||
Object obj = redisTemplate.opsForValue().get(key);
|
||||
if (obj != null) {
|
||||
return (T)obj;
|
||||
} else {
|
||||
if (handler != null) {
|
||||
obj = handler.handle();
|
||||
if (!ObjectUtils.isEmpty(obj)) {
|
||||
if (time > 0) {
|
||||
set(key, obj, time);
|
||||
} else {
|
||||
set(key, obj);
|
||||
}
|
||||
return (T)obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T get(String key, INullValueHandler<T> handler) {
|
||||
return get(key, handler, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(String key) {
|
||||
return get(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean del(String key) {
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long ssl(String key) {
|
||||
return redisTemplate.opsForValue().getOperations().getExpire(key);
|
||||
}
|
||||
|
||||
|
||||
/****
|
||||
* 通过pipeline进行批量设置
|
||||
* 报了一个错误,参考下面的文章得到了问题的解决方案:
|
||||
* https://blog.csdn.net/myfwjy/article/details/100776426
|
||||
* 《Redis使用Pipeline时对象序列化失败org.springframework.data.redis.serializer.SerializationException》
|
||||
* @param map
|
||||
*/
|
||||
@Override
|
||||
public void setPipe(Map<String, Object> map) {
|
||||
|
||||
RedisSerializer keySerializer = redisTemplate.getKeySerializer();
|
||||
RedisSerializer valueSerializer = redisTemplate.getValueSerializer();
|
||||
|
||||
List list = redisTemplate.executePipelined((RedisCallback<String>) connection -> {
|
||||
Iterator<Entry<String, Object>> iterator = map.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<String, Object> next = iterator.next();
|
||||
|
||||
connection.set(keySerializer.serialize(next.getKey()), valueSerializer.serialize(next.getValue()));
|
||||
}
|
||||
return null;
|
||||
//加不加下面的这一行代码应该都可以
|
||||
}, redisTemplate.getValueSerializer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getPipe(List<String> keys) {
|
||||
List<Object> list = redisTemplate.executePipelined((RedisCallback<?>) connection -> {
|
||||
for (String s : keys) {
|
||||
connection.get(s.getBytes());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
//
|
||||
//
|
||||
// List<Object> list1 = redisTemplate.opsForValue().multiGet(keys);
|
||||
// System.out.println("multiGet获取结果" + list1);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setHash(String key, Map<String, Object> map) {
|
||||
redisTemplate.opsForHash().putAll(key, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getHash(String key) {
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasKey(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(List<String> keys) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> scanKeys(String keyWords) {
|
||||
return scanPatternKey(keyWords + "*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> scanPatternKey(String pattern) {
|
||||
return (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
|
||||
Set<String> keysTmp = new HashSet<>();
|
||||
Cursor<byte[]> cursor = connection.scan(
|
||||
new ScanOptions.ScanOptionsBuilder().match(
|
||||
pattern
|
||||
).count(10000).build()
|
||||
);
|
||||
|
||||
while (cursor.hasNext()) {
|
||||
keysTmp.add(new String(cursor.next()));
|
||||
}
|
||||
|
||||
return keysTmp;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
package cn.axzo.msg.center.inside.notices.redis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* jedis 操作
|
||||
* @author Smile
|
||||
*/
|
||||
public interface IAxzoJedisManager {
|
||||
|
||||
/**
|
||||
* 值对象设置
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
boolean set(final String key, Object value);
|
||||
|
||||
/**
|
||||
* 值对象设置
|
||||
* @param key
|
||||
* @param value
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
boolean set(final String key, Object value, long time);
|
||||
|
||||
/**
|
||||
* 设置延长超时时间
|
||||
* @param key
|
||||
* @param value
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
boolean setIfPresent(String key, Object value, long time);
|
||||
|
||||
/**
|
||||
* 返回
|
||||
* @param key
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> T get(final String key, INullValueHandler<T> handler);
|
||||
|
||||
/**
|
||||
* 返回
|
||||
* @param key
|
||||
* @param handler
|
||||
* @param time
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> T get(final String key, INullValueHandler<T> handler, long time);
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
* @param key
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> T get(final String key);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
boolean del(final String key);
|
||||
|
||||
Long ssl(final String key);
|
||||
|
||||
/**
|
||||
* 批量设置
|
||||
* @param map
|
||||
*/
|
||||
void setPipe(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 批量获取
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
List<Object> getPipe(List<String> keys);
|
||||
|
||||
/**
|
||||
* 设置hash
|
||||
* @param key key
|
||||
* @param map map
|
||||
*/
|
||||
void setHash(String key, Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 获取hash
|
||||
* @param key key
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getHash(String key);
|
||||
|
||||
/**
|
||||
* 是否存在key
|
||||
* @param key key
|
||||
*/
|
||||
boolean hasKey(String key);
|
||||
|
||||
/**
|
||||
* 批量删除key
|
||||
*/
|
||||
void del(List<String> keys);
|
||||
|
||||
/**
|
||||
* scan 获取数据
|
||||
*/
|
||||
Set<String> scanKeys(String keyWords);
|
||||
|
||||
Set<String> scanPatternKey(String pattern);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.axzo.msg.center.inside.notices.redis;
|
||||
|
||||
/**
|
||||
* @author Smile
|
||||
*/
|
||||
public interface INullValueHandler<T> {
|
||||
|
||||
/**
|
||||
* 处理
|
||||
* @return
|
||||
*/
|
||||
T handle();
|
||||
|
||||
}
|
||||
@ -2,12 +2,10 @@ package cn.axzo.msg.center.inside.notices.service;
|
||||
|
||||
|
||||
|
||||
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.api.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.api.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.common.page.PageResult;
|
||||
import cn.axzo.msg.center.domain.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.domain.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.inside.notices.model.response.MessageTotalRes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : liuchuntao
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
package cn.axzo.msg.center.inside.notices.service;
|
||||
|
||||
|
||||
import cn.axzo.msg.center.api.request.*;
|
||||
import cn.axzo.msg.center.api.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.domain.entity.MessageRecord;
|
||||
import cn.axzo.msg.center.domain.enums.UserTypeEnum;
|
||||
import cn.axzo.msg.center.domain.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.domain.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.inside.notices.model.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.api.request.CmsReadMsgReq;
|
||||
import cn.axzo.msg.center.api.request.GeneralMessage;
|
||||
import cn.axzo.msg.center.api.request.MsgReturnParamRes;
|
||||
import cn.axzo.msg.center.common.page.PageResult;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
@ -57,18 +53,6 @@ public interface MessageRecordService {
|
||||
*/
|
||||
IPage<MessageRecord> querySendFailMsg(IPage<MessageRecord> page);
|
||||
|
||||
|
||||
/**
|
||||
* 多身份融合查询
|
||||
*
|
||||
* 业务上是按照端([cms/从业人员 APP], [工人 APP])将同一个自然人在指定端下身份融合数据查询出来
|
||||
* @param req
|
||||
* @param identityIds
|
||||
* @param personId
|
||||
* @return
|
||||
*/
|
||||
PageResult<MessageNewRes> mixIdentityPageMsgInfo(CmsMsgQueryReq req, List<Long> identityIds, Long personId);
|
||||
|
||||
MessageTotalRes statisticsMsg4Construction(Long identityId, UserTypeEnum userTypeEnum);
|
||||
|
||||
MessageTotalRes statisticsMsg4Trade(Long personId);
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.msg.center.inside.notices.service;
|
||||
|
||||
|
||||
|
||||
import cn.axzo.msg.center.domain.dto.MsgBody4GuestDTO;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* @author: wangli
|
||||
* @date: 2022/5/24 17:25
|
||||
*/
|
||||
public interface NewImService {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 服务端发送消息
|
||||
*
|
||||
* @param msg 消息内容
|
||||
*/
|
||||
void sendImMessage(MsgBody4GuestDTO msg);
|
||||
|
||||
/**
|
||||
* 同步发送消息
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
void syncSendImMessage(MsgBody4GuestDTO msg);
|
||||
|
||||
}
|
||||
@ -2,6 +2,9 @@ package cn.axzo.msg.center.inside.notices.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.util.AssertUtil;
|
||||
import cn.axzo.framework.auth.domain.ContextInfoHolder;
|
||||
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.api.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.api.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.common.enums.SystemTypeEnum;
|
||||
import cn.axzo.msg.center.common.exception.ServiceException;
|
||||
import cn.axzo.msg.center.common.page.PageResult;
|
||||
@ -13,16 +16,12 @@ import cn.axzo.msg.center.domain.entity.MessageRouter;
|
||||
import cn.axzo.msg.center.domain.enums.MsgRouteTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.NativeTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.UserTypeEnum;
|
||||
import cn.axzo.msg.center.domain.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.domain.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.inside.notices.model.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.inside.notices.service.*;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@ -4,10 +4,8 @@ import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||
import cn.axzo.basics.common.util.AssertUtil;
|
||||
import cn.axzo.framework.auth.domain.ContextInfoHolder;
|
||||
import cn.axzo.msg.center.api.enums.*;
|
||||
import cn.axzo.msg.center.api.request.CmsReadMsgReq;
|
||||
import cn.axzo.msg.center.api.request.GeneralMessage;
|
||||
import cn.axzo.msg.center.api.request.MsgBody4Guest;
|
||||
import cn.axzo.msg.center.api.request.MsgReturnParamRes;
|
||||
import cn.axzo.msg.center.api.request.*;
|
||||
import cn.axzo.msg.center.api.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.common.enums.IdentityType;
|
||||
import cn.axzo.msg.center.common.exception.ServiceException;
|
||||
import cn.axzo.msg.center.common.model.ProfileIdRepair;
|
||||
@ -16,16 +14,15 @@ import cn.axzo.msg.center.common.utils.BeanConvertUtils;
|
||||
import cn.axzo.msg.center.common.utils.PlaceholderResolver;
|
||||
import cn.axzo.msg.center.common.utils.SpringUtils;
|
||||
import cn.axzo.msg.center.dal.*;
|
||||
import cn.axzo.msg.center.domain.dto.CmsMsgQueryReqDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MessageNewResDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MsgStatisticsDTO;
|
||||
import cn.axzo.msg.center.domain.entity.*;
|
||||
import cn.axzo.msg.center.domain.enums.ModuleBizTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.MsgRouteTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.NativeTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.UserTypeEnum;
|
||||
import cn.axzo.msg.center.domain.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.domain.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.inside.notices.event.SendMessageEvent;
|
||||
import cn.axzo.msg.center.inside.notices.model.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.inside.notices.service.MessageRecordService;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
import cn.azxo.framework.common.utils.LogUtil.ErrorLevel;
|
||||
@ -151,14 +148,20 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
}
|
||||
|
||||
List<MessageRecord> pushMessages = new ArrayList<>();
|
||||
if(ReceiveTypeEnum.NOT_IDENTITY.equals(basic.getReceiveType())) {
|
||||
toIds.forEach(i -> {
|
||||
MessageRecord messageRecord = BeanConvertUtils.copyBean(basic, MessageRecord.class);
|
||||
messageRecord.setToId(i);
|
||||
messageRecord.setPersonId(i);
|
||||
pushMessages.add(messageRecord);
|
||||
});
|
||||
/*if(ReceiveTypeEnum.NOT_IDENTITY.equals(basic.getReceiveType())) {
|
||||
toIds.forEach(i -> {
|
||||
MessageRecord messageRecord = BeanConvertUtils.copyBean(basic, MessageRecord.class);
|
||||
messageRecord.setToId(0L);
|
||||
messageRecord.setPersonId(i);
|
||||
pushMessages.add(messageRecord);
|
||||
});
|
||||
}/*else{
|
||||
}else{
|
||||
// 根据身份获取自然人信息
|
||||
Map<Long, IdentityProfileDto> profileMap = identityProfileService.findProfileByIdSetV2(
|
||||
new HashSet<>(toIds), ConvertIdentity(basic.getReceiveType()));
|
||||
@ -376,9 +379,26 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
ReceiveTypeEnum receiveTypeEnum = ReceiveTypeEnum.getByMessage(userTypeEnum.getName());
|
||||
IPage page = req.toPage();
|
||||
ArrayList<Integer> states = buildStates(req);
|
||||
IPage<MessageNewRes> iPage = messageRecordDao.pageMsgInfo(req, page, receiveTypeEnum.getCode(),
|
||||
CmsMsgQueryReqDTO param=BeanConvertUtils.copyBean(req, CmsMsgQueryReqDTO.class);
|
||||
IPage<MessageNewResDTO> iPage = messageRecordDao.pageMsgInfo(param, page, receiveTypeEnum.getCode(),
|
||||
personId, identityId, states);
|
||||
return new PageResult<>(iPage.getRecords(), iPage.getTotal());
|
||||
return convertPageMessageNewRes(iPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换返回值
|
||||
* @param iPage
|
||||
* @return
|
||||
*/
|
||||
private PageResult<MessageNewRes> convertPageMessageNewRes(IPage<MessageNewResDTO> iPage){
|
||||
if(iPage == null || CollectionUtils.isEmpty(iPage.getRecords())){
|
||||
return new PageResult<>();
|
||||
}
|
||||
List<MessageNewRes> records=new ArrayList<>(iPage.getRecords().size());
|
||||
for (MessageNewResDTO record : iPage.getRecords()) {
|
||||
BeanConvertUtils.copyBean(record, MessageNewRes.class);
|
||||
}
|
||||
return new PageResult<>(records, iPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -389,9 +409,10 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
.select(MessageModule::getId)
|
||||
.list().stream().map(MessageModule::getId).collect(Collectors.toList());
|
||||
ArrayList<Integer> states = buildStates(req);
|
||||
IPage<MessageNewRes> iPage = messageRecordDao.pageMsgInfo4WechatAndTrade(req, moduleIds, personId,
|
||||
CmsMsgQueryReqDTO param= BeanConvertUtils.copyBean(req, CmsMsgQueryReqDTO.class);
|
||||
IPage<MessageNewResDTO> iPage = messageRecordDao.pageMsgInfo4WechatAndTrade(param, moduleIds, personId,
|
||||
states);
|
||||
return new PageResult<>(iPage.getRecords(), iPage.getTotal());
|
||||
return convertPageMessageNewRes(iPage);
|
||||
}
|
||||
|
||||
private static ArrayList<Integer> buildStates(CmsMsgQueryReq req) {
|
||||
@ -586,12 +607,5 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MessageNewRes> mixIdentityPageMsgInfo(CmsMsgQueryReq req, List<Long> identityIds, Long personId) {
|
||||
ArrayList<Integer> states = buildStates(req);
|
||||
IPage<MessageNewRes> iPage = messageRecordDao.mixIdentityPageMsgInfo(req, identityIds, personId, states);
|
||||
return new PageResult<>(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
package cn.axzo.msg.center.inside.notices.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.page.PageResult;
|
||||
import cn.axzo.core.service.ServiceException;
|
||||
import cn.axzo.core.web.Result;
|
||||
import cn.axzo.core.web.Results;
|
||||
import cn.axzo.msg.center.api.MessageServiceApi;
|
||||
import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.api.request.GeneralMessage;
|
||||
import cn.axzo.msg.center.api.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.api.request.MsgReturnParamRes;
|
||||
import cn.axzo.msg.center.api.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.api.response.Relation;
|
||||
import cn.axzo.msg.center.api.response.Template;
|
||||
import cn.axzo.msg.center.common.utils.CustomBeanUtils;
|
||||
@ -54,6 +58,16 @@ public class MessageServiceApiImpl implements MessageServiceApi {
|
||||
return Results.ok(messageRecordService.pushMsg(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MessageTotalRes> msgTotal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<PageResult<MessageNewRes>> msgList(CmsMsgQueryReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> changeMessageState(List<Long> msgId, MsgStateEnum state) {
|
||||
if (CollectionUtils.isEmpty(msgId)) {
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.axzo.msg.center.inside.notices.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.BeanMapper;
|
||||
import cn.axzo.msg.center.api.request.MsgBody4Guest;
|
||||
import cn.axzo.msg.center.domain.dto.MsgBody4GuestDTO;
|
||||
import cn.axzo.msg.center.inside.notices.service.IYouMengMessageService;
|
||||
import cn.axzo.msg.center.inside.notices.service.NewImService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author: wangli
|
||||
* @date: 2022/5/24 17:43
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RefreshScope
|
||||
public class NewImServiceImpl implements NewImService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IYouMengMessageService youMengMessageService;
|
||||
|
||||
@Override
|
||||
public void sendImMessage(MsgBody4GuestDTO msg) {
|
||||
syncSendImMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncSendImMessage(MsgBody4GuestDTO msg) {
|
||||
MsgBody4Guest msgBody4Guest = BeanMapper.copyBean(msg, MsgBody4Guest.class);
|
||||
youMengMessageService.sendPushMessage(msgBody4Guest);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
package cn.axzo.msg.center.inside.notices.utils;
|
||||
|
||||
import cn.axzo.msg.center.inside.notices.redis.AxzoJedisManager;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.dingtalk.api.request.OapiGettokenRequest;
|
||||
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request.Msg;
|
||||
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request.Text;
|
||||
import com.dingtalk.api.request.OapiV2UserGetbymobileRequest;
|
||||
import com.dingtalk.api.response.OapiGettokenResponse;
|
||||
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
|
||||
import com.dingtalk.api.response.OapiV2UserGetbymobileResponse;
|
||||
|
||||
/**
|
||||
* 钉钉消息推送工具类
|
||||
* <p>
|
||||
* 使用说明: 1. 登录钉钉开放平台,选择公司.地址:https://open-dev.dingtalk.com/
|
||||
* <p>
|
||||
* 2. 在首页点击立即创建应用, 选择 H5 微应用接即可,并配置应用名称/应用描述. 开发方式选择"企业自主开发"
|
||||
* <p>
|
||||
* 3. 选择创建的应用->开发管理,并设置服务器出口IP.(及应用调用钉钉开放接口的授权IP)
|
||||
* <p>
|
||||
* 4. 选择创建的应用->权限管理,并搜索"根据手机号姓名获取成员信息的接口访问权限"即可.
|
||||
* <p>
|
||||
* 5. 在 Nacos 中配置应用的 AgentId,Appkey,AppSecret.
|
||||
*
|
||||
* @author: wangli
|
||||
* @date: 2022/1/21 16:26
|
||||
*/
|
||||
@Component
|
||||
@RefreshScope
|
||||
public class DingTalkUtilWangli {
|
||||
|
||||
@Autowired
|
||||
private AxzoJedisManager jedisManager;
|
||||
/**
|
||||
* 推送工作消息地址
|
||||
*/
|
||||
private static final String PUSH_MSG_URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2";
|
||||
/**
|
||||
* 根据手机号获取用户id
|
||||
*/
|
||||
private static final String GET_USERID_BY_MOBILE_URL = "https://oapi.dingtalk.com/topapi/v2/user/getbymobile";
|
||||
/**
|
||||
* 获取企业内部应用的 accessToken
|
||||
*/
|
||||
private static final String GET_TOKEN = "https://oapi.dingtalk.com/gettoken";
|
||||
|
||||
@Value("${dingtalk.agentId:1447949753}")
|
||||
private Long AgentId;
|
||||
@Value("${dingtalk.AppKey:dinghkmjx7tpy9jkxvyh}")
|
||||
private String AppKey;
|
||||
@Value("${dingtalk.AppSecret:Xtf-qpTA96vRBSVeiFbmPVFVgflW_F0K5En17qjJHM6qufSJqOzX2u57qe5ME1zM}")
|
||||
private String AppSecret;
|
||||
private String DINGTALK_TOKEN = "DINGTALK-TOKEN";
|
||||
|
||||
public void sendMsg(String mobile, String msg) {
|
||||
getUserId(mobile);
|
||||
try {
|
||||
DingTalkClient client = new DefaultDingTalkClient(PUSH_MSG_URL);
|
||||
OapiMessageCorpconversationAsyncsendV2Request req = new OapiMessageCorpconversationAsyncsendV2Request();
|
||||
req.setAgentId(AgentId);
|
||||
req.setToAllUser(false);
|
||||
req.setUseridList(getUserId(mobile));
|
||||
Msg innerMsg = new Msg();
|
||||
innerMsg.setMsgtype("text");
|
||||
Text text = new Text();
|
||||
text.setContent(msg);
|
||||
innerMsg.setText(text);
|
||||
req.setMsg(innerMsg);
|
||||
OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(req, getToken());
|
||||
System.out.println(rsp.getBody());
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String getUserId(String mobile) {
|
||||
String userId = null;
|
||||
try {
|
||||
DingTalkClient client = new DefaultDingTalkClient(GET_USERID_BY_MOBILE_URL);
|
||||
OapiV2UserGetbymobileRequest req = new OapiV2UserGetbymobileRequest();
|
||||
req.setMobile(mobile);
|
||||
OapiV2UserGetbymobileResponse rsp = client.execute(req, getToken());
|
||||
userId = rsp.getResult().getUserid();
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return userId;
|
||||
}
|
||||
|
||||
private String getToken() {
|
||||
return jedisManager.get(DINGTALK_TOKEN, () -> {
|
||||
String token = null;
|
||||
try {
|
||||
DingTalkClient client = new DefaultDingTalkClient(GET_TOKEN);
|
||||
OapiGettokenRequest req = new OapiGettokenRequest();
|
||||
req.setHttpMethod("GET");
|
||||
req.setAppkey(AppKey);
|
||||
req.setAppsecret(AppSecret);
|
||||
OapiGettokenResponse rsp = client.execute(req);
|
||||
token = rsp.getAccessToken();
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return token;
|
||||
}, 7000);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,11 +1,17 @@
|
||||
package cn.axzo.msg.center.api;
|
||||
|
||||
|
||||
import cn.axzo.basics.common.page.PageResult;
|
||||
import cn.axzo.core.web.Result;
|
||||
import cn.axzo.core.web.Results;
|
||||
import cn.axzo.framework.auth.annotation.PreBuildContext;
|
||||
import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.api.fallback.MessageServiceApiFallBack;
|
||||
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.api.request.GeneralMessage;
|
||||
import cn.axzo.msg.center.api.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.api.request.MsgReturnParamRes;
|
||||
import cn.axzo.msg.center.api.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.api.response.Relation;
|
||||
import cn.axzo.msg.center.api.response.Template;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
@ -31,6 +37,25 @@ public interface MessageServiceApi {
|
||||
@RequestMapping(value = "api/message/push", method = RequestMethod.POST)
|
||||
Result<List<MsgReturnParamRes>> pushMsg(@RequestBody @Valid GeneralMessage message);
|
||||
|
||||
/**
|
||||
* 消息\待办数量总数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("v1/msg/total")
|
||||
//@PreBuildContext
|
||||
Result<MessageTotalRes> msgTotal();
|
||||
|
||||
/**
|
||||
* 消息列表搜索、待办列表
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("v1/msg/list")
|
||||
/*@PreBuildContext*/
|
||||
Result<PageResult<MessageNewRes>> msgList(@RequestBody @Valid CmsMsgQueryReq req);
|
||||
|
||||
/**
|
||||
* 变更执行消息的状态
|
||||
*
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
package cn.axzo.msg.center.api.fallback;
|
||||
|
||||
import cn.axzo.basics.common.page.PageResult;
|
||||
import cn.axzo.core.web.Result;
|
||||
import cn.axzo.core.web.Results;
|
||||
import cn.axzo.msg.center.api.MessageServiceApi;
|
||||
import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.api.request.GeneralMessage;
|
||||
import cn.axzo.msg.center.api.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.api.request.MsgReturnParamRes;
|
||||
import cn.axzo.msg.center.api.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.api.response.Relation;
|
||||
import cn.axzo.msg.center.api.response.Template;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -29,6 +33,18 @@ public class MessageServiceApiFallBack implements MessageServiceApi {
|
||||
return Results.fail("调用推送消息接口超时");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MessageTotalRes> msgTotal() {
|
||||
log.info("消息待办数量总数超时");
|
||||
return Results.fail("消息待办数量总数超时");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<PageResult<MessageNewRes>> msgList(CmsMsgQueryReq req) {
|
||||
log.info("消息列表搜索、待办列表超时,req:{}",req);
|
||||
return Results.fail("消息列表搜索、待办列表超时");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> changeMessageState(List<Long> msgId, MsgStateEnum state) {
|
||||
log.info("调用变更消息状态超时, msgId = {}, state = {}", msgId, state.getMessage());
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.domain.request;
|
||||
package cn.axzo.msg.center.api.request;
|
||||
|
||||
import cn.axzo.basics.common.page.PageRequest;
|
||||
import lombok.Data;
|
||||
@ -8,6 +8,7 @@ import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 通用消息
|
||||
@ -19,7 +20,7 @@ import javax.validation.constraints.NotNull;
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString
|
||||
public class GeneralMessage extends AbstractMessage {
|
||||
public class GeneralMessage extends AbstractMessage implements Serializable {
|
||||
|
||||
/**
|
||||
* 接收者角色类型
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.domain.request;
|
||||
package cn.axzo.msg.center.api.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.inside.notices.model.response;
|
||||
package cn.axzo.msg.center.api.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -8,12 +8,12 @@ import cn.axzo.msg.center.api.enums.MsgTypeEnum;
|
||||
import cn.axzo.msg.center.api.enums.ReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.api.request.CmsReadMsgReq;
|
||||
import cn.axzo.msg.center.dal.mapper.MessageRecordMapper;
|
||||
import cn.axzo.msg.center.domain.dto.CmsMsgQueryReqDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MessageNewResDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MsgStatisticsDTO;
|
||||
import cn.axzo.msg.center.domain.entity.MessageRecord;
|
||||
import cn.axzo.msg.center.domain.enums.ModuleBizTypeEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntity;
|
||||
import cn.axzo.msg.center.domain.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.domain.request.MessageNewRes;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -65,13 +65,13 @@ public class MessageRecordDao extends
|
||||
.update();
|
||||
}
|
||||
|
||||
public IPage<MessageNewRes> pageMsgInfo(CmsMsgQueryReq req, IPage page, Integer receiveType,
|
||||
public IPage<MessageNewResDTO> pageMsgInfo(CmsMsgQueryReqDTO req, IPage page, Integer receiveType,
|
||||
Long personId, Long identityId, List<Integer> states) {
|
||||
return baseMapper.pageMsgInfo(req, page, receiveType, personId, identityId, states);
|
||||
}
|
||||
|
||||
public IPage<MessageNewRes> mixIdentityPageMsgInfo(CmsMsgQueryReq req, List<Long> identityIds,
|
||||
Long personId, ArrayList<Integer> states) {
|
||||
public IPage<MessageNewResDTO> mixIdentityPageMsgInfo(CmsMsgQueryReqDTO req, List<Long> identityIds,
|
||||
Long personId, ArrayList<Integer> states) {
|
||||
return baseMapper.mixIdentityPageMsgInfo(req, req.toPage(), identityIds, personId, states);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class MessageRecordDao extends
|
||||
ReceiveTypeEnum.NOT_IDENTITY.getCode());
|
||||
}
|
||||
|
||||
public IPage<MessageNewRes> pageMsgInfo4WechatAndTrade(CmsMsgQueryReq req,
|
||||
public IPage<MessageNewResDTO> pageMsgInfo4WechatAndTrade(CmsMsgQueryReqDTO req,
|
||||
List<Long> moduleIds, Long personId, ArrayList<Integer> states) {
|
||||
return baseMapper.pageMsgInfo4WechatAndTrade(req, req.toPage(), moduleIds, personId,
|
||||
ReceiveTypeEnum.NOT_IDENTITY.getCode(), states);
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
package cn.axzo.msg.center.dal.mapper;
|
||||
|
||||
|
||||
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.api.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.domain.dto.CmsMsgQueryReqDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MessageNewResDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MsgStatisticsDTO;
|
||||
import cn.axzo.msg.center.domain.entity.MessageRecord;
|
||||
import cn.axzo.msg.center.domain.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.domain.request.MessageNewRes;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -27,17 +28,17 @@ public interface MessageRecordMapper extends BaseMapper<MessageRecord>{
|
||||
@Param("identityId") Long identityId,
|
||||
@Param("receiveType") Integer receiveType);
|
||||
|
||||
IPage<MessageNewRes> pageMsgInfo(@Param("req") CmsMsgQueryReq req, IPage page,
|
||||
@Param("receiveType")Integer receiveType,
|
||||
@Param("personId") Long personId,
|
||||
@Param("identityId")Long identityId,
|
||||
@Param("states")List<Integer> states);
|
||||
IPage<MessageNewResDTO> pageMsgInfo(@Param("req") CmsMsgQueryReqDTO req, IPage page,
|
||||
@Param("receiveType")Integer receiveType,
|
||||
@Param("personId") Long personId,
|
||||
@Param("identityId")Long identityId,
|
||||
@Param("states")List<Integer> states);
|
||||
|
||||
IPage<MessageNewRes> mixIdentityPageMsgInfo(@Param("req") CmsMsgQueryReq req, IPage page,
|
||||
@Param("identityIds") List<Long> identityIds, @Param("personId") Long personId,
|
||||
@Param("states")List<Integer> states);
|
||||
IPage<MessageNewResDTO> mixIdentityPageMsgInfo(@Param("req") CmsMsgQueryReqDTO req, IPage page,
|
||||
@Param("identityIds") List<Long> identityIds, @Param("personId") Long personId,
|
||||
@Param("states")List<Integer> states);
|
||||
|
||||
IPage<MessageNewRes> pageMsgInfo4WechatAndTrade(@Param("req") CmsMsgQueryReq req, IPage page,
|
||||
IPage<MessageNewResDTO> pageMsgInfo4WechatAndTrade(@Param("req") CmsMsgQueryReqDTO req, IPage page,
|
||||
@Param("moduleIds") List<Long> moduleIds, @Param("personId") Long personId,
|
||||
@Param("receiveType") Integer receiveType, @Param("states") List<Integer> states);
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
</select>
|
||||
|
||||
<select id="pageMsgInfo"
|
||||
resultType="cn.axzo.msg.center.domain.request.MessageNewRes">
|
||||
resultType="cn.axzo.msg.center.domain.dto.MessageNewResDTO">
|
||||
select record.id msgId,
|
||||
record.title as msgTitle,
|
||||
record.content as content,
|
||||
@ -71,7 +71,7 @@
|
||||
order by record.create_at desc,record.id desc
|
||||
</select>
|
||||
<select id="mixIdentityPageMsgInfo"
|
||||
resultType="cn.axzo.msg.center.domain.request.MessageNewRes">
|
||||
resultType="cn.axzo.msg.center.domain.dto.MessageNewResDTO">
|
||||
select record.id msgId,
|
||||
record.title as msgTitle,
|
||||
record.content as content,
|
||||
@ -119,7 +119,7 @@
|
||||
order by record.create_at desc,record.id desc
|
||||
</select>
|
||||
<select id="pageMsgInfo4WechatAndTrade"
|
||||
resultType="cn.axzo.msg.center.domain.request.MessageNewRes">
|
||||
resultType="cn.axzo.msg.center.domain.dto.MessageNewResDTO">
|
||||
select record.id msgId,
|
||||
record.title as msgTitle,
|
||||
record.content as content,
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.axzo.msg.center.domain.dto;
|
||||
|
||||
import cn.axzo.basics.common.page.PageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class CmsMsgQueryReqDTO extends PageRequest {
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
private String searchKey;
|
||||
|
||||
|
||||
/**
|
||||
* 消息类型 1:普通消息 2:待办
|
||||
*/
|
||||
@NotNull(message = "消息类型必传")
|
||||
private Integer msgType;
|
||||
|
||||
|
||||
/**
|
||||
* 消息状态
|
||||
* 0:消息中心-全部 1:消息中心-未读
|
||||
* <p
|
||||
* 1:待办-待处理 2:待办-已完成
|
||||
*/
|
||||
private int msgStatus;
|
||||
|
||||
|
||||
/**
|
||||
* 待办、消息模块类型Id - 针对待办使用
|
||||
*/
|
||||
private Long moduleId;
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
package cn.axzo.msg.center.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName MessageDto
|
||||
* @Description 每次只拿模块内最新一条通知消息(第一条已读,第二条未读,也存在小红点)
|
||||
* @Author zhangran
|
||||
* @Date 2022/3/21 14:50
|
||||
**/
|
||||
@Data
|
||||
public class MessageNewResDTO {
|
||||
|
||||
/**
|
||||
* 消息Id
|
||||
*/
|
||||
private Long msgId;
|
||||
/**
|
||||
* 模块图标
|
||||
*/
|
||||
private String msgIcon;
|
||||
/**
|
||||
* 模块名称
|
||||
*/
|
||||
private String msgName;
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
private String msgTitle;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 接收人类型
|
||||
*/
|
||||
private Integer receiveType;
|
||||
|
||||
/**
|
||||
* 消息所属标识类型 1:项目 2:企业
|
||||
*/
|
||||
private Integer terminalType;
|
||||
/**
|
||||
* 项目Id/企业Id 用于跳转
|
||||
*/
|
||||
private Long terminalId;
|
||||
/**
|
||||
* 项目名称/企业名称 有则展示
|
||||
*/
|
||||
private String terminalName;
|
||||
/**
|
||||
* 普通消息状态 1.未读 2.已读
|
||||
* <p>
|
||||
* 待办消息状态 1:待处理 2:已完成
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 消息时间
|
||||
*/
|
||||
private Date msgDate;
|
||||
|
||||
/**
|
||||
* 扩展参数 JsonString
|
||||
*/
|
||||
private String ext;
|
||||
/**
|
||||
* 路由类型(0=null 1=uniapp 2=native 3=H5 4=web 5=WeChat_MP)", example = "1
|
||||
*/
|
||||
private Integer routerType;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
*/
|
||||
private String router;
|
||||
|
||||
/**
|
||||
* 路由参数 JsonString
|
||||
*/
|
||||
private String routerParam;
|
||||
|
||||
/**
|
||||
* 关联Id
|
||||
*/
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 原typeId
|
||||
*/
|
||||
private Integer oldTypeId;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.axzo.msg.center.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author: wangli
|
||||
* @date: 2022/5/24 18:06
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class MsgBody4GuestDTO {
|
||||
|
||||
/**
|
||||
* 聊天模式类型 安心筑项目使用1 临时聊天
|
||||
*/
|
||||
private Integer cy = 1;
|
||||
/**
|
||||
* 消息发送者的id
|
||||
*/
|
||||
private String f;
|
||||
/**
|
||||
* 消息内容字段
|
||||
*/
|
||||
private String m;
|
||||
/**
|
||||
* 消息内容扩展字段2
|
||||
*/
|
||||
private String m2;
|
||||
/**
|
||||
* 消息内容扩展字段3
|
||||
*/
|
||||
private String m3;
|
||||
/**
|
||||
* 消息发送人的昵称
|
||||
*/
|
||||
private String nickName;
|
||||
/**
|
||||
* 消息接收者的id
|
||||
*/
|
||||
private String t;
|
||||
/**
|
||||
* 普通文字消息0 图片消息1 语音留言消息2
|
||||
*/
|
||||
private Integer ty;
|
||||
private String userAvatarFileName;
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package cn.axzo.msg.center.domain.dto;
|
||||
|
||||
|
||||
import cn.axzo.msg.center.domain.enums.PlatOmsWhereEnum;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName PlatDeptUserDto
|
||||
* @Description 人员部门岗位
|
||||
* @Author zhangran
|
||||
* @Date 2022/1/25 14:50
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PlatDeptLogDto {
|
||||
|
||||
private final static String WHERE_OP_TMPL= "{}管理页-{}{}";
|
||||
|
||||
public final static String EDIT_OP = "编辑";
|
||||
public final static String ADD_OP = "添加";
|
||||
public final static String DELETE_OP = "删除";
|
||||
public final static String REMOVE_OP = "移除";
|
||||
|
||||
|
||||
/**
|
||||
* 地方
|
||||
*/
|
||||
private PlatOmsWhereEnum where;
|
||||
/**
|
||||
* 操作:ADD_OP, EDIT_OP, DELETE_OP
|
||||
*/
|
||||
private String op;
|
||||
/**
|
||||
* 操作数据
|
||||
*/
|
||||
private String data;
|
||||
|
||||
public String getTitle(){
|
||||
return "操作"+where.name;
|
||||
}
|
||||
|
||||
public String getContent(String phone){
|
||||
String part1 = StrUtil.format(WHERE_OP_TMPL, where.name, op, where.name);
|
||||
String part2 = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss");
|
||||
return part1+"、"+part2+"、"+data+"、"+phone;
|
||||
}
|
||||
|
||||
|
||||
public Integer getType(){
|
||||
return where.code;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
public enum PlatOmsWhereEnum {
|
||||
|
||||
/**
|
||||
* 枚举值
|
||||
*/
|
||||
WHERE_DEPT(101,"部门"),
|
||||
WHERE_ACCT(102,"人员账号"),
|
||||
WHERE_DEPT_GROUP(103,"部门权限"),
|
||||
WHERE_DEPT_PERSON(104,"成员"),
|
||||
WHERE_DEPT_POSITION_GROUP(105,"岗位权限"),
|
||||
WHERE_DEPT_POSITION(106,"岗位标签"),
|
||||
WHERE_OMS_ELEMENT(107,"OMS权限配置");
|
||||
|
||||
|
||||
public final Integer code;
|
||||
|
||||
public final String name;
|
||||
|
||||
|
||||
PlatOmsWhereEnum(Integer code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@ -3,16 +3,21 @@ package cn.axzo.msg.center.webapi;
|
||||
import cn.axzo.core.web.Result;
|
||||
import cn.axzo.core.web.Results;
|
||||
import cn.axzo.framework.auth.annotation.PreBuildContext;
|
||||
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.api.request.GeneralMessage;
|
||||
import cn.axzo.msg.center.api.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.api.request.MsgReturnParamRes;
|
||||
import cn.axzo.msg.center.api.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.common.page.PageResult;
|
||||
import cn.axzo.msg.center.domain.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.domain.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.inside.notices.model.response.MessageTotalRes;
|
||||
import cn.axzo.msg.center.inside.notices.service.MessageCoreService;
|
||||
import cn.axzo.msg.center.inside.notices.service.MessageRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
@ -24,8 +29,24 @@ import javax.validation.Valid;
|
||||
@RequestMapping("webApi/message")
|
||||
public class MessageController {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private MessageCoreService messageCoreService;
|
||||
@Resource
|
||||
private MessageRecordService messageRecordService;
|
||||
|
||||
|
||||
/**
|
||||
* 新增推送消息接口
|
||||
*
|
||||
* @param message
|
||||
* @return 消息唯一主键
|
||||
*/
|
||||
@RequestMapping(value = "api/message/push", method = RequestMethod.POST)
|
||||
Result<List<MsgReturnParamRes>> pushMsg(@RequestBody GeneralMessage message){
|
||||
return Results.ok(messageRecordService.pushMsg(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息\待办数量总数
|
||||
|
||||
@ -84,6 +84,10 @@
|
||||
<artifactId>msg-notices-http-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<artifactId>msg-center-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- <build>-->
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
package cn.axzo.msg.center.notices.client.config;
|
||||
|
||||
import cn.axzo.msg.center.common.utils.SpringUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jiachao
|
||||
* @date 2021/7/2
|
||||
*/
|
||||
@Configuration
|
||||
public class SpringUtilsConfig {
|
||||
/**
|
||||
* Spring 工具类
|
||||
*
|
||||
* @param applicationContext 上下文
|
||||
*/
|
||||
@Bean
|
||||
public SpringUtils getSpringUtils(ApplicationContext applicationContext) {
|
||||
SpringUtils instance = SpringUtils.getInstance();
|
||||
SpringUtils.setApplicationContext(applicationContext);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user