|
@@ -1,9 +1,11 @@
|
|
|
-using Hotline.Settings;
|
|
|
+using Hotline.Permissions;
|
|
|
+using Hotline.Settings;
|
|
|
using Hotline.Settings.CommonOpinions;
|
|
|
using Hotline.Share.Dtos.Order;
|
|
|
using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using MongoDB.Driver;
|
|
|
+using XF.Domain.Exceptions;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
|
{
|
|
@@ -56,6 +58,7 @@ namespace Hotline.Api.Controllers
|
|
|
await _commonOpinionDomainService.DelCommonOpinion(dto.Ids, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
+ #region 省市区
|
|
|
/// <summary>
|
|
|
/// 获取省市区树形
|
|
|
/// </summary>
|
|
@@ -65,5 +68,70 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
return await _systemAreaDomainService.GetAreaTree();
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 新增省市区
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.AddArea)]
|
|
|
+ [HttpPost("add-aear")]
|
|
|
+ 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)]
|
|
|
+ [HttpPost("modify-area")]
|
|
|
+ public async Task ModifyArea([FromBody]ModifyAreaDto dto)
|
|
|
+ {
|
|
|
+ var model = await _systemAreaDomainService.GetArea(dto.Id,HttpContext.RequestAborted);
|
|
|
+ if (model is null)
|
|
|
+ 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)]
|
|
|
+ [HttpGet("del-area/{id}")]
|
|
|
+ public async Task DelArea(string id)
|
|
|
+ {
|
|
|
+ var model = await _systemAreaDomainService.GetArea(id, HttpContext.RequestAborted);
|
|
|
+ if (model is null)
|
|
|
+ throw UserFriendlyException.SameMessage("未知数据,请刷新页面");
|
|
|
+
|
|
|
+ await _systemAreaDomainService.DelArea(id, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取区域
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.GetArea)]
|
|
|
+ [HttpGet("get-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
|
|
|
}
|
|
|
}
|