SystemArea.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using SqlSugar;
  2. using System.Runtime.CompilerServices;
  3. using XF.Domain.Exceptions;
  4. using XF.Domain.Repository;
  5. namespace Hotline.Settings
  6. {
  7. public class SystemArea: CreationSoftDeleteEntity
  8. {
  9. /// <summary>
  10. /// 区域名称
  11. /// </summary>
  12. public string AreaName { get; set; }
  13. /// <summary>
  14. /// 上级ID
  15. /// </summary>
  16. [SugarColumn(IsNullable = true)]
  17. public string ParentId { get; set; }
  18. /// <summary>
  19. /// 简称
  20. /// </summary>
  21. public string AreaNameAbbreviation { get; set; }
  22. /// <summary>
  23. /// 是否可以修改
  24. /// </summary>
  25. [SugarColumn(DefaultValue = "f")]
  26. public bool IsCanModify { get; set; }
  27. [SugarColumn(IsIgnore = true)]
  28. public List<SystemArea> Children { get; set; }
  29. }
  30. public static class AreaExtensions
  31. {
  32. /// <summary>
  33. /// 获取最末级区域对应编码(最后2位)
  34. /// </summary>
  35. /// <param name="areaCode"></param>
  36. /// <returns></returns>
  37. /// <exception cref="UserFriendlyException"></exception>
  38. public static string GetLastAreaCode(this string areaCode)
  39. {
  40. if (areaCode.Length < 6)
  41. throw new UserFriendlyException("非法区域编码");
  42. return areaCode.Substring(areaCode.Length - 2, 2);
  43. }
  44. }
  45. }