Search in sources :

Example 6 with Message

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;
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) PmphUser(com.bc.pmpheep.back.po.PmphUser) MyMessageVO(com.bc.pmpheep.back.vo.MyMessageVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterUser(com.bc.pmpheep.back.po.WriterUser) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 7 with Message

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);
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage)

Example 8 with Message

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);
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage)

Example 9 with Message

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);
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage)

Example 10 with Message

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);
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage)

Aggregations

Message (com.bc.pmpheep.general.po.Message)27 UserMessage (com.bc.pmpheep.back.po.UserMessage)21 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)20 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)20 ArrayList (java.util.ArrayList)19 Declaration (com.bc.pmpheep.back.po.Declaration)7 Material (com.bc.pmpheep.back.po.Material)7 OrgUser (com.bc.pmpheep.back.po.OrgUser)7 PmphUser (com.bc.pmpheep.back.po.PmphUser)6 WriterUser (com.bc.pmpheep.back.po.WriterUser)5 BaseTest (com.bc.pmpheep.test.BaseTest)4 Test (org.junit.Test)4 MessageAttachment (com.bc.pmpheep.back.po.MessageAttachment)3 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)3 Textbook (com.bc.pmpheep.back.po.Textbook)3 PageResult (com.bc.pmpheep.back.plugin.PageResult)2 CmsContent (com.bc.pmpheep.back.po.CmsContent)2 DecPosition (com.bc.pmpheep.back.po.DecPosition)2 DecPositionPublished (com.bc.pmpheep.back.po.DecPositionPublished)2 MyMessageVO (com.bc.pmpheep.back.vo.MyMessageVO)2