Search in sources :

Example 1 with MyMessageVO

use of com.bc.pmpheep.back.vo.MyMessageVO in project pmph by BCSquad.

the class UserMessageServiceTest method testListMyMessage.

@Test
@Rollback(Const.ISROLLBACK)
public void testListMyMessage() {
    MyMessageVO myMessageVO = new MyMessageVO();
    myMessageVO.setUserId(1L);
    myMessageVO.setUserType(1);
    PageParameter pageParameter = new PageParameter<>();
    PageResult pageResult = new PageResult<>();
    pageParameter.setParameter(myMessageVO);
    pageResult = userMessageService.listMyMessage(pageParameter);
    Assert.assertNotNull("查询成功了", pageResult);
}
Also used : MyMessageVO(com.bc.pmpheep.back.vo.MyMessageVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 2 with MyMessageVO

use of com.bc.pmpheep.back.vo.MyMessageVO in project pmph by BCSquad.

the class UserMessageServiceTest method testListMyMessageOfIcon.

@Test
@Rollback(Const.ISROLLBACK)
public void testListMyMessageOfIcon() {
    MyMessageVO myMessageVO = new MyMessageVO();
    myMessageVO.setUserId(1L);
    myMessageVO.setUserType(1);
    PageParameter pageParameter = new PageParameter<>();
    PageResult pageResult = new PageResult<>();
    pageParameter.setParameter(myMessageVO);
    pageResult = userMessageService.listMyMessageOfIcon(pageParameter);
    Assert.assertNotNull("查询成功了", pageResult);
}
Also used : MyMessageVO(com.bc.pmpheep.back.vo.MyMessageVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 3 with MyMessageVO

use of com.bc.pmpheep.back.vo.MyMessageVO 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 4 with MyMessageVO

use of com.bc.pmpheep.back.vo.MyMessageVO in project pmph by BCSquad.

the class UserMessageServiceImpl method listMyMessage.

@Override
public PageResult<MyMessageVO> listMyMessage(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, "发送者类型不正确!");
            }
        }
        pageResult.setRows(list);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : 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 5 with MyMessageVO

use of com.bc.pmpheep.back.vo.MyMessageVO in project pmph by BCSquad.

the class UserMessageServiceImpl method updateMyMessageDetail.

@Override
public MyMessageVO updateMyMessageDetail(Long id) throws CheckedServiceException {
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "消息id为空!");
    }
    MyMessageVO myMessageVO = userMessageDao.getMyMessageDetail(id);
    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());
    List<MessageAttachment> messageAttachments = messageAttachmentService.getMessageAttachmentByMsgId(myMessageVO.getMsgId());
    for (MessageAttachment messageAttachment : messageAttachments) {
        messageAttachment.setAttachment(RouteUtil.MONGODB_FILE + messageAttachment.getAttachment());
    }
    myMessageVO.setMessageAttachments(messageAttachments);
    UserMessage userMessage = new UserMessage();
    userMessage.setId(id);
    userMessage.setIsRead(true);
    userMessageDao.updateUserMessage(userMessage);
    return myMessageVO;
}
Also used : MessageAttachment(com.bc.pmpheep.back.po.MessageAttachment) 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) UserMessage(com.bc.pmpheep.back.po.UserMessage) WriterUser(com.bc.pmpheep.back.po.WriterUser)

Aggregations

MyMessageVO (com.bc.pmpheep.back.vo.MyMessageVO)7 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)4 PageResult (com.bc.pmpheep.back.plugin.PageResult)4 PmphUser (com.bc.pmpheep.back.po.PmphUser)3 WriterUser (com.bc.pmpheep.back.po.WriterUser)3 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)3 LogDetail (com.bc.pmpheep.annotation.LogDetail)2 UserMessage (com.bc.pmpheep.back.po.UserMessage)2 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)2 Message (com.bc.pmpheep.general.po.Message)2 BaseTest (com.bc.pmpheep.test.BaseTest)2 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)2 Test (org.junit.Test)2 Rollback (org.springframework.test.annotation.Rollback)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 MessageAttachment (com.bc.pmpheep.back.po.MessageAttachment)1