|
|
@@ -2,7 +2,9 @@ package com.zhongshu.card.server.core.service.scene;
|
|
|
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.zhongshu.card.client.model.base.SortParam;
|
|
|
+import com.zhongshu.card.client.model.org.role.RoleSimpleModel;
|
|
|
import com.zhongshu.card.client.model.scene.RoleBindAllParam;
|
|
|
import com.zhongshu.card.client.model.scene.RoleBindSceneParam;
|
|
|
import com.zhongshu.card.client.model.scene.RoleSceneInfoModel;
|
|
|
@@ -17,6 +19,7 @@ import com.zhongshu.card.server.core.domain.scene.ProjectSceneInfo;
|
|
|
import com.zhongshu.card.server.core.domain.scene.RoleSceneInfo;
|
|
|
import com.zhongshu.card.server.core.domain.scene.SceneInfo;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.service.user.RoleServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
@@ -53,6 +56,9 @@ public class RoleSceneInfoService extends SuperService {
|
|
|
@Autowired
|
|
|
private RoleDao roleDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RoleServiceImpl roleServiceImpl;
|
|
|
+
|
|
|
public ResultContent bindScene(RoleBindSceneParam param) {
|
|
|
ProjectSceneInfo entity = projectSceneInfoDao.findTopById(param.getId());
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
|
@@ -158,6 +164,33 @@ public class RoleSceneInfoService extends SuperService {
|
|
|
return models;
|
|
|
}
|
|
|
|
|
|
+ public List<SceneInfoModel> getUserAllEnableScenes() {
|
|
|
+ // 得到当前用户所有的角色
|
|
|
+ ResultContent<List<RoleSimpleModel>> content = roleServiceImpl.xcxGetCurrentRoles();
|
|
|
+ if (content.isSuccess()) {
|
|
|
+ List<RoleSimpleModel> roles = content.getContent();
|
|
|
+ if (ObjectUtils.isNotEmpty(roles)) {
|
|
|
+ List<SceneInfoModel> models = new ArrayList<>();
|
|
|
+ List<String> roleIds = roles.stream().map(it -> it.getId()).collect(Collectors.toUnmodifiableList());
|
|
|
+ List<RoleSceneInfo> list = roleSceneInfoDao.findByRoleIdInOrderBySortAsc(roleIds);
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ list.stream().forEach(it -> {
|
|
|
+ SceneInfo sceneInfo = it.getSceneInfo();
|
|
|
+ ProjectSceneInfo projectSceneInfo = it.getProjectSceneInfo();
|
|
|
+ if (ObjectUtils.isNotEmpty(projectSceneInfo) && ObjectUtils.isNotEmpty(sceneInfo)) {
|
|
|
+ if (projectSceneInfo.getState() == DataState.Enable && sceneInfo.getState() == DataState.Enable) {
|
|
|
+ models.add(sceneInfoService.toModel(sceneInfo));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 去重
|
|
|
+ return models.stream().distinct().collect(Collectors.toUnmodifiableList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Lists.newArrayList();
|
|
|
+ }
|
|
|
+
|
|
|
public ResultContent<RoleSceneInfoModel> getDetailById(String id) {
|
|
|
RoleSceneInfo entity = roleSceneInfoDao.findTopById(id);
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|