docs: 添加管理平台标准加密算法 Kotlin 参考实现
This commit is contained in:
22
docs/工具箱端-授权对接指南/utils/RegionUtil.kt
Normal file
22
docs/工具箱端-授权对接指南/utils/RegionUtil.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
package top.tangyh.lamp.filing.utils
|
||||
|
||||
import kotlin.text.substring
|
||||
|
||||
object RegionUtil {
|
||||
fun getLevel(code: String?): String {
|
||||
if (code == null || code.length != 6) {
|
||||
return "无效编码"
|
||||
}
|
||||
|
||||
val province = code.substring(0, 2)
|
||||
val city = code.substring(2, 4)
|
||||
val county = code.substring(4, 6)
|
||||
|
||||
return when {
|
||||
city == "00" && county == "00" -> "province"
|
||||
city != "00" && county == "00" -> "city"
|
||||
county != "00" -> "county"
|
||||
else -> "未知级别"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user