Search in sources :

Example 11 with PmphGroupMember

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

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

the class PmphGroupMemberServiceImpl method updatePmphGroupMemberDisplayName.

@Override
public String updatePmphGroupMemberDisplayName(Long groupId, Long id, String displayName, 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, "该用户为空");
    }
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "未选择小组成员");
    }
    if (StringUtil.isEmpty(displayName)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "成员昵称不能为空");
    }
    PmphGroupMember member = new PmphGroupMember();
    member.setId(id);
    member.setDisplayName(displayName);
    if (pmphUser.getIsAdmin() || isFounder(groupId, sessionId)) {
        pmphGroupMemberDao.update(member);
        result = "SUCCESS";
    } else if (isFounderOrisAdmin(groupId, sessionId)) {
        PmphGroupMember pmphGroupMember = pmphGroupMemberDao.getPmphGroupMemberById(id);
        if (pmphGroupMember.getIsFounder() || pmphGroupMember.getIsAdmin()) {
            throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "管理员只能修改自己或普通成员的小组内昵称");
        } else {
            pmphGroupMemberDao.update(member);
            result = "SUCCESS";
        }
    } else {
        PmphGroupMember pmphGroupMember = pmphGroupMemberDao.getPmphGroupMemberById(id);
        if (pmphUser.getId().equals(pmphGroupMember.getUserId()) && !pmphGroupMember.getIsWriter()) {
            pmphGroupMemberDao.update(member);
            result = "SUCCESS";
        } else {
            throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "普通成员只能修改自己的昵称");
        }
    }
    return result;
}
Also used : PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 13 with PmphGroupMember

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

the class PmphGroupMemberServiceImpl method updateMemberIdentity.

@Override
public String updateMemberIdentity(Long groupId, List<PmphGroupMember> members, 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, "用户为空");
    }
    if (pmphUser.getIsAdmin() || isFounder(groupId, sessionId)) {
        // 只有小组创建者与超级管理员可以修改小组人员权限
        if (null == members || members.size() == 0) {
            throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "参数不能为空");
        } else {
            for (PmphGroupMember pmphGroupMember : members) {
                PmphGroupMember member = pmphGroupMemberDao.getPmphGroupMemberById(pmphGroupMember.getId());
                if (member.getIsFounder() && !pmphGroupMember.getIsAdmin()) {
                    throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组创建者不能取消管理员身份");
                }
                if (pmphGroupMember.getIsAdmin()) {
                    if (member.getIsAdmin() || member.getIsFounder()) {
                        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "该用户已是小组管理员了");
                    } else {
                        pmphGroupMember.setIsAdmin(true);
                    }
                } else {
                    if (member.getIsAdmin()) {
                        pmphGroupMember.setIsAdmin(false);
                    } else {
                        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "该用户不是小组管理员");
                    }
                }
                pmphGroupMemberDao.updatePmphGroupMember(pmphGroupMember);
            }
            result = "SUCCESS";
        }
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "只有创建者有此权限操作");
    }
    return result;
}
Also used : PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Aggregations

PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)13 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)10 PmphUser (com.bc.pmpheep.back.po.PmphUser)8 ArrayList (java.util.ArrayList)5 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)4 LogDetail (com.bc.pmpheep.annotation.LogDetail)3 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)3 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)3 Gson (com.google.gson.Gson)3 IOException (java.io.IOException)3 Type (java.lang.reflect.Type)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 Textbook (com.bc.pmpheep.back.po.Textbook)2 Material (com.bc.pmpheep.back.po.Material)1 MaterialProjectEditor (com.bc.pmpheep.back.po.MaterialProjectEditor)1 WriterUser (com.bc.pmpheep.back.po.WriterUser)1 TextbookDecVO (com.bc.pmpheep.back.vo.TextbookDecVO)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1