use of com.bc.pmpheep.general.po.Message in project pmph by BCSquad.
the class UserMessageServiceImpl method listMyMessageOfIcon.
@Override
public PageResult<MyMessageVO> listMyMessageOfIcon(PageParameter<MyMessageVO> pageParameter) throws CheckedServiceException {
if (ObjectUtil.isNull(pageParameter.getParameter().getUserId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户id为空!");
}
if (ObjectUtil.isNull(pageParameter.getParameter().getUserType())) {
throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户类型为空!");
}
PageResult<MyMessageVO> pageResult = new PageResult<MyMessageVO>();
Integer total = userMessageDao.listMyMessageTotal(pageParameter);
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
if (total > 0) {
List<MyMessageVO> list = userMessageDao.listMyMessage(pageParameter);
for (MyMessageVO myMessageVO : list) {
switch(myMessageVO.getSenderType()) {
case 0:
myMessageVO.setSenderName("系统");
break;
case 1:
PmphUser pmphUser = pmphUserService.get(myMessageVO.getSenderId());
myMessageVO.setSenderAvatar(pmphUser.getAvatar());
myMessageVO.setSenderName(pmphUser.getRealname());
break;
case 2:
WriterUser writerUser = writerUserService.get(myMessageVO.getSenderId());
myMessageVO.setSenderAvatar(writerUser.getAvatar());
myMessageVO.setSenderName(writerUser.getRealname());
break;
case 3:
// 现在没有机构用户
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "发送者类型不正确!");
}
Message message = messageService.get(myMessageVO.getMsgId());
if (ObjectUtil.isNull(message)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "没有获取到内容!");
}
myMessageVO.setContent(message.getContent());
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
return pageResult;
}
use of com.bc.pmpheep.general.po.Message in project pmph by BCSquad.
the class SystemMessageService method sendWhenInviteJoinGroup.
/**
* 任意用户被邀请进入小组 向被邀请人发出
*
* @author Mryang
* @createDate 2017年11月17日 下午2:16:36
* @param inviterName
* 邀请人名字
* @param groupId
* 小组id
* @param invitedPersonIds
* 被邀请人ids
* @param invitedPersonType
* 被邀请人类型: 1=社内用户/2=作家/3=机构用户
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenInviteJoinGroup(String inviterName, Long groupId, List<Long> invitedPersonIds, short invitedPersonType) throws CheckedServiceException, IOException {
if (StringUtils.isEmpty(inviterName)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "邀请人为空");
}
if (null == invitedPersonIds || invitedPersonIds.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "被邀请人为空");
}
// 获取小组
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
if (null == pmphGroup) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组不存在");
}
String msgContent = "您被[<font color='red'>" + inviterName + "</font>]邀请加入[<font color='red'>" + pmphGroup.getGroupName() + "]</font>小组";
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 组装消息和消息对象
List<UserMessage> userMessageList = new ArrayList<UserMessage>(invitedPersonIds.size());
List<String> userIds = new ArrayList<String>(invitedPersonIds.size());
for (Long id : invitedPersonIds) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), id, invitedPersonType, null);
userMessageList.add(userMessage);
userIds.add(invitedPersonType + "_" + id);
}
// 发送消息
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
use of com.bc.pmpheep.general.po.Message in project pmph by BCSquad.
the class SystemMessageService method sendWhenTeacherCertificationAudit.
/**
* 教师认证审 向教师用户发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午2:52:53
* @param auditorOrgName
* 认证机构名称,如:首都医科大学,如是人卫社认证的审核,则为:人民卫生出版社
* @param teacherIds
* 教师ids
* @param isPass
* true 通过/false 退回
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenTeacherCertificationAudit(String auditorOrgName, List<Long> teacherIds, boolean isPass) throws CheckedServiceException, IOException {
if (StringUtils.isEmpty(auditorOrgName)) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEACHER_CHECK, CheckedExceptionResult.NULL_PARAM, "审核机构为空");
}
if (null == teacherIds || teacherIds.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEACHER_CHECK, CheckedExceptionResult.NULL_PARAM, "认证的教师为空");
}
// 存入消息主体
// 退回
String msgContent = "抱歉,您提交的教师认证资料已被[<font color='red'>" + auditorOrgName + "</font>]管理员退回,请您核对后重试";
if (isPass) {
// 通过
msgContent = "恭喜!您提交的教师认证资料已通过[<font color='red'>" + auditorOrgName + "</font>]管理员审核";
}
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 组装消息和消息对象
List<UserMessage> userMessageList = new ArrayList<UserMessage>(teacherIds.size());
List<String> userIds = new ArrayList<String>(teacherIds.size());
// 发送消息
for (Long id : teacherIds) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), id, new Short("2"), null);
userMessageList.add(userMessage);
userIds.add("2_" + id);
}
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
use of com.bc.pmpheep.general.po.Message in project pmph by BCSquad.
the class SystemMessageService method sendWhenKickingOutGroup.
/**
* 任意用户被踢出进入小组 向被踢出人发出
*
* @author Mryang
* @createDate 2017年11月17日 下午2:16:36
* @param inviterName
* 踢出人名字
* @param groupId
* 小组id
* @param invitedPersonIds
* 被踢出人ids
* @param invitedPersonType
* 被踢出人类型: 1=社内用户/2=作家/3=机构用户
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenKickingOutGroup(String inviterName, Long groupId, List<Long> invitedPersonIds, short invitedPersonType) throws CheckedServiceException, IOException {
if (StringUtils.isEmpty(inviterName)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "邀请人为空");
}
if (null == invitedPersonIds || invitedPersonIds.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "被邀请人为空");
}
// 获取小组
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
if (null == pmphGroup) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组不存在");
}
String msgContent = "您被[<font color='red'>" + inviterName + "</font>]移出群组[<font color='red'>" + pmphGroup.getGroupName() + "]</font>";
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 组装消息和消息对象
List<UserMessage> userMessageList = new ArrayList<UserMessage>(invitedPersonIds.size());
List<String> userIds = new ArrayList<String>(invitedPersonIds.size());
for (Long id : invitedPersonIds) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), id, invitedPersonType, null);
userMessageList.add(userMessage);
userIds.add(invitedPersonType + "_" + id);
}
// 发送消息
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
use of com.bc.pmpheep.general.po.Message in project pmph by BCSquad.
the class SystemMessageService method sendWhenManagerCertificationAudit.
/**
* 学校管理员认证 向机构用户发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午3:01:42
* @param orguserIds
* 机构用户ids
* @param isPass
* true 通过/false 退回
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenManagerCertificationAudit(List<Long> orguserIds, boolean isPass) throws CheckedServiceException, IOException {
if (null == orguserIds || orguserIds.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.SCHOOL_ADMIN_CHECK, CheckedExceptionResult.NULL_PARAM, "认证的管理员为空");
}
// 存入消息主体
// 退回
String msgContent = "抱歉,您提交的管理员认证资料已被退回,请您修改后重试";
if (isPass) {
// 通过
msgContent = "恭喜!您提交的管理员认证资料已通过审核";
}
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 组装消息和消息对象
List<UserMessage> userMessageList = new ArrayList<UserMessage>(orguserIds.size());
List<String> userIds = new ArrayList<String>(orguserIds.size());
// 发送消息
for (Long id : orguserIds) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), id, new Short("3"), null);
userMessageList.add(userMessage);
userIds.add("3_" + id);
}
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
Aggregations