Search in sources :

Example 6 with PmphGroup

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

the class PmphGroupMemberServiceImpl method addEditorBookGroup.

@Override
public String addEditorBookGroup(Long textbookId, String sessionId) throws CheckedServiceException {
    String result = "FAIL";
    // 获取用户信息 进行判断用户是否有权限操作
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "该用户为空");
    }
    // 查询书籍信息
    Textbook textbook = textbookService.getTextbookById(textbookId);
    // 查询教材信息
    Material material = materialService.getMaterialById(textbook.getMaterialId());
    // 查询该教材是否存在项目编辑
    MaterialProjectEditor materialProjectEditor = materialProjectEditorService.getMaterialProjectEditorByMaterialIdAndUserId(material.getId(), pmphUser.getId());
    // 通过书籍id查询所有主编、副主编、编委
    List<TextbookDecVO> textbookDecVOs = decPositionService.getTextbookEditorList(textbookId);
    List<PmphGroupMember> list = new ArrayList<PmphGroupMember>(textbookDecVOs.size());
    // 通过书籍id查询小组
    PmphGroup pmphGroup = pmphGroupService.getPmphGroupByTextbookId(textbookId);
    // 判断当前教材是否有更新小组的权限
    // 小组权限的判断
    Long materialId = textbook.getMaterialId();
    String myPower = textbookService.listBookPosition(1, 9999, null, "[" + textbookId + "]", null, materialId, sessionId).getRows().get(0).getMyPower();
    String groupPower = myPower.substring(6, 7);
    if ("1".equals(groupPower)) {
        // if(null!=material.getPlanPermission()||null!=material.getProjectPermission()){
        // if(!BinaryUtil.getBit(material.getPlanPermission(), 7)||!BinaryUtil.getBit(material.getProjectPermission(), 7)){
        // throw new CheckedServiceException(CheckedExceptionBusiness.GROUP,
        // CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有更新成员权限 ");
        // }
        // }
        // 通过小组id查询小组现有成员
        List<PmphGroupMember> pmphGroupMembers = pmphGroupMemberDao.listPmphGroupMembers(pmphGroup.getId());
        List<Long> groupUserIdList = new ArrayList<Long>(pmphGroupMembers.size());
        for (PmphGroupMember pmphGroupMember : pmphGroupMembers) {
            groupUserIdList.add(pmphGroupMember.getUserId());
        }
        // 通过遍历把不存在的成员添加到list中
        for (TextbookDecVO textbookDecVO : textbookDecVOs) {
            Long userId = textbookDecVO.getUserId();
            if (!groupUserIdList.contains(userId)) {
                list.add(new PmphGroupMember(userId, Const.TRUE, textbook.getMaterialId(), textbookId));
            }
        }
        if (CollectionUtil.isEmpty(list)) {
            throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.SUCCESS, "小组成员已是最新");
        }
        pmphGroupMemberService.addPmphGroupMemberOnGroup(pmphGroup.getId(), list, sessionId);
        result = "SUCCESS";
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有更新成员权限 ");
    }
    return result;
}
Also used : MaterialProjectEditor(com.bc.pmpheep.back.po.MaterialProjectEditor) PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) Textbook(com.bc.pmpheep.back.po.Textbook) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) TextbookDecVO(com.bc.pmpheep.back.vo.TextbookDecVO)

Example 7 with PmphGroup

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

the class PmphGroupServiceImpl method updatePmphGroup.

/**
 * @param PmphGroup
 * @return 影响行数
 * @throws CheckedServiceException
 * @throws IOException
 * @update Mryang 2017.10.13 15:20
 */
@Override
public Integer updatePmphGroup(MultipartFile file, PmphGroup pmphGroup) throws CheckedServiceException, IOException {
    if (null == pmphGroup) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "参数对象为空");
    }
    if (null == pmphGroup.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键为空");
    }
    // 修改小组图片
    if (null != file) {
        Long id = pmphGroup.getId();
        PmphGroup pmphGroupOld = getPmphGroupById(id);
        if (null != pmphGroupOld && null != pmphGroupOld.getGroupImage() && !"".equals(pmphGroupOld.getGroupImage())) {
            fileService.remove(pmphGroupOld.getGroupImage());
        }
        String newGroupImage = fileService.save(file, ImageType.GROUP_AVATAR, pmphGroup.getId());
        pmphGroup.setGroupImage(newGroupImage);
    }
    return pmphGroupDao.updatePmphGroup(pmphGroup);
}
Also used : PmphGroup(com.bc.pmpheep.back.po.PmphGroup) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 8 with PmphGroup

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

the class PmphGroupServiceImpl method addEditorSelcetionGroup.

@Override
public PmphGroup addEditorSelcetionGroup(String sessionId, List<PmphGroupMember> list, Long textbookId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (list.size() == 0) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "成员名单为空,更新失败");
    }
    Textbook textbook = textbookService.getTextbookById(textbookId);
    list.get(0).setTextbookId(textbookId);
    list.get(0).setMaterialId(textbook.getMaterialId());
    // 未上传小组头像时,获取默认小组头像路径
    String groupImage = RouteUtil.DEFAULT_GROUP_IMAGE;
    PmphGroup pmphGroup = new PmphGroup();
    // 查询小组名称是否已存在 不存在直接用书名
    if (ObjectUtil.isNull(pmphGroupDao.getPmphGroupByGroupName(textbook.getTextbookName()))) {
        pmphGroup.setGroupName(textbook.getTextbookName());
    } else {
        // 存在则用书名加当前小组总数进行区分
        Long count = pmphGroupDao.getPmphGroupCount();
        pmphGroup.setGroupName(textbook.getTextbookName() + count);
    }
    pmphGroup.setGroupImage(groupImage);
    pmphGroup.setBookId(textbookId);
    pmphGroup.setFounderId(pmphUser.getId());
    pmphGroupDao.addPmphGroup(pmphGroup);
    if (null != pmphGroup.getId()) {
        // 判断是否新增小组成功,如果成功则调用PmphGroupMemberService添加小组成员的方法将创建者添加到小组中
        PmphGroupMember pmphGroupMember = new PmphGroupMember();
        pmphGroupMember.setGroupId(pmphGroup.getId());
        pmphGroupMember.setIsFounder(true);
        pmphGroupMember.setUserId(pmphUser.getId());
        pmphGroupMember.setDisplayName(pmphUser.getRealname());
        pmphGroupMemberService.addPmphGroupMember(pmphGroupMember);
        // 批量把前台传入的作家用户添加到该小组
        pmphGroupMemberService.addPmphGroupMemberOnGroup(pmphGroup.getId(), list, sessionId);
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.OBJECT_NOT_FOUND, "添加小组和成员失败");
    }
    return pmphGroup;
}
Also used : PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) PmphUser(com.bc.pmpheep.back.po.PmphUser) Textbook(com.bc.pmpheep.back.po.Textbook) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 9 with PmphGroup

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

the class PmphUserServiceImpl method getListPmphUser.

@Override
public PageResult<PmphUserManagerVO> getListPmphUser(PageParameter<PmphUserManagerVO> pageParameter, Long groupId) throws CheckedServiceException {
    String name = pageParameter.getParameter().getName();
    if (StringUtil.notEmpty(name)) {
        pageParameter.getParameter().setName(name);
    }
    String path = pageParameter.getParameter().getPath();
    Long departmentId = pageParameter.getParameter().getDepartmentId();
    if (StringUtil.notEmpty(path) && ObjectUtil.notNull(departmentId)) {
        pageParameter.getParameter().setPath(path + "-" + java.lang.String.valueOf(departmentId) + '-');
    }
    PageResult<PmphUserManagerVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = pmphUserDao.getListPmphUserTotal(pageParameter);
    if (total > 0) {
        List<PmphUserManagerVO> list = pmphUserDao.getListPmphUser(pageParameter);
        for (PmphUserManagerVO pmphUserManagerVO : list) {
            List<PmphRoleVO> pmphRoles = pmphRoleDao.listPmphUserRoleByUserId(pmphUserManagerVO.getId());
            pmphUserManagerVO.setPmphRoles(pmphRoles);
        }
        pageResult.setRows(list);
    }
    pageResult.setTotal(total);
    // 设置职位
    if (null != pageResult.getRows() && pageResult.getRows().size() > 0 && null != groupId) {
        // 清空职位
        for (PmphUserManagerVO pmphUserManagerVO : pageResult.getRows()) {
            pmphUserManagerVO.setPosition("无");
        }
        PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
        Long bookId = pmphGroup.getBookId();
        if (null != bookId && bookId.intValue() > 0) {
            Textbook textbook = textbookService.getTextbookById(bookId);
            Material material = materialService.getMaterialById(textbook.getMaterialId());
            List<MaterialProjectEditorVO> projects = materialProjectEditorService.listMaterialProjectEditors(textbook.getMaterialId());
            for (PmphUserManagerVO pmphUserManagerVO : pageResult.getRows()) {
                Long pmphUserId = pmphUserManagerVO.getId();
                String posotion = null;
                if (material.getDirector().intValue() == pmphUserId.intValue()) {
                    posotion = "主任";
                }
                if (null != projects && projects.size() > 0) {
                    for (MaterialProjectEditorVO item : projects) {
                        if (item.getEditorId().intValue() == pmphUserId.intValue()) {
                            posotion += (posotion == null) ? "项目编辑" : ",项目编辑";
                            break;
                        }
                    }
                }
                if (textbook.getPlanningEditor().intValue() == pmphUserId.intValue()) {
                    posotion += (posotion == null) ? "策划编辑" : ",策划编辑";
                }
                pmphUserManagerVO.setPosition(posotion == null ? "无" : posotion);
            }
        }
    }
    // 设置职位 end
    return pageResult;
}
Also used : Material(com.bc.pmpheep.back.po.Material) PageResult(com.bc.pmpheep.back.plugin.PageResult) MaterialProjectEditorVO(com.bc.pmpheep.back.vo.MaterialProjectEditorVO) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) Textbook(com.bc.pmpheep.back.po.Textbook) PmphUserManagerVO(com.bc.pmpheep.back.vo.PmphUserManagerVO) PmphRoleVO(com.bc.pmpheep.back.vo.PmphRoleVO)

Example 10 with PmphGroup

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

the class GroupController method pmphGroup.

/**
 * 根据小组名称模糊查询获取当前用户的小组
 *
 * @author Mryang
 * @param pmphGroup
 * @return
 * @createDate 2017年9月21日 下午4:02:57
 */
@RequestMapping(value = "/list/pmphGroup", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "根据小组名称模糊查询获取当前用户的小组")
@ResponseBody
public ResponseBean pmphGroup(@RequestParam(name = "groupName", defaultValue = "") String groupName, HttpServletRequest request) {
    /*
		 * --------- 以下是正确的示例 ---------
		 * 
		 * 在ResponseBean初始化时,通过ResponseBeanAop对其构造函数进行切面编程,
		 * 因此返回时<务必>要使用ResponseBean的构造函数即 new ResponseBean(anything)
		 */
    PmphGroup pmphGroup = new PmphGroup();
    if (StringUtil.isEmpty(groupName)) {
        pmphGroup.setGroupName(groupName.trim());
    }
    String sessionId = CookiesUtil.getSessionId(request);
    return new ResponseBean(pmphGroupService.listPmphGroup(pmphGroup, sessionId));
}
Also used : PmphGroup(com.bc.pmpheep.back.po.PmphGroup) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

PmphGroup (com.bc.pmpheep.back.po.PmphGroup)18 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)13 PmphUser (com.bc.pmpheep.back.po.PmphUser)7 ArrayList (java.util.ArrayList)7 Textbook (com.bc.pmpheep.back.po.Textbook)4 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)4 PageResult (com.bc.pmpheep.back.plugin.PageResult)3 Material (com.bc.pmpheep.back.po.Material)3 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)3 UserMessage (com.bc.pmpheep.back.po.UserMessage)3 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)3 Message (com.bc.pmpheep.general.po.Message)3 HashMap (java.util.HashMap)3 LogDetail (com.bc.pmpheep.annotation.LogDetail)2 PmphGroupListVO (com.bc.pmpheep.back.vo.PmphGroupListVO)2 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)2 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2