|
|
@@ -1,7 +1,7 @@
|
|
|
package com.zhongshu.card.server.core.service.projectAbout;
|
|
|
|
|
|
-import com.github.microservice.auth.client.service.RoleService;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
+import com.zhongshu.card.client.model.org.role.RoleModel;
|
|
|
import com.zhongshu.card.client.model.projectAbout.projectCommon.ProjectCommonConfigModel;
|
|
|
import com.zhongshu.card.client.model.projectAbout.projectCommon.ProjectCommonConfigParam;
|
|
|
import com.zhongshu.card.client.model.projectAbout.projectCommon.ProjectCommonSuperParam;
|
|
|
@@ -16,10 +16,13 @@ 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;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 项目的 关联的物联网 ak sk 设置
|
|
|
@@ -55,6 +58,8 @@ public class ProjectCommonConfigService extends SuperService {
|
|
|
if (ObjectUtils.isEmpty(projectInfo)) {
|
|
|
return ResultContent.buildFail(String.format("项目oid不存在:%s", projectOid));
|
|
|
}
|
|
|
+ // 数据检查
|
|
|
+
|
|
|
ProjectCommonConfig entity = commonConfigDao.findTopByProjectOid(projectOid);
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
|
entity = new ProjectCommonConfig();
|
|
|
@@ -82,12 +87,26 @@ public class ProjectCommonConfigService extends SuperService {
|
|
|
* @return
|
|
|
*/
|
|
|
public ResultContent<ProjectCommonConfigModel> getInfo(String projectOid) {
|
|
|
+ return ResultContent.buildSuccess(getInfoByOid(projectOid));
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<ProjectCommonConfigModel> getXcxInfo(String projectOid) {
|
|
|
+ if (StringUtils.isEmpty(projectOid)) {
|
|
|
+ projectOid = getCurrentProjectOid();
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(getInfoByOid(projectOid));
|
|
|
+ }
|
|
|
+
|
|
|
+ public ProjectCommonConfigModel getInfoByOid(String projectOid) {
|
|
|
+ if (StringUtils.isEmpty(projectOid)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
ProjectCommonConfig entity = commonConfigDao.findTopByProjectOid(projectOid);
|
|
|
ProjectCommonConfigModel model = null;
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
model = toModel(entity);
|
|
|
}
|
|
|
- return ResultContent.buildSuccess(model);
|
|
|
+ return model;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -157,10 +176,24 @@ public class ProjectCommonConfigService extends SuperService {
|
|
|
model = new ProjectCommonConfigModel();
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(entity.getRoleIds())) {
|
|
|
- List<Role> roles = roleDao.findByIdIn(entity.getRoleIds());
|
|
|
- model.setRoles(roleService.toModels(roles));
|
|
|
+ // 可选择角色
|
|
|
+ List<RoleModel> roleModels = new ArrayList<RoleModel>();
|
|
|
+ List<String> roleIds = new ArrayList<>();
|
|
|
+ if (entity.getIsAllowSelectRole() != null && entity.getIsAllowSelectRole()) {
|
|
|
+ roleIds = entity.getRoleIds();
|
|
|
+ if (ObjectUtils.isNotEmpty(entity.getRoleIds())) {
|
|
|
+ List<Role> roles = roleDao.findByIdIn(entity.getRoleIds());
|
|
|
+ model.setRoles(roleService.toModels(roles));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<Role> roles = roleService.getVisitorRoles(entity.getProjectOid());
|
|
|
+ if (ObjectUtils.isNotEmpty(roles)) {
|
|
|
+ roleModels = roleService.toModels(roles);
|
|
|
+ roleIds = roles.stream().map(Role::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
}
|
|
|
+ model.setRoles(roleModels);
|
|
|
+ model.setRoleIds(roleIds);
|
|
|
}
|
|
|
return model;
|
|
|
}
|