|
@@ -4,6 +4,7 @@ using Hotline.Settings;
|
|
using Hotline.Share.Dtos;
|
|
using Hotline.Share.Dtos;
|
|
using Hotline.Share.Dtos.Dic;
|
|
using Hotline.Share.Dtos.Dic;
|
|
using Hotline.Share.Dtos.Menu;
|
|
using Hotline.Share.Dtos.Menu;
|
|
|
|
+using Hotline.Share.Dtos.Settings;
|
|
using Hotline.Share.Dtos.Trunk;
|
|
using Hotline.Share.Dtos.Trunk;
|
|
using Hotline.Share.Requests;
|
|
using Hotline.Share.Requests;
|
|
using MapsterMapper;
|
|
using MapsterMapper;
|
|
@@ -24,7 +25,8 @@ namespace Hotline.Api.Controllers
|
|
private readonly ISystemMenuRepository _systemMenuRepository;
|
|
private readonly ISystemMenuRepository _systemMenuRepository;
|
|
private readonly ISysDicTypeRepository _sysDicTypeRepository;
|
|
private readonly ISysDicTypeRepository _sysDicTypeRepository;
|
|
private readonly ISysDicDataRepository _sysDicDataRepository;
|
|
private readonly ISysDicDataRepository _sysDicDataRepository;
|
|
-
|
|
|
|
|
|
+ private readonly ISystemAreaDomainService _systemAreaDomainService;
|
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 系统管理相关接口
|
|
/// 系统管理相关接口
|
|
@@ -39,13 +41,16 @@ namespace Hotline.Api.Controllers
|
|
ISystemSettingRepository systemSettingsRepository,
|
|
ISystemSettingRepository systemSettingsRepository,
|
|
ISystemMenuRepository systemMenuRepository,
|
|
ISystemMenuRepository systemMenuRepository,
|
|
ISysDicTypeRepository sysDicTypeRepository,
|
|
ISysDicTypeRepository sysDicTypeRepository,
|
|
- ISysDicDataRepository sysDicDataRepository)
|
|
|
|
|
|
+ ISysDicDataRepository sysDicDataRepository,
|
|
|
|
+ ISystemAreaDomainService systemAreaDomainService
|
|
|
|
+ )
|
|
{
|
|
{
|
|
_mapper = mapper;
|
|
_mapper = mapper;
|
|
_systemSettingsRepository = systemSettingsRepository;
|
|
_systemSettingsRepository = systemSettingsRepository;
|
|
_systemMenuRepository = systemMenuRepository;
|
|
_systemMenuRepository = systemMenuRepository;
|
|
_sysDicTypeRepository = sysDicTypeRepository;
|
|
_sysDicTypeRepository = sysDicTypeRepository;
|
|
_sysDicDataRepository = sysDicDataRepository;
|
|
_sysDicDataRepository = sysDicDataRepository;
|
|
|
|
+ _systemAreaDomainService = systemAreaDomainService;
|
|
}
|
|
}
|
|
|
|
|
|
#region 菜单管理
|
|
#region 菜单管理
|
|
@@ -299,7 +304,85 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
+ #region 行政区划
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取省市区树形
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpGet("area/tree")]
|
|
|
|
+ public async Task<List<SystemArea>> GetAreaTree()
|
|
|
|
+ {
|
|
|
|
+ return await _systemAreaDomainService.GetAreaTree();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 新增省市区
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [Permission(EPermission.AddArea)]
|
|
|
|
+ [HttpPost("area")]
|
|
|
|
+ public async Task AddArea([FromBody] AddAreaDto dto)
|
|
|
|
+ {
|
|
|
|
+ var model = _mapper.Map<SystemArea>(dto);
|
|
|
|
+ model.IsCanModify = true;
|
|
|
|
+ await _systemAreaDomainService.AddArea(model, HttpContext.RequestAborted);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 修改省市区
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [Permission(EPermission.ModifyArea)]
|
|
|
|
+ [HttpPut("area")]
|
|
|
|
+ public async Task ModifyArea([FromBody] ModifyAreaDto dto)
|
|
|
|
+ {
|
|
|
|
+ var model = await _systemAreaDomainService.GetArea(dto.Id, HttpContext.RequestAborted);
|
|
|
|
+ if (model is null)
|
|
|
|
+ throw UserFriendlyException.SameMessage("未知数据,请刷新页面");
|
|
|
|
+ if (!model.IsCanModify)
|
|
|
|
+ throw UserFriendlyException.SameMessage("系统数据,不能修改");
|
|
|
|
+
|
|
|
|
+ model = _mapper.Map<SystemArea>(dto);
|
|
|
|
+ await _systemAreaDomainService.ModifyArea(model, HttpContext.RequestAborted);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 删除省市区(逻辑)
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="id"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [Permission(EPermission.DelArea)]
|
|
|
|
+ [HttpDelete("area/{id}")]
|
|
|
|
+ public async Task DelArea(string id)
|
|
|
|
+ {
|
|
|
|
+ var model = await _systemAreaDomainService.GetArea(id, HttpContext.RequestAborted);
|
|
|
|
+ if (model is null)
|
|
|
|
+ throw UserFriendlyException.SameMessage("未知数据,请刷新页面");
|
|
|
|
+ if (!model.IsCanModify)
|
|
|
|
+ throw UserFriendlyException.SameMessage("系统数据不能删除");
|
|
|
|
+
|
|
|
|
+ await _systemAreaDomainService.DelArea(id, HttpContext.RequestAborted);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取区域
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="id"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [Permission(EPermission.GetArea)]
|
|
|
|
+ [HttpGet("area/{id}")]
|
|
|
|
+ public async Task<SystemArea?> GetArea(string id)
|
|
|
|
+ {
|
|
|
|
+ var model = await _systemAreaDomainService.GetArea(id, HttpContext.RequestAborted);
|
|
|
|
+ if (model is null)
|
|
|
|
+ throw UserFriendlyException.SameMessage("未知数据,请刷新页面");
|
|
|
|
+ return model;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|