Search in sources :

Example 91 with PmphUser

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;
}
Also used : TopicTextVO(com.bc.pmpheep.back.vo.TopicTextVO) PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 92 with PmphUser

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;
}
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 93 with PmphUser

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;
}
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 94 with PmphUser

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"));
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphUserManagerVO(com.bc.pmpheep.back.vo.PmphUserManagerVO) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 95 with PmphUser

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);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Aggregations

PmphUser (com.bc.pmpheep.back.po.PmphUser)102 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)81 ArrayList (java.util.ArrayList)33 PageResult (com.bc.pmpheep.back.plugin.PageResult)17 HashMap (java.util.HashMap)13 Material (com.bc.pmpheep.back.po.Material)11 WriterUser (com.bc.pmpheep.back.po.WriterUser)11 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)10 PmphRole (com.bc.pmpheep.back.po.PmphRole)9 UserMessage (com.bc.pmpheep.back.po.UserMessage)9 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)9 BaseTest (com.bc.pmpheep.test.BaseTest)9 Test (org.junit.Test)9 CmsContent (com.bc.pmpheep.back.po.CmsContent)8 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)8 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)7 Textbook (com.bc.pmpheep.back.po.Textbook)7 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)6 Gson (com.google.gson.Gson)6 OrgUser (com.bc.pmpheep.back.po.OrgUser)5