修改pc已读消息列表
This commit is contained in:
@@ -2,10 +2,11 @@ package com.ruoyi.cms.controller.cms;
|
|||||||
|
|
||||||
import com.ruoyi.cms.domain.AppNotice;
|
import com.ruoyi.cms.domain.AppNotice;
|
||||||
import com.ruoyi.cms.domain.Notice;
|
import com.ruoyi.cms.domain.Notice;
|
||||||
|
import com.ruoyi.cms.domain.vo.NoticeTotal;
|
||||||
import com.ruoyi.cms.service.IAppNoticeService;
|
import com.ruoyi.cms.service.IAppNoticeService;
|
||||||
import com.ruoyi.cms.service.IAppUserService;
|
import com.ruoyi.cms.service.IAppUserService;
|
||||||
|
import com.ruoyi.cms.util.NoticeUtils;
|
||||||
import com.ruoyi.cms.util.RoleUtils;
|
import com.ruoyi.cms.util.RoleUtils;
|
||||||
import com.ruoyi.cms.util.StringUtil;
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.HttpStatus;
|
import com.ruoyi.common.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
@@ -152,7 +153,8 @@ public class CmsNoticeController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
startPage();
|
startPage();
|
||||||
notice.setIsRead(StringUtil.NOTICE_YD);
|
notice.setIsRead(NoticeUtils.NOTICE_YD);
|
||||||
|
notice.setRemark(NoticeUtils.NOTICE_TYPE);
|
||||||
List<Notice> notices = noticeService.selectListAppNotices(notice);
|
List<Notice> notices = noticeService.selectListAppNotices(notice);
|
||||||
return getDataTable(notices);
|
return getDataTable(notices);
|
||||||
}
|
}
|
||||||
@@ -177,4 +179,33 @@ public class CmsNoticeController extends BaseController
|
|||||||
noticeService.readSysNotices(id,userId);
|
noticeService.readSysNotices(id,userId);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取消息条数
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取移动端用户消息条数")
|
||||||
|
@GetMapping("/noticTotal")
|
||||||
|
public AjaxResult getNoticTotal(Notice notice){
|
||||||
|
if(!SecurityUtils.isLogin()){
|
||||||
|
error(HttpStatus.ERROR,"未登录!");
|
||||||
|
}
|
||||||
|
if(notice.getUserId()==null){
|
||||||
|
String idCard= RoleUtils.getCurrentUseridCard();
|
||||||
|
AppUser appUser=appUserService.selectAppuserByIdcard(idCard);
|
||||||
|
if(appUser==null){
|
||||||
|
error(HttpStatus.ERROR,"用户信息未完善,请完善身份证信息!");
|
||||||
|
}else{
|
||||||
|
notice.setUserId(appUser.getUserId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
startPage();
|
||||||
|
NoticeTotal notices = noticeService.noticTotal(notice);
|
||||||
|
return success(notices);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取移动端用户消息条数")
|
||||||
|
@DeleteMapping("/deleteNotice/{ids}")
|
||||||
|
public AjaxResult deleteNotice(@PathVariable Long[] ids){
|
||||||
|
return success(noticeService.removeNotice(ids));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class Notice extends BaseEntity
|
|||||||
@ApiModelProperty("日期")
|
@ApiModelProperty("日期")
|
||||||
private Date date;
|
private Date date;
|
||||||
|
|
||||||
@ApiModelProperty("通知类型")
|
@ApiModelProperty("通知类型 1系统通知(包括录用) 2职位上新")
|
||||||
private String noticeType;
|
private String noticeType;
|
||||||
|
|
||||||
@ApiModelProperty("公告内容")
|
@ApiModelProperty("公告内容")
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.cms.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息条数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class NoticeTotal {
|
||||||
|
/**
|
||||||
|
* 未读消息
|
||||||
|
*/
|
||||||
|
private Integer qbxx;
|
||||||
|
/**
|
||||||
|
* 全部未读
|
||||||
|
*/
|
||||||
|
private Integer wdxx;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.ruoyi.cms.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.ruoyi.cms.domain.Notice;
|
import com.ruoyi.cms.domain.Notice;
|
||||||
|
import com.ruoyi.cms.domain.vo.NoticeTotal;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -10,4 +11,6 @@ public interface NoticeMapper extends BaseMapper<Notice>
|
|||||||
{
|
{
|
||||||
|
|
||||||
List<Notice> getNoticlist(Notice notice);
|
List<Notice> getNoticlist(Notice notice);
|
||||||
|
|
||||||
|
NoticeTotal noticTotal(Notice notice);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.ruoyi.cms.domain.AppNotice;
|
|||||||
import com.ruoyi.cms.domain.Job;
|
import com.ruoyi.cms.domain.Job;
|
||||||
import com.ruoyi.cms.domain.Notice;
|
import com.ruoyi.cms.domain.Notice;
|
||||||
import com.ruoyi.cms.domain.vo.AppNoticeVO;
|
import com.ruoyi.cms.domain.vo.AppNoticeVO;
|
||||||
|
import com.ruoyi.cms.domain.vo.NoticeTotal;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -89,4 +90,8 @@ public interface IAppNoticeService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Notice> selectListAppNotices(Notice notice);
|
List<Notice> selectListAppNotices(Notice notice);
|
||||||
|
|
||||||
|
NoticeTotal noticTotal(Notice notice);
|
||||||
|
|
||||||
|
int removeNotice(Long[] ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,17 @@ package com.ruoyi.cms.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.ruoyi.cms.domain.*;
|
import com.ruoyi.cms.domain.*;
|
||||||
|
import com.ruoyi.cms.domain.vo.NoticeTotal;
|
||||||
import com.ruoyi.cms.mapper.*;
|
import com.ruoyi.cms.mapper.*;
|
||||||
import com.ruoyi.cms.service.IAppNoticeService;
|
import com.ruoyi.cms.service.IAppNoticeService;
|
||||||
|
import com.ruoyi.cms.util.NoticeUtils;
|
||||||
import com.ruoyi.cms.util.StringUtil;
|
import com.ruoyi.cms.util.StringUtil;
|
||||||
import com.ruoyi.common.core.domain.entity.AppUser;
|
import com.ruoyi.common.core.domain.entity.AppUser;
|
||||||
import com.ruoyi.common.utils.SiteSecurityUtils;
|
import com.ruoyi.common.utils.SiteSecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -127,7 +130,7 @@ public class AppNoticeServiceImpl implements IAppNoticeService
|
|||||||
Notice notice = new Notice();
|
Notice notice = new Notice();
|
||||||
notice.setUserId(appUser.getUserId());
|
notice.setUserId(appUser.getUserId());
|
||||||
notice.setTitle("职位上新");
|
notice.setTitle("职位上新");
|
||||||
notice.setIsRead(StringUtil.NOTICE_WD);
|
notice.setIsRead(NoticeUtils.NOTICE_WD);
|
||||||
notice.setDate(new Date());
|
notice.setDate(new Date());
|
||||||
//todo update number of job
|
//todo update number of job
|
||||||
notice.setSubTitle("这里有10个岗位很适合你,快来看看吧");
|
notice.setSubTitle("这里有10个岗位很适合你,快来看看吧");
|
||||||
@@ -169,14 +172,14 @@ public class AppNoticeServiceImpl implements IAppNoticeService
|
|||||||
List<Long> longs = StringUtil.convertStringToLongList(ids);
|
List<Long> longs = StringUtil.convertStringToLongList(ids);
|
||||||
List<Notice> notices = noticeInfoMapper.selectBatchIds(longs);
|
List<Notice> notices = noticeInfoMapper.selectBatchIds(longs);
|
||||||
notices.forEach(notice -> {
|
notices.forEach(notice -> {
|
||||||
notice.setIsRead(StringUtil.NOTICE_YD);
|
notice.setIsRead(NoticeUtils.NOTICE_YD);
|
||||||
noticeInfoMapper.updateById(notice);
|
noticeInfoMapper.updateById(notice);
|
||||||
});
|
});
|
||||||
List<Notice> notices1 = noticeInfoMapper.selectList(Wrappers.<Notice>lambdaQuery().eq(Notice::getUserId, SiteSecurityUtils.getUserId()).eq(Notice::getRemark, "notice_bar").eq(Notice::getTitle, "系统通知").orderByDesc(Notice::getCreateTime).last("limit 1"));
|
List<Notice> notices1 = noticeInfoMapper.selectList(Wrappers.<Notice>lambdaQuery().eq(Notice::getUserId, SiteSecurityUtils.getUserId()).eq(Notice::getRemark, "notice_bar").eq(Notice::getTitle, "系统通知").orderByDesc(Notice::getCreateTime).last("limit 1"));
|
||||||
Notice notice = notices1.get(0);
|
Notice notice = notices1.get(0);
|
||||||
notice.setNotReadCount(notice.getNotReadCount() - longs.size());
|
notice.setNotReadCount(notice.getNotReadCount() - longs.size());
|
||||||
if(notice.getNotReadCount()==0){
|
if(notice.getNotReadCount()==0){
|
||||||
notice.setIsRead(StringUtil.NOTICE_YD);
|
notice.setIsRead(NoticeUtils.NOTICE_YD);
|
||||||
}
|
}
|
||||||
noticeInfoMapper.updateById(notice);
|
noticeInfoMapper.updateById(notice);
|
||||||
}
|
}
|
||||||
@@ -186,7 +189,7 @@ public class AppNoticeServiceImpl implements IAppNoticeService
|
|||||||
List<Long> longs = StringUtil.convertStringToLongList(ids);
|
List<Long> longs = StringUtil.convertStringToLongList(ids);
|
||||||
List<Notice> notices = noticeInfoMapper.selectBatchIds(longs);
|
List<Notice> notices = noticeInfoMapper.selectBatchIds(longs);
|
||||||
notices.forEach(notice -> {
|
notices.forEach(notice -> {
|
||||||
notice.setIsRead(StringUtil.NOTICE_YD);
|
notice.setIsRead(NoticeUtils.NOTICE_YD);
|
||||||
notice.setNotReadCount(0);
|
notice.setNotReadCount(0);
|
||||||
noticeInfoMapper.updateById(notice);
|
noticeInfoMapper.updateById(notice);
|
||||||
});
|
});
|
||||||
@@ -201,8 +204,8 @@ public class AppNoticeServiceImpl implements IAppNoticeService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Notice> selectListAppNotRead(Notice notice) {
|
public List<Notice> selectListAppNotRead(Notice notice) {
|
||||||
notice.setRemark(StringUtil.NOTICE_TYPE);
|
notice.setRemark(NoticeUtils.NOTICE_TYPE);
|
||||||
notice.setIsRead(StringUtil.NOTICE_WD);
|
notice.setIsRead(NoticeUtils.NOTICE_WD);
|
||||||
//List<Notice> sysNoticeList = noticeInfoMapper.selectList(Wrappers.<Notice>lambdaQuery().eq(Notice::getUserId, notice.getUserId()).eq(Notice::getRemark,"notice_bar").eq(Notice::getIsRead,0).orderByDesc(Notice::getCreateTime));
|
//List<Notice> sysNoticeList = noticeInfoMapper.selectList(Wrappers.<Notice>lambdaQuery().eq(Notice::getUserId, notice.getUserId()).eq(Notice::getRemark,"notice_bar").eq(Notice::getIsRead,0).orderByDesc(Notice::getCreateTime));
|
||||||
return noticeInfoMapper.getNoticlist(notice);
|
return noticeInfoMapper.getNoticlist(notice);
|
||||||
}
|
}
|
||||||
@@ -212,26 +215,41 @@ public class AppNoticeServiceImpl implements IAppNoticeService
|
|||||||
List<Long> longs = StringUtil.convertStringToLongList(ids);
|
List<Long> longs = StringUtil.convertStringToLongList(ids);
|
||||||
List<Notice> notices = noticeInfoMapper.selectBatchIds(longs);
|
List<Notice> notices = noticeInfoMapper.selectBatchIds(longs);
|
||||||
notices.forEach(notice -> {
|
notices.forEach(notice -> {
|
||||||
notice.setIsRead(StringUtil.NOTICE_YD);
|
Notice upNotic=new Notice();
|
||||||
noticeInfoMapper.updateById(notice);
|
upNotic.setNoticeId(notice.getNoticeId());
|
||||||
|
upNotic.setIsRead(NoticeUtils.NOTICE_YD);
|
||||||
|
noticeInfoMapper.updateById(upNotic);
|
||||||
});
|
});
|
||||||
List<Notice> notices1 = noticeInfoMapper.selectList(Wrappers.<Notice>lambdaQuery().eq(Notice::getUserId, userId).eq(Notice::getRemark, "notice_bar").eq(Notice::getTitle, "系统通知").orderByDesc(Notice::getCreateTime).last("limit 1"));
|
List<Notice> notices1 = noticeInfoMapper.selectList(Wrappers.<Notice>lambdaQuery().eq(Notice::getUserId, userId).eq(Notice::getRemark, "notice_bar").orderByDesc(Notice::getCreateTime).last("limit 1"));
|
||||||
Notice notice = notices1.get(0);
|
if(notices1!=null&¬ices1.size()>0){
|
||||||
notice.setNotReadCount(notice.getNotReadCount() - longs.size());
|
Notice parmNotice = notices1.get(0);
|
||||||
|
Notice notice=new Notice();
|
||||||
|
notice.setNoticeId(parmNotice.getNoticeId());
|
||||||
|
notice.setNotReadCount(parmNotice.getNotReadCount()!=null?parmNotice.getNotReadCount() - longs.size():0);
|
||||||
if(notice.getNotReadCount()==0){
|
if(notice.getNotReadCount()==0){
|
||||||
notice.setIsRead(StringUtil.NOTICE_YD);
|
notice.setIsRead(NoticeUtils.NOTICE_YD);
|
||||||
}
|
}
|
||||||
noticeInfoMapper.updateById(notice);
|
noticeInfoMapper.updateById(notice);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Notice> selectListAppNotics(Notice notice) {
|
public List<Notice> selectListAppNotics(Notice notice) {
|
||||||
notice.setRemark(StringUtil.NOTICE_TYPE);
|
notice.setRemark(NoticeUtils.NOTICE_TYPE);
|
||||||
return noticeInfoMapper.getNoticlist(notice);
|
return noticeInfoMapper.getNoticlist(notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Notice> selectListAppNotices(Notice notice){
|
public List<Notice> selectListAppNotices(Notice notice){
|
||||||
return noticeInfoMapper.getNoticlist(notice);
|
return noticeInfoMapper.getNoticlist(notice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NoticeTotal noticTotal(Notice notice){
|
||||||
|
return noticeInfoMapper.noticTotal(notice);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int removeNotice(Long[] ids){
|
||||||
|
int t=noticeInfoMapper.deleteBatchIds(Arrays.asList(ids));
|
||||||
|
return t;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.ruoyi.cms.mapper.EmployeeConfirmMapper;
|
|||||||
import com.ruoyi.cms.mapper.JobApplyMapper;
|
import com.ruoyi.cms.mapper.JobApplyMapper;
|
||||||
import com.ruoyi.cms.mapper.NoticeMapper;
|
import com.ruoyi.cms.mapper.NoticeMapper;
|
||||||
import com.ruoyi.cms.service.EmployeeConfirmService;
|
import com.ruoyi.cms.service.EmployeeConfirmService;
|
||||||
|
import com.ruoyi.cms.util.NoticeUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -39,12 +40,12 @@ public class EmployeeConfirmServiceImpl implements EmployeeConfirmService {
|
|||||||
jobApplyMapper.updateById(apply);
|
jobApplyMapper.updateById(apply);
|
||||||
}
|
}
|
||||||
//添加消息
|
//添加消息
|
||||||
/*Notice notice=new Notice();
|
Notice notice=new Notice();
|
||||||
notice.setUserId();
|
notice.setUserId(employeeConfirm.getUserId());
|
||||||
notice.setBussinessId();
|
notice.setBussinessId(employeeConfirm.getId());
|
||||||
notice.setIsRead(0);
|
notice.setIsRead(NoticeUtils.NOTICE_WD);
|
||||||
notice
|
notice.setTitle("");
|
||||||
noticeMapper.insert(notice);*/
|
noticeMapper.insert(notice);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.cms.util;
|
||||||
|
|
||||||
|
public class NoticeUtils {
|
||||||
|
/**
|
||||||
|
* 消息已读
|
||||||
|
*/
|
||||||
|
public static final String NOTICE_YD="1";
|
||||||
|
/**
|
||||||
|
* 消息未读
|
||||||
|
*/
|
||||||
|
public static final String NOTICE_WD="0";
|
||||||
|
|
||||||
|
public static final String NOTICE_TYPE="notice_bar";
|
||||||
|
}
|
||||||
@@ -25,16 +25,6 @@ public class StringUtil {
|
|||||||
* pc端-企业
|
* pc端-企业
|
||||||
*/
|
*/
|
||||||
public static final String SYS_QY = "100";
|
public static final String SYS_QY = "100";
|
||||||
/**
|
|
||||||
* 消息已读
|
|
||||||
*/
|
|
||||||
public static final String NOTICE_YD="1";
|
|
||||||
/**
|
|
||||||
* 消息未读
|
|
||||||
*/
|
|
||||||
public static final String NOTICE_WD="0";
|
|
||||||
|
|
||||||
public static final String NOTICE_TYPE="notice_bar";
|
|
||||||
|
|
||||||
public static Boolean isEmptyOrNull(String s){
|
public static Boolean isEmptyOrNull(String s){
|
||||||
if(Objects.isNull(s)){return true;}
|
if(Objects.isNull(s)){return true;}
|
||||||
|
|||||||
@@ -20,4 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="noticTotal" parameterType="com.ruoyi.cms.domain.Notice" resultType="com.ruoyi.cms.domain.vo.NoticeTotal">
|
||||||
|
select count(user_id) qbxx,sum(case when is_read='0' then 1 else 0 end)
|
||||||
|
wdxx from notice where del_flag='0'
|
||||||
|
<if test="userId!=null">
|
||||||
|
and user_id=#{userId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -18,6 +18,9 @@ import org.apache.commons.lang3.time.DateFormatUtils;
|
|||||||
*/
|
*/
|
||||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
{
|
{
|
||||||
|
// 固定东八区时区
|
||||||
|
private static final ZoneId ZONE_ID = ZoneId.of("Asia/Shanghai");
|
||||||
|
|
||||||
public static String YYYY = "yyyy";
|
public static String YYYY = "yyyy";
|
||||||
|
|
||||||
public static String YYYY_MM = "yyyy-MM";
|
public static String YYYY_MM = "yyyy-MM";
|
||||||
@@ -188,4 +191,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||||
return Date.from(zdt.toInstant());
|
return Date.from(zdt.toInstant());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date 转 LocalDateTime(东八区)
|
||||||
|
*/
|
||||||
|
public static LocalDateTime dateToLocalDateTime(Date date) {
|
||||||
|
if (date == null) {
|
||||||
|
date=new Date();
|
||||||
|
}
|
||||||
|
return date.toInstant()
|
||||||
|
.atZone(ZONE_ID)
|
||||||
|
.toLocalDateTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user