Search in sources :

Example 1 with MaterialMainInfoVO

use of com.bc.pmpheep.back.vo.MaterialMainInfoVO 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)

Aggregations

Material (com.bc.pmpheep.back.po.Material)1 PmphRole (com.bc.pmpheep.back.po.PmphRole)1 PmphUser (com.bc.pmpheep.back.po.PmphUser)1 MaterialMainInfoVO (com.bc.pmpheep.back.vo.MaterialMainInfoVO)1 MaterialProjectEditorVO (com.bc.pmpheep.back.vo.MaterialProjectEditorVO)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1