use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupMemberServiceImpl method deletePmphGroupMemberByIds.
@Override
public String deletePmphGroupMemberByIds(Long groupId, Long[] ids, 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()) {
if (!isFounderOrisAdmin(groupId, sessionId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有操作权限");
}
}
Long userid = pmphUser.getId();
PmphGroupMemberVO currentUser = pmphGroupMemberDao.getPmphGroupMemberByMemberId(groupId, userid, false);
if (null == ids || ids.length == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键不能为空");
} else {
for (Long id : ids) {
PmphGroupMember pmphGroupMember = pmphGroupMemberDao.getPmphGroupMemberById(id);
if (userid == pmphGroupMember.getUserId() && !pmphGroupMember.getIsWriter()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "您无权限删除管理员,请重新选择");
}
if (pmphUser.getIsAdmin() || currentUser.getIsFounder()) {
// 只有小组创建者和超级管理员可以删除小组成员
if (pmphGroupMemberDao.getPmphGroupMemberById(id).getIsFounder()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "小组创建者不能删除,请重新选择");
}
pmphGroupMemberDao.deletePmphGroupMemberById(id);
} else {
// 管理员进入的方法
if (currentUser.getIsAdmin() && (pmphGroupMember.getIsFounder() || pmphGroupMember.getIsAdmin())) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "您无权限删除管理员,请重新选择");
} else {
pmphGroupMemberDao.deletePmphGroupMemberById(id);
}
}
}
result = "SUCCESS";
}
return result;
}
use of com.bc.pmpheep.back.po.PmphUser 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;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupMemberServiceImpl method isFounder.
@Override
public Boolean isFounder(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 (currentUser.getIsFounder()) {
flag = true;
}
return flag;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupMemberServiceImpl method addPmphGroupMemberOnGroup.
@Override
public String addPmphGroupMemberOnGroup(Long groupId, List<PmphGroupMember> pmphGroupMembers, 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=new Textbook();
* if(null!=pmphGroupMembers.get(0).getTextbookId()){
* //查询书籍信息
* textbook=textbookService.getTextbookById(pmphGroupMembers.get(0).getTextbookId());
* }
* Material material=new Material();
* if(null!=pmphGroupMembers.get(0).getMaterialId()){
* //查询教材信息
* material=materialService.getMaterialById(pmphGroupMembers.get(0).getMaterialId());
* }
* //查询该教材是否存在项目编辑
* MaterialProjectEditor materialProjectEditor=materialProjectEditorService.getMaterialProjectEditorByMaterialIdAndUserId(material.getId(), pmphUser.getId());
* ////判断当前教材是否有创建小组的权限
* if (!material.getDirector().equals(pmphUser.getId()) && !textbook.getPlanningEditor().equals(pmphUser.getId())
* && null == materialProjectEditor && !pmphUser.getIsAdmin()) {
* throw new CheckedServiceException(CheckedExceptionBusiness.GROUP,
* CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有此操作权限");
*
* }
* if (null != material.getPlanPermission()) {
* if (!BinaryUtil.getBit(material.getPlanPermission(), 7)) {
* throw new CheckedServiceException(CheckedExceptionBusiness.GROUP,
* CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有此操作权限");
* }
* }
* if (null != material.getProjectPermission()) {
* if (!BinaryUtil.getBit(material.getProjectPermission(), 7)) {
* throw new CheckedServiceException(CheckedExceptionBusiness.GROUP,
* CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有此操作权限");
* }
* }
*/
// 小组权限的判断
Long materialId = pmphGroupMembers.get(0).getMaterialId();
Long textBookId = pmphGroupMembers.get(0).getTextbookId();
String myPower = textbookService.listBookPosition(1, 9999, null, "[" + textBookId + "]", null, materialId, sessionId).getRows().get(0).getMyPower();
String groupPower = myPower.substring(6, 7);
/**
* if (pmphUser.getIsAdmin() || isFounderOrisAdmin(groupId, sessionId)
* ||material.getDirector()==pmphUser.getId()||textbook.getPlanningEditor()==pmphUser.getId()
* ||pmphUser.getId()==materialProjectEditor.getEditorId()) {// 是超级管理员或者该小组的创建人和管理员才可以添加成员
*/
if ("1".equals(groupPower)) {
// 小组权限的判断 end
if (pmphGroupMembers.size() > 0) {
List<Long> writers = new ArrayList<>();
List<Long> pmphs = new ArrayList<>();
for (PmphGroupMember pmphGroupMember : pmphGroupMembers) {
PmphGroupMemberVO groupMember = pmphGroupMemberDao.getPmphGroupMemberByMemberId(groupId, pmphGroupMember.getUserId(), // 查看当前添加人员是否以前在小组中
pmphGroupMember.getIsWriter());
if (ObjectUtil.isNull(groupMember)) {
// 当前人员以前不在小组中
if (null == pmphGroupMember.getUserId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "成员id为空");
}
if (pmphGroupMember.getIsWriter()) {
WriterUser writerUser = writerUserService.get(pmphGroupMember.getUserId());
pmphGroupMember.setDisplayName(writerUser.getRealname());
writers.add(pmphGroupMember.getUserId());
} else {
PmphUser user = pmphUserService.get(pmphGroupMember.getUserId());
pmphGroupMember.setDisplayName(user.getRealname());
pmphs.add(pmphGroupMember.getUserId());
}
pmphGroupMember.setGroupId(groupId);
pmphGroupMemberDao.addPmphGroupMember(pmphGroupMember);
} else {
if (groupMember.getIsDeleted()) {
pmphGroupMember.setGroupId(groupId);
pmphGroupMember.setIsDeleted(false);
pmphGroupMemberDao.update(pmphGroupMember);
if (groupMember.getIsWriter()) {
writers.add(pmphGroupMember.getUserId());
} else {
pmphs.add(pmphGroupMember.getUserId());
}
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "该用户已在小组中,请勿重复添加");
}
}
}
// 向添加的小组成员发送消息
try {
if (!writers.isEmpty()) {
// 向作家用户发送消息
systemMessageService.sendWhenInviteJoinGroup(pmphUser.getRealname(), groupId, writers, (short) 2);
}
if (!pmphs.isEmpty()) {
// 向社内用户发送消息
systemMessageService.sendWhenInviteJoinGroup(pmphUser.getRealname(), groupId, pmphs, (short) 1);
}
} catch (IOException e) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "发送消息失败" + e.getMessage());
}
result = "SUCCESS";
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "参数为空");
}
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有此操作权限");
}
return result;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupServiceImpl method addPmphGroupOnGroup.
@Override
public PmphGroup addPmphGroupOnGroup(String file, PmphGroup pmphGroup, HttpServletRequest request) throws CheckedServiceException, IOException {
String sessionId = CookiesUtil.getSessionId(request);
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
if (ObjectUtil.notNull(pmphGroupDao.getPmphGroupByGroupName(pmphGroup.getGroupName()))) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "该小组名称已被使用,请重新输入");
}
// 未上传小组头像时,获取默认小组头像路径
String groupImage = RouteUtil.DEFAULT_GROUP_IMAGE;
if (!StringUtil.isEmpty(file)) {
groupImage = saveFileToMongoDB(file, request);
}
pmphGroup.setGroupImage(groupImage);
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);
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.OBJECT_NOT_FOUND, "添加小组失败");
}
return pmphGroup;
}
Aggregations