SystemArea.cs 1.3 KB

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