use of com.bc.pmpheep.service.exception.CheckedServiceException 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.service.exception.CheckedServiceException 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.service.exception.CheckedServiceException in project pmph by BCSquad.
the class PmphGroupMessageServiceImpl method listPmphGroupMessage.
@Override
public PageResult<PmphGroupMessageVO> listPmphGroupMessage(PageParameter<PmphGroupMessageVO> pageParameter) throws CheckedServiceException {
if (null == pageParameter.getParameter().getGroupId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组id为空");
}
if (null == pageParameter.getParameter().getGmtCreate()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "进入小组时间为空");
}
PageResult<PmphGroupMessageVO> pageResult = new PageResult<>();
int total = pmphGroupMessageDao.getPmphGroupMessageTotal(pageParameter);
if (total > 0) {
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
List<PmphGroupMessageVO> list = pmphGroupMessageDao.listPmphGroupMessage(pageParameter);
Collections.reverse(list);
for (PmphGroupMessageVO pmphGroupMessageVO : list) {
if (0 != pmphGroupMessageVO.getMemberId()) {
if (null == pmphGroupMessageVO.getIsWriter()) {
pmphGroupMessageVO.setAvatar(RouteUtil.DEFAULT_USER_AVATAR);
pmphGroupMessageVO.setMemberName("该人员已经退出小组");
} else {
if (pmphGroupMessageVO.getIsWriter()) {
pmphGroupMessageVO.setUserType(Const.SENDER_TYPE_2);
pmphGroupMessageVO.setAvatar(RouteUtil.userAvatar(writerUserService.get(pmphGroupMessageVO.getUserId()).getAvatar()));
} else {
pmphGroupMessageVO.setAvatar(RouteUtil.userAvatar(pmphUserService.get(pmphGroupMessageVO.getUserId()).getAvatar()));
pmphGroupMessageVO.setUserType(Const.SENDER_TYPE_1);
}
}
} else {
pmphGroupMessageVO.setUserId(0L);
pmphGroupMessageVO.setUserType(Const.SENDER_TYPE_0);
}
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
return pageResult;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class PmphGroupMessageServiceImpl method deletePmphGroupMessageById.
/**
* @param id
* @return 影响行数
* @throws CheckedServiceException
* @throws IOException
*/
@Override
public String deletePmphGroupMessageById(Long id, String sessionId) throws CheckedServiceException, IOException {
if (null == id) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键为空");
}
PmphGroupMessage pmphGroupMessage = pmphGroupMessageDao.getPmphGroupMessageById(id);
Long groupId = pmphGroupMessage.getGroupId();
int num = pmphGroupMessageDao.deletePmphGroupMessageById(id);
if (num > 0) {
// 删除成功 撤销消息
WebScocketMessage webScocketMessage = new WebScocketMessage();
webScocketMessage.setId(String.valueOf(id));
webScocketMessage.setGroupId(groupId);
webScocketMessage.setSendType(Const.SEND_MSG_TYPE_1);
List<PmphGroupMemberVO> list = pmphGroupMemberService.listPmphGroupMember(groupId, sessionId);
List<String> ids = new ArrayList<String>();
for (PmphGroupMemberVO groupMemberVO : list) {
String tempId = (groupMemberVO.getIsWriter() ? "2" : "1") + "_" + groupMemberVO.getUserId();
ids.add(tempId);
}
handler.sendWebSocketMessageToUser(ids, webScocketMessage);
}
return "SUCCESS";
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class PmphGroupServiceImpl method updatePmphGroup.
/**
* @param PmphGroup
* @return 影响行数
* @throws CheckedServiceException
* @throws IOException
* @update Mryang 2017.10.13 15:20
*/
@Override
public Integer updatePmphGroup(MultipartFile file, PmphGroup pmphGroup) throws CheckedServiceException, IOException {
if (null == pmphGroup) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "参数对象为空");
}
if (null == pmphGroup.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键为空");
}
// 修改小组图片
if (null != file) {
Long id = pmphGroup.getId();
PmphGroup pmphGroupOld = getPmphGroupById(id);
if (null != pmphGroupOld && null != pmphGroupOld.getGroupImage() && !"".equals(pmphGroupOld.getGroupImage())) {
fileService.remove(pmphGroupOld.getGroupImage());
}
String newGroupImage = fileService.save(file, ImageType.GROUP_AVATAR, pmphGroup.getId());
pmphGroup.setGroupImage(newGroupImage);
}
return pmphGroupDao.updatePmphGroup(pmphGroup);
}
Aggregations