Commit a7423b56 by zhangkb

修改根据关键字查找目录接口

parent 9bb7fd0c
...@@ -48,8 +48,9 @@ public class IndCatalogCtrl { ...@@ -48,8 +48,9 @@ public class IndCatalogCtrl {
@ApiOperation(value = "根据关键字搜索获取基础指标目录", notes = "根据关键字搜索获取基础指标目录") @ApiOperation(value = "根据关键字搜索获取基础指标目录", notes = "根据关键字搜索获取基础指标目录")
@PostMapping(value = "/getBaseIndCatalogByKeyword") @PostMapping(value = "/getBaseIndCatalogByKeyword")
public List<IndCatalog> getBaseIndCatalogByKeyword(@RequestParam(required=false) String keyword){ public List<IndCatalog> getBaseIndCatalogByKeyword(@RequestParam(required=false) String keyword,
return indCatalogService.getCatalogByKeyword(keyword); @RequestParam List<String> codes){
return indCatalogService.getCatalogByKeyword(keyword,codes);
} }
//考核指标目录 //考核指标目录
...@@ -75,7 +76,8 @@ public class IndCatalogCtrl { ...@@ -75,7 +76,8 @@ public class IndCatalogCtrl {
@ApiOperation(value = "根据关键字搜索获取考核指标目录", notes = "根据关键字搜索获取考核指标目录") @ApiOperation(value = "根据关键字搜索获取考核指标目录", notes = "根据关键字搜索获取考核指标目录")
@PostMapping(value = "/getDriveIndCatalogByKeyword") @PostMapping(value = "/getDriveIndCatalogByKeyword")
public List<DriveIndCatalog> getDriveIndCatalogByKeyword(@RequestParam(required=false) String keyword){ public List<DriveIndCatalog> getDriveIndCatalogByKeyword(@RequestParam(required=false) String keyword,
return driveIndCatalogService.getCatalogByKeyword(keyword); @RequestParam List<String> codes){
return driveIndCatalogService.getCatalogByKeyword(keyword,codes);
} }
} }
...@@ -17,5 +17,5 @@ public interface DriveIndCatalogMapper extends BaseMapper<DriveIndCatalog>{ ...@@ -17,5 +17,5 @@ public interface DriveIndCatalogMapper extends BaseMapper<DriveIndCatalog>{
public List<DriveIndCatalog> findByParentId(@Param("pid") Integer pid); public List<DriveIndCatalog> findByParentId(@Param("pid") Integer pid);
public List<DriveIndCatalog> findByKeyword(@Param("keyword") String keyword); public List<DriveIndCatalog> findByKeyword(Map<String,Object> params);
} }
...@@ -18,5 +18,5 @@ public interface IndCatalogMapper extends BaseMapper<IndCatalog>{ ...@@ -18,5 +18,5 @@ public interface IndCatalogMapper extends BaseMapper<IndCatalog>{
public List<IndCatalog> findByParentId(@Param("pid") Integer pid); public List<IndCatalog> findByParentId(@Param("pid") Integer pid);
public List<IndCatalog> findByKeyword(@Param("keyword") String keyword); public List<IndCatalog> findByKeyword(Map<String,Object> params);
} }
...@@ -84,11 +84,13 @@ public class DriveIndCatalogService { ...@@ -84,11 +84,13 @@ public class DriveIndCatalogService {
} }
//根据关键字获取目录树 //根据关键字获取目录树
public List<DriveIndCatalog> getCatalogByKeyword(String keyword){ public List<DriveIndCatalog> getCatalogByKeyword(String keyword,List<String> codes){
if(StringUtils.isBlank(keyword)) { if(StringUtils.isBlank(keyword)) {
return new ArrayList<>(); return new ArrayList<>();
}else {
return driveIndCatalogMapper.findByKeyword("%"+keyword+"%");
} }
Map<String,Object> params = new HashMap<>();
params.put("keyword", "%"+keyword+"%");
params.put("codes", codes);
return driveIndCatalogMapper.findByKeyword(params);
} }
} }
...@@ -83,10 +83,13 @@ public class IndCatalogService { ...@@ -83,10 +83,13 @@ public class IndCatalogService {
} }
//根据目录树获取 //根据目录树获取
public List<IndCatalog> getCatalogByKeyword(String keyword){ public List<IndCatalog> getCatalogByKeyword(String keyword,List<String> codes){
if(StringUtils.isBlank(keyword)) { if(StringUtils.isBlank(keyword)) {
return new ArrayList<>(); return new ArrayList<>();
} }
return indCatalogMapper.findByKeyword("%"+keyword+"%"); Map<String,Object> params = new HashMap<>();
params.put("keyword", "%"+keyword+"%");
params.put("codes", codes);
return indCatalogMapper.findByKeyword(params);
} }
} }
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
<select id="findByKeyword" resultType="com.keymobile.indicators.model.entity.indicators.DriveIndCatalog" > <select id="findByKeyword" resultType="com.keymobile.indicators.model.entity.indicators.DriveIndCatalog" >
select * select *
from drive_ind_catalog from drive_ind_catalog
where catalog_name like #{keyword} where catalog_name like #{keyword} and
code in
<foreach item="id" collection="codes" open="(" close=")" separator=",">
#{id}
</foreach>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -27,9 +27,13 @@ ...@@ -27,9 +27,13 @@
where parent_id = #{pid} where parent_id = #{pid}
</select> </select>
<select id="findByKeyword" resultType="com.keymobile.indicators.model.entity.indicators.IndCatalog" > <select id="findByKeyword" parameterType="map" resultType="com.keymobile.indicators.model.entity.indicators.IndCatalog" >
select * select *
from base_ind_catalog from base_ind_catalog
where catalog_name like #{keyword} where catalog_name like #{keyword} and
code in
<foreach item="id" collection="codes" open="(" close=")" separator=",">
#{id}
</foreach>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
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