Search in sources :

Example 6 with PmphGroupMember

use of com.bc.pmpheep.back.po.PmphGroupMember 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());
    // 未上传小组头像时,获取默认小组头像路径
    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(pmphUser.getRealname());
        pmphGroupMemberService.addPmphGroupMember(pmphGroupMember);
        // 批量把前台传入的作家用户添加到该小组
        pmphGroupMemberService.addPmphGroupMemberOnGroup(pmphGroup.getId(), list, sessionId);
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.OBJECT_NOT_FOUND, "添加小组和成员失败");
    }
    return pmphGroup;
}
Also used : PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) PmphUser(com.bc.pmpheep.back.po.PmphUser) Textbook(com.bc.pmpheep.back.po.Textbook) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 7 with PmphGroupMember

use of com.bc.pmpheep.back.po.PmphGroupMember in project pmph by BCSquad.

the class GroupController method groupMember.

/**
 * 功能描述:添加小组成员
 *
 * @param pmphGroupMembers
 *            需要小组Id 成员Id 是否作家用户
 * @return 是否成功
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "添加小组成员")
@RequestMapping(value = "/add/groupMember", method = RequestMethod.POST)
public ResponseBean groupMember(Long groupId, String pmphGroupMembers, HttpServletRequest request) {
    Gson gson = new Gson();
    Type type = new TypeToken<ArrayList<PmphGroupMember>>() {
    }.getType();
    List<PmphGroupMember> list = gson.fromJson(pmphGroupMembers, type);
    String sessionId = CookiesUtil.getSessionId(request);
    return new ResponseBean(pmphGroupMemberService.addPmphGroupMembers(groupId, list));
}
Also used : Type(java.lang.reflect.Type) PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with PmphGroupMember

use of com.bc.pmpheep.back.po.PmphGroupMember in project pmph by BCSquad.

the class GroupController method identity.

/**
 * 功能描述:批量修改小组成员权限
 *
 * @param listPar
 *            成员id
 * @return 是否成功
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "批量修改小组成员权限")
@RequestMapping(value = "/update/identity", method = RequestMethod.PUT)
public ResponseBean identity(Long groupId, String pmphGroupMembers, HttpServletRequest request) {
    Gson gson = new Gson();
    Type type = new TypeToken<ArrayList<PmphGroupMember>>() {
    }.getType();
    List<PmphGroupMember> list = gson.fromJson(pmphGroupMembers, type);
    String sessionId = CookiesUtil.getSessionId(request);
    return new ResponseBean(pmphGroupMemberService.updateMemberIdentity(groupId, list, sessionId));
}
Also used : Type(java.lang.reflect.Type) PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with PmphGroupMember

use of com.bc.pmpheep.back.po.PmphGroupMember in project pmph by BCSquad.

the class GroupController method addEditorGroup.

/**
 * 功能描述:职位遴选页面新建小组
 *
 * @param textbookId
 * @param pmphGroupMembers
 * @param request
 * @return 是否成功
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "职位遴选页面新建小组")
@RequestMapping(value = "/addEditorGroup", method = RequestMethod.POST)
public ResponseBean addEditorGroup(Long textbookId, String pmphGroupMembers, HttpServletRequest request) {
    try {
        String sessionId = CookiesUtil.getSessionId(request);
        Gson gson = new Gson();
        Type type = new TypeToken<ArrayList<PmphGroupMember>>() {
        }.getType();
        List<PmphGroupMember> list = gson.fromJson(pmphGroupMembers, type);
        return new ResponseBean(pmphGroupService.addEditorSelcetionGroup(sessionId, list, textbookId));
    } catch (Exception e) {
        return new ResponseBean(e);
    }
}
Also used : Type(java.lang.reflect.Type) PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) IOException(java.io.IOException) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with PmphGroupMember

use of com.bc.pmpheep.back.po.PmphGroupMember in project pmph by BCSquad.

the class PmphGroupMemberServiceImpl method updateGroupMemberByIds.

@Override
public String updateGroupMemberByIds(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 (pmphUser.getIsAdmin() || currentUser.getIsFounder()) {
                // 只有小组创建者和超级管理员可以删除小组成员
                if (pmphGroupMemberDao.getPmphGroupMemberById(id).getIsFounder()) {
                    throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "小组创建者不能删除,请重新选择");
                }
                pmphGroupMemberDao.updateGroupMemberById(id);
            } else {
                // 管理员进入的方法
                if (currentUser.getIsAdmin() && (pmphGroupMember.getIsFounder() || pmphGroupMember.getIsAdmin())) {
                    throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "您无权限删除管理员,请重新选择");
                } else {
                    pmphGroupMemberDao.updateGroupMemberById(id);
                }
            }
        }
        result = "SUCCESS";
    }
    return result;
}
Also used : PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Aggregations

PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)13 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)10 PmphUser (com.bc.pmpheep.back.po.PmphUser)8 ArrayList (java.util.ArrayList)5 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)4 LogDetail (com.bc.pmpheep.annotation.LogDetail)3 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)3 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)3 Gson (com.google.gson.Gson)3 IOException (java.io.IOException)3 Type (java.lang.reflect.Type)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 Textbook (com.bc.pmpheep.back.po.Textbook)2 Material (com.bc.pmpheep.back.po.Material)1 MaterialProjectEditor (com.bc.pmpheep.back.po.MaterialProjectEditor)1 WriterUser (com.bc.pmpheep.back.po.WriterUser)1 TextbookDecVO (com.bc.pmpheep.back.vo.TextbookDecVO)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1