Commit a3548a7d authored by 张辰's avatar 张辰

实时发送消息

parent 0a2f0251
......@@ -13,24 +13,24 @@ public class CreateThemeReq {
@NotNull(message = "类型不能为空")
@ApiModelProperty(value = "类型 1:讨论无标题 2:长文有标题")
private Integer themeType;
public Integer themeType;
@ApiModelProperty(value = "标题")
private String title;
public String title;
@NotEmpty(message = "内容不能为空")
@ApiModelProperty(value = "文本内容")
private List<ThemeContentReq> content;
public List<ThemeContentReq> content;
@ApiModelProperty(value = "所属的话题id")
private String topicId = "";
public String topicId = "";
@ApiModelProperty(value = "修改,则传入正在编辑的ThemeId")
private String editThemeId = "";
public String editThemeId = "";
@ApiModelProperty("是否同步到社区 0为不同步 1为同步 默认不同步")
private Integer syncToNewComm = 0;
public Integer syncToNewComm = 0;
}
......@@ -26,6 +26,7 @@ import com.tanpu.community.service.NotificationService;
import com.tanpu.community.service.ReportLogService;
import com.tanpu.community.service.ThemeService;
import com.tanpu.community.service.TopicService;
import com.tanpu.community.service.quartz.TopicReportService;
import com.tanpu.community.util.ConvertUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -64,11 +65,16 @@ public class CommentManager {
@Autowired
private ThemeService themeService;
@Resource
private TopicService topicService;
@Resource
private FeignService feignService;
@Autowired
private TopicReportService topicReportService;
// 评论(对主题)
// 发表评论(对主题)
public CommentQo comment(CreateCommentReq req, String userId) {
......@@ -101,6 +107,7 @@ public class CommentManager {
if (themeEntity == null) {
throw new BizException(ErrorCodeConstant.UNREACHABLE);
}
notificationService.insert(userId, themeEntity.getAuthorId(), NotificationTypeEnum.COMMENT, commentEntity.getCommentId(), req.getComment());
notificationService.putNotifyCache(themeEntity.getAuthorId(), userId, NotificationTypeEnum.COMMENT);
......@@ -114,6 +121,9 @@ public class CommentManager {
notificationService.putNotifyCache(commentTheme.getAuthorId(), userId, NotificationTypeEnum.FORWARD);
}
if (StringUtils.isNotBlank(themeEntity.getTopicId())) {
topicReportService.reportTopicOnTime(themeEntity.getTopicId());
}
return commentQo;
}
......
......@@ -50,6 +50,7 @@ import com.tanpu.community.feign.community.FeignClientForCommunity;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.service.*;
import com.tanpu.community.service.base.ESService;
import com.tanpu.community.service.quartz.TopicReportService;
import com.tanpu.community.util.BizUtils;
import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.OtherUtil;
......@@ -144,9 +145,13 @@ public class ThemeManager {
@Resource
private ThemeTextCheckService themeTextCheckService;
@Resource
private TopicService topicService;
@Autowired
private TopicReportService topicReportService;
@PostConstruct
public void init() throws IOException {
File f = new File(tmpDir);
......@@ -273,6 +278,10 @@ public class ThemeManager {
}
if (StringUtils.isNotBlank(req.topicId)) {
topicReportService.reportTopicOnTime(req.topicId);
}
return CommonResp.success(themeResp);
......
......@@ -100,6 +100,10 @@ public class TopicService {
return topicMapper.selectList(new LambdaQueryWrapper<TopicEntity>().in(TopicEntity::getTopicId, topicIds));
}
public TopicEntity queryById(String topicId) {
return topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicId, topicId));
}
/**
* CRUD Topic_Follow
......
......@@ -13,6 +13,7 @@ import com.tanpu.community.service.ThemeService;
import com.tanpu.community.service.TopicService;
import com.tanpu.community.service.VisitLogService;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.util.*;
@Service
@Slf4j
public class TopicReportService {
@Value("${wxcp.topicreport.agentId}")
......@@ -47,6 +49,17 @@ public class TopicReportService {
private FeignClientForFatools feignClientForFatools;
public static String content_report_topic_ontime = "话题(%s) 有一个新的讨论/评论";
public void reportTopicOnTime(String topicId) {
TopicEntity topic = topicService.queryById(topicId);
if (topic == null || topic.getSyncCorpWechat() == 0) return;
String content = String.format(content_report_topic_ontime, topic.getTopicTitle());
List<String> wxcpIds = getTopicManagerWxcpIds(topic.getTopicId());
sendReportMessage(content, wxcpIds);
}
// 每个工作日早上09:30汇报
public static String content_report_topic_weekday = "话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 昨日新增成员: %s, 昨日新增讨论";
public void reportTopicWeekday() {
......@@ -137,6 +150,7 @@ public class TopicReportService {
parmMap.put("content", content);
parmMap.put("list", wxcpIds);
log.info("sendTopicReportMessage wxcpIds: {}, content: {}", JSON.toJSONString(wxcpIds), content);
feignClientForWxcp.sendMessage(agentId, corpId, JSON.toJSONString(parmMap));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment