Commit 58730fff authored by wujipeng's avatar wujipeng
Browse files

搜索道路名称

parent ecb1ffa0
...@@ -43,5 +43,12 @@ public class RoadController { ...@@ -43,5 +43,12 @@ public class RoadController {
return roadService.importRoadData(file); return roadService.importRoadData(file);
} }
/**
* 搜索道路名称
*/
@GetMapping("/search")
public Result<List<String>> search(@RequestParam(name = "roadName") String roadName) {
return Result.success(roadService.search(roadName));
}
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import com.example.pipelinenetwork.pojo.entity.RoadEntity; ...@@ -5,6 +5,7 @@ import com.example.pipelinenetwork.pojo.entity.RoadEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map; import java.util.Map;
@Mapper @Mapper
...@@ -14,4 +15,7 @@ public interface RoadMapper extends BaseMapper<RoadEntity> { ...@@ -14,4 +15,7 @@ public interface RoadMapper extends BaseMapper<RoadEntity> {
* 根据经纬度匹配最近的路段 * 根据经纬度匹配最近的路段
*/ */
Map<String, Object> matchNearestRoad(@Param("lng") Double lng, @Param("lat") Double lat); Map<String, Object> matchNearestRoad(@Param("lng") Double lng, @Param("lat") Double lat);
List<String> search(@Param("roadName") String roadName);
} }
\ No newline at end of file
...@@ -24,6 +24,6 @@ public interface RoadService extends IService<RoadEntity> { ...@@ -24,6 +24,6 @@ public interface RoadService extends IService<RoadEntity> {
Result<RoadVO> queryByRoadName(RoadDTO roadDTO); Result<RoadVO> queryByRoadName(RoadDTO roadDTO);
List<String> search(String roadName);
} }
...@@ -139,6 +139,11 @@ public class RoadServiceImpl extends ServiceImpl<RoadMapper, RoadEntity> impleme ...@@ -139,6 +139,11 @@ public class RoadServiceImpl extends ServiceImpl<RoadMapper, RoadEntity> impleme
return Result.success(result); return Result.success(result);
} }
@Override
public List<String> search(String roadName) {
return baseMapper.search(roadName);
}
/** /**
* 解析Excel并生成SQL语句(不执行) * 解析Excel并生成SQL语句(不执行)
*/ */
......
...@@ -17,4 +17,14 @@ ...@@ -17,4 +17,14 @@
distance ASC distance ASC
LIMIT 1 LIMIT 1
</select> </select>
<select id="search" resultType="java.lang.String">
select
name
from
road
where
name like concat('%',#{roadName},'%')
group by
name
</select>
</mapper> </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