注释完善,SysNotificationVo改名为NewSysNotificationVo #21
|
|
@ -1,11 +1,12 @@
|
|||
package cn.org.gitlink.notification.model.dao.entity.vo;
|
||||
|
||||
public class SysNotificationAddVo {
|
||||
public class NewSysNotificationVo {
|
||||
|
||||
private String platform;
|
||||
|
||||
private long sender;
|
||||
|
||||
//接受者id,单个id或多个 example:"1"/"1,2,3"
|
||||
private String receivers;
|
||||
|
||||
private String content;
|
||||
|
|
@ -1,22 +1,28 @@
|
|||
package cn.org.gitlink.notification.model.service.notification;
|
||||
|
||||
import cn.org.gitlink.notification.model.dao.entity.SysNotification;
|
||||
import cn.org.gitlink.notification.model.dao.entity.vo.SysNotificationAddVo;
|
||||
import cn.org.gitlink.notification.model.dao.entity.vo.NewSysNotificationVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysNotificationService extends IService<SysNotification> {
|
||||
boolean addSysNotificationForUsers(SysNotificationAddVo sysNotification);
|
||||
//给用户发送消息
|
||||
boolean addSysNotificationForUsers(NewSysNotificationVo sysNotification);
|
||||
|
||||
//变更消息状态
|
||||
int changeStatusByNotificationIds(String platform, String notificationIds, Integer status);
|
||||
|
||||
//获取全部未读消息数量
|
||||
int getAllNewSysNotificationNumber(String platform, Integer receiver);
|
||||
|
||||
//获取未读消息列表
|
||||
List<SysNotification> getUnreadSysNotificationsList(String platform, Integer receiver, Integer notificationNumber);
|
||||
|
||||
//根据类型获取未读系统消息数量
|
||||
int getSysNotificationNumberByType(String platform, Integer receiver, Integer type);
|
||||
|
||||
//获取全部消息分页列表
|
||||
Page<SysNotification> getAllSysNotificationsPageList(int curPage, int pageSize, String orderBy, String platform, Integer receiver);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.org.gitlink.notification.model.service.notification.impl;
|
||||
|
||||
import cn.org.gitlink.notification.model.dao.entity.SysNotification;
|
||||
import cn.org.gitlink.notification.model.dao.entity.vo.SysNotificationAddVo;
|
||||
import cn.org.gitlink.notification.model.dao.entity.vo.NewSysNotificationVo;
|
||||
import cn.org.gitlink.notification.model.dao.mapper.SysNotificationMapper;
|
||||
import cn.org.gitlink.notification.model.service.notification.SysNotificationService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
|
@ -15,43 +15,85 @@ import java.util.List;
|
|||
@Service(value = "sysNotificationServiceImpl")
|
||||
public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMapper, SysNotification> implements SysNotificationService {
|
||||
|
||||
/**
|
||||
* @Description: 给用户发送消息
|
||||
* @Param: [newSysNotificationVo]
|
||||
* @return: boolean
|
||||
* @Author: wanjia
|
||||
* @Date: 2021/9/8
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean addSysNotificationForUsers(SysNotificationAddVo sysNotificationAddVo) {
|
||||
public boolean addSysNotificationForUsers(NewSysNotificationVo newSysNotificationVo) {
|
||||
SysNotification sysNotification = new SysNotification();
|
||||
sysNotification.setSender(sysNotificationAddVo.getSender());
|
||||
sysNotification.setContent(sysNotificationAddVo.getContent());
|
||||
sysNotification.setNotificationUrl(sysNotificationAddVo.getNotification_url());
|
||||
sysNotification.setType(sysNotificationAddVo.getType());
|
||||
List<String> list = Arrays.asList(sysNotificationAddVo.getReceivers().split(","));
|
||||
sysNotification.setSender(newSysNotificationVo.getSender());
|
||||
sysNotification.setContent(newSysNotificationVo.getContent());
|
||||
sysNotification.setNotificationUrl(newSysNotificationVo.getNotification_url());
|
||||
sysNotification.setType(newSysNotificationVo.getType());
|
||||
List<String> list = Arrays.asList(newSysNotificationVo.getReceivers().split(","));
|
||||
for(String s : list){
|
||||
sysNotification.setReceiver(Long.parseLong(s));
|
||||
baseMapper.insertSelective(sysNotificationAddVo.getPlatform(), sysNotification);
|
||||
baseMapper.insertSelective(newSysNotificationVo.getPlatform(), sysNotification);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 变更消息状态
|
||||
* @Param: [platform:平台编码, notificationIds:消息id example-"23,24,25", status:1-未读2-已读]
|
||||
* @return: int
|
||||
* @Author: wanjia
|
||||
* @Date: 2021/9/8
|
||||
*/
|
||||
@Override
|
||||
public int changeStatusByNotificationIds(String platform, String notificationIds, Integer status) {
|
||||
return baseMapper.updateStatusByNotificationId(platform, notificationIds, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 获取全部未读消息数量
|
||||
* @Param: [platform:平台编码, receiver:接收者id]
|
||||
* @return: int
|
||||
* @Author: wanjia
|
||||
* @Date: 2021/9/8
|
||||
*/
|
||||
@Override
|
||||
public int getAllNewSysNotificationNumber(String platform, Integer receiver) {
|
||||
return baseMapper.getNewSysNotificationNumber(platform, receiver);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 获取未读消息列表
|
||||
* @Param: [platform:平台编码, receiver:接收者id, notificationNumber:消息limit数]
|
||||
* @return: java.util.List<SysNotification>
|
||||
* @Author: wanjia
|
||||
* @Date: 2021/9/8
|
||||
*/
|
||||
@Override
|
||||
public List<SysNotification> getUnreadSysNotificationsList(String platform, Integer receiver, Integer notificationNumber) {
|
||||
List<SysNotification> sysNotificationList = baseMapper.getUnreadSysNotificationsList(platform, receiver, 1, notificationNumber);
|
||||
return sysNotificationList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 根据类型获取未读系统消息数量
|
||||
* @Param: [platform:平台编码, receiver:接收者id, type:消息类型1-系统消息2-@我]
|
||||
* @return: int
|
||||
* @Author: wanjia
|
||||
* @Date: 2021/9/8
|
||||
*/
|
||||
@Override
|
||||
public int getSysNotificationNumberByType(String platform, Integer receiver, Integer type) {
|
||||
return baseMapper.getSysNotificationNumberByType(platform, receiver, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 获取全部消息分页列表
|
||||
* @Param: [curPage, pageSize, orderBy, platform:平台编码, receiver:接受者id]
|
||||
* @return: Page<SysNotification>
|
||||
* @Author: wanjia
|
||||
* @Date: 2021/9/8
|
||||
*/
|
||||
@Override
|
||||
public Page<SysNotification> getAllSysNotificationsPageList(int curPage, int pageSize, String orderBy, String platform, Integer receiver) {
|
||||
Page page = new Page<SysNotification>(curPage, pageSize);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package cn.org.gitlink.notification.model.service.notification;
|
|||
|
||||
import cn.org.gitlink.notification.model.ModelApplicationTest;
|
||||
import cn.org.gitlink.notification.model.dao.entity.SysNotification;
|
||||
import cn.org.gitlink.notification.model.dao.entity.vo.SysNotificationAddVo;
|
||||
import cn.org.gitlink.notification.model.dao.entity.vo.NewSysNotificationVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -32,13 +32,13 @@ public class ServiceTests {
|
|||
int i = sysNotificationService.getAllNewSysNotificationNumber("gitlink", 234);
|
||||
List<SysNotification> sysNotificationList = sysNotificationService.getUnreadSysNotificationsList("gitlink", 100, 20);
|
||||
Page<SysNotification> sysNotificationPage = sysNotificationService.getAllSysNotificationsPageList(1,10,"","gitlink", 100);
|
||||
SysNotificationAddVo sysNotificationAddVo = new SysNotificationAddVo();
|
||||
sysNotificationAddVo.setSender((long) -1);
|
||||
sysNotificationAddVo.setReceivers("7,8");
|
||||
sysNotificationAddVo.setContent("baladiwei 在 gitlink-notification-system 修改ReadMe 文件的标题");
|
||||
sysNotificationAddVo.setNotification_url("www.baidu.com");
|
||||
sysNotificationAddVo.setPlatform("gitlink");
|
||||
boolean j = sysNotificationService.addSysNotificationForUsers(sysNotificationAddVo);
|
||||
NewSysNotificationVo newSysNotificationVo = new NewSysNotificationVo();
|
||||
newSysNotificationVo.setSender((long) -1);
|
||||
newSysNotificationVo.setReceivers("7,8");
|
||||
newSysNotificationVo.setContent("baladiwei 在 gitlink-notification-system 修改ReadMe 文件的标题");
|
||||
newSysNotificationVo.setNotification_url("www.baidu.com");
|
||||
newSysNotificationVo.setPlatform("gitlink");
|
||||
boolean j = sysNotificationService.addSysNotificationForUsers(newSysNotificationVo);
|
||||
logger.info("insertResult:" + j);
|
||||
int k = sysNotificationService.changeStatusByNotificationIds("gitlink", "2,3", 2);
|
||||
logger.info("updateStatus:" + k);
|
||||
|
|
|
|||
Loading…
Reference in New Issue