|
|
@@ -6,11 +6,9 @@ import com.github.microservice.net.ResultMessage;
|
|
|
import com.zhongshu.card.client.model.scene.ProjectBindSceneParam;
|
|
|
import com.zhongshu.card.client.model.scene.ProjectSceneInfoModel;
|
|
|
import com.zhongshu.card.client.model.scene.ProjectSceneInfoSearch;
|
|
|
-import com.zhongshu.card.client.model.scene.RoleBindAllParam;
|
|
|
import com.zhongshu.card.client.type.DataState;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
import com.zhongshu.card.server.core.dao.scene.ProjectSceneInfoDao;
|
|
|
-import com.zhongshu.card.server.core.dao.scene.RoleSceneInfoDao;
|
|
|
import com.zhongshu.card.server.core.dao.scene.SceneInfoDao;
|
|
|
import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
import com.zhongshu.card.server.core.domain.scene.ProjectSceneInfo;
|
|
|
@@ -26,7 +24,9 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
@@ -64,20 +64,57 @@ public class ProjectSceneInfoService extends SuperService {
|
|
|
if (ObjectUtils.isEmpty(organization)) {
|
|
|
return ResultContent.buildFail("项目不存在");
|
|
|
}
|
|
|
- ProjectSceneInfo projectSceneInfo = projectSceneInfoDao.findTopBySceneInfoAndProjectOid(entity, param.getProjectOid());
|
|
|
+ ProjectSceneInfo projectSceneInfo = buildProjectScene(entity, organization);
|
|
|
if (ObjectUtils.isNotEmpty(projectSceneInfo)) {
|
|
|
- return ResultContent.buildFail(String.format("项目已存在场景:%s", entity.getName()));
|
|
|
+ projectSceneInfoDao.save(projectSceneInfo);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 绑定多个
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent bindScenes(ProjectBindSceneParam param) {
|
|
|
+ List<String> ids = param.getIds();
|
|
|
+ if (ObjectUtils.isEmpty(ids)) {
|
|
|
+ return ResultContent.buildFail("ids不能为空");
|
|
|
+ }
|
|
|
+ Organization organization = organizationDao.findTopByOid(param.getProjectOid());
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ return ResultContent.buildFail("项目不存在");
|
|
|
+ }
|
|
|
+ List<ProjectSceneInfo> list = new ArrayList<>();
|
|
|
+ for (String id : ids) {
|
|
|
+ SceneInfo entity = sceneInfoDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ ProjectSceneInfo projectSceneInfo = buildProjectScene(entity, organization);
|
|
|
+ if (ObjectUtils.isEmpty(projectSceneInfo)) {
|
|
|
+ list.add(projectSceneInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ projectSceneInfoDao.saveAll(list);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ private ProjectSceneInfo buildProjectScene(SceneInfo entity, Organization projectInfo) {
|
|
|
+ ProjectSceneInfo projectSceneInfo = projectSceneInfoDao.findTopBySceneInfoAndProjectOid(entity, projectInfo.getOid());
|
|
|
+ if (ObjectUtils.isEmpty(projectSceneInfo)) {
|
|
|
+ projectSceneInfo = new ProjectSceneInfo();
|
|
|
}
|
|
|
- projectSceneInfo = new ProjectSceneInfo();
|
|
|
projectSceneInfo.setSceneInfo(entity);
|
|
|
projectSceneInfo.setSceneInfoId(entity.getId());
|
|
|
projectSceneInfo.setName(entity.getName());
|
|
|
projectSceneInfo.setSceneType(entity.getSceneType());
|
|
|
projectSceneInfo.setSceneState(entity.getState());
|
|
|
-
|
|
|
projectSceneInfo.setState(entity.getState());
|
|
|
- projectSceneInfoDao.save(projectSceneInfo);
|
|
|
- return ResultContent.buildSuccess();
|
|
|
+ projectSceneInfo.setProjectOid(projectInfo.getOid());
|
|
|
+ return projectSceneInfo;
|
|
|
}
|
|
|
|
|
|
public ResultContent<Page<ProjectSceneInfoModel>> page(ProjectSceneInfoSearch param, Pageable pageable) {
|