Search in sources :

Example 16 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult 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 17 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult 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 18 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult in project pmph by BCSquad.

the class WriterPointLogServiceImpl method getListWriterPointLog.

@Override
public PageResult<WriterPointLogVO> getListWriterPointLog(PageParameter<WriterPointLogVO> pageParameter) throws CheckedServiceException {
    PageResult<WriterPointLogVO> pageResult = new PageResult<WriterPointLogVO>();
    // 开始时间
    String startTime = pageParameter.getParameter().getStartTime();
    // 结束时间
    String endTime = pageParameter.getParameter().getEndTime();
    Long userId = pageParameter.getParameter().getUserId();
    WriterPointLogVO writerPointLogVO = new WriterPointLogVO();
    if (StringUtil.isEmpty(startTime) && StringUtil.isEmpty(endTime)) {
        writerPointLogVO.setStartTime(null);
        writerPointLogVO.setEndTime(null);
    } else {
        writerPointLogVO.setStartTime(startTime + " 00:00:00");
        writerPointLogVO.setEndTime(endTime + " 23:59:59");
    }
    if (StringUtil.isEmpty(startTime) && StringUtil.notEmpty(endTime)) {
        writerPointLogVO.setStartTime(endTime + " 00:00:00");
        writerPointLogVO.setEndTime(endTime + " 23:59:59");
    } else if (StringUtil.isEmpty(endTime) && StringUtil.notEmpty(startTime)) {
        writerPointLogVO.setStartTime(startTime + " 00:00:00");
        writerPointLogVO.setEndTime(startTime + " 23:59:59");
    }
    if (ObjectUtil.notNull(userId)) {
        writerPointLogVO.setUserId(userId);
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_POINT_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    pageParameter.setParameter(writerPointLogVO);
    // 将页面大小和页面页码拷贝
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 包含数据总条数的数据集
    List<WriterPointLogVO> writerPointLogVOs = writerPointLogDao.listWriterPointLogVO(pageParameter);
    if (CollectionUtil.isNotEmpty(writerPointLogVOs)) {
        Integer count = writerPointLogVOs.get(0).getCount();
        pageResult.setTotal(count);
        pageResult.setRows(writerPointLogVOs);
    }
    return pageResult;
}
Also used : WriterPointLogVO(com.bc.pmpheep.back.vo.WriterPointLogVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 19 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult 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 20 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult in project pmph by BCSquad.

the class PmphUserServiceImpl method getListByUsernameAndRealname.

@Override
public PageResult<PmphUserManagerVO> getListByUsernameAndRealname(String name, int number, int size) throws CheckedServiceException {
    if (null == name || "".equals(name)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "模糊查询条件为空");
    }
    List<PmphUser> pmphUsers = pmphUserDao.getListByUsernameAndRealname(name, (number - 1) * size, size);
    PageResult<PmphUserManagerVO> page = new PageResult<>();
    page.setFirst(true);
    page.setLast(true);
    page.setPageNumber(number);
    page.setPageSize(size);
    if (!pmphUsers.isEmpty()) {
        List<PmphUserManagerVO> list = new ArrayList<>();
        for (PmphUser user : pmphUsers) {
            PmphUserManagerVO userVO = new PmphUserManagerVO();
            PmphDepartment department = pmphDepartmentDao.getPmphDepartmentById(user.getDepartmentId());
            if (null != department) {
                userVO.setDepartmentName(department.getDpName());
            }
            try {
                BeanUtils.copyProperties(userVO, user);
            } catch (BeansException ex) {
                throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.VO_CONVERSION_FAILED, ex.getMessage());
            }
            list.add(userVO);
        }
        page.setRows(list);
    }
    return page;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PmphUserManagerVO(com.bc.pmpheep.back.vo.PmphUserManagerVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) PmphDepartment(com.bc.pmpheep.back.po.PmphDepartment) BeansException(org.springframework.beans.BeansException)

Aggregations

PageResult (com.bc.pmpheep.back.plugin.PageResult)57 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)33 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)24 BaseTest (com.bc.pmpheep.test.BaseTest)20 Test (org.junit.Test)20 PmphUser (com.bc.pmpheep.back.po.PmphUser)17 ArrayList (java.util.ArrayList)13 Rollback (org.springframework.test.annotation.Rollback)12 HashMap (java.util.HashMap)8 CmsContentVO (com.bc.pmpheep.back.vo.CmsContentVO)4 MyMessageVO (com.bc.pmpheep.back.vo.MyMessageVO)4 OrgVO (com.bc.pmpheep.back.vo.OrgVO)4 WriterUserManagerVO (com.bc.pmpheep.back.vo.WriterUserManagerVO)4 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)3 PmphRole (com.bc.pmpheep.back.po.PmphRole)3 SysOperation (com.bc.pmpheep.back.po.SysOperation)3 WriterUser (com.bc.pmpheep.back.po.WriterUser)3 PmphUserManagerVO (com.bc.pmpheep.back.vo.PmphUserManagerVO)3 Material (com.bc.pmpheep.back.po.Material)2 PmphDepartment (com.bc.pmpheep.back.po.PmphDepartment)2