Search in sources :

Example 6 with PmphRole

use of com.bc.pmpheep.back.po.PmphRole in project pmph by BCSquad.

the class BookCorrectionServiceImpl method listBookCorrectionAudit.

@Override
public PageResult<BookCorrectionAuditVO> listBookCorrectionAudit(HttpServletRequest request, Integer pageNumber, Integer pageSize, String bookname, Boolean isOver, Boolean result) throws CheckedServiceException {
    if (null == request.getSession(false)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "会话过期");
    }
    // 获取当前用户
    String sessionId = CookiesUtil.getSessionId(request);
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    if (null == pageNumber || pageNumber < 1) {
        pageNumber = 1;
    }
    if (null == pageSize || pageSize < 1) {
        pageSize = Integer.MAX_VALUE;
    }
    Long editorId = pmphUser.getId();
    // 权限的检查
    List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
    // 系统管理员权限检查
    for (PmphRole pmphRole : pmphRoles) {
        if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName().trim())) {
            // 我是系统管理原
            editorId = null;
        }
    }
    // 权限由菜单控制
    editorId = null;
    Map<String, Object> map = new HashMap<String, Object>(4);
    map.put("start", (pageNumber - 1) * pageSize);
    map.put("pageSize", pageSize);
    map.put("result", result);
    map.put("bookname", StringUtil.toAllCheck(bookname));
    map.put("editorId", editorId);
    if (null != isOver && isOver) {
        // APP的已完成
        map.put("isOver", 1);
    } else {
        map.put("isOver", 2);
    }
    // 返回实体
    PageResult<BookCorrectionAuditVO> pageResult = new PageResult<BookCorrectionAuditVO>();
    pageResult.setPageNumber(pageNumber);
    pageResult.setPageSize(pageSize);
    // 获取总数
    Integer total = bookCorrectionDao.listBookCorrectionAuditTotal(map);
    if (null != total && total > 0) {
        List<BookCorrectionAuditVO> rows = bookCorrectionDao.listBookCorrectionAudit(map);
        pageResult.setRows(rows);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) HashMap(java.util.HashMap) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) BookCorrectionAuditVO(com.bc.pmpheep.back.vo.BookCorrectionAuditVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) PmphRole(com.bc.pmpheep.back.po.PmphRole)

Example 7 with PmphRole

use of com.bc.pmpheep.back.po.PmphRole in project pmph by BCSquad.

the class MaterialServiceImpl method updateMaterial.

/**
 * 通过主键id更新material 不为null 的字段
 *
 * @param Material
 * @return 影响行数
 * @throws CheckedServiceException
 */
@Override
public Integer updateMaterial(Material material, String sessionId) throws CheckedServiceException {
    if (null == material.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "主键为空");
    }
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    // if (!pmphUser.getIsAdmin()) {
    // throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL,
    // CheckedExceptionResult.ILLEGAL_PARAM,
    // "该用户没有操作权限");
    // }
    // 教材权限的检查
    List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
    Integer power = null;
    // 系统管理员权限检查
    for (PmphRole pmphRole : pmphRoles) {
        if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName())) {
            // 我是系统管理原
            power = 1;
        }
    }
    // 教材主任检查
    Material materialDirector = materialService.getMaterialById(material.getId());
    if (null == power) {
        if (null != materialDirector && null != materialDirector.getDirector() && pmphUser.getId().equals(materialDirector.getDirector())) {
            // 我是教材的主任
            power = 2;
        }
    }
    return materialDao.updateMaterial(material);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) PmphRole(com.bc.pmpheep.back.po.PmphRole)

Example 8 with PmphRole

use of com.bc.pmpheep.back.po.PmphRole in project pmph by BCSquad.

the class MaterialServiceImpl method getMaterialMainInfoById.

@Override
public MaterialMainInfoVO getMaterialMainInfoById(Long materialId, String sessionId) throws CheckedServiceException {
    // 验证用户
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    // 教材权限的检查
    List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
    // 下面进行授权
    Integer projectEditorPowers = 0;
    Integer role = 0;
    // 系统管理员权限检查
    for (PmphRole pmphRole : pmphRoles) {
        if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName())) {
            // 我是系统管理原
            // "11111111";
            projectEditorPowers = 255;
            role = 1;
        }
    }
    // 教材主任检查
    Material material = this.getMaterialById(materialId);
    if (null != material && null != material.getDirector() && pmphUser.getId().equals(material.getDirector())) {
        // 我是教材的主任
        projectEditorPowers = 255;
        role = (0 == role.intValue() ? 2 : role);
    }
    // 教材项目编辑检查
    List<MaterialProjectEditorVO> materialProjectEditors = materialProjectEditorService.listMaterialProjectEditors(materialId);
    if (null != materialProjectEditors && materialProjectEditors.size() > 0) {
        for (MaterialProjectEditorVO materialProjectEditor : materialProjectEditors) {
            if (null != materialProjectEditor && null != materialProjectEditor.getEditorId() && materialProjectEditor.getEditorId().equals(pmphUser.getId())) {
                // 我是教材的项目编辑
                projectEditorPowers = (projectEditorPowers | material.getProjectPermission());
                role = (0 == role.intValue() ? 3 : role);
            }
        }
    }
    // 教材策划编辑检查
    Integer num = this.getPlanningEditorSum(materialId, pmphUser.getId());
    if (null != num && num.intValue() > 0) {
        // 我是教材的策划编辑编辑
        projectEditorPowers = (projectEditorPowers | material.getPlanPermission());
        role = (0 == role.intValue() ? 4 : role);
    }
    MaterialMainInfoVO materialMainInfoVO = new MaterialMainInfoVO(materialId, material.getMaterialName(), material.getIsPublished(), material.getIsAllTextbookPublished(), material.getIsForceEnd(), material.getIsDeleted(), StringUtil.tentToBinary(projectEditorPowers), role);
    return materialMainInfoVO;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) MaterialMainInfoVO(com.bc.pmpheep.back.vo.MaterialMainInfoVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) MaterialProjectEditorVO(com.bc.pmpheep.back.vo.MaterialProjectEditorVO) PmphRole(com.bc.pmpheep.back.po.PmphRole)

Example 9 with PmphRole

use of com.bc.pmpheep.back.po.PmphRole in project pmph by BCSquad.

the class PmphRoleServiceImpl method getList.

@Override
public List<PmphRole> getList(String roleName) throws CheckedServiceException {
    List<PmphRole> pmphRoles = roleDao.getListRole(roleName);
    for (PmphRole pmphRole : pmphRoles) {
        List<Long> subList = this.getListPmphRolePermissionIdByRoleId(pmphRole.getId());
        pmphRole.setPmphRolePermissionChild(subList);
        if (ObjectUtil.isNull(pmphRoleMaterialService.getPmphRoleMaterialByRoleId(pmphRole.getId()))) {
            pmphRole.setMaterialPermission("00000000");
        } else {
            pmphRole.setMaterialPermission(StringUtil.tentToBinary(pmphRoleMaterialService.getPmphRoleMaterialByRoleId(pmphRole.getId()).getPermission()));
        }
    }
    return pmphRoles;
}
Also used : PmphRole(com.bc.pmpheep.back.po.PmphRole)

Example 10 with PmphRole

use of com.bc.pmpheep.back.po.PmphRole 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

PmphRole (com.bc.pmpheep.back.po.PmphRole)11 PmphUser (com.bc.pmpheep.back.po.PmphUser)9 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)8 HashMap (java.util.HashMap)7 Material (com.bc.pmpheep.back.po.Material)4 ArrayList (java.util.ArrayList)4 PageResult (com.bc.pmpheep.back.plugin.PageResult)3 DesRun (com.bc.pmpheep.back.util.DesRun)3 Gson (com.google.gson.Gson)3 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)2 WriterUser (com.bc.pmpheep.back.po.WriterUser)2 BookCorrectionAuditVO (com.bc.pmpheep.back.vo.BookCorrectionAuditVO)2 BookPositionVO (com.bc.pmpheep.back.vo.BookPositionVO)2 MaterialProjectEditorVO (com.bc.pmpheep.back.vo.MaterialProjectEditorVO)2 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)2 TypeToken (com.google.gson.reflect.TypeToken)2 Map (java.util.Map)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 DecPosition (com.bc.pmpheep.back.po.DecPosition)1