Commit 8e195190 authored by suhuiguang's avatar suhuiguang

修改数据绑定查询接口为一个

parent 65e84da4
...@@ -115,32 +115,24 @@ public class PlanVisual3dController extends BaseController { ...@@ -115,32 +115,24 @@ public class PlanVisual3dController extends BaseController {
* @return 资源设备 or 数据项 * @return 资源设备 or 数据项
*/ */
@Authorization(ingore = true) @Authorization(ingore = true)
@GetMapping(value = "resource/common") @GetMapping(value = "common/dataBind")
@ApiOperation(value = "设备、数据项查询", notes = "按照资源类型type查询设备,按照资源类型type和设备id查询数据项") @ApiOperation(value = "设备、数据项查询", notes = "按照资源类型type查询设备,按照资源类型type和设备id查询数据项")
public CommonResponse getResourceCommon( public CommonResponse getResourceCommon(
@ApiParam(value = "资源类型") @RequestParam(required = false) String type, @ApiParam(value = "资源类型") @RequestParam(required = false) String type,
@ApiParam(value = "主键id") @RequestParam(required = false) Long id) { @ApiParam(value = "主键id") @RequestParam(required = false) Long id) {
if(!StringUtil.isNotEmpty(type)){ //1.查询数据类型
return CommonResponseUtil.success(); if (!StringUtil.isNotEmpty(type)) {
return CommonResponseUtil.success(planVisual3dService.getResourceTypeList());
} }
if(StringUtil.isNotEmpty(type) && !StringUtil.isNotEmpty(id)){ //2.查询类型对应数据
if (StringUtil.isNotEmpty(type) && !StringUtil.isNotEmpty(id)) {
return planVisual3dService.getResourceListByType(type); return planVisual3dService.getResourceListByType(type);
} }
if(StringUtil.isNotEmpty(type) && StringUtil.isNotEmpty(id)){ //3.查询绑定项数据
if (StringUtil.isNotEmpty(type) && StringUtil.isNotEmpty(id)) {
List<Map<String, Object>> list = planVisual3dService.getResourceById(type, id); List<Map<String, Object>> list = planVisual3dService.getResourceById(type, id);
return CommonResponseUtil.success(list); return CommonResponseUtil.success(list);
} }
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
/**
* 资源类型查询
* @return list
*/
@Authorization(ingore = true)
@ApiOperation(value = "资源类型查询",notes = "资源类型查询")
@GetMapping(value ="resource/type/list")
public CommonResponse getResourceList(){
return CommonResponseUtil.success(planVisual3dService.getResourceTypeList());
}
} }
...@@ -6,7 +6,7 @@ import java.util.List; ...@@ -6,7 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface PlanVisual3dMapper extends BaseMapper { public interface PlanVisual3dMapper extends BaseMapper {
List<HashMap<String,String>> getResourceListByType(@Param("type") String type); List<HashMap<String,Object>> getResourceListByType(@Param("type") String type);
Map<String, Object> queryOneByTypeAndId(@Param("type") String type, @Param("id") Long id); Map<String, Object> queryOneByTypeAndId(@Param("type") String type, @Param("id") Long id);
} }
...@@ -191,6 +191,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -191,6 +191,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
list = dictList.stream().map(e->{ list = dictList.stream().map(e->{
Map<String, Object> newMap = new HashMap<String, Object>(); Map<String, Object> newMap = new HashMap<String, Object>();
newMap.put("key",e.getDictValue()); newMap.put("key",e.getDictValue());
newMap.put("value",e.getDictValue());//前端级联Cascader使用
newMap.put("isLeaf",false);////前端级联Cascader使用
newMap.put("dataType","type");
newMap.put("label",e.getDictName()); newMap.put("label",e.getDictName());
return newMap; return newMap;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
......
...@@ -5,7 +5,11 @@ ...@@ -5,7 +5,11 @@
<!--查询--> <!--查询-->
<select id="getResourceListByType" resultType="java.util.HashMap"> <select id="getResourceListByType" resultType="java.util.HashMap">
SELECT SELECT
rs.id as `key` ,rs.name as label,rs.code rs.id as `key` ,
rs.id AS `value`,
rs.name as label,
rs.code ,
'id' as dataType
from from
<choose> <choose>
<when test="type=='fireCar'"> <when test="type=='fireCar'">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment