给多个用户添加系统/@我消息 #14
|
|
@ -0,0 +1,64 @@
|
|||
package cn.org.gitlink.notification.model.dao.entity.vo;
|
||||
|
||||
public class SysNotificationAddVo {
|
||||
|
||||
private String platform;
|
||||
|
||||
private long sender;
|
||||
|
||||
private String receivers;
|
||||
|
||||
private String content;
|
||||
|
||||
private String notification_url;
|
||||
|
||||
private Byte type;
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public long getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setSender(long sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public String getReceivers() {
|
||||
return receivers;
|
||||
}
|
||||
|
||||
public void setReceivers(String receivers) {
|
||||
this.receivers = receivers;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getNotification_url() {
|
||||
return notification_url;
|
||||
}
|
||||
|
||||
public void setNotification_url(String notification_url) {
|
||||
this.notification_url = notification_url;
|
||||
}
|
||||
|
||||
public Byte getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Byte type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysNotificationService extends IService<SysNotification> {
|
||||
int addSysNotificationForUsers(String platform, SysNotification sysNotification);
|
||||
boolean addSysNotificationForUsers(SysNotificationAddVo sysNotification);
|
||||
|
||||
int changeStatusByNotificationIds(String platform, String notificationIds, Byte status);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,34 @@
|
|||
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.mapper.SysNotificationMapper;
|
||||
import cn.org.gitlink.notification.model.service.notification.SysNotificationService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysNotificationServiceImpl extends ServiceImpl<SysNotificationMapper, SysNotification> implements SysNotificationService {
|
||||
|
||||
@Override
|
||||
public int addSysNotificationForUsers(String platform, SysNotification sysNotification) {
|
||||
return baseMapper.insertSelective(platform, sysNotification);
|
||||
@Transactional
|
||||
public boolean addSysNotificationForUsers(SysNotificationAddVo sysNotificationAddVo) {
|
||||
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(","));
|
||||
for(String s : list){
|
||||
sysNotification.setReceiver(Long.parseLong(s));
|
||||
baseMapper.insertSelective(sysNotificationAddVo.getPlatform(), sysNotification);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,6 +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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -31,12 +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);
|
||||
SysNotification sysNotification = new SysNotification();
|
||||
sysNotification.setSender((long) -1);
|
||||
sysNotification.setReceiver((long) 100);
|
||||
sysNotification.setContent("baladiwei 在 gitlink-notification-system 修改ReadMe 文件的标题");
|
||||
sysNotification.setNotificationUrl("www.baidu.com");
|
||||
int j = sysNotificationService.addSysNotificationForUsers("gitlink", sysNotification);
|
||||
SysNotificationAddVo sysNotificationAddVo = new SysNotificationAddVo();
|
||||
sysNotificationAddVo.setSender((long) -1);
|
||||
sysNotificationAddVo.setReceivers("1,2,3,4");
|
||||
sysNotificationAddVo.setContent("baladiwei 在 gitlink-notification-system 修改ReadMe 文件的标题");
|
||||
sysNotificationAddVo.setNotification_url("www.baidu.com");
|
||||
sysNotificationAddVo.setPlatform("gitlink");
|
||||
boolean j = sysNotificationService.addSysNotificationForUsers(sysNotificationAddVo);
|
||||
logger.info("insertResult:" + j);
|
||||
int k = sysNotificationService.changeStatusByNotificationIds("gitlink", "2,3", (byte) 2);
|
||||
logger.info("updateStatus:" + k);
|
||||
|
|
|
|||
Loading…
Reference in New Issue