use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class TopicServiceImpl method topicTextVO.
@Override
public TopicTextVO topicTextVO(TopicLog topicLog, String sessionId, Long id) throws CheckedServiceException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser)) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空!");
}
topicLog.setUserId(pmphUser.getId());
if (ObjectUtil.isNull(id)) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "选题申报的id为空!");
}
topicLogService.add(topicLog);
TopicTextVO topicTextVO = topicDao.getTopicTextVO(id);
topicTextVO.setTopicExtra(topicExtraService.getTopicExtraByTopicId(id));
topicTextVO.setTopicWriters(topicWriertService.listTopicWriterByTopicId(id));
switch(topicTextVO.getRank()) {
case 0:
topicTextVO.setRankType("低");
break;
case 1:
topicTextVO.setRankType("中");
break;
case 2:
topicTextVO.setRankType("高");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "没有这个级别");
}
switch(topicTextVO.getSource()) {
case 0:
topicTextVO.setSourceType("社策划");
break;
case 1:
topicTextVO.setSourceType("编辑策划");
break;
case 2:
topicTextVO.setSourceType("专家策划");
break;
case 3:
topicTextVO.setSourceType("离退休编审策划");
break;
case 4:
topicTextVO.setSourceType("上级交办");
break;
case 5:
topicTextVO.setSourceType("作者投稿");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "没有这个选题来源");
}
switch(topicTextVO.getReader()) {
case 0:
topicTextVO.setReadType("医务工作者");
break;
case 1:
topicTextVO.setReadType("医学院校师生");
break;
case 2:
topicTextVO.setReadType("大众");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "没有这个阅读人群");
}
switch(topicTextVO.getType()) {
case 0:
topicTextVO.setTypeName("专著");
break;
case 1:
topicTextVO.setTypeName("基础理论");
break;
case 2:
topicTextVO.setTypeName("论文集");
break;
case 3:
topicTextVO.setTypeName("科普");
break;
case 4:
topicTextVO.setTypeName("应用技术");
break;
case 5:
topicTextVO.setTypeName("工具书");
break;
case 6:
topicTextVO.setTypeName("其他");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.ILLEGAL_PARAM, "没有这个图书类别");
}
return topicTextVO;
}
use of com.bc.pmpheep.back.po.PmphUser 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.po.PmphUser 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;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphUserServiceTest method testUpdatePmphUserOfBack.
@Test
public void testUpdatePmphUserOfBack() {
PmphUser pmphUser = new PmphUser();
pmphUser.setUsername("BBB");
pmphUser.setPassword("666");
pmphUser.setAvatar("110");
pmphUser.setRealname("CCC");
PmphUser pmphUser2 = new PmphUser();
pmphUser2 = userService.add(pmphUser);
pmphUser2.setPassword("777");
PmphUserManagerVO managerVO = new PmphUserManagerVO();
managerVO.setId(pmphUser2.getId());
managerVO.setUsername(pmphUser2.getUsername());
managerVO.setRealname(pmphUser2.getRealname());
managerVO.setRealname("角色");
managerVO.setHandphone("18728090611");
managerVO.setEmail("1249115@qq.com");
String result = userService.updatePmphUserOfBack(managerVO);
Assert.assertTrue("更新失败", result.equals("SUCCESS"));
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphUserServiceTest method testGet.
@Test
public void testGet() {
PmphUser puPmphUser;
// 按ID查询对象
puPmphUser = userService.get(1L);
Assert.assertNotNull("查询失败", puPmphUser);
}
Aggregations