|
|
@@ -6,6 +6,8 @@ import com.zhongshu.card.client.model.base.SortParam;
|
|
|
import com.zhongshu.card.client.model.scene.RoleBindAllParam;
|
|
|
import com.zhongshu.card.client.model.scene.RoleBindSceneParam;
|
|
|
import com.zhongshu.card.client.model.scene.RoleSceneInfoModel;
|
|
|
+import com.zhongshu.card.client.model.scene.SceneInfoModel;
|
|
|
+import com.zhongshu.card.client.type.DataState;
|
|
|
import com.zhongshu.card.server.core.dao.org.RoleDao;
|
|
|
import com.zhongshu.card.server.core.dao.scene.ProjectSceneInfoDao;
|
|
|
import com.zhongshu.card.server.core.dao.scene.RoleSceneInfoDao;
|
|
|
@@ -13,10 +15,12 @@ import com.zhongshu.card.server.core.dao.scene.SceneInfoDao;
|
|
|
import com.zhongshu.card.server.core.domain.org.Role;
|
|
|
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.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -43,6 +47,9 @@ public class RoleSceneInfoService extends SuperService {
|
|
|
@Autowired
|
|
|
private RoleSceneInfoDao roleSceneInfoDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SceneInfoService sceneInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RoleDao roleDao;
|
|
|
|
|
|
@@ -116,6 +123,12 @@ public class RoleSceneInfoService extends SuperService {
|
|
|
return roleSceneInfo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询角色绑定的所有的数据
|
|
|
+ *
|
|
|
+ * @param roleId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public ResultContent<List<RoleSceneInfoModel>> list(String roleId) {
|
|
|
List<RoleSceneInfoModel> models = new ArrayList<>();
|
|
|
List<RoleSceneInfo> list = roleSceneInfoDao.findByRoleIdOrderBySortAsc(roleId);
|
|
|
@@ -125,6 +138,31 @@ public class RoleSceneInfoService extends SuperService {
|
|
|
return ResultContent.buildSuccess(models);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询角色可用的场景
|
|
|
+ *
|
|
|
+ * @param roleId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<SceneInfoModel> getAllEnableScenes(String roleId) {
|
|
|
+ List<SceneInfoModel> models = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(roleId)) {
|
|
|
+ List<RoleSceneInfo> list = roleSceneInfoDao.findByRoleIdOrderBySortAsc(roleId);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
public ResultContent<RoleSceneInfoModel> getDetailById(String id) {
|
|
|
RoleSceneInfo entity = roleSceneInfoDao.findTopById(id);
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|