小程序通知 未读通知id的集合,添加已读记录
This commit is contained in:
parent
1bccc67846
commit
0a9bc9eca2
@ -2,16 +2,10 @@ package com.xhpc.system.controller;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xhpc.system.domain.SysXhpcNoticeReadEntity;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.xhpc.common.core.utils.SecurityUtils;
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
import com.xhpc.common.core.web.controller.BaseController;
|
import com.xhpc.common.core.web.controller.BaseController;
|
||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
@ -103,6 +97,11 @@ public class SysNoticeController extends BaseController
|
|||||||
return getDataTable(noticeService.show());
|
return getDataTable(noticeService.show());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Showing the number of notices which have not been read in small app.
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping(value = "/showNotRead")
|
@GetMapping(value = "/showNotRead")
|
||||||
public AjaxResult showNotRead(Integer userId){
|
public AjaxResult showNotRead(Integer userId){
|
||||||
|
|
||||||
@ -110,6 +109,20 @@ public class SysNoticeController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Showing ids which have not been read in small app.
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/showNotReadIds")
|
||||||
|
public AjaxResult showNotReadIds(Integer userId){
|
||||||
|
|
||||||
|
return AjaxResult.success(noticeService.showNotReadIds(userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public AjaxResult add(@RequestBody SysXhpcNoticeReadEntity sysXhpcNoticeReadEntity){
|
||||||
|
|
||||||
|
return noticeService.addReadItem(sysXhpcNoticeReadEntity.getNoticeId(), sysXhpcNoticeReadEntity.getUserId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.xhpc.system.domain;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-05 17
|
||||||
|
*/
|
||||||
|
public class SysXhpcNoticeReadEntity extends BaseEntity {
|
||||||
|
private Integer noticeId;
|
||||||
|
private Long userId;
|
||||||
|
private Long readId;
|
||||||
|
private Integer delFlag;
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
public Integer getNoticeId() {
|
||||||
|
return noticeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNoticeId(Integer noticeId) {
|
||||||
|
this.noticeId = noticeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getReadId() {
|
||||||
|
return readId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadId(Long readId) {
|
||||||
|
this.readId = readId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDelFlag() {
|
||||||
|
return delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelFlag(Integer delFlag) {
|
||||||
|
this.delFlag = delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
package com.xhpc.system.domain;
|
|
||||||
|
|
||||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* program: ruoyi
|
|
||||||
* User: HongYun
|
|
||||||
* Date:2021-08-05 16
|
|
||||||
*/
|
|
||||||
public class XhpcNoticeReadEntity extends BaseEntity {
|
|
||||||
// private
|
|
||||||
}
|
|
||||||
@ -75,7 +75,9 @@ public interface SysNoticeMapper
|
|||||||
int countNotRead(@Param("userId") Integer userId);
|
int countNotRead(@Param("userId") Integer userId);
|
||||||
|
|
||||||
|
|
||||||
List<Integer> selectNotReadIds(@Param("userId") Integer userId);
|
List<Map<String,Object>> selectNotReadIds(@Param("userId") Integer userId);
|
||||||
|
|
||||||
|
int insertIntoRead(@Param("noticeId") Integer noticeId,@Param("userId") Long userId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.xhpc.system.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
import com.xhpc.system.domain.SysNotice;
|
import com.xhpc.system.domain.SysNotice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,9 +69,21 @@ public interface ISysNoticeService
|
|||||||
List<Map<String,Object>> show();
|
List<Map<String,Object>> show();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the number of notices which have not been read in small app.
|
* Showing the number of notices which have not been read in small app.
|
||||||
* @param userId
|
* @param userId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int showNotRead(Integer userId);
|
int showNotRead(Integer userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Showing ids which have not been read in small app.
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Map<String,Object>> showNotReadIds(Integer userId);
|
||||||
|
|
||||||
|
|
||||||
|
AjaxResult addReadItem(Integer noticeId,Long userId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.xhpc.system.service.impl;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
import com.xhpc.system.domain.SysNotice;
|
import com.xhpc.system.domain.SysNotice;
|
||||||
import com.xhpc.system.mapper.SysNoticeMapper;
|
import com.xhpc.system.mapper.SysNoticeMapper;
|
||||||
import com.xhpc.system.service.ISysNoticeService;
|
import com.xhpc.system.service.ISysNoticeService;
|
||||||
@ -104,4 +105,20 @@ public class SysNoticeServiceImpl implements ISysNoticeService
|
|||||||
|
|
||||||
return noticeMapper.countNotRead(userId);
|
return noticeMapper.countNotRead(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> showNotReadIds(Integer userId) {
|
||||||
|
|
||||||
|
return noticeMapper.selectNotReadIds(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult addReadItem(Integer noticeId, Long userId) {
|
||||||
|
|
||||||
|
int res=noticeMapper.insertIntoRead(noticeId, userId);
|
||||||
|
if(res==0){
|
||||||
|
return AjaxResult.error("插入失败");
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,11 +102,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="countNotRead" resultType="java.lang.Integer">
|
<select id="countNotRead" resultType="java.lang.Integer">
|
||||||
select count(notice_id) from sys_notice where notice_id not in (select r.notice_id from xhpc_notice_read as r left join sys_notice as n on r.notice_id=n.notice_id left join xhpc_app_user as u on r.user_id=u.app_user_id where r.user_id=10)
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectNotReadIds" resultType="java.lang.Integer">
|
select count(notice_id)
|
||||||
|
from sys_notice
|
||||||
|
where notice_id
|
||||||
|
not in
|
||||||
|
(
|
||||||
|
select r.notice_id
|
||||||
|
from xhpc_notice_read as r left join sys_notice as n
|
||||||
|
on r.notice_id=n.notice_id left join xhpc_app_user as u
|
||||||
|
on r.user_id=u.app_user_id
|
||||||
|
where r.user_id=#{userId}
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
<select id="selectNotReadIds" resultType="map">
|
||||||
|
|
||||||
|
select notice_id as noticeId
|
||||||
|
from sys_notice
|
||||||
|
where notice_id
|
||||||
|
not in
|
||||||
|
(
|
||||||
|
select r.notice_id
|
||||||
|
from xhpc_notice_read as r left join sys_notice as n
|
||||||
|
on r.notice_id=n.notice_id left join xhpc_app_user as u
|
||||||
|
on r.user_id=u.app_user_id
|
||||||
|
where r.user_id=#{userId}
|
||||||
|
)
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertIntoRead">
|
||||||
|
|
||||||
|
insert into xhpc_notice_read (user_id,notice_id) values(#{userId},#{noticeId})
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user