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();
}
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;
}
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;
}
Aggregations