API:add param for notification list
This commit is contained in:
parent
a7c8fc105f
commit
2f3bdd12da
|
|
@ -39,6 +39,7 @@ public interface SysNotificationMapper extends BaseMapper<SysNotification> {
|
|||
|
||||
List<SysNotification> getSysNotificationPageList(Page page, String orderBy,
|
||||
@Param("type") int type,
|
||||
@Param("source") String source,
|
||||
@Param("platform") String platform,
|
||||
@Param("receiver") Integer receiver,
|
||||
@Param("status") Integer status);
|
||||
|
|
|
|||
|
|
@ -36,16 +36,17 @@ public interface SysNotificationService extends IService<SysNotification> {
|
|||
/**
|
||||
* 获取消息列表
|
||||
*
|
||||
* @param type 类型 -1 全部 1 系统消息、2 @我
|
||||
* @param page 页码
|
||||
* @param size 页大小
|
||||
* @param platform 平台编号
|
||||
* @param receiver 消息接收者
|
||||
* @param status 状态 -1 全部、1 未读 2 已读
|
||||
* @param type 类型 -1 全部 1 系统消息、2 @我
|
||||
* @param source
|
||||
* @param page 页码
|
||||
* @param size 页大小
|
||||
* @return
|
||||
*/
|
||||
|
||||
Page<SysNotification> getNotification(String platform, Integer receiver, Integer status, Integer type, Integer page, Integer size) throws Exception;
|
||||
Page<SysNotification> getNotification(String platform, Integer receiver, Integer status, Integer type, String source, Integer page, Integer size) throws Exception;
|
||||
|
||||
/**
|
||||
* @Description: 批量删除系统消息
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMappe
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean sendNotification(NewSysNotificationVo newSysNotificationVo) throws Exception {
|
||||
public boolean sendNotification(NewSysNotificationVo newSysNotificationVo) {
|
||||
List<SysNotification> sysNotificationList = new ArrayList<>();
|
||||
List<String> list = Arrays.asList(newSysNotificationVo.getReceivers().split(","));
|
||||
for (String receiver : list) {
|
||||
|
|
@ -51,7 +51,7 @@ public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMappe
|
|||
}
|
||||
|
||||
@Override
|
||||
public int markNotificationAs(String platform, Integer receiver, String notificationIds, Integer status, Integer type) throws Exception {
|
||||
public int markNotificationAs(String platform, Integer receiver, String notificationIds, Integer status, Integer type) {
|
||||
int count = baseMapper.updateStatusByNotificationId(platform, receiver, notificationIds, status, type);
|
||||
if (count > 0) {
|
||||
this.delUserCache(platform, receiver);
|
||||
|
|
@ -60,7 +60,7 @@ public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMappe
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getNotificationCount(String platform, Integer receiver, Integer type, Integer status) throws Exception {
|
||||
public int getNotificationCount(String platform, Integer receiver, Integer type, Integer status) {
|
||||
String cacheKey = cacheKeyForCount(platform, receiver, type, status);
|
||||
Object foundResult = this.redisUtil.get(cacheKey);
|
||||
if (foundResult != null) {
|
||||
|
|
@ -73,7 +73,7 @@ public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMappe
|
|||
|
||||
|
||||
@Override
|
||||
public Page<SysNotification> getNotification(String platform, Integer receiver, Integer status, Integer type, Integer page, Integer size) throws Exception {
|
||||
public Page<SysNotification> getNotification(String platform, Integer receiver, Integer status, Integer type, String source, Integer page, Integer size) {
|
||||
String cacheKey = cacheKeyForPage(platform, receiver, type, status, page, size);
|
||||
Object foundResult = this.redisUtil.get(cacheKey);
|
||||
if (foundResult != null) {
|
||||
|
|
@ -82,7 +82,7 @@ public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMappe
|
|||
|
||||
Page<SysNotification> pageItem = new Page<SysNotification>(page, size);
|
||||
List<SysNotification> sysNotificationList = baseMapper.getSysNotificationPageList(
|
||||
pageItem, "", type, platform, receiver, status
|
||||
pageItem, "", type, source, platform, receiver, status
|
||||
);
|
||||
pageItem.setRecords(sysNotificationList);
|
||||
this.redisUtil.set(cacheKey, pageItem);
|
||||
|
|
@ -90,7 +90,7 @@ public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMappe
|
|||
}
|
||||
|
||||
@Override
|
||||
public int deleteNotifications(String platform, Integer receiver, String notificationIds, Integer type) throws Exception {
|
||||
public int deleteNotifications(String platform, Integer receiver, String notificationIds, Integer type) {
|
||||
int count = baseMapper.deleteNotificationByIds(platform, receiver, notificationIds, type);
|
||||
if (count > 0) {
|
||||
this.delUserCache(platform, receiver);
|
||||
|
|
|
|||
|
|
@ -202,6 +202,9 @@
|
|||
<if test="status != -1">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="source != null and source != ''">
|
||||
and source = #{source}
|
||||
</if>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
<update id="deleteNotificationByIds">
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class ServiceTests {
|
|||
@Test
|
||||
public void testSysNotificationService() throws Exception {
|
||||
int i = sysNotificationService.getNotificationCount("gitlink", 234,1,1);
|
||||
Page<SysNotification> sysNotificationPage = sysNotificationService.getNotification("gitlink", 100,1,1,1,20);
|
||||
Page<SysNotification> sysNotificationPage = sysNotificationService.getNotification("gitlink", 100,1,1, "IssueChanged", 1,20);
|
||||
NewSysNotificationVo newSysNotificationVo = new NewSysNotificationVo();
|
||||
newSysNotificationVo.setSender(1);
|
||||
newSysNotificationVo.setReceivers("7,8");
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@ public class NotificationController {
|
|||
@ApiParam(value = "消息类型:值为-1时,获取全部信息;值为1时,获取系统消息;值为2时,获取@我消息", defaultValue = "-1")
|
||||
@RequestParam(name = "type", required = false, defaultValue = "-1") Integer type,
|
||||
|
||||
@ApiParam(value = "消息来源")
|
||||
@RequestParam(name = "source", required = false) String source,
|
||||
|
||||
@ApiParam(value = "页码:值为-1时(默认值),不开启分页;", required = false, defaultValue = "-1")
|
||||
@RequestParam(name = "page", required = false, defaultValue = "-1") Integer page,
|
||||
|
||||
|
|
@ -88,7 +91,7 @@ public class NotificationController {
|
|||
}
|
||||
|
||||
//分页的数据
|
||||
Page foundPage = notificationService.getNotification(platform, receiver, status, type, page, size);
|
||||
Page foundPage = notificationService.getNotification(platform, receiver, status, type, source, page, size);
|
||||
if (foundPage != null) {
|
||||
notificationListVo.setPageNum(foundPage.getCurrent());
|
||||
notificationListVo.setPageSize(foundPage.getSize());
|
||||
|
|
|
|||
Loading…
Reference in New Issue