Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
pipeline-network
Commits
58730fff
Commit
58730fff
authored
Jul 24, 2026
by
wujipeng
Browse files
搜索道路名称
parent
ecb1ffa0
Changes
5
Show whitespace changes
Inline
Side-by-side
src/main/java/com/example/pipelinenetwork/controller/RoadController.java
View file @
58730fff
...
...
@@ -43,5 +43,12 @@ public class RoadController {
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
src/main/java/com/example/pipelinenetwork/mapper/RoadMapper.java
View file @
58730fff
...
...
@@ -5,6 +5,7 @@ import com.example.pipelinenetwork.pojo.entity.RoadEntity;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
@Mapper
...
...
@@ -14,4 +15,7 @@ public interface RoadMapper extends BaseMapper<RoadEntity> {
* 根据经纬度匹配最近的路段
*/
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
src/main/java/com/example/pipelinenetwork/service/RoadService.java
View file @
58730fff
...
...
@@ -24,6 +24,6 @@ public interface RoadService extends IService<RoadEntity> {
Result
<
RoadVO
>
queryByRoadName
(
RoadDTO
roadDTO
);
List
<
String
>
search
(
String
roadName
);
}
src/main/java/com/example/pipelinenetwork/service/impl/RoadServiceImpl.java
View file @
58730fff
...
...
@@ -139,6 +139,11 @@ public class RoadServiceImpl extends ServiceImpl<RoadMapper, RoadEntity> impleme
return
Result
.
success
(
result
);
}
@Override
public
List
<
String
>
search
(
String
roadName
)
{
return
baseMapper
.
search
(
roadName
);
}
/**
* 解析Excel并生成SQL语句(不执行)
*/
...
...
src/main/resources/com/example/pipelinenetwork/mapper/RoadMapper.xml
View file @
58730fff
...
...
@@ -17,4 +17,14 @@
distance ASC
LIMIT 1
</select>
<select
id=
"search"
resultType=
"java.lang.String"
>
select
name
from
road
where
name like concat('%',#{roadName},'%')
group by
name
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment