Search in sources :

Example 1 with MaterialListVO

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

the class MaterialServiceImpl method addMaterialContact.

/**
 * 功能描述:想每个教材中加入联系人信息
 *
 * @param list
 *            教材集合
 * @return
 */
public List<MaterialListVO> addMaterialContact(List<MaterialListVO> list, String sessionId) {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    for (MaterialListVO materialListVO : list) {
        materialListVO.setFounderName(pmphUserService.get(materialListVO.getFounderId()).getRealname());
        materialListVO.setIsMy(false);
        // 获取联系人
        materialListVO.setContacts(materialContactService.listMaterialContactByMaterialId(materialListVO.getId()));
        if (!materialListVO.getIsPublished()) {
            if (textbookService.getTextbookByMaterialId(materialListVO.getId()).size() == 0) {
                // 判断新建教材时是否到了书目录页面
                materialListVO.setMaterialStep("设置书目录");
            }
            if (ObjectUtil.isNull(cmsContentService.getCmsContentByMaterialId(materialListVO.getId()))) {
                // 判断新建教材时是否到了编辑通知详情页面
                materialListVO.setMaterialStep("编辑通知详情");
            }
        }
        if (pmphUser.getIsAdmin()) {
            // 如果是超级管理员则为所欲为
            materialListVO.setIsMy(true);
        }
        if (pmphUser.getId().equals(materialListVO.getFounderId())) {
            // 判断是否是创建者
            materialListVO.setIsMy(true);
            materialListVO.setIsFounder(true);
        } else {
            materialListVO.setIsFounder(false);
        }
        if (pmphUser.getId().equals(materialListVO.getDirector())) {
            // 判断是否是主任
            materialListVO.setIsMy(true);
            materialListVO.setIsDirector(true);
        } else {
            materialListVO.setIsDirector(false);
        }
        if (!ObjectUtil.isNull(materialProjectEditorService.getMaterialProjectEditorByMaterialIdAndUserId(materialListVO.getId(), pmphUser.getId()))) {
            // 判断是否为项目编辑
            materialListVO.setIsMy(true);
        }
        if (!CollectionUtil.isEmpty(textbookService.getTextbookByMaterialIdAndUserId(materialListVO.getId(), pmphUser.getId()))) {
            // 判断是否为策划编辑
            materialListVO.setIsMy(true);
        }
        if (materialListVO.getIsPublished()) {
            if (materialListVO.getIsForceEnd() || materialListVO.getIsAllTextbookPublished()) {
                materialListVO.setState("已结束");
            } else {
                materialListVO.setState("已发布");
            }
        } else {
            materialListVO.setState("未发布");
        }
        String myPower = getMaterialMainInfoById(materialListVO.getId(), sessionId).getMyPower();
        if (materialListVO.getIsFounder()) {
            myPower = "1" + myPower.substring(1);
        }
        materialListVO.setMyPower(myPower);
    }
    return list;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) MaterialListVO(com.bc.pmpheep.back.vo.MaterialListVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 2 with MaterialListVO

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

the class MaterialController method list.

/**
 * 功能描述:初始化/条件查询教材列表
 *
 * @param request
 * @param pageSize
 *            当前页条数
 * @param pageNumber
 *            当前页数
 * @param isMy
 *            是否我的
 * @param state
 *            当前状态
 * @param materialName
 *            教材名称
 * @param contactUserName
 *            联系人名称
 * @return
 */
@ResponseBody
@LogDetail(businessType = Business_Type, logRemark = "查询教材公告列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseBean list(HttpServletRequest request, Integer pageSize, Integer pageNumber, Boolean isMy, String state, String materialName, String contactUserName) {
    String sessionId = CookiesUtil.getSessionId(request);
    PageParameter<MaterialListVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    MaterialListVO materialListVO = new MaterialListVO();
    materialListVO.setIsMy(isMy);
    materialListVO.setState(state);
    materialListVO.setContactUserName(contactUserName);
    materialListVO.setMaterialName(materialName);
    pageParameter.setParameter(materialListVO);
    return new ResponseBean(materialService.listMaterials(pageParameter, sessionId));
}
Also used : MaterialListVO(com.bc.pmpheep.back.vo.MaterialListVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MaterialListVO

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

the class MaterialServiceImpl method listMaterials.

@Override
public PageResult<MaterialListVO> listMaterials(PageParameter<MaterialListVO> pageParameter, String sessionId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(pageParameter)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    PageResult<MaterialListVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    List<MaterialListVO> list = new ArrayList<>();
    if (pmphUser.getIsAdmin()) {
        pageParameter.getParameter().setIsMy(null);
    }
    if (null != pageParameter.getParameter().getIsMy() && !pageParameter.getParameter().getIsMy()) {
        pageParameter.getParameter().setIsMy(null);
    }
    if (!ObjectUtil.isNull(pageParameter.getParameter().getIsMy()) && pageParameter.getParameter().getIsMy()) {
        pageParameter.getParameter().setUserId(pmphUser.getId());
    }
    Integer total = 0;
    String state = pageParameter.getParameter().getState();
    if ("已结束".equals(state)) {
        pageParameter.getParameter().setIsAllTextbookPublished(true);
        pageParameter.getParameter().setIsForceEnd(true);
        pageParameter.getParameter().setIsPublished(true);
        total = materialDao.listMaterialEndTotal(pageParameter);
        if (total > 0) {
            list = materialDao.listMaterialEnd(pageParameter);
        }
    } else {
        if (!StringUtil.isEmpty(state)) {
            switch(state) {
                case "未发布":
                    pageParameter.getParameter().setIsAllTextbookPublished(false);
                    pageParameter.getParameter().setIsForceEnd(false);
                    pageParameter.getParameter().setIsPublished(false);
                    break;
                case "已发布":
                    pageParameter.getParameter().setIsAllTextbookPublished(false);
                    pageParameter.getParameter().setIsForceEnd(false);
                    pageParameter.getParameter().setIsPublished(true);
                    break;
                case "未结束":
                    pageParameter.getParameter().setIsAllTextbookPublished(false);
                    pageParameter.getParameter().setIsForceEnd(false);
                    pageParameter.getParameter().setIsPublished(null);
                    break;
                default:
                    throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "教材状态错误");
            }
        }
        total = materialDao.listMaterialTotal(pageParameter);
        if (total > 0) {
            list = materialDao.listMaterial(pageParameter);
        }
    }
    list = addMaterialContact(list, sessionId);
    pageResult.setRows(list);
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) MaterialListVO(com.bc.pmpheep.back.vo.MaterialListVO) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 4 with MaterialListVO

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

the class PmphUserServiceImpl method getPersonalCenter.

@Override
public Map<String, Object> getPersonalCenter(HttpServletRequest request, String state, String materialName, String groupName, String title, String bookname, String name, String authProgress, String topicBookname) {
    String sessionId = CookiesUtil.getSessionId(request);
    PmphUser sessionPmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == sessionPmphUser) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    // 获取用户角色
    List<PmphRole> rolelist = roleService.getPmphRoleByUserId(sessionPmphUser.getId());
    // 用于装所有的数据map
    Map<String, Object> map = new HashMap<>();
    // 教师认证总数量
    Integer writerUserCount = writerUserService.getCount();
    // 机构认证数量orgList
    Integer orgerCount = orgUserService.getCount();
    // 小组
    PmphGroupListVO pmphGroup = new PmphGroupListVO();
    PageParameter<PmphGroupListVO> pageParameterPmphGroup = new PageParameter<>();
    pageParameterPmphGroup.setParameter(pmphGroup);
    // 小组结果
    PageResult<PmphGroupListVO> pageResultPmphGroup = pmphGroupService.getlistPmphGroup(pageParameterPmphGroup, sessionId);
    // 教材申报
    PageParameter<MaterialListVO> pageParameter2 = new PageParameter<>();
    MaterialListVO materialListVO = new MaterialListVO();
    materialListVO.setState(state);
    materialListVO.setMaterialName(materialName);
    pageParameter2.setParameter(materialListVO);
    // 教材申报的结果
    PageResult<MaterialListVO> pageResultMaterialListVO = materialService.listMaterials(pageParameter2, sessionId);
    // 文章审核
    PageParameter<CmsContentVO> pageParameter1 = new PageParameter<>();
    CmsContentVO cmsContentVO = new CmsContentVO();
    cmsContentVO.setTitle(title);
    cmsContentVO.setCategoryId(Const.CMS_CATEGORY_ID_1);
    pageParameter1.setParameter(cmsContentVO);
    // 文章审核的结果
    PageResult<CmsContentVO> pageResultCmsContentVO = cmsContentService.listCmsContent(pageParameter1, sessionId);
    map.put("cmsContent", pageResultCmsContentVO);
    // 图书纠错审核
    PageResult<BookCorrectionAuditVO> pageResultBookCorrectionAuditVO = bookCorrectionService.listBookCorrectionAudit(request, Const.PAGE_NUMBER, Const.PAGE_SIZE, bookname, null, null);
    map.put("bookCorrectionAudit", pageResultBookCorrectionAuditVO);
    // 图书评论审核
    PageParameter<BookUserCommentVO> pageParameter = new PageParameter<>();
    BookUserCommentVO bookUserCommentVO = new BookUserCommentVO();
    // 去除空格
    bookUserCommentVO.setName(name.replaceAll(" ", ""));
    pageParameter.setParameter(bookUserCommentVO);
    PageResult<BookUserCommentVO> pageResultBookUserCommentVO = bookUserCommentService.listBookUserCommentAdmin(pageParameter);
    map.put("bookUserComment", pageResultBookUserCommentVO);
    // 选题申报
    PageParameter<TopicDeclarationVO> pageParameter3 = new PageParameter<>();
    // 选题申报当前用户角色
    PmphIdentity pmphIdentity = pmphUserService.identity(sessionId);
    TopicDeclarationVO topicDeclarationVO = new TopicDeclarationVO();
    // 是否由主任受理
    if (pmphIdentity.getIsDirector()) {
        topicDeclarationVO.setIsDirectorHandling(true);
    }
    // 是否由运维人员受理
    if (pmphIdentity.getIsOpts()) {
        topicDeclarationVO.setIsOptsHandling(true);
    }
    // 是否由编辑受理
    if (pmphIdentity.getIsEditor()) {
        topicDeclarationVO.setIsEditorHandling(true);
    }
    for (PmphRole pmphRole : rolelist) {
        // 编辑
        if (2 == pmphRole.getId()) {
            topicDeclarationVO.setIsEditorHandling(true);
        }
        // 主任
        if (9 == pmphRole.getId()) {
            topicDeclarationVO.setIsDirectorHandling(true);
        }
    }
    String[] strs = authProgress.split(",");
    List<Long> progress = new ArrayList<>();
    for (String str : strs) {
        progress.add(Long.valueOf(str));
    }
    topicDeclarationVO.setBookname(topicBookname);
    pageParameter3.setParameter(topicDeclarationVO);
    // 
    if (sessionPmphUser.getIsAdmin()) {
        PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = topicService.listMyTopic(progress, pageParameter3, null);
        // topicService.listCheckTopic(progress, pageParameter3);
        map.put("topicList", pageResultTopicDeclarationVO);
    } else {
        if (2 == rolelist.get(0).getId() || 9 == rolelist.get(0).getId() || 1 == rolelist.get(0).getId()) {
            PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = topicService.listMyTopic(progress, pageParameter3, sessionPmphUser.getId());
            // topicService.listCheckTopic(progress, pageParameter3);
            map.put("topicList", pageResultTopicDeclarationVO);
        } else {
            PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = new PageResult<>();
            List<TopicDeclarationVO> list = new ArrayList<>();
            pageResultTopicDeclarationVO.setPageNumber(0);
            pageResultTopicDeclarationVO.setRows(list);
            pageResultTopicDeclarationVO.setPageTotal(0);
            pageResultTopicDeclarationVO.setStart(0);
            pageResultTopicDeclarationVO.setTotal(0);
            ;
            map.put("topicList", pageResultTopicDeclarationVO);
        }
    }
    // 获取用户上次登录时间
    List<SysOperation> listSysOperation = sysOperationService.getSysOperation(sessionPmphUser.getId());
    Timestamp loginTime = DateUtil.getCurrentTime();
    if (!listSysOperation.isEmpty()) {
        loginTime = listSysOperation.get(0).getOperateDate();
    }
    // 把其他模块的数据都装入map中返回给前端
    map.put("materialList", pageResultMaterialListVO);
    map.put("pmphGroup", pageResultPmphGroup);
    map.put("writerUserCount", writerUserCount);
    map.put("orgUserCount", orgerCount);
    // 把用户信息存入map
    map.put("pmphUser", sessionPmphUser);
    // 把用户角色存入map
    map.put("pmphRole", rolelist);
    // 把选题申报的当前身份存入map
    map.put("pmphIdentity", pmphIdentity);
    // 存入用户上次操作时间
    map.put("loginTime", loginTime);
    return map;
}
Also used : SysOperation(com.bc.pmpheep.back.po.SysOperation) CmsContentVO(com.bc.pmpheep.back.vo.CmsContentVO) HashMap(java.util.HashMap) MaterialListVO(com.bc.pmpheep.back.vo.MaterialListVO) ArrayList(java.util.ArrayList) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) Timestamp(java.sql.Timestamp) BookCorrectionAuditVO(com.bc.pmpheep.back.vo.BookCorrectionAuditVO) PmphRole(com.bc.pmpheep.back.po.PmphRole) PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphIdentity(com.bc.pmpheep.back.vo.PmphIdentity) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) TopicDeclarationVO(com.bc.pmpheep.back.vo.TopicDeclarationVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) BookUserCommentVO(com.bc.pmpheep.back.vo.BookUserCommentVO) PmphGroupListVO(com.bc.pmpheep.back.vo.PmphGroupListVO)

Aggregations

MaterialListVO (com.bc.pmpheep.back.vo.MaterialListVO)4 PmphUser (com.bc.pmpheep.back.po.PmphUser)3 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)3 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)2 PageResult (com.bc.pmpheep.back.plugin.PageResult)2 ArrayList (java.util.ArrayList)2 LogDetail (com.bc.pmpheep.annotation.LogDetail)1 PmphRole (com.bc.pmpheep.back.po.PmphRole)1 SysOperation (com.bc.pmpheep.back.po.SysOperation)1 BookCorrectionAuditVO (com.bc.pmpheep.back.vo.BookCorrectionAuditVO)1 BookUserCommentVO (com.bc.pmpheep.back.vo.BookUserCommentVO)1 CmsContentVO (com.bc.pmpheep.back.vo.CmsContentVO)1 PmphGroupListVO (com.bc.pmpheep.back.vo.PmphGroupListVO)1 PmphIdentity (com.bc.pmpheep.back.vo.PmphIdentity)1 TopicDeclarationVO (com.bc.pmpheep.back.vo.TopicDeclarationVO)1 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)1 Timestamp (java.sql.Timestamp)1 HashMap (java.util.HashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1