Search in sources :

Example 41 with PageResult

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

the class TopicServiceImpl method listTopicDirectorVOs.

public PageResult<TopicDirectorVO> listTopicDirectorVOs(String sessionId, PageParameter<TopicDirectorVO> pageParameter) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    PageResult<TopicDirectorVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    Integer total = 0;
    String submitTime = DateUtil.date2Str(pageParameter.getParameter().getSubmitTime(), "yyyy-MM-dd");
    if (pmphUser.getIsAdmin()) {
        total = topicDao.totalDirectorView(pageParameter.getParameter().getBookname(), submitTime);
        if (total > 0) {
            List<TopicDirectorVO> list = topicDao.listDirectorView(pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
            list = addTypeNameDirector(list);
            pageResult.setRows(list);
        }
    } else {
        total = topicDao.totalTopicDirectorVOs(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime);
        if (total > 0) {
            List<TopicDirectorVO> list = topicDao.listTopicDirectorVOs(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
            list = addTypeNameDirector(list);
            pageResult.setRows(list);
        }
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) TopicDirectorVO(com.bc.pmpheep.back.vo.TopicDirectorVO) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 42 with PageResult

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

the class UserMessageServiceImpl method listMessage.

@Override
public PageResult<UserMessageVO> listMessage(PageParameter<UserMessageVO> pageParameter, String sessionId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(pmphUser.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    // 如果是系统管理员,则查询所有,否则查询对应的消息
    if (Const.FALSE == pmphUser.getIsAdmin()) {
        List<Long> ids = new ArrayList<Long>();
        // 如果是主任,获取主任所在部门下的所有用户
        if (Const.TRUE == pmphUser.getIsDirector()) {
            // 社内部门父级节点ID
            Long parentId = 1L;
            PmphDepartment pmphDepartment = pmphDepartmentService.getPmphDepartmentById(pmphUser.getDepartmentId());
            // 如果是父级部门主任,则可以查看子级部门下的所有用户发送的消息
            if (parentId.longValue() == pmphDepartment.getParentId().longValue()) {
                PageParameter<PmphUserManagerVO> parameter = new PageParameter<>(1, 2000);
                PmphUserManagerVO pmphUserManagerVO = new PmphUserManagerVO();
                pmphUserManagerVO.setPath(pmphDepartment.getPath());
                pmphUserManagerVO.setDepartmentId(pmphDepartment.getId());
                parameter.setParameter(pmphUserManagerVO);
                PageResult<PmphUserManagerVO> listPageResult = pmphUserService.getListPmphUser(parameter, null);
                List<PmphUserManagerVO> listPmphUserManagerVOs = listPageResult.getRows();
                for (PmphUserManagerVO pmManagerVO : listPmphUserManagerVOs) {
                    ids.add(pmManagerVO.getId());
                }
            } else {
                // 如果是子级部门主任,则只可以查看子级部门下的用户发送的消息
                List<PmphUser> pmphUsers = pmphUserService.listPmphUserByDepartmentId(pmphUser.getDepartmentId());
                if (CollectionUtil.isNotEmpty(pmphUsers)) {
                    for (PmphUser user : pmphUsers) {
                        ids.add(user.getId());
                    }
                }
            }
        } else {
            ids.add(pmphUser.getId());
        }
        pageParameter.getParameter().setSenderIds(ids);
    }
    PageResult<UserMessageVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    Integer total = userMessageDao.getMessageTotal(pageParameter);
    if (total > 0) {
        List<UserMessageVO> list = userMessageDao.listMessage(pageParameter);
        Message message;
        for (UserMessageVO userMessageVO : list) {
            message = messageService.get(userMessageVO.getMsgId());
            if (ObjectUtil.notNull(message)) {
                userMessageVO.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) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) UserMessageVO(com.bc.pmpheep.back.vo.UserMessageVO) PmphUserManagerVO(com.bc.pmpheep.back.vo.PmphUserManagerVO) PmphDepartment(com.bc.pmpheep.back.po.PmphDepartment)

Example 43 with PageResult

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

the class UserMessageServiceImpl method listMessageState.

@Override
public PageResult<MessageStateVO> listMessageState(PageParameter<MessageStateVO> pageParameter, String sessionId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(pmphUser.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (StringUtil.isEmpty(pageParameter.getParameter().getMsgId()) && ObjectUtil.isNull(pageParameter.getParameter().getMaterialId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "消息为空");
    }
    // 搜索条件,按收件人或单位搜索
    String orgNameOrReceiver = pageParameter.getParameter().getName();
    // 防止输入空格查询,如果为" "
    if (StringUtil.isEmpty(orgNameOrReceiver)) {
        pageParameter.getParameter().setName(null);
    } else {
        pageParameter.getParameter().setName(orgNameOrReceiver.replaceAll(" ", ""));
    }
    if (Const.FALSE.booleanValue() == pmphUser.getIsAdmin().booleanValue()) {
        pageParameter.getParameter().setSenderId(pmphUser.getId());
    }
    PageResult<MessageStateVO> pageResult = new PageResult<MessageStateVO>();
    // 将页面大小和页面页码拷贝
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 包含数据总条数的数据集
    List<MessageStateVO> messageStateList = userMessageDao.listMessageState(pageParameter);
    if (!messageStateList.isEmpty() && messageStateList.size() > 0) {
        Integer count = messageStateList.get(0).getCount();
        pageResult.setTotal(count);
        pageResult.setRows(messageStateList);
    }
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) MessageStateVO(com.bc.pmpheep.back.vo.MessageStateVO) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 44 with PageResult

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

the class OrgSeviceTest method testListOrg.

@Test
public void testListOrg() {
    OrgVO orgVO = new OrgVO();
    orgVO.getOrgName();
    PageResult<OrgVO> page = new PageResult<OrgVO>();
    PageParameter<OrgVO> pageParameter = new PageParameter<OrgVO>();
    pageParameter.setParameter(orgVO);
    page = orgService.listOrg(pageParameter);
}
Also used : OrgVO(com.bc.pmpheep.back.vo.OrgVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 45 with PageResult

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

the class OrgSeviceTest method testGetSchoolAdminCheckList.

@Test
public void testGetSchoolAdminCheckList() {
    PageParameter pageParameter = new PageParameter<>();
    PageResult<OrgVO> pageResult = new PageResult<OrgVO>();
    OrgVO orgVO = new OrgVO();
    orgVO.setOrgName(null);
    orgVO.setAreaId(null);
    orgVO.setRealname(null);
    pageParameter.setPageNumber(1);
    pageParameter.setPageSize(20);
    pageParameter.setParameter(orgVO);
    pageResult = orgService.getSchoolAdminCheckList(pageParameter);
    Assert.assertNotNull("获取学校管理员审核列表失败", pageResult);
}
Also used : OrgVO(com.bc.pmpheep.back.vo.OrgVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

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