|
|
@@ -3,7 +3,9 @@ package com.zhongshu.card.server.core.service.scene;
|
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
-import com.zhongshu.card.client.model.scene.*;
|
|
|
+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.type.DataState;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
import com.zhongshu.card.server.core.dao.scene.ProjectSceneInfoDao;
|
|
|
@@ -12,6 +14,7 @@ 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;
|
|
|
import com.zhongshu.card.server.core.domain.scene.SceneInfo;
|
|
|
+import com.zhongshu.card.server.core.service.base.CommonService;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -22,6 +25,9 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* @author TRX
|
|
|
* @date 2024/11/22
|
|
|
@@ -42,6 +48,15 @@ public class ProjectSceneInfoService extends SuperService {
|
|
|
@Autowired
|
|
|
private OrganizationDao organizationDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SceneInfoService sceneInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RoleSceneInfoService roleSceneInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CommonService commonService;
|
|
|
+
|
|
|
public ResultContent bindScene(ProjectBindSceneParam param) {
|
|
|
SceneInfo entity = sceneInfoDao.findTopById(param.getId());
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
|
@@ -61,7 +76,8 @@ public class ProjectSceneInfoService extends SuperService {
|
|
|
projectSceneInfo.setName(entity.getName());
|
|
|
projectSceneInfo.setSceneType(entity.getSceneType());
|
|
|
projectSceneInfo.setSceneState(entity.getState());
|
|
|
- projectSceneInfo.setState(DataState.Enable);
|
|
|
+
|
|
|
+ projectSceneInfo.setState(entity.getState());
|
|
|
projectSceneInfoDao.save(projectSceneInfo);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -88,6 +104,7 @@ public class ProjectSceneInfoService extends SuperService {
|
|
|
projectSceneInfoDao.delete(entity);
|
|
|
|
|
|
// 删除关联的信息
|
|
|
+ roleSceneInfoService.deleteByProjectSceneId(entity.getId());
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -96,16 +113,63 @@ public class ProjectSceneInfoService extends SuperService {
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
}
|
|
|
+ if (state == DataState.Enable) {
|
|
|
+ DataState sceneState = entity.getSceneInfo().getState();
|
|
|
+ if (sceneState == DataState.Disable) {
|
|
|
+ return ResultContent.buildFail("平台上的场景已禁用,不能启用");
|
|
|
+ }
|
|
|
+ }
|
|
|
entity.setState(state);
|
|
|
projectSceneInfoDao.save(entity);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ public ResultContent changeStateBySceneInfoId(String sceneInfoId, DataState state) {
|
|
|
+ if (StringUtils.isNotEmpty(sceneInfoId)) {
|
|
|
+ Map<String, Object> where = new HashMap<>();
|
|
|
+ where.put("sceneInfoId", sceneInfoId);
|
|
|
+
|
|
|
+ Map<String, Object> standardData = new HashMap<>();
|
|
|
+ standardData.put("sceneState", state);
|
|
|
+
|
|
|
+ commonService.updateData(where, standardData, ProjectSceneInfo.class.getSimpleName());
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 场景信息发送变化,编辑项目上的关联数据
|
|
|
+ *
|
|
|
+ * @param sceneInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent updateAllSceneInfo(SceneInfo sceneInfo) {
|
|
|
+ if (ObjectUtils.isNotEmpty(sceneInfo)) {
|
|
|
+ Map<String, Object> where = new HashMap<>();
|
|
|
+ where.put("sceneInfoId", sceneInfo.getId());
|
|
|
+
|
|
|
+ Map<String, Object> standardData = new HashMap<>();
|
|
|
+ standardData.put("name", sceneInfo.getName());
|
|
|
+ standardData.put("sceneType", sceneInfo.getSceneType());
|
|
|
+ standardData.put("sceneState", sceneInfo.getState());
|
|
|
+
|
|
|
+ commonService.updateData(where, standardData, ProjectSceneInfo.class.getSimpleName());
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent deleteBySceneInfoId(String sceneInfoId) {
|
|
|
+ if (ObjectUtils.isNotEmpty(sceneInfoId)) {
|
|
|
+ projectSceneInfoDao.deleteBySceneInfoId(sceneInfoId);
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
public ProjectSceneInfoModel toModel(ProjectSceneInfo entity) {
|
|
|
ProjectSceneInfoModel model = new ProjectSceneInfoModel();
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
-
|
|
|
+ model.setSceneInfo(sceneInfoService.toModel(entity.getSceneInfo()));
|
|
|
}
|
|
|
return model;
|
|
|
}
|