use of com.bc.pmpheep.back.po.PmphGroup in project pmph by BCSquad.
the class PmphGroupServiceImpl method deletePmphGroupById.
/**
* @param PmphGroup
* @return 影响行数
* @throws CheckedServiceException
*/
@Override
public String deletePmphGroupById(PmphGroup pmphGroup, 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() || pmphGroupMemberService.isFounder(pmphGroup.getId(), sessionId)) {
// 超级管理员与小组创建者才有权利删除小组
if (null == pmphGroup.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键为空");
}
PmphGroup group = pmphGroupDao.getPmphGroupById(pmphGroup.getId());
// 获取该小组的文件
List<PmphGroupFile> pmphGroupFiles = pmphGroupFileService.listPmphGroupFileByGroupId(pmphGroup.getId());
Long[] ids = new Long[pmphGroupFiles.size()];
for (int i = 0; i < pmphGroupFiles.size(); i++) {
PmphGroupFile pmphGroupFile = pmphGroupFiles.get(i);
ids[i] = pmphGroupFile.getId();
}
// 删除小组
int num = pmphGroupDao.deletePmphGroupById(pmphGroup.getId());
if (num > 0) {
if (ArrayUtil.isNotEmpty(ids)) {
// 判断该小组是否有文件
// 删除小组文件
pmphGroupFileService.deletePmphGroupFileById(pmphGroup.getId(), ids, sessionId);
}
if (!RouteUtil.DEFAULT_GROUP_IMAGE.equals(group.getGroupImage())) {
// 解散小组时删除小组头像
fileService.remove(group.getGroupImage());
}
// 删除小组消息
pmphGroupMessageService.deletePmphGroupMessageByGroupId(pmphGroup.getId());
// 删除小组成员
result = pmphGroupMemberService.deletePmphGroupMemberOnGroup(pmphGroup.getId());
}
} 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 GroupController method pmphGroupFile.
/**
* 上传文件时的小组列表
*
* @author Mryang
* @param pmphGroup
* @return
* @createDate 2017年9月21日 下午4:02:57
*/
@RequestMapping(value = "/list/pmphGroupFile", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "上传文件时的小组列表")
@ResponseBody
public ResponseBean pmphGroupFile(HttpServletRequest request) {
PmphGroup pmphGroup = new PmphGroup();
String sessionId = CookiesUtil.getSessionId(request);
return new ResponseBean(pmphGroupService.listPmphGroupFile(pmphGroup, sessionId));
}
use of com.bc.pmpheep.back.po.PmphGroup in project pmph by BCSquad.
the class PmphGroupMemberServiceImpl method listPmphGroupMember.
@Override
public List<PmphGroupMemberVO> listPmphGroupMember(Long groupId, String sessionId) throws CheckedServiceException {
if (null == groupId || groupId == 0) {
List<PmphGroupListVO> myPmphGroupListVOList = pmphGroupService.listPmphGroup(new PmphGroup(), sessionId);
if (null == myPmphGroupListVOList || myPmphGroupListVOList.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "你没有小组!");
}
// 初始化页面时没有参数传入则直接调用初始化时小组排序的第一个小组id
groupId = myPmphGroupListVOList.get(0).getId();
}
List<PmphGroupMemberVO> list = pmphGroupMemberDao.listPmphGroupMember(groupId);
for (PmphGroupMemberVO pmphGroupMemberVO : list) {
if (pmphGroupMemberVO.getIsWriter()) {
pmphGroupMemberVO.setAvatar(RouteUtil.userAvatar(writerUserService.get(pmphGroupMemberVO.getUserId()).getAvatar()));
pmphGroupMemberVO.setUserType(Const.SENDER_TYPE_2);
} else {
pmphGroupMemberVO.setAvatar(RouteUtil.userAvatar(pmphUserService.get(pmphGroupMemberVO.getUserId()).getAvatar()));
pmphGroupMemberVO.setUserType(Const.SENDER_TYPE_1);
}
}
return list;
}
Aggregations