Class LocationService
java.lang.Object
io.leandev.appfuse.almanac.location.LocationService
國家 / 行政區劃代碼服務
提供與上一代 appfuse-common 等價的 ISO 國家代碼轉換與行政區劃查找,差別在於
資料來源由內建 CSV 改為 almanac(GET /api/v1/location/...)。查得的清單以
檔案型快取保存。
- Since:
- 4.0
-
Constructor Summary
ConstructorsConstructorDescriptionLocationService(AlmanacClient client, CacheManager cacheManager, Duration ttl) 建立服務 -
Method Summary
Modifier and TypeMethodDescriptionconvertISO2CountryToISO3(String iso2Code) 將 ISO 3166-1 alpha-2 國家代碼轉為 alpha-3convertISO3CountryToISO2(String iso3Code) 將 ISO 3166-1 alpha-3 國家代碼轉為 alpha-2取得所有國家findSubdivisionCodeByISO2AndName(String iso2Code, String subdivisionName) 以國家 alpha-2 與行政區劃名稱(部分比對)查找行政區劃代碼(去掉國家前綴)findSubdivisions(String iso2Code) 取得指定國家的所有行政區劃
-
Constructor Details
-
LocationService
建立服務- Parameters:
client- almanac 客戶端cacheManager- 快取管理器ttl- 快取存活時間
-
-
Method Details
-
convertISO2CountryToISO3
-
convertISO3CountryToISO2
-
findSubdivisionCodeByISO2AndName
以國家 alpha-2 與行政區劃名稱(部分比對)查找行政區劃代碼(去掉國家前綴)
例:
findSubdivisionCodeByISO2AndName("US", "California")→CA- Parameters:
iso2Code- 國家 alpha-2 代碼subdivisionName- 行政區劃名稱(部分比對、大小寫不拘)- Returns:
- 行政區劃代碼(不含
國家-前綴);查無則回 null
-
findAllCountries
-
findSubdivisions
取得指定國家的所有行政區劃- Parameters:
iso2Code- 國家 alpha-2 代碼(大小寫不拘)- Returns:
- 行政區劃清單
-