Commit 495ec7e1 by 陈健智

非人工项目方案增加编辑权限限制

parent 1aad1048
...@@ -69,12 +69,17 @@ public class UserRole { ...@@ -69,12 +69,17 @@ public class UserRole {
*/ */
private Integer searchWholeRange; private Integer searchWholeRange;
/**
* 方案设置参数,仅非人工项目(1:开启,2:关闭),默认值为:1
*/
private Integer planConfiguration;
public void setRoleId(Integer roleId) { public void setRoleId(Integer roleId) {
this.roleId = roleId; this.roleId = roleId;
this.key = Tools.concat(projectId, roleId); this.key = Tools.concat(projectId, roleId);
} }
public UserRole(String projectId, int roleId, Long expiredTime, Integer exportAmount, int rights, int range) { public UserRole(String projectId, int roleId, Long expiredTime, Integer exportAmount, Integer rights, Integer range, Integer planConfiguration) {
this.projectId = projectId; this.projectId = projectId;
this.roleId = roleId; this.roleId = roleId;
this.expiredTime = expiredTime; this.expiredTime = expiredTime;
...@@ -82,6 +87,7 @@ public class UserRole { ...@@ -82,6 +87,7 @@ public class UserRole {
this.key = Tools.concat(projectId, roleId); this.key = Tools.concat(projectId, roleId);
this.searchWholeRights = rights; this.searchWholeRights = rights;
this.searchWholeRange = range; this.searchWholeRange = range;
this.planConfiguration = planConfiguration;
} }
public static UserRole createFromUserDto(UserDTO userDTO) { public static UserRole createFromUserDto(UserDTO userDTO) {
...@@ -100,10 +106,10 @@ public class UserRole { ...@@ -100,10 +106,10 @@ public class UserRole {
calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.SECOND, 59);
expiredTime = calendar.getTime().getTime(); expiredTime = calendar.getTime().getTime();
} }
return new UserRole(userDTO.getProjectId(), userDTO.getRoleId(), expiredTime, exportAmount, userDTO.getSearchWholeRights(), userDTO.getSearchWholeRange()); return new UserRole(userDTO.getProjectId(), userDTO.getRoleId(), expiredTime, exportAmount, userDTO.getSearchWholeRights(), userDTO.getSearchWholeRange(), userDTO.getPlanConfiguration());
} }
public static UserRole defaultUserRole(Date now) { public static UserRole defaultUserRole(Date now) {
return new UserRole(DEFAULT_PROJECT_ID, DEFAULT_ROLE_ID, DateUtils.addDays(now, 30).getTime(), DEFAULT_EXPORT_LIMIT, 1, 1); return new UserRole(DEFAULT_PROJECT_ID, DEFAULT_ROLE_ID, DateUtils.addDays(now, 30).getTime(), DEFAULT_EXPORT_LIMIT, 1, 1, null);
} }
} }
...@@ -85,4 +85,10 @@ public class UserDTO { ...@@ -85,4 +85,10 @@ public class UserDTO {
*/ */
@ApiModelProperty("全网搜索数据跨度") @ApiModelProperty("全网搜索数据跨度")
private Integer searchWholeRange; private Integer searchWholeRange;
/**
* 方案设置参数(1:开启,2:关闭),默认值为:1
*/
@ApiModelProperty("方案设置参数(1:开启,2:关闭)")
private Integer planConfiguration;
} }
...@@ -790,6 +790,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -790,6 +790,7 @@ public class ProjectServiceImpl implements ProjectService {
List<Project> lists; List<Project> lists;
Map<String, Date> roleExpired = new HashMap<>(); Map<String, Date> roleExpired = new HashMap<>();
Map<String, Pair<Integer, Integer>> searchWholeInfo = new HashMap<>(); Map<String, Pair<Integer, Integer>> searchWholeInfo = new HashMap<>();
Map<String, Integer> planConfigurationInfo = new HashMap<>();
if (user.isSuperAdmin()) { if (user.isSuperAdmin()) {
lists = projectDao.findListByKeywordFuzz(null, null); lists = projectDao.findListByKeywordFuzz(null, null);
} else { } else {
...@@ -801,6 +802,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -801,6 +802,7 @@ public class ProjectServiceImpl implements ProjectService {
lists.add(projectDao.findOneById(userRole.getProjectId())); lists.add(projectDao.findOneById(userRole.getProjectId()));
roleExpired.put(userRole.getProjectId(), null == userRole.getExpiredTime() ? null : new Date(userRole.getExpiredTime())); roleExpired.put(userRole.getProjectId(), null == userRole.getExpiredTime() ? null : new Date(userRole.getExpiredTime()));
searchWholeInfo.put(userRole.getProjectId(), Pair.of(userRole.getSearchWholeRights(), userRole.getSearchWholeRange())); searchWholeInfo.put(userRole.getProjectId(), Pair.of(userRole.getSearchWholeRights(), userRole.getSearchWholeRange()));
planConfigurationInfo.put(userRole.getProjectId(), userRole.getPlanConfiguration());
} }
}); });
} }
...@@ -812,7 +814,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -812,7 +814,7 @@ public class ProjectServiceImpl implements ProjectService {
json.put("extraProjectName", project.getExtraProjectName()); json.put("extraProjectName", project.getExtraProjectName());
json.put("group", project.getBrandLinkedGroup()); json.put("group", project.getBrandLinkedGroup());
json.put("avatarUrl", project.getAvatarUrl()); json.put("avatarUrl", project.getAvatarUrl());
json.put("permission", getPermissionList(project)); json.put("permission", getPermissionList(project, planConfigurationInfo, user.isSuperAdmin()));
json.put("isManual", project.isManual()); json.put("isManual", project.isManual());
if (!project.isManual()) { if (!project.isManual()) {
json.put("markModel", project.getMarkModel()); json.put("markModel", project.getMarkModel());
...@@ -859,7 +861,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -859,7 +861,7 @@ public class ProjectServiceImpl implements ProjectService {
* @param project * @param project
* @return * @return
*/ */
private List<Map<String, Object>> getPermissionList(Project project) { private List<Map<String, Object>> getPermissionList(Project project, Map<String, Integer> planConfigurationInfo, boolean isSuperAdmin) {
List<Map<String, Object>> permissionList = new ArrayList<>(); List<Map<String, Object>> permissionList = new ArrayList<>();
// 定制化模块权限 // 定制化模块权限
List<String> moduleShowList = project.getModuleShowList(); List<String> moduleShowList = project.getModuleShowList();
...@@ -872,6 +874,20 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -872,6 +874,20 @@ public class ProjectServiceImpl implements ProjectService {
channelPermission.put("positiveChannel", Objects.nonNull(jsonObject) && Objects.nonNull(jsonObject.getLong(EmotionEnum.POSITIVE.getName())) && 0 != jsonObject.getLong(EmotionEnum.POSITIVE.getName())); channelPermission.put("positiveChannel", Objects.nonNull(jsonObject) && Objects.nonNull(jsonObject.getLong(EmotionEnum.POSITIVE.getName())) && 0 != jsonObject.getLong(EmotionEnum.POSITIVE.getName()));
channelPermission.put("negativeChannel", Objects.nonNull(jsonObject) && Objects.nonNull(jsonObject.getLong(EmotionEnum.NEGATIVE.getName())) && 0 != jsonObject.getLong(EmotionEnum.NEGATIVE.getName())); channelPermission.put("negativeChannel", Objects.nonNull(jsonObject) && Objects.nonNull(jsonObject.getLong(EmotionEnum.NEGATIVE.getName())) && 0 != jsonObject.getLong(EmotionEnum.NEGATIVE.getName()));
permissionList.add(channelPermission); permissionList.add(channelPermission);
// 非人工项目方案编辑权限
if (!project.isManual()) {
if (isSuperAdmin) {
Map<String, Object> planConfigurationPermission = new HashMap<>();
planConfigurationPermission.put("planConfiguration", 1);
permissionList.add(planConfigurationPermission);
} else {
if (Objects.nonNull(planConfigurationInfo.get(project.getId()))) {
Map<String, Object> planConfigurationPermission = new HashMap<>();
planConfigurationPermission.put("planConfiguration", planConfigurationInfo.get(project.getId()));
permissionList.add(planConfigurationPermission);
}
}
}
return permissionList; return permissionList;
} }
......
...@@ -239,6 +239,10 @@ public class UserServiceImpl implements UserService { ...@@ -239,6 +239,10 @@ public class UserServiceImpl implements UserService {
OptionalInt.of(userDTO.getSearchWholeRights()).ifPresent(userRole::setSearchWholeRights); OptionalInt.of(userDTO.getSearchWholeRights()).ifPresent(userRole::setSearchWholeRights);
OptionalInt.of(userDTO.getSearchWholeRange()).ifPresent(userRole::setSearchWholeRange); OptionalInt.of(userDTO.getSearchWholeRange()).ifPresent(userRole::setSearchWholeRange);
} }
// 方案编辑权限
if (!GlobalPojo.PROJECT_MAP.get(userRole.getProjectId()).isManual()){
userRole.setPlanConfiguration(userDTO.getPlanConfiguration());
}
userDao.updateOneByIdWithField(userDTO.getId(), new Update().set("roles", roles)); userDao.updateOneByIdWithField(userDTO.getId(), new Update().set("roles", roles));
}); });
Optional.of(userDTO.getNickname()).ifPresent(nickName -> userDao.updateOneByIdWithField(userDTO.getId(), new Update().set("nickname", nickName))); Optional.of(userDTO.getNickname()).ifPresent(nickName -> userDao.updateOneByIdWithField(userDTO.getId(), new Update().set("nickname", nickName)));
...@@ -332,8 +336,13 @@ public class UserServiceImpl implements UserService { ...@@ -332,8 +336,13 @@ public class UserServiceImpl implements UserService {
if (RoleEnum.CUSTOMER.getState() == userProject.getRoleId()) { if (RoleEnum.CUSTOMER.getState() == userProject.getRoleId()) {
expiredTime = userProject.getExpiredTime(); expiredTime = userProject.getExpiredTime();
} }
// 方案编辑权限默认
Integer planConfiguration = null;
if (!project.isManual()){
planConfiguration = 1;
}
// 给默认全网搜权益 // 给默认全网搜权益
userRoles.add(new UserRole(project.getId(), userProject.getRoleId(), expiredTime, userProject.getExportAmount(), 1, 1)); userRoles.add(new UserRole(project.getId(), userProject.getRoleId(), expiredTime, userProject.getExportAmount(), 1, 1, planConfiguration));
hit.set(true); hit.set(true);
} }
}); });
...@@ -462,6 +471,7 @@ public class UserServiceImpl implements UserService { ...@@ -462,6 +471,7 @@ public class UserServiceImpl implements UserService {
jsonObject.put("key", role.getKey()); jsonObject.put("key", role.getKey());
jsonObject.put("searchWholeRights", role.getSearchWholeRights()); jsonObject.put("searchWholeRights", role.getSearchWholeRights());
jsonObject.put("searchWholeRange", role.getSearchWholeRange()); jsonObject.put("searchWholeRange", role.getSearchWholeRange());
jsonObject.put("planConfiguration", role.getPlanConfiguration());
resList.add(jsonObject); resList.add(jsonObject);
} }
} }
...@@ -549,6 +559,7 @@ public class UserServiceImpl implements UserService { ...@@ -549,6 +559,7 @@ public class UserServiceImpl implements UserService {
json.put("expiredTime", role.getExpiredTime()); json.put("expiredTime", role.getExpiredTime());
json.put("searchWholeRights", role.getSearchWholeRights()); json.put("searchWholeRights", role.getSearchWholeRights());
json.put("searchWholeRange", role.getSearchWholeRange()); json.put("searchWholeRange", role.getSearchWholeRange());
json.put("planConfiguration", role.getPlanConfiguration());
return json; return json;
}).filter(Objects::nonNull).collect(Collectors.toList()); }).filter(Objects::nonNull).collect(Collectors.toList());
jsonObject.put("roles", roles); jsonObject.put("roles", roles);
...@@ -626,6 +637,7 @@ public class UserServiceImpl implements UserService { ...@@ -626,6 +637,7 @@ public class UserServiceImpl implements UserService {
result.put("exportAmount", userRole.getExportAmount()); result.put("exportAmount", userRole.getExportAmount());
result.put("searchWholeRights", userRole.getSearchWholeRights()); result.put("searchWholeRights", userRole.getSearchWholeRights());
result.put("searchWholeRange", userRole.getSearchWholeRange()); result.put("searchWholeRange", userRole.getSearchWholeRange());
result.put("planConfiguration", userRole.getPlanConfiguration());
}); });
return result; return result;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment