12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using DataTransmission.Entity;
- using SqlSugar;
- namespace Hotline.Settings
- {
- [SugarTable("system_area")]
- public class SystemArea: CreationSoftDeleteEntity
- {
- /// <summary>
- /// 区域名称
- /// </summary>
- public string AreaName { get; set; }
- /// <summary>
- /// 上级ID
- /// </summary>
- [SugarColumn(IsNullable = true)]
- public string ParentId { get; set; }
- /// <summary>
- /// 简称
- /// </summary>
- public string AreaNameAbbreviation { get; set; }
- /// <summary>
- /// 是否可以修改
- /// </summary>
- [SugarColumn(DefaultValue = "f")]
- public bool IsCanModify { get; set; }
- [SugarColumn(IsIgnore = true)]
- public List<SystemArea> Children { get; set; }
- }
- public static class AreaExtensions
- {
- /// <summary>
- /// 获取最末级区域对应编码(最后2位)
- /// </summary>
- /// <param name="areaCode"></param>
- /// <returns></returns>
- /// <exception cref="UserFriendlyException"></exception>
- public static string GetLastAreaCode(this string areaCode)
- {
- if (areaCode.Length < 6)
- throw new Exception("非法区域编码");
- return areaCode.Substring(areaCode.Length - 2, 2);
- }
- }
- }
|