use of com.bc.pmpheep.back.po.PmphGroup in project pmph by BCSquad.
the class MaterialServiceImpl method updateMaterial.
@Override
public String updateMaterial(Long id, String sessionId) throws CheckedServiceException {
Material material = materialDao.getMaterialById(id);
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (pmphUser.getIsAdmin() || pmphUser.getId().equals(material.getDirector()) || pmphUser.getId().equals(material.getFounderId())) {
List<Textbook> list = textbookService.getTextbookByMaterialId(id);
for (Textbook textbook : list) {
PmphGroup group = pmphGroupService.getPmphGroupByTextbookId(textbook.getId());
if (ObjectUtil.notNull(group)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "您在" + textbook.getTextbookName() + "书籍下还有未解散的小组,请先解散小组");
}
}
material = new Material();
material.setId(id);
material.setIsDeleted(true);
materialDao.updateMaterial(material);
cmsContentService.updateCmsContentByMaterialId(id);
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "您没有删除教材" + material.getMaterialName() + "的权限");
}
return "SUCCESS";
}
use of com.bc.pmpheep.back.po.PmphGroup in project pmph by BCSquad.
the class SystemMessageService method sendWhenInviteJoinGroup.
/**
* 任意用户被邀请进入小组 向被邀请人发出
*
* @author Mryang
* @createDate 2017年11月17日 下午2:16:36
* @param inviterName
* 邀请人名字
* @param groupId
* 小组id
* @param invitedPersonIds
* 被邀请人ids
* @param invitedPersonType
* 被邀请人类型: 1=社内用户/2=作家/3=机构用户
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenInviteJoinGroup(String inviterName, Long groupId, List<Long> invitedPersonIds, short invitedPersonType) throws CheckedServiceException, IOException {
if (StringUtils.isEmpty(inviterName)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "邀请人为空");
}
if (null == invitedPersonIds || invitedPersonIds.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "被邀请人为空");
}
// 获取小组
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
if (null == pmphGroup) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组不存在");
}
String msgContent = "您被[<font color='red'>" + inviterName + "</font>]邀请加入[<font color='red'>" + pmphGroup.getGroupName() + "]</font>小组";
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 组装消息和消息对象
List<UserMessage> userMessageList = new ArrayList<UserMessage>(invitedPersonIds.size());
List<String> userIds = new ArrayList<String>(invitedPersonIds.size());
for (Long id : invitedPersonIds) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), id, invitedPersonType, null);
userMessageList.add(userMessage);
userIds.add(invitedPersonType + "_" + id);
}
// 发送消息
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
use of com.bc.pmpheep.back.po.PmphGroup in project pmph by BCSquad.
the class GroupController method pmphGroup.
/**
* 根据小组名称模糊查询获取当前用户的小组
*
* @author Mryang
* @param pmphGroup
* @return
* @createDate 2017年9月21日 下午4:02:57
*/
@RequestMapping(value = "/list/pmphGroup", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "根据小组名称模糊查询获取当前用户的小组")
@ResponseBody
public ResponseBean pmphGroup(@RequestParam(name = "groupName", defaultValue = "") String groupName, HttpServletRequest request) {
/*
* --------- 以下是正确的示例 ---------
*
* 在ResponseBean初始化时,通过ResponseBeanAop对其构造函数进行切面编程,
* 因此返回时<务必>要使用ResponseBean的构造函数即 new ResponseBean(anything)
*/
PmphGroup pmphGroup = new PmphGroup();
if (!StringUtil.isEmpty(groupName)) {
pmphGroup.setGroupName(groupName.trim());
}
String sessionId = CookiesUtil.getSessionId(request);
return new ResponseBean(pmphGroupService.listPmphGroup(pmphGroup, sessionId));
}
use of com.bc.pmpheep.back.po.PmphGroup 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());
List<Long> groupUserIdNotWriterList = new ArrayList<Long>(pmphGroupMembers.size());
for (PmphGroupMember pmphGroupMember : pmphGroupMembers) {
if (pmphGroupMember.getIsWriter()) {
groupUserIdList.add(pmphGroupMember.getUserId());
} else {
groupUserIdNotWriterList.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, textbookDecVO.getRealname()));
}
}
if (!ObjectUtil.isNull(textbook.getPlanningEditor()) && !groupUserIdNotWriterList.contains(textbook.getPlanningEditor())) {
list.add(new PmphGroupMember(textbook.getPlanningEditor(), Const.FALSE, textbook.getMaterialId(), textbookId, textbook.getRealname()));
}
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.PmphGroup in project pmph by BCSquad.
the class PmphGroupServiceImpl method addEditorSelcetionGroup.
@Override
public PmphGroup addEditorSelcetionGroup(String sessionId, List<PmphGroupMember> list, Long textbookId) throws CheckedServiceException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
if (list.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "成员名单为空,更新失败");
}
Textbook textbook = textbookService.getTextbookById(textbookId);
list.get(0).setTextbookId(textbookId);
list.get(0).setMaterialId(textbook.getMaterialId());
/*if(ObjectUtil.isNull(textbook.getPlanningEditor())){
PmphGroupMember pmphGroupMember = new PmphGroupMember();
pmphGroupMember.setUserId(textbook.getPlanningEditor());
pmphGroupMember.setIsWriter(false);
list.add(pmphGroupMember);
}*/
// 未上传小组头像时,获取默认小组头像路径
String groupImage = RouteUtil.DEFAULT_GROUP_IMAGE;
PmphGroup pmphGroup = new PmphGroup();
// 查询小组名称是否已存在 不存在直接用书名
if (ObjectUtil.isNull(pmphGroupDao.getPmphGroupByGroupName(textbook.getTextbookName()))) {
pmphGroup.setGroupName(textbook.getTextbookName());
} else {
// 存在则用书名加当前小组总数进行区分
Long count = pmphGroupDao.getPmphGroupCount();
pmphGroup.setGroupName(textbook.getTextbookName() + count);
}
pmphGroup.setGroupImage(groupImage);
pmphGroup.setBookId(textbookId);
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(StringUtil.isEmpty(pmphUser.getRealname()) ? pmphUser.getUsername() : pmphUser.getRealname());
pmphGroupMemberService.addPmphGroupMember(pmphGroupMember);
// 新增小组成员--策划编辑
if (!ObjectUtil.isNull(textbook.getPlanningEditor())) {
pmphGroupMember.setGroupId(pmphGroup.getId());
pmphGroupMember.setUserId(textbook.getPlanningEditor());
pmphGroupMember.setIsFounder(false);
pmphGroupMember.setIsWriter(false);
pmphGroupMember.setDisplayName(textbook.getRealname());
pmphGroupMemberService.addPmphGroupMember(pmphGroupMember);
}
// 批量把前台传入的作家用户添加到该小组
pmphGroupMemberService.addPmphGroupMemberOnGroup(pmphGroup.getId(), list, sessionId);
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.OBJECT_NOT_FOUND, "添加小组和成员失败");
}
return pmphGroup;
}
Aggregations