use of com.bc.pmpheep.back.plugin.PageParameter in project pmph by BCSquad.
the class TextbookServiceImpl method listBookPosition.
@Override
public PageResult<BookPositionVO> listBookPosition(Integer pageNumber, Integer pageSize, Integer state, String textBookIds, String bookName, Long materialId, String sessionId) {
// 验证用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
// 教材权限的检查
List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
Integer power = null;
// 系统管理员权限检查
for (PmphRole pmphRole : pmphRoles) {
if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName())) {
// 我是系统管理原
power = 1;
}
}
// 教材主任检查
Material material = materialService.getMaterialById(materialId);
if (null == power) {
if (null != material && null != material.getDirector() && pmphUser.getId().equals(material.getDirector())) {
// 我是教材的主任
power = 2;
}
}
// 教材项目编辑检查
if (null == power) {
List<MaterialProjectEditorVO> materialProjectEditors = materialProjectEditorService.listMaterialProjectEditors(materialId);
if (null != materialProjectEditors && materialProjectEditors.size() > 0) {
for (MaterialProjectEditorVO materialProjectEditor : materialProjectEditors) {
if (null != materialProjectEditor && null != materialProjectEditor.getEditorId() && materialProjectEditor.getEditorId().equals(pmphUser.getId())) {
// 我是教材的项目编辑
power = 3;
}
}
}
}
// 教材策划编辑检查
if (null == power) {
Integer num = materialService.getPlanningEditorSum(materialId, pmphUser.getId());
if (null != num && num > 0) {
// 我是教材的策划编辑编辑
power = 4;
}
}
if (null == power) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "该教材您没操作权限");
}
// 拼装复合参数
Map<String, Object> map = new HashMap<String, Object>();
// 教材id
map.put("materialId", materialId);
if (StringUtil.notEmpty(textBookIds)) {
Gson gson = new Gson();
List<Long> bookIds = gson.fromJson(textBookIds, new TypeToken<ArrayList<Long>>() {
}.getType());
if (null != bookIds && bookIds.size() > 0) {
// 书籍id
map.put("list", bookIds);
}
}
if (null != state && !state.equals(0)) {
// 书籍状态
map.put("state", state);
}
String bookNameTemp = StringUtil.toAllCheck(bookName);
if (null != bookNameTemp) {
// 书籍名称
map.put("bookName", bookNameTemp);
}
// 用户id
map.put("pmphUserId", pmphUser.getId());
// 用户id
map.put("power", power);
PageParameter<Map<String, Object>> pageParameter = new PageParameter<Map<String, Object>>(pageNumber, pageSize, map);
PageResult<BookPositionVO> pageResult = new PageResult<>();
// 获取总数
Integer total = textbookDao.listBookPositionTotal(pageParameter);
if (null != total && total > 0) {
List<BookPositionVO> rows = textbookDao.listBookPosition(pageParameter);
// 下面进行授权
for (BookPositionVO row : rows) {
String rowpower = "000000";
if (power == 1 || power == 2) {
// 管理员或者主任
rowpower = "11111111";
} else if (power == 3) {
// 教材项目编辑
// 因为项目编辑的权限不是全部 ,因此要检查我是不是这本书的策划编辑,如果是 ,这本书我的权利就是项目编辑+策划编辑的权利
Integer tempProjectPermission = material.getProjectPermission();
if (null != row && null != row.getPlanningEditor() && null != pmphUser.getId() && row.getPlanningEditor().intValue() == pmphUser.getId().intValue()) {
// 我又是策划编辑
tempProjectPermission = (tempProjectPermission | material.getPlanPermission());
}
rowpower = StringUtil.tentToBinary(tempProjectPermission);
} else if (power == 4) {
// 教材策划编辑
rowpower = StringUtil.tentToBinary(material.getPlanPermission());
}
// 把权限拿出来一个个判断
// 分配策划编辑的权限
String s1 = rowpower.substring(0, 1);
String s2 = rowpower.substring(1, 2);
String s3 = rowpower.substring(2, 3);
String s4 = rowpower.substring(3, 4);
String s5 = rowpower.substring(4, 5);
String s6 = rowpower.substring(5, 6);
String s7 = rowpower.substring(6, 7);
// qiangzhijiesu
String s8 = rowpower.substring(7, 8);
if (material.getIsForceEnd() || material.getIsAllTextbookPublished()) {
// 教材结束或者强制结束
s2 = "0";
s3 = "0";
s4 = "0";
s5 = "0";
s6 = "0";
} else if (row.getIsLocked() || row.getIsPublished()) {
// 书籍已经发布了或者确认了名单
s2 = (power == 1 || power == 2) ? s2 : "0";
s3 = (power == 1 || power == 2) ? s3 : "0";
s4 = (power == 1 || power == 2) ? s4 : "0";
s5 = "0";
}
rowpower = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8;
row.setMyPower(rowpower);
}
pageResult.setRows(rows);
}
pageResult.setTotal(total);
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
return pageResult;
}
use of com.bc.pmpheep.back.plugin.PageParameter in project pmph by BCSquad.
the class UserMessageServiceImpl method listMessage.
@Override
public PageResult<UserMessageVO> listMessage(PageParameter<UserMessageVO> pageParameter, String sessionId) throws CheckedServiceException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
if (ObjectUtil.isNull(pmphUser.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
// 如果是系统管理员,则查询所有,否则查询对应的消息
if (Const.FALSE == pmphUser.getIsAdmin()) {
List<Long> ids = new ArrayList<Long>();
// 如果是主任,获取主任所在部门下的所有用户
if (Const.TRUE == pmphUser.getIsDirector()) {
// 社内部门父级节点ID
Long parentId = 1L;
PmphDepartment pmphDepartment = pmphDepartmentService.getPmphDepartmentById(pmphUser.getDepartmentId());
// 如果是父级部门主任,则可以查看子级部门下的所有用户发送的消息
if (parentId.longValue() == pmphDepartment.getParentId().longValue()) {
PageParameter<PmphUserManagerVO> parameter = new PageParameter<>(1, 2000);
PmphUserManagerVO pmphUserManagerVO = new PmphUserManagerVO();
pmphUserManagerVO.setPath(pmphDepartment.getPath());
pmphUserManagerVO.setDepartmentId(pmphDepartment.getId());
parameter.setParameter(pmphUserManagerVO);
PageResult<PmphUserManagerVO> listPageResult = pmphUserService.getListPmphUser(parameter, null);
List<PmphUserManagerVO> listPmphUserManagerVOs = listPageResult.getRows();
for (PmphUserManagerVO pmManagerVO : listPmphUserManagerVOs) {
ids.add(pmManagerVO.getId());
}
} else {
// 如果是子级部门主任,则只可以查看子级部门下的用户发送的消息
List<PmphUser> pmphUsers = pmphUserService.listPmphUserByDepartmentId(pmphUser.getDepartmentId());
if (CollectionUtil.isNotEmpty(pmphUsers)) {
for (PmphUser user : pmphUsers) {
ids.add(user.getId());
}
}
}
} else {
ids.add(pmphUser.getId());
}
pageParameter.getParameter().setSenderIds(ids);
}
PageResult<UserMessageVO> pageResult = new PageResult<>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
Integer total = userMessageDao.getMessageTotal(pageParameter);
if (total > 0) {
List<UserMessageVO> list = userMessageDao.listMessage(pageParameter);
Message message;
for (UserMessageVO userMessageVO : list) {
message = messageService.get(userMessageVO.getMsgId());
if (ObjectUtil.notNull(message)) {
userMessageVO.setContent(message.getContent());
}
}
pageResult.setRows(list);
pageResult.setTotal(total);
}
return pageResult;
}
use of com.bc.pmpheep.back.plugin.PageParameter in project pmph by BCSquad.
the class BookController method list.
/**
* 功能描述:初始化/条件查询书籍信息
*
* @param pageSize
* 当页条数
* @param pageNumber
* 当前页数
* @param type
* 书籍类别
* @param name
* 书籍名称/ISBN
* @param isOnSale
* 是否上架
* @param isNew
* 是否新书
* @param isPromote
* 是否推荐
* @param path
* 书籍类别根路径
* @return
*/
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "初始化/条件查询书籍信息")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseBean list(Integer pageSize, Integer pageNumber, Long type, String name, Boolean isOnSale, Boolean isNew, Boolean isPromote, String path) {
PageParameter<BookVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
BookVO bookVO = new BookVO();
bookVO.setName(name);
bookVO.setIsNew(isNew);
bookVO.setPath(path);
bookVO.setType(type);
bookVO.setIsOnSale(isOnSale);
bookVO.setIsPromote(isPromote);
pageParameter.setParameter(bookVO);
return new ResponseBean(bookService.listBookVO(pageParameter));
}
use of com.bc.pmpheep.back.plugin.PageParameter in project pmph by BCSquad.
the class DecPositionController method schoolListChosen.
/**
* Description:加载学校统计结果(按当选数排序)
*
* @author:lyc
* @date:2017年12月1日下午6:50:23
* @param
* @return ResponseBean
*/
@ResponseBody
@RequestMapping(value = "/list/schoolListChosen", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "加载学校统计结果(按当选数排序)")
public ResponseBean schoolListChosen(Integer pageSize, Integer pageNumber, Long materialId, String schoolName) {
PageParameter<DeclarationResultSchoolVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
DeclarationResultSchoolVO declarationResultSchoolVO = new DeclarationResultSchoolVO();
declarationResultSchoolVO.setMaterialId(materialId);
declarationResultSchoolVO.setSchoolName(schoolName);
pageParameter.setParameter(declarationResultSchoolVO);
return new ResponseBean(decPositionService.listChosenDeclarationResultSchoolVOs(pageParameter));
}
use of com.bc.pmpheep.back.plugin.PageParameter in project pmph by BCSquad.
the class DecPositionController method bookList.
/**
* Description:加载书本统计结果
*
* @author:lyc
* @date:2017年12月1日下午6:50:46
* @param
* @return ResponseBean
*/
@ResponseBody
@RequestMapping(value = "/list/bookList", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "加载书本统计结果")
public ResponseBean bookList(Integer pageSize, Integer pageNumber, Long materialId, String bookName) {
PageParameter<DeclarationResultBookVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
DeclarationResultBookVO declarationResultBookVO = new DeclarationResultBookVO();
declarationResultBookVO.setMaterialId(materialId);
declarationResultBookVO.setBookName(bookName);
pageParameter.setParameter(declarationResultBookVO);
return new ResponseBean(decPositionService.listDeclarationResultBookVOs(pageParameter));
}
Aggregations