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;
}
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));
}
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));
}
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);
}
}
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;
}
Aggregations