Search in sources :

Example 11 with PmphGroupMemberVO

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

the class PmphGroupMemberServiceImpl method isFounderOrisAdmin.

@Override
public Boolean isFounderOrisAdmin(Long groupId, String sessionId) throws CheckedServiceException {
    boolean flag = false;
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    Long memberId = pmphUser.getId();
    PmphGroupMemberVO currentUser = pmphGroupMemberDao.getPmphGroupMemberByMemberId(groupId, memberId, false);
    if (null != currentUser) {
        if (currentUser.getIsFounder() || currentUser.getIsAdmin()) {
            flag = true;
        }
    }
    return flag;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 12 with PmphGroupMemberVO

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

the class PmphGroupMemberServiceImpl method addPmphGroupMembers.

@Override
public Integer addPmphGroupMembers(Long groupId, List<PmphGroupMember> pmphGroupMembers) throws CheckedServiceException {
    if (null == pmphGroupMembers || pmphGroupMembers.size() == 0) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "参数为空");
    }
    for (PmphGroupMember pmphGroupMember : pmphGroupMembers) {
        Boolean isWriter = pmphGroupMember.getIsWriter();
        isWriter = (isWriter == null || !isWriter) ? false : true;
        PmphGroupMemberVO member = getPmphGroupMemberByMemberId(groupId, pmphGroupMember.getUserId(), isWriter);
        if (null == member || member.getId() == null) {
            if (StringUtil.isEmpty(pmphGroupMember.getDisplayName())) {
                if (isWriter) {
                    pmphGroupMember.setDisplayName(writerUserService.get(pmphGroupMember.getUserId()).getRealname());
                } else {
                    pmphGroupMember.setDisplayName(pmphUserService.get(pmphGroupMember.getUserId()).getRealname());
                }
            }
            pmphGroupMember.setGroupId(groupId);
            this.addPmphGroupMember(pmphGroupMember);
        } else {
            PmphGroupMember reUseMember = new PmphGroupMember();
            reUseMember.setId(member.getId());
            reUseMember.setIsDeleted(false);
            pmphGroupMemberDao.updatePmphGroupMember(reUseMember);
        }
    }
    return pmphGroupMembers.size();
}
Also used : PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 13 with PmphGroupMemberVO

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

the class PmphGroupMemberServiceImpl method listPmphGroupMember.

@Override
public List<PmphGroupMemberVO> listPmphGroupMember(Long groupId, String sessionId) throws CheckedServiceException {
    if (null == groupId || groupId == 0) {
        List<PmphGroupListVO> myPmphGroupListVOList = pmphGroupService.listPmphGroup(new PmphGroup(), sessionId);
        if (null == myPmphGroupListVOList || myPmphGroupListVOList.size() == 0) {
            throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "你没有小组!");
        }
        // 初始化页面时没有参数传入则直接调用初始化时小组排序的第一个小组id
        groupId = myPmphGroupListVOList.get(0).getId();
    }
    List<PmphGroupMemberVO> list = pmphGroupMemberDao.listPmphGroupMember(groupId);
    for (PmphGroupMemberVO pmphGroupMemberVO : list) {
        if (pmphGroupMemberVO.getIsWriter()) {
            pmphGroupMemberVO.setAvatar(RouteUtil.userAvatar(writerUserService.get(pmphGroupMemberVO.getUserId()).getAvatar()));
            pmphGroupMemberVO.setUserType(Const.SENDER_TYPE_2);
        } else {
            pmphGroupMemberVO.setAvatar(RouteUtil.userAvatar(pmphUserService.get(pmphGroupMemberVO.getUserId()).getAvatar()));
            pmphGroupMemberVO.setUserType(Const.SENDER_TYPE_1);
        }
    }
    return list;
}
Also used : PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PmphGroupListVO(com.bc.pmpheep.back.vo.PmphGroupListVO)

Example 14 with PmphGroupMemberVO

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

the class PmphGroupMemberServiceImpl method getPmphGroupMemberByMemberId.

@Override
public PmphGroupMemberVO getPmphGroupMemberByMemberId(Long groupId, Long userId, Boolean isWriter) throws CheckedServiceException {
    if (null == userId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "组员id不能为空");
    }
    PmphGroupMemberVO pmphGroupMemberVO = pmphGroupMemberDao.getPmphGroupMemberByMemberId(groupId, userId, isWriter);
    if (ObjectUtil.isNull(pmphGroupMemberVO)) {
        return null;
    // throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM,
    // "你不是该小组的组员");
    }
    pmphGroupMemberVO.setAvatar(isWriter ? writerUserService.get(userId).getAvatar() : pmphUserService.get(userId).getAvatar());
    return pmphGroupMemberVO;
}
Also used : PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Aggregations

PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)14 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)14 PmphUser (com.bc.pmpheep.back.po.PmphUser)9 ArrayList (java.util.ArrayList)6 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)4 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)3 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)3 PmphGroupFile (com.bc.pmpheep.back.po.PmphGroupFile)2 PmphGroupMessage (com.bc.pmpheep.back.po.PmphGroupMessage)2 PmphGroupListVO (com.bc.pmpheep.back.vo.PmphGroupListVO)2 UserMessage (com.bc.pmpheep.back.po.UserMessage)1 WriterUser (com.bc.pmpheep.back.po.WriterUser)1 Message (com.bc.pmpheep.general.po.Message)1 IOException (java.io.IOException)1