diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/controller/SysNoticeController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/controller/SysNoticeController.java index 1fafd517..22a17e94 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/controller/SysNoticeController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/controller/SysNoticeController.java @@ -2,16 +2,10 @@ package com.xhpc.system.controller; import java.util.List; +import com.xhpc.system.domain.SysXhpcNoticeReadEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -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 org.springframework.web.bind.annotation.*; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; @@ -103,6 +97,11 @@ public class SysNoticeController extends BaseController return getDataTable(noticeService.show()); } + /** + * Showing the number of notices which have not been read in small app. + * @param userId + * @return + */ @GetMapping(value = "/showNotRead") 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()); + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/SysXhpcNoticeReadEntity.java b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/SysXhpcNoticeReadEntity.java new file mode 100644 index 00000000..448d9c4d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/SysXhpcNoticeReadEntity.java @@ -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; + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/XhpcNoticeReadEntity.java b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/XhpcNoticeReadEntity.java deleted file mode 100644 index 8edebd93..00000000 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/XhpcNoticeReadEntity.java +++ /dev/null @@ -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 -} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/mapper/SysNoticeMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/mapper/SysNoticeMapper.java index 67049dd5..1d4772bf 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/mapper/SysNoticeMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/mapper/SysNoticeMapper.java @@ -75,7 +75,9 @@ public interface SysNoticeMapper int countNotRead(@Param("userId") Integer userId); - List selectNotReadIds(@Param("userId") Integer userId); + List> selectNotReadIds(@Param("userId") Integer userId); + + int insertIntoRead(@Param("noticeId") Integer noticeId,@Param("userId") Long userId); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/service/ISysNoticeService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/service/ISysNoticeService.java index 4510917b..f3465ecb 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/service/ISysNoticeService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/service/ISysNoticeService.java @@ -3,6 +3,7 @@ package com.xhpc.system.service; import java.util.List; import java.util.Map; +import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.system.domain.SysNotice; /** @@ -68,9 +69,21 @@ public interface ISysNoticeService List> 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 * @return */ int showNotRead(Integer userId); + + /** + * Showing ids which have not been read in small app. + * @param userId + * @return + */ + List> showNotReadIds(Integer userId); + + + AjaxResult addReadItem(Integer noticeId,Long userId); + + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/service/impl/SysNoticeServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/service/impl/SysNoticeServiceImpl.java index c73da00c..d389cb91 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/service/impl/SysNoticeServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/service/impl/SysNoticeServiceImpl.java @@ -3,6 +3,7 @@ package com.xhpc.system.service.impl; import java.util.List; import java.util.Map; +import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.system.domain.SysNotice; import com.xhpc.system.mapper.SysNoticeMapper; import com.xhpc.system.service.ISysNoticeService; @@ -104,4 +105,20 @@ public class SysNoticeServiceImpl implements ISysNoticeService return noticeMapper.countNotRead(userId); } + + @Override + public List> 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(); + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml index fbc46710..585a2040 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -102,11 +102,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + + insert into xhpc_notice_read (user_id,notice_id) values(#{userId},#{noticeId}) + +