Commit 7016fa62 authored by wujipeng's avatar wujipeng
Browse files

获取下游数据

parent a8d42a77
......@@ -31,5 +31,11 @@ public class MetaDataController {
return Result.success(metaDataService.getUpDataById(id));
}
@ApiOperation("获取下游数据")
@GetMapping("/down/{id}")
public Result<List<MetaDataVO>> getDownDataById(@PathVariable String id) {
return Result.success(metaDataService.getDownDataById(id));
}
}
......@@ -18,4 +18,5 @@ import java.util.List;
public interface MetaDataMapper extends BaseMapper<MetaDataEntity> {
List<MetaDataVO> getUpDataById(@Param("id") String id);
List<MetaDataVO> getDownDataById(@Param("id")String id);
}
......@@ -32,11 +32,6 @@ public class Result<T> implements Serializable {
*/
private Long timestamp;
/**
* 请求路径
*/
private String path;
/**
* 构造方法
*/
......@@ -123,18 +118,4 @@ public class Result<T> implements Serializable {
return success(data, message);
}
/**
* 链式调用设置路径
*/
public Result<T> path(String path) {
this.setPath(path);
return this;
}
/**
* 判断是否成功
*/
public Boolean isSuccess() {
return HttpStatus.OK.value() == this.code;
}
}
\ No newline at end of file
......@@ -15,4 +15,7 @@ import java.util.List;
public interface MetaDataService extends IService<MetaDataEntity> {
List<MetaDataVO> getUpDataById(String id);
List<MetaDataVO> getDownDataById(String id);
}
......@@ -21,4 +21,9 @@ public class MetaDataServiceImpl extends ServiceImpl<MetaDataMapper, MetaDataEnt
public List<MetaDataVO> getUpDataById(String id) {
return baseMapper.getUpDataById(id);
}
@Override
public List<MetaDataVO> getDownDataById(String id) {
return baseMapper.getDownDataById(id);
}
}
......@@ -14,6 +14,35 @@
INNER JOIN downstream d ON m.formula LIKE CONCAT('%{', d.id, '}%')
)
SELECT distinct * FROM downstream;
</select>
<select id="getDownDataById" resultType="com.ruzhoukj.integration.pojo.vo.MetaDataVO">
WITH RECURSIVE downstream AS (
SELECT
id,
name,
value,
reunite,
formula,
attribute,
0 AS level,
CAST(NULL AS CHAR(256)) AS parent_id
FROM meta_data
WHERE id = #{id}
UNION ALL
SELECT
m.id,
m.name,
m.value,
m.reunite,
m.formula,
m.attribute,
d.level + 1 AS level,
d.id AS parent_id
FROM meta_data m
INNER JOIN downstream d ON d.formula LIKE CONCAT('%{', m.id, '}%')
)
SELECT * FROM downstream WHERE id != #{id}
</select>
</mapper>
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