From fdb4b4897bf610f5c4eea0acc3fc83324dce9b2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=A4=A7=E4=BD=AC=E6=B0=94=E5=9C=BA?=
<188633308@qq.com>
Date: Fri, 30 Apr 2021 11:31:14 +0800
Subject: [PATCH] =?UTF-8?q?fix=20=E5=8C=BA=E5=9F=9F=E6=9F=A5=E6=89=BE?=
=?UTF-8?q?=E7=88=B6=E7=BA=A7=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Api/Ewide.Core/Entity/SysAreaCode.cs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/Api/Ewide.Core/Entity/SysAreaCode.cs b/Api/Ewide.Core/Entity/SysAreaCode.cs
index f6eea58..74b7ed8 100644
--- a/Api/Ewide.Core/Entity/SysAreaCode.cs
+++ b/Api/Ewide.Core/Entity/SysAreaCode.cs
@@ -37,10 +37,20 @@ namespace Ewide.Core
[Comment("排序")]
public int Sort { get; set; }
+
///
/// 父节点就是去掉后面两位
///
- public string ParentCode => LevelType>1?Code[0..(Code.Length-2)]:string.Empty;
+ public string ParentCode => LevelType switch
+ {
+ // 市级 => 没有父级 3302
+ 1 => string.Empty,
+ // 区级 => 6位取4位得到市级 330201
+ 2 => Code[0..(Code.Length - 2)],
+ // 其他 => 去除后3位得到上级 330201001
+ _ => Code[0..(Code.Length - 3)],
+ };
+
///
/// 多个区域有多个用户绑定自定义数据
///