diff --git a/src/main/java/com/steadon/saber/biz/INotificationBiz.java b/src/main/java/com/steadon/saber/biz/INotificationBiz.java index b8cba8fb7fb9be980c4c0065bae333b9db070127..51f835b830eafbe96133a0aad841ec52d8d211aa 100644 --- a/src/main/java/com/steadon/saber/biz/INotificationBiz.java +++ b/src/main/java/com/steadon/saber/biz/INotificationBiz.java @@ -1,8 +1,12 @@ package com.steadon.saber.biz; import com.steadon.saber.pojo.SaberResponse; +import com.steadon.saber.pojo.domain.Notification; +import com.steadon.saber.pojo.model.pageData.PageData; import com.steadon.saber.pojo.model.request.NotificationRequest; public interface INotificationBiz { SaberResponse<String> notification(String appCode, NotificationRequest request); + + SaberResponse<PageData<Notification>> getNotificationBatch(Integer pageNo, Integer pageSize); } diff --git a/src/main/java/com/steadon/saber/biz/impl/NotificationBiz.java b/src/main/java/com/steadon/saber/biz/impl/NotificationBiz.java index f4ca6f719b13870d499a6aeee3689c922871050b..6d757cd4c48859268ff94de48ec6d6f16f84c57b 100644 --- a/src/main/java/com/steadon/saber/biz/impl/NotificationBiz.java +++ b/src/main/java/com/steadon/saber/biz/impl/NotificationBiz.java @@ -7,8 +7,10 @@ import com.steadon.saber.handler.chain.model.MessageInfo; import com.steadon.saber.handler.chain.model.MessageStrategy; import com.steadon.saber.handler.factory.MessageStrategyFactory; import com.steadon.saber.pojo.SaberResponse; +import com.steadon.saber.pojo.domain.Notification; import com.steadon.saber.pojo.domain.NotificationRule; import com.steadon.saber.pojo.domain.UserInfo; +import com.steadon.saber.pojo.model.pageData.PageData; import com.steadon.saber.pojo.model.request.NotificationRequest; import com.steadon.saber.service.BusinessService; import com.steadon.saber.service.NotificationService; @@ -81,4 +83,10 @@ public class NotificationBiz implements INotificationBiz { notificationService.addNotification(messageInfo); return SaberResponse.success(); } + + @Override + public SaberResponse<PageData<Notification>> getNotificationBatch(Integer pageNo, Integer pageSize) { + PageData<Notification> notificationPageData = notificationService.getNotificationBatch(pageNo, pageSize); + return SaberResponse.success(notificationPageData); + } } \ No newline at end of file diff --git a/src/main/java/com/steadon/saber/controller/NotificationController.java b/src/main/java/com/steadon/saber/controller/NotificationController.java index 3f6f4115933a77b1c20d8048321e3228607c5a67..86529a6bb3893741c3a50db8bf976344fd5bfcd1 100644 --- a/src/main/java/com/steadon/saber/controller/NotificationController.java +++ b/src/main/java/com/steadon/saber/controller/NotificationController.java @@ -2,6 +2,8 @@ package com.steadon.saber.controller; import com.steadon.saber.biz.INotificationBiz; import com.steadon.saber.pojo.SaberResponse; +import com.steadon.saber.pojo.domain.Notification; +import com.steadon.saber.pojo.model.pageData.PageData; import com.steadon.saber.pojo.model.request.NotificationRequest; import lombok.AllArgsConstructor; import org.springframework.validation.annotation.Validated; @@ -19,4 +21,11 @@ public class NotificationController { @Validated @RequestBody NotificationRequest request) { return iNotificationBiz.notification(appCode, request); } + + @GetMapping("/notification/list") + public SaberResponse<PageData<Notification>> showNotification(@RequestParam(value = "page_no", required = false, defaultValue = "1") Integer pageNo, + @RequestParam(value = "page_size", required = false, defaultValue = "10") Integer pageSize) { + return iNotificationBiz.getNotificationBatch(pageNo, pageSize); + } + } diff --git a/src/main/java/com/steadon/saber/service/NotificationService.java b/src/main/java/com/steadon/saber/service/NotificationService.java index c23a17325b95dd5ed5cc1c07d9d5b7f4ed188e0f..ca9211e8f1c174fb14184cb2945165e13be5fe63 100644 --- a/src/main/java/com/steadon/saber/service/NotificationService.java +++ b/src/main/java/com/steadon/saber/service/NotificationService.java @@ -1,6 +1,7 @@ package com.steadon.saber.service; import com.steadon.saber.handler.chain.model.MessageInfo; +import com.steadon.saber.pojo.domain.Notification; import com.steadon.saber.pojo.domain.NotificationRule; import com.steadon.saber.pojo.domain.vo.NotificationRuleVo; import com.steadon.saber.pojo.model.pageData.PageData; @@ -20,4 +21,6 @@ public interface NotificationService { void deleteNotificationRule(Integer ruleId); PageData<NotificationRuleVo> getNotificationRuleBatch(Integer pageNo, Integer pageSize); + + PageData<Notification> getNotificationBatch(Integer pageNo, Integer pageSize); } \ No newline at end of file diff --git a/src/main/java/com/steadon/saber/service/impl/NotificationServiceImpl.java b/src/main/java/com/steadon/saber/service/impl/NotificationServiceImpl.java index c6898391212a70d4188b2fe07582fb53b18f5a39..b26ef103da45ddfb5beee8d4a377ccd6efcc67ac 100644 --- a/src/main/java/com/steadon/saber/service/impl/NotificationServiceImpl.java +++ b/src/main/java/com/steadon/saber/service/impl/NotificationServiceImpl.java @@ -152,4 +152,11 @@ public class NotificationServiceImpl implements NotificationService { IPage<NotificationRuleVo> pageData = notificationRuleMapper.selectVoPage(page); return new PageData<NotificationRuleVo>().praiseIPage(pageData); } + + @Override + public PageData<Notification> getNotificationBatch(Integer pageNo, Integer pageSize) { + Page<Notification> page = new Page<>(pageNo, pageSize); + Page<Notification> pageData = notificationMapper.selectPage(page, null); + return new PageData<Notification>().praiseIPage(pageData); + } }