Search in sources :

Example 16 with PmphGroup

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;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphGroupFile(com.bc.pmpheep.back.po.PmphGroupFile) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 17 with PmphGroup

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));
}
Also used : PmphGroup(com.bc.pmpheep.back.po.PmphGroup) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 18 with PmphGroup

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;
}
Also used : PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PmphGroupListVO(com.bc.pmpheep.back.vo.PmphGroupListVO)

Aggregations

PmphGroup (com.bc.pmpheep.back.po.PmphGroup)18 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)13 PmphUser (com.bc.pmpheep.back.po.PmphUser)7 ArrayList (java.util.ArrayList)7 Textbook (com.bc.pmpheep.back.po.Textbook)4 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)4 PageResult (com.bc.pmpheep.back.plugin.PageResult)3 Material (com.bc.pmpheep.back.po.Material)3 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)3 UserMessage (com.bc.pmpheep.back.po.UserMessage)3 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)3 Message (com.bc.pmpheep.general.po.Message)3 HashMap (java.util.HashMap)3 LogDetail (com.bc.pmpheep.annotation.LogDetail)2 PmphGroupListVO (com.bc.pmpheep.back.vo.PmphGroupListVO)2 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)2 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2