|
@@ -14,13 +14,10 @@ import com.dragon.tj.portal.common.enums.message.MessageInfoErrorEnums;
|
|
|
import com.dragon.tj.portal.common.enums.message.MsgRecordTypeEnum;
|
|
|
import com.dragon.tj.portal.common.enums.message.ReadStatusEnum;
|
|
|
import com.dragon.tj.portal.common.enums.message.ScopeEnums;
|
|
|
-import com.dragon.tj.portal.common.vo.message.MessageInfoParam;
|
|
|
-import com.dragon.tj.portal.common.vo.message.MessageInfoVO;
|
|
|
import com.dragon.tj.portal.common.vo.message.MessagePageParam;
|
|
|
import com.dragon.tj.portal.common.vo.notice.NoticeInfoParam;
|
|
|
import com.dragon.tj.portal.common.vo.notice.NoticeInfoVO;
|
|
|
import com.dragon.tj.portal.component.exception.message.MessageInfoException;
|
|
|
-import com.dragon.tj.portal.component.message.KafkaInitialConfiguration;
|
|
|
import com.dragon.tj.portal.component.message.MessageProducer;
|
|
|
import com.dragon.tj.portal.entity.MessageInfo;
|
|
|
import com.dragon.tj.portal.entity.MsgRecord;
|
|
@@ -37,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -74,15 +72,18 @@ public class NoticeInfoServiceImpl extends ServiceImpl<NoticeInfoMapper, NoticeI
|
|
|
@Autowired
|
|
|
private NoticeInfoVOConvert noticeInfoVOConvert;
|
|
|
|
|
|
+ @Value("${notice-secret:true}")
|
|
|
+ private boolean noticeSecret;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public R send(NoticeInfoReq noticeInfoReq) {
|
|
|
- this.validate(noticeInfoReq);
|
|
|
- //判断scopeId及获得对应的人
|
|
|
- boolean b = transferIds(noticeInfoReq);
|
|
|
+ if (this.validate(noticeInfoReq)) {
|
|
|
+ return R.ok(this.transferIds(noticeInfoReq));
|
|
|
+ }
|
|
|
//封装消息
|
|
|
//保存及推送mq
|
|
|
- return R.ok(b);
|
|
|
+ return R.failed(false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -133,7 +134,7 @@ public class NoticeInfoServiceImpl extends ServiceImpl<NoticeInfoMapper, NoticeI
|
|
|
Integer messageType = noticeInfoReq.getMessageType();
|
|
|
String scopeId = noticeInfoReq.getScopeId();
|
|
|
Set<String> messageClientIds = this.getMessageClientIds(messageType, scopeId);
|
|
|
- log.info("transferIds-scopeId-{}-{}",scopeId,messageClientIds);
|
|
|
+ log.info("transferIds-scopeId-{}-{}", scopeId, messageClientIds);
|
|
|
if (CollUtil.isNotEmpty(messageClientIds)) {
|
|
|
NoticeInfoSend noticeInfoSend = this.doSaveNoticeInfo(noticeInfoReq, messageClientIds);
|
|
|
isSend = producer.send("sseTopic-a1", JSON.toJSONString(noticeInfoSend));
|
|
@@ -170,21 +171,21 @@ public class NoticeInfoServiceImpl extends ServiceImpl<NoticeInfoMapper, NoticeI
|
|
|
return messageClientIds;
|
|
|
}
|
|
|
|
|
|
- private void validate(NoticeInfoReq noticeInfoReq) {
|
|
|
-
|
|
|
-
|
|
|
- //TODO 校验一下topic
|
|
|
+ private boolean validate(NoticeInfoReq noticeInfoReq) {
|
|
|
|
|
|
String id = noticeInfoReq.getId();
|
|
|
Long t = noticeInfoReq.getT();
|
|
|
String scopeId = noticeInfoReq.getScopeId();
|
|
|
log.info("noticeInfoReq-validate-start-{}", noticeInfoReq.getId());
|
|
|
- String correctHash = DigestUtils.md5Hex(id + t);
|
|
|
- if (!correctHash.equalsIgnoreCase(noticeInfoReq.getK())) {
|
|
|
- return;
|
|
|
+ if (noticeSecret) {
|
|
|
+ String correctHash = DigestUtils.md5Hex(id + t);
|
|
|
+ if (!correctHash.equalsIgnoreCase(noticeInfoReq.getK())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
- log.info("noticeInfoReq-validate-end-{}-{}", scopeId, id);
|
|
|
|
|
|
+ log.info("noticeInfoReq-validate-end-{}-{}", scopeId, id);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -231,4 +232,9 @@ public class NoticeInfoServiceImpl extends ServiceImpl<NoticeInfoMapper, NoticeI
|
|
|
log.info("doSaveNoticeInfo-end-{}-{}", noticeInfoReq.getId(), messageClientIds);
|
|
|
return noticeInfoSend;
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String correctHash = DigestUtils.md5Hex("1" + "333");
|
|
|
+ System.out.println(correctHash);
|
|
|
+ }
|
|
|
}
|