Search in sources :

Example 1 with PmphGroupMessageVO

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

the class PmphGroupMessageServiceImpl method listPmphGroupMessage.

@Override
public PageResult<PmphGroupMessageVO> listPmphGroupMessage(PageParameter<PmphGroupMessageVO> pageParameter) throws CheckedServiceException {
    if (null == pageParameter.getParameter().getGroupId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组id为空");
    }
    if (null == pageParameter.getParameter().getGmtCreate()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "进入小组时间为空");
    }
    PageResult<PmphGroupMessageVO> pageResult = new PageResult<>();
    int total = pmphGroupMessageDao.getPmphGroupMessageTotal(pageParameter);
    if (total > 0) {
        PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
        List<PmphGroupMessageVO> list = pmphGroupMessageDao.listPmphGroupMessage(pageParameter);
        Collections.reverse(list);
        for (PmphGroupMessageVO pmphGroupMessageVO : list) {
            if (0 != pmphGroupMessageVO.getMemberId()) {
                if (null == pmphGroupMessageVO.getIsWriter()) {
                    pmphGroupMessageVO.setAvatar(RouteUtil.DEFAULT_USER_AVATAR);
                    pmphGroupMessageVO.setMemberName("该人员已经退出小组");
                } else {
                    if (pmphGroupMessageVO.getIsWriter()) {
                        pmphGroupMessageVO.setUserType(Const.SENDER_TYPE_2);
                        pmphGroupMessageVO.setAvatar(RouteUtil.userAvatar(writerUserService.get(pmphGroupMessageVO.getUserId()).getAvatar()));
                    } else {
                        pmphGroupMessageVO.setAvatar(RouteUtil.userAvatar(pmphUserService.get(pmphGroupMessageVO.getUserId()).getAvatar()));
                        pmphGroupMessageVO.setUserType(Const.SENDER_TYPE_1);
                    }
                }
            } else {
                pmphGroupMessageVO.setUserId(0L);
                pmphGroupMessageVO.setUserType(Const.SENDER_TYPE_0);
            }
        }
        pageResult.setRows(list);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphGroupMessageVO(com.bc.pmpheep.back.vo.PmphGroupMessageVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 2 with PmphGroupMessageVO

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

the class GroupController method message.

/**
 * 功能描述:进入小组的时候获取历史消息
 *
 * @param pageSize
 *            获取的条数
 * @param pageNumber
 *            当前第几页
 * @param groupId
 *            小组id
 * @param nowTime
 *            进入小组的时间节点
 * @return 消息结果集
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "获取历史消息")
@RequestMapping(value = "/list/message", method = RequestMethod.GET)
public ResponseBean message(Integer pageSize, Integer pageNumber, Long groupId, Long baseTime) {
    PageParameter<PmphGroupMessageVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    PmphGroupMessageVO pmphGroupMessageVO = new PmphGroupMessageVO();
    pmphGroupMessageVO.setGmtCreate(new Timestamp(baseTime));
    pmphGroupMessageVO.setGroupId(groupId);
    pageParameter.setParameter(pmphGroupMessageVO);
    return new ResponseBean(pmphGroupMessageService.listPmphGroupMessage(pageParameter));
}
Also used : PmphGroupMessageVO(com.bc.pmpheep.back.vo.PmphGroupMessageVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) Timestamp(java.sql.Timestamp) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PmphGroupMessageVO

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

the class PmphGroupMessageServiceTest method testListPmphGroupMessage.

@Test
public void testListPmphGroupMessage() {
    pmphGroupMessageService.addPmphGroupMessage(pmphGroupMessage);
    PageParameter<PmphGroupMessageVO> pageParameter = new PageParameter<>(1, 20);
    PmphGroupMessageVO pmphGroupMessageVO = new PmphGroupMessageVO();
    pmphGroupMessageVO.setGmtCreate(DateUtil.getCurrentTime());
    pmphGroupMessageVO.setGroupId(pmphGroupMessage.getGroupId());
    pageParameter.setParameter(pmphGroupMessageVO);
    Assert.assertNotNull("获取数据失败", pmphGroupMessageService.listPmphGroupMessage(pageParameter));
}
Also used : PmphGroupMessageVO(com.bc.pmpheep.back.vo.PmphGroupMessageVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Aggregations

PmphGroupMessageVO (com.bc.pmpheep.back.vo.PmphGroupMessageVO)3 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)2 LogDetail (com.bc.pmpheep.annotation.LogDetail)1 PageResult (com.bc.pmpheep.back.plugin.PageResult)1 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1 BaseTest (com.bc.pmpheep.test.BaseTest)1 Timestamp (java.sql.Timestamp)1 Test (org.junit.Test)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1