Search in sources :

Example 1 with PmphGroup

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

the class MaterialServiceImpl method updateMaterial.

@Override
public String updateMaterial(Long id, String sessionId) throws CheckedServiceException {
    Material material = materialDao.getMaterialById(id);
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (pmphUser.getIsAdmin() || pmphUser.getId().equals(material.getDirector()) || pmphUser.getId().equals(material.getFounderId())) {
        List<Textbook> list = textbookService.getTextbookByMaterialId(id);
        for (Textbook textbook : list) {
            PmphGroup group = pmphGroupService.getPmphGroupByTextbookId(textbook.getId());
            if (ObjectUtil.notNull(group)) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "您在" + textbook.getTextbookName() + "书籍下还有未解散的小组,请先解散小组");
            }
        }
        material = new Material();
        material.setId(id);
        material.setIsDeleted(true);
        materialDao.updateMaterial(material);
        cmsContentService.updateCmsContentByMaterialId(id);
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "您没有删除教材" + material.getMaterialName() + "的权限");
    }
    return "SUCCESS";
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) Textbook(com.bc.pmpheep.back.po.Textbook) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) Material(com.bc.pmpheep.back.po.Material) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 2 with PmphGroup

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

the class SystemMessageService method sendWhenInviteJoinGroup.

/**
 * 任意用户被邀请进入小组 向被邀请人发出
 *
 * @author Mryang
 * @createDate 2017年11月17日 下午2:16:36
 * @param inviterName
 *            邀请人名字
 * @param groupId
 *            小组id
 * @param invitedPersonIds
 *            被邀请人ids
 * @param invitedPersonType
 *            被邀请人类型: 1=社内用户/2=作家/3=机构用户
 * @throws CheckedServiceException
 * @throws IOException
 */
public void sendWhenInviteJoinGroup(String inviterName, Long groupId, List<Long> invitedPersonIds, short invitedPersonType) throws CheckedServiceException, IOException {
    if (StringUtils.isEmpty(inviterName)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "邀请人为空");
    }
    if (null == invitedPersonIds || invitedPersonIds.size() == 0) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "被邀请人为空");
    }
    // 获取小组
    PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
    if (null == pmphGroup) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组不存在");
    }
    String msgContent = "您被[<font color='red'>" + inviterName + "</font>]邀请加入[<font color='red'>" + pmphGroup.getGroupName() + "]</font>小组";
    // 存入消息主体
    Message message = new Message(msgContent);
    message = messageService.add(message);
    String msg_id = message.getId();
    // 组装消息和消息对象
    List<UserMessage> userMessageList = new ArrayList<UserMessage>(invitedPersonIds.size());
    List<String> userIds = new ArrayList<String>(invitedPersonIds.size());
    for (Long id : invitedPersonIds) {
        UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), id, invitedPersonType, null);
        userMessageList.add(userMessage);
        userIds.add(invitedPersonType + "_" + id);
    }
    // 发送消息
    userMessageService.addUserMessageBatch(userMessageList);
    // websocket推送页面消息
    WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
    myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage)

Example 3 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)

Example 4 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());
        List<Long> groupUserIdNotWriterList = new ArrayList<Long>(pmphGroupMembers.size());
        for (PmphGroupMember pmphGroupMember : pmphGroupMembers) {
            if (pmphGroupMember.getIsWriter()) {
                groupUserIdList.add(pmphGroupMember.getUserId());
            } else {
                groupUserIdNotWriterList.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, textbookDecVO.getRealname()));
            }
        }
        if (!ObjectUtil.isNull(textbook.getPlanningEditor()) && !groupUserIdNotWriterList.contains(textbook.getPlanningEditor())) {
            list.add(new PmphGroupMember(textbook.getPlanningEditor(), Const.FALSE, textbook.getMaterialId(), textbookId, textbook.getRealname()));
        }
        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 5 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());
    /*if(ObjectUtil.isNull(textbook.getPlanningEditor())){
			PmphGroupMember pmphGroupMember = new PmphGroupMember();
			pmphGroupMember.setUserId(textbook.getPlanningEditor());
			pmphGroupMember.setIsWriter(false);
			list.add(pmphGroupMember);
		}*/
    // 未上传小组头像时,获取默认小组头像路径
    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(StringUtil.isEmpty(pmphUser.getRealname()) ? pmphUser.getUsername() : pmphUser.getRealname());
        pmphGroupMemberService.addPmphGroupMember(pmphGroupMember);
        // 新增小组成员--策划编辑
        if (!ObjectUtil.isNull(textbook.getPlanningEditor())) {
            pmphGroupMember.setGroupId(pmphGroup.getId());
            pmphGroupMember.setUserId(textbook.getPlanningEditor());
            pmphGroupMember.setIsFounder(false);
            pmphGroupMember.setIsWriter(false);
            pmphGroupMember.setDisplayName(textbook.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)

Aggregations

PmphGroup (com.bc.pmpheep.back.po.PmphGroup)17 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)12 PmphUser (com.bc.pmpheep.back.po.PmphUser)7 ArrayList (java.util.ArrayList)5 PageResult (com.bc.pmpheep.back.plugin.PageResult)4 Textbook (com.bc.pmpheep.back.po.Textbook)4 HashMap (java.util.HashMap)4 Material (com.bc.pmpheep.back.po.Material)3 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)3 LogDetail (com.bc.pmpheep.annotation.LogDetail)2 DecPositionPublished (com.bc.pmpheep.back.po.DecPositionPublished)2 Declaration (com.bc.pmpheep.back.po.Declaration)2 PmphGroupListVO (com.bc.pmpheep.back.vo.PmphGroupListVO)2 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)2 WriterUserManagerVO (com.bc.pmpheep.back.vo.WriterUserManagerVO)2 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)2 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)2 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2