use of org.jeecg.modules.system.entity.SysAnnouncementSend in project jeecg-boot by jeecgboot.
the class SysAnnouncementController method listByUser.
/**
* @功能:补充用户数据,并返回系统消息
* @return
*/
@RequestMapping(value = "/listByUser", method = RequestMethod.GET)
public Result<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
Result<Map<String, Object>> result = new Result<Map<String, Object>>();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
// 1.将系统消息补充到用户通告阅读标记表中
LambdaQueryWrapper<SysAnnouncement> querySaWrapper = new LambdaQueryWrapper<SysAnnouncement>();
// 全部人员
querySaWrapper.eq(SysAnnouncement::getMsgType, CommonConstant.MSG_TYPE_ALL);
// 未删除
querySaWrapper.eq(SysAnnouncement::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
// 已发布
querySaWrapper.eq(SysAnnouncement::getSendStatus, CommonConstant.HAS_SEND);
// 新注册用户不看结束通知
querySaWrapper.ge(SysAnnouncement::getEndTime, sysUser.getCreateTime());
// update-begin--Author:liusq Date:20210108 for:[JT-424] 【开源issue】bug处理--------------------
querySaWrapper.notInSql(SysAnnouncement::getId, "select annt_id from sys_announcement_send where user_id='" + userId + "'");
// update-begin--Author:liusq Date:20210108 for: [JT-424] 【开源issue】bug处理--------------------
List<SysAnnouncement> announcements = sysAnnouncementService.list(querySaWrapper);
if (announcements.size() > 0) {
for (int i = 0; i < announcements.size(); i++) {
// update-begin--Author:wangshuai Date:20200803 for: 通知公告消息重复LOWCOD-759--------------------
// 因为websocket没有判断是否存在这个用户,要是判断会出现问题,故在此判断逻辑
LambdaQueryWrapper<SysAnnouncementSend> query = new LambdaQueryWrapper<>();
query.eq(SysAnnouncementSend::getAnntId, announcements.get(i).getId());
query.eq(SysAnnouncementSend::getUserId, userId);
SysAnnouncementSend one = sysAnnouncementSendService.getOne(query);
if (null == one) {
log.info("listByUser接口新增了SysAnnouncementSend:pageSize{}:" + pageSize);
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
announcementSend.setAnntId(announcements.get(i).getId());
announcementSend.setUserId(userId);
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
sysAnnouncementSendService.save(announcementSend);
log.info("announcementSend.toString()", announcementSend.toString());
}
// update-end--Author:wangshuai Date:20200803 for: 通知公告消息重复LOWCOD-759------------
}
}
// 2.查询用户未读的系统消息
Page<SysAnnouncement> anntMsgList = new Page<SysAnnouncement>(0, pageSize);
// 通知公告消息
anntMsgList = sysAnnouncementService.querySysCementPageByUserId(anntMsgList, userId, "1");
Page<SysAnnouncement> sysMsgList = new Page<SysAnnouncement>(0, pageSize);
// 系统消息
sysMsgList = sysAnnouncementService.querySysCementPageByUserId(sysMsgList, userId, "2");
Map<String, Object> sysMsgMap = new HashMap<String, Object>();
sysMsgMap.put("sysMsgList", sysMsgList.getRecords());
sysMsgMap.put("sysMsgTotal", sysMsgList.getTotal());
sysMsgMap.put("anntMsgList", anntMsgList.getRecords());
sysMsgMap.put("anntMsgTotal", anntMsgList.getTotal());
result.setSuccess(true);
result.setResult(sysMsgMap);
return result;
}
use of org.jeecg.modules.system.entity.SysAnnouncementSend in project jeecg-boot by jeecgboot.
the class SysAnnouncementSendController method eidt.
/**
* 编辑
* @param sysAnnouncementSend
* @return
*/
@PutMapping(value = "/edit")
public Result<SysAnnouncementSend> eidt(@RequestBody SysAnnouncementSend sysAnnouncementSend) {
Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
SysAnnouncementSend sysAnnouncementSendEntity = sysAnnouncementSendService.getById(sysAnnouncementSend.getId());
if (sysAnnouncementSendEntity == null) {
result.error500("未找到对应实体");
} else {
boolean ok = sysAnnouncementSendService.updateById(sysAnnouncementSend);
// TODO 返回false说明什么?
if (ok) {
result.success("修改成功!");
}
}
return result;
}
use of org.jeecg.modules.system.entity.SysAnnouncementSend in project jeecg-boot by jeecgboot.
the class SysAnnouncementSendController method queryById.
/**
* 通过id查询
* @param id
* @return
*/
@GetMapping(value = "/queryById")
public Result<SysAnnouncementSend> queryById(@RequestParam(name = "id", required = true) String id) {
Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
SysAnnouncementSend sysAnnouncementSend = sysAnnouncementSendService.getById(id);
if (sysAnnouncementSend == null) {
result.error500("未找到对应实体");
} else {
result.setResult(sysAnnouncementSend);
result.setSuccess(true);
}
return result;
}
use of org.jeecg.modules.system.entity.SysAnnouncementSend in project jeecg-boot by jeecgboot.
the class SysAnnouncementServiceImpl method saveAnnouncement.
@Transactional
@Override
public void saveAnnouncement(SysAnnouncement sysAnnouncement) {
if (sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_ALL)) {
sysAnnouncementMapper.insert(sysAnnouncement);
} else {
// 1.插入通告表记录
sysAnnouncementMapper.insert(sysAnnouncement);
// 2.插入用户通告阅读标记表记录
String userId = sysAnnouncement.getUserIds();
String[] userIds = userId.substring(0, (userId.length() - 1)).split(",");
String anntId = sysAnnouncement.getId();
Date refDate = new Date();
for (int i = 0; i < userIds.length; i++) {
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
announcementSend.setAnntId(anntId);
announcementSend.setUserId(userIds[i]);
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
announcementSend.setReadTime(refDate);
sysAnnouncementSendMapper.insert(announcementSend);
}
}
}
use of org.jeecg.modules.system.entity.SysAnnouncementSend in project jeecg-boot by jeecgboot.
the class SysAnnouncementServiceImpl method upDateAnnouncement.
/**
* @功能:编辑消息信息
*/
@Transactional
@Override
public boolean upDateAnnouncement(SysAnnouncement sysAnnouncement) {
// 1.更新系统信息表数据
sysAnnouncementMapper.updateById(sysAnnouncement);
String userId = sysAnnouncement.getUserIds();
if (oConvertUtils.isNotEmpty(userId) && sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_UESR)) {
// 2.补充新的通知用户数据
String[] userIds = userId.substring(0, (userId.length() - 1)).split(",");
String anntId = sysAnnouncement.getId();
Date refDate = new Date();
for (int i = 0; i < userIds.length; i++) {
LambdaQueryWrapper<SysAnnouncementSend> queryWrapper = new LambdaQueryWrapper<SysAnnouncementSend>();
queryWrapper.eq(SysAnnouncementSend::getAnntId, anntId);
queryWrapper.eq(SysAnnouncementSend::getUserId, userIds[i]);
List<SysAnnouncementSend> announcementSends = sysAnnouncementSendMapper.selectList(queryWrapper);
if (announcementSends.size() <= 0) {
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
announcementSend.setAnntId(anntId);
announcementSend.setUserId(userIds[i]);
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
announcementSend.setReadTime(refDate);
sysAnnouncementSendMapper.insert(announcementSend);
}
}
// 3. 删除多余通知用户数据
Collection<String> delUserIds = Arrays.asList(userIds);
LambdaQueryWrapper<SysAnnouncementSend> queryWrapper = new LambdaQueryWrapper<SysAnnouncementSend>();
queryWrapper.notIn(SysAnnouncementSend::getUserId, delUserIds);
queryWrapper.eq(SysAnnouncementSend::getAnntId, anntId);
sysAnnouncementSendMapper.delete(queryWrapper);
}
return true;
}
Aggregations