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());
for (PmphGroupMember pmphGroupMember : pmphGroupMembers) {
groupUserIdList.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));
}
}
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 updatePmphGroup.
/**
* @param PmphGroup
* @return 影响行数
* @throws CheckedServiceException
* @throws IOException
* @update Mryang 2017.10.13 15:20
*/
@Override
public Integer updatePmphGroup(MultipartFile file, PmphGroup pmphGroup) throws CheckedServiceException, IOException {
if (null == pmphGroup) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "参数对象为空");
}
if (null == pmphGroup.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键为空");
}
// 修改小组图片
if (null != file) {
Long id = pmphGroup.getId();
PmphGroup pmphGroupOld = getPmphGroupById(id);
if (null != pmphGroupOld && null != pmphGroupOld.getGroupImage() && !"".equals(pmphGroupOld.getGroupImage())) {
fileService.remove(pmphGroupOld.getGroupImage());
}
String newGroupImage = fileService.save(file, ImageType.GROUP_AVATAR, pmphGroup.getId());
pmphGroup.setGroupImage(newGroupImage);
}
return pmphGroupDao.updatePmphGroup(pmphGroup);
}
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());
// 未上传小组头像时,获取默认小组头像路径
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.PmphGroup in project pmph by BCSquad.
the class PmphUserServiceImpl method getListPmphUser.
@Override
public PageResult<PmphUserManagerVO> getListPmphUser(PageParameter<PmphUserManagerVO> pageParameter, Long groupId) throws CheckedServiceException {
String name = pageParameter.getParameter().getName();
if (StringUtil.notEmpty(name)) {
pageParameter.getParameter().setName(name);
}
String path = pageParameter.getParameter().getPath();
Long departmentId = pageParameter.getParameter().getDepartmentId();
if (StringUtil.notEmpty(path) && ObjectUtil.notNull(departmentId)) {
pageParameter.getParameter().setPath(path + "-" + java.lang.String.valueOf(departmentId) + '-');
}
PageResult<PmphUserManagerVO> pageResult = new PageResult<>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
int total = pmphUserDao.getListPmphUserTotal(pageParameter);
if (total > 0) {
List<PmphUserManagerVO> list = pmphUserDao.getListPmphUser(pageParameter);
for (PmphUserManagerVO pmphUserManagerVO : list) {
List<PmphRoleVO> pmphRoles = pmphRoleDao.listPmphUserRoleByUserId(pmphUserManagerVO.getId());
pmphUserManagerVO.setPmphRoles(pmphRoles);
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
// 设置职位
if (null != pageResult.getRows() && pageResult.getRows().size() > 0 && null != groupId) {
// 清空职位
for (PmphUserManagerVO pmphUserManagerVO : pageResult.getRows()) {
pmphUserManagerVO.setPosition("无");
}
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
Long bookId = pmphGroup.getBookId();
if (null != bookId && bookId.intValue() > 0) {
Textbook textbook = textbookService.getTextbookById(bookId);
Material material = materialService.getMaterialById(textbook.getMaterialId());
List<MaterialProjectEditorVO> projects = materialProjectEditorService.listMaterialProjectEditors(textbook.getMaterialId());
for (PmphUserManagerVO pmphUserManagerVO : pageResult.getRows()) {
Long pmphUserId = pmphUserManagerVO.getId();
String posotion = null;
if (material.getDirector().intValue() == pmphUserId.intValue()) {
posotion = "主任";
}
if (null != projects && projects.size() > 0) {
for (MaterialProjectEditorVO item : projects) {
if (item.getEditorId().intValue() == pmphUserId.intValue()) {
posotion += (posotion == null) ? "项目编辑" : ",项目编辑";
break;
}
}
}
if (textbook.getPlanningEditor().intValue() == pmphUserId.intValue()) {
posotion += (posotion == null) ? "策划编辑" : ",策划编辑";
}
pmphUserManagerVO.setPosition(posotion == null ? "无" : posotion);
}
}
}
// 设置职位 end
return pageResult;
}
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));
}
Aggregations