Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
base_platform_enterprise
gic-store
Commits
7d65bc09
Commit
7d65bc09
authored
Nov 26, 2019
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
省市区查询
parent
ca1934ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
ProvincesApiService.java
.../main/java/com/gic/store/service/ProvincesApiService.java
+2
-0
ProvincesApiServiceImpl.java
...gic/store/service/outer/impl/ProvincesApiServiceImpl.java
+23
-0
No files found.
gic-store-api/src/main/java/com/gic/store/service/ProvincesApiService.java
View file @
7d65bc09
...
...
@@ -61,4 +61,6 @@ public interface ProvincesApiService {
ServiceResponse
<
List
<
CountyDTO
>>
queryCounty
(
String
search
);
ServiceResponse
<
ProvinceDTO
>
getProvinceById
(
String
provinceId
);
ServiceResponse
<
String
>
getProvinceNameByAreaId
(
String
aredId
);
}
gic-store-service/src/main/java/com/gic/store/service/outer/impl/ProvincesApiServiceImpl.java
View file @
7d65bc09
...
...
@@ -7,6 +7,9 @@ import com.gic.redis.data.util.RedisUtil;
import
com.gic.store.dto.CityDTO
;
import
com.gic.store.dto.CountyDTO
;
import
com.gic.store.dto.ProvinceDTO
;
import
com.gic.store.entity.TabCity
;
import
com.gic.store.entity.TabCounty
;
import
com.gic.store.entity.TabProvince
;
import
com.gic.store.service.ProvincesApiService
;
import
com.gic.store.service.ProvincesService
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -15,7 +18,9 @@ import org.springframework.stereotype.Service;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
@Service
(
"provincesApiService"
)
public
class
ProvincesApiServiceImpl
implements
ProvincesApiService
{
...
...
@@ -85,4 +90,22 @@ public class ProvincesApiServiceImpl implements ProvincesApiService {
}
return
ServiceResponse
.
failure
(
ErrorCode
.
NOTEXISTS
.
getCode
(),
"省份不存在"
);
}
@Override
public
ServiceResponse
<
String
>
getProvinceNameByAreaId
(
String
areaId
)
{
List
<
TabCounty
>
tabCounties
=
this
.
provincesService
.
selectAllCounty
();
List
<
TabCity
>
tabCities
=
this
.
provincesService
.
selectAllCity
();
List
<
TabProvince
>
tabProvinces
=
this
.
provincesService
.
selectAllProvince
();
Map
<
String
,
TabCounty
>
countyMap
=
tabCounties
.
stream
().
collect
(
Collectors
.
toMap
(
TabCounty:
:
getCountyId
,
a
->
a
,
(
k1
,
k2
)
->
k1
));
Map
<
String
,
TabCity
>
tabCityMap
=
tabCities
.
stream
().
collect
(
Collectors
.
toMap
(
TabCity:
:
getCityId
,
a
->
a
,
(
k1
,
k2
)
->
k1
));
Map
<
String
,
TabProvince
>
provinceMap
=
tabProvinces
.
stream
().
collect
(
Collectors
.
toMap
(
TabProvince:
:
getProvinceId
,
a
->
a
,
(
k1
,
k2
)
->
k1
));
StringBuilder
stringBuilder
=
new
StringBuilder
();
if
(
countyMap
.
containsKey
(
areaId
)){
TabCounty
tabCounty
=
countyMap
.
get
(
areaId
);
stringBuilder
.
append
(
provinceMap
.
get
(
tabCounty
.
getProvinceId
()).
getProvinceName
()).
append
(
"/"
);
stringBuilder
.
append
(
tabCityMap
.
get
(
tabCounty
.
getCityId
()).
getCityName
()).
append
(
"/"
);
stringBuilder
.
append
(
tabCounty
.
getCountyName
());
}
return
ServiceResponse
.
success
(
stringBuilder
.
toString
());
}
}
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