2 changed files with 112 additions and 3 deletions
@ -0,0 +1,104 @@ |
|||
package com.kms.yg.znjg.controller; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.kms.yg.znjg.domain.SyScene; |
|||
import com.kms.yg.znjg.domain.SySceneConfigRelation; |
|||
import com.kms.yg.znjg.mapper.SySceneConfigRelationMapper; |
|||
import com.kms.yg.znjg.mapper.SySceneMapper; |
|||
import com.kms.yg.znjg.service.SySceneConfigRelationService; |
|||
import com.kms.yg.znjg.service.SySceneService; |
|||
import com.kms.yxgh.base.Response; |
|||
import io.swagger.annotations.Api; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @description 地图场景环境和视角配置管理 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/map/scene/config") |
|||
@Api(tags = "地图场景环境和视角配置管理") |
|||
public class SySceneConfigRelationController { |
|||
@Autowired |
|||
private SySceneConfigRelationService sySceneConfigRelationService; |
|||
|
|||
@Autowired |
|||
private SySceneConfigRelationMapper sySceneConfigRelationMapper; |
|||
|
|||
@Autowired |
|||
private SySceneMapper sySceneMapper; |
|||
|
|||
/** |
|||
* 保存/更新环境和视角配置对象 |
|||
* |
|||
* @param sySceneConfigRelation |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/saveOrUpdateConfig") |
|||
public Response<String> saveOrUpdateConfig(@RequestBody SySceneConfigRelation sySceneConfigRelation) { |
|||
Response<String> responseInfo = new Response<>(); |
|||
try { |
|||
if (sySceneConfigRelation.getSceneId() == null) { |
|||
throw new Exception("场景id不能为空"); |
|||
} |
|||
QueryWrapper<SyScene> wrapper = new QueryWrapper<>(); |
|||
// and 语句
|
|||
Map<String, Object> map = new HashMap(); |
|||
map.put("id", sySceneConfigRelation.getSceneId()); |
|||
map.put("is_valid", 1); |
|||
wrapper.allEq(map); |
|||
List<SyScene> sceneList = sySceneMapper.selectList(wrapper); |
|||
if (sceneList == null || sceneList.size() == 0) { |
|||
throw new Exception("场景不存在"); |
|||
} |
|||
sySceneConfigRelation.setIsValid(1); |
|||
sySceneConfigRelationService.saveOrUpdate(sySceneConfigRelation); |
|||
responseInfo.setCode("200"); |
|||
responseInfo.setData("保存成功"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
responseInfo.setCode("500"); |
|||
responseInfo.setMsg(e.getMessage()); |
|||
} |
|||
return responseInfo; |
|||
} |
|||
|
|||
/** |
|||
* 根据id查询场景环境以及相机配置信息 |
|||
* |
|||
* @param sceneId 场景id |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
@GetMapping(value = "/findConfigBySceneId/{sceneId}") |
|||
public Response<SySceneConfigRelation> findConfigBySceneId(@PathVariable(value = "sceneId") String sceneId) throws Exception { |
|||
Response<SySceneConfigRelation> responseInfo = new Response<>(); |
|||
try { |
|||
// 组装查询条件
|
|||
QueryWrapper<SySceneConfigRelation> wrapper = new QueryWrapper<>(); |
|||
// and 语句
|
|||
Map<String, Object> map = new HashMap(); |
|||
map.put("scene_id", sceneId); |
|||
map.put("is_valid", 1); |
|||
wrapper.allEq(map); |
|||
List<SySceneConfigRelation> sySceneConfigRelations = sySceneConfigRelationMapper.selectList(wrapper); |
|||
if (sySceneConfigRelations != null && sySceneConfigRelations.size() > 0) { |
|||
responseInfo.setCode("200"); |
|||
responseInfo.setData(sySceneConfigRelations.get(0)); |
|||
} else { |
|||
responseInfo.setCode("200"); |
|||
responseInfo.setData(null); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
responseInfo.setCode("500"); |
|||
responseInfo.setMsg(e.getMessage()); |
|||
} |
|||
return responseInfo; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue