use of com.bc.pmpheep.back.vo.MaterialProjectEditorVO 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.vo.MaterialProjectEditorVO in project pmph by BCSquad.
the class MaterialProjectEditorServiceTest method testListMaterialProjectEditors.
@Test
@Rollback(Const.ISROLLBACK)
public void testListMaterialProjectEditors() {
MaterialProjectEditor materialProjectEditor1 = new MaterialProjectEditor(1L, 1L);
materialProjectEditorService.addMaterialProjectEditor(materialProjectEditor1);
materialProjectEditorService.addMaterialProjectEditor(materialProjectEditor1);
// 根据教材id批量查找项目编辑
List<MaterialProjectEditorVO> materialProjectEditor = materialProjectEditorService.listMaterialProjectEditors(128L);
Assert.assertTrue("listMaterialProjectEditors查询失败", materialProjectEditor.size() > 0);
List<MaterialProjectEditorVO> materialProjectEditor2 = materialProjectEditorService.listMaterialProjectEditors(12345678987654L);
Assert.assertTrue("listMaterialProjectEditors查询失败", materialProjectEditor2 != null);
}
Aggregations