add 动态消息发布时发送系统消息
This commit is contained in:
+2
-2
@@ -81,7 +81,7 @@ public class LawsNewsFeedController extends JeroController<LawsNewsFeed, ILawsNe
|
||||
if (!Objects.isNull(lawsNewsFeed.getReleaseTime())) {
|
||||
lawsNewsFeed.setReleaseTime(new Date());
|
||||
}
|
||||
lawsNewsFeedService.add(lawsNewsFeed);
|
||||
lawsNewsFeedService.add(lawsNewsFeed, "save");
|
||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class LawsNewsFeedController extends JeroController<LawsNewsFeed, ILawsNe
|
||||
// 不管第几次发布,发布时间都更新
|
||||
lawsNewsFeed.setReleaseTime(new Date());
|
||||
lawsNewsFeed.setReleaseStatus(1);
|
||||
lawsNewsFeedService.add(lawsNewsFeed);
|
||||
lawsNewsFeedService.add(lawsNewsFeed, "release");
|
||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public interface ILawsNewsFeedService extends IService<LawsNewsFeed> {
|
||||
* @param lawsNewsFeed
|
||||
* @return
|
||||
*/
|
||||
void add(LawsNewsFeed lawsNewsFeed);
|
||||
void add(LawsNewsFeed lawsNewsFeed, String type);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
|
||||
+29
-10
@@ -1,8 +1,8 @@
|
||||
package com.jero.modules.laws.standard.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.common.api.vo.SendMessageAPI;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.laws.common.constant.FieldCommon;
|
||||
import com.jero.modules.laws.common.constant.ResultCommon;
|
||||
@@ -11,7 +11,8 @@ import com.jero.modules.laws.standard.entity.LawsPushRange;
|
||||
import com.jero.modules.laws.standard.mapper.LawsNewsFeedMapper;
|
||||
import com.jero.modules.laws.standard.service.ILawsNewsFeedService;
|
||||
import com.jero.modules.laws.standard.service.ILawsPushRangeService;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
import com.spire.ms.System.Collections.ArrayList;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -21,15 +22,10 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
@@ -48,6 +44,10 @@ public class LawsNewsFeedServiceImpl extends ServiceImpl<LawsNewsFeedMapper, Law
|
||||
private ILawsPushRangeService lawsPushRangeService;
|
||||
@Autowired
|
||||
private LawsNewsFeedMapper lawsNewsFeedMapper;
|
||||
@Autowired
|
||||
private SendMessageAPI sendMessageAPI;
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
@@ -122,7 +122,7 @@ public class LawsNewsFeedServiceImpl extends ServiceImpl<LawsNewsFeedMapper, Law
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(LawsNewsFeed lawsNewsFeed) {
|
||||
public void add(LawsNewsFeed lawsNewsFeed, String type) {
|
||||
if (StringUtils.isBlank(lawsNewsFeed.getDynamicHeading())) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "dynamicHeading");
|
||||
}
|
||||
@@ -164,6 +164,25 @@ public class LawsNewsFeedServiceImpl extends ServiceImpl<LawsNewsFeedMapper, Law
|
||||
pushRangeList.add(lawsPushRange);
|
||||
});
|
||||
lawsPushRangeService.saveBatch(pushRangeList);
|
||||
|
||||
if ("release".equals(type)) {
|
||||
// 发送消息
|
||||
SendMessageDTO sendMessageDTO = new SendMessageDTO();
|
||||
sendMessageDTO.setTemplateCode("laws_news_feed");
|
||||
sendMessageDTO.setToUserId(pushRange);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("title", lawsNewsFeed.getDynamicHeading());
|
||||
|
||||
LambdaQueryWrapper<SysDictItem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(SysDictItem::getItemValue, lawsNewsFeed.getDynamicClassification());
|
||||
lambdaQueryWrapper.eq(SysDictItem::getDictId, "1704331613726781442");
|
||||
SysDictItem sysDictItem = sysDictItemService.getOne(lambdaQueryWrapper);
|
||||
|
||||
map.put("type", sysDictItem.getItemText());
|
||||
map.put("name", loginUser.getRealname());
|
||||
sendMessageDTO.setMap(map);
|
||||
sendMessageAPI.sendMessage(sendMessageDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user