Search in sources :

Example 1 with UserMessageVO

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

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

the class UserMessageController method message.

/**
 * 功能描述:初始化/消息标题查询系统消息
 *
 * @param pageNumber 当前页
 * @param pageSize 页面数据条数
 * @param title 标题
 * @return
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "查询系统消息列表")
@RequestMapping(value = "/list/message", method = RequestMethod.GET)
public ResponseBean message(@RequestParam("pageNumber") Integer pageNumber, @RequestParam("pageSize") Integer pageSize, @RequestParam("title") String title, HttpServletRequest request) {
    PageParameter<UserMessageVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    UserMessageVO userMessageVO = new UserMessageVO();
    if (StringUtil.notEmpty(title)) {
        // 去除空格
        userMessageVO.setTitle(title.replaceAll(" ", ""));
    }
    pageParameter.setParameter(userMessageVO);
    String sessionId = CookiesUtil.getSessionId(request);
    return new ResponseBean(userMessageService.listMessage(pageParameter, sessionId));
}
Also used : PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) UserMessageVO(com.bc.pmpheep.back.vo.UserMessageVO) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PageParameter (com.bc.pmpheep.back.plugin.PageParameter)2 UserMessageVO (com.bc.pmpheep.back.vo.UserMessageVO)2 LogDetail (com.bc.pmpheep.annotation.LogDetail)1 PageResult (com.bc.pmpheep.back.plugin.PageResult)1 PmphDepartment (com.bc.pmpheep.back.po.PmphDepartment)1 PmphUser (com.bc.pmpheep.back.po.PmphUser)1 UserMessage (com.bc.pmpheep.back.po.UserMessage)1 PmphUserManagerVO (com.bc.pmpheep.back.vo.PmphUserManagerVO)1 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)1 Message (com.bc.pmpheep.general.po.Message)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)1 ArrayList (java.util.ArrayList)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1