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;
}
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));
}
Aggregations