|
@@ -6,7 +6,9 @@ using Hotline.CallCenter.Manage;
|
|
|
using Hotline.CallCenter.Tels;
|
|
|
using Hotline.Permissions;
|
|
|
using Hotline.Repository.SqlSugar.CallCenter;
|
|
|
+using Hotline.Settings;
|
|
|
using Hotline.Share.Dtos.CallCenter;
|
|
|
+using Hotline.Share.Dtos.Trunk;
|
|
|
using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Share.Requests;
|
|
|
using Hotline.Users;
|
|
@@ -35,6 +37,7 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly ICallRepository _callRepository;
|
|
|
+ private readonly ITrunkIvrManagerRepository _trunkIvrManagerRepository;
|
|
|
|
|
|
public PbxController(
|
|
|
ITelRepository telRepository,
|
|
@@ -47,7 +50,8 @@ namespace Hotline.Api.Controllers
|
|
|
IDeviceManager deviceManager,
|
|
|
IUserCacheManager userCacheManager,
|
|
|
ISessionContext sessionContext,
|
|
|
- ICallRepository callRepository)
|
|
|
+ ICallRepository callRepository,
|
|
|
+ ITrunkIvrManagerRepository trunkIvrManagerRepository)
|
|
|
{
|
|
|
_telRepository = telRepository;
|
|
|
_telDomainService = telDomainService;
|
|
@@ -60,6 +64,7 @@ namespace Hotline.Api.Controllers
|
|
|
_userCacheManager = userCacheManager;
|
|
|
_sessionContext = sessionContext;
|
|
|
_callRepository = callRepository;
|
|
|
+ _trunkIvrManagerRepository = trunkIvrManagerRepository;
|
|
|
}
|
|
|
|
|
|
#region 话机
|
|
@@ -584,6 +589,82 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 线路管理
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取线路列表
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.GetTrunkList)]
|
|
|
+ [HttpGet("turnk-list")]
|
|
|
+ public async Task<List<TrunkIvrManager>> GetTrunkList()
|
|
|
+ {
|
|
|
+ return await _trunkIvrManagerRepository.QueryAsync();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取线路对象
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.GetTrunk)]
|
|
|
+ [HttpGet("trunk/{id}")]
|
|
|
+ public async Task<TrunkIvrManager> GetTrunk(string id)
|
|
|
+ {
|
|
|
+ var trunk = await _trunkIvrManagerRepository.GetAsync(id, HttpContext.RequestAborted);
|
|
|
+ if (trunk is null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效线路");
|
|
|
+ return trunk;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 新增线路
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.AddTrunk)]
|
|
|
+ [HttpPost("addtrunk")]
|
|
|
+ public async Task AddTrunk([FromBody] AddTrunkDto dto)
|
|
|
+ {
|
|
|
+ var trunk = _mapper.Map<TrunkIvrManager>(dto);
|
|
|
+ await _trunkIvrManagerRepository.AddAsync(trunk, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 修改线路
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.UpdateTrunk)]
|
|
|
+ [HttpPost("updatetrunk")]
|
|
|
+ public async Task UpdateTrunk([FromBody] UpdateTrunkDto dto)
|
|
|
+ {
|
|
|
+ var trunk = await _trunkIvrManagerRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
|
|
|
+ if (trunk is null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效线路");
|
|
|
+
|
|
|
+ _mapper.Map(dto, trunk);
|
|
|
+ await _trunkIvrManagerRepository.UpdateAsync(trunk, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除线路
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Permission(EPermission.RemoveTrunk)]
|
|
|
+ [HttpGet("removetrunk/{id}")]
|
|
|
+ public async Task RemoveTrunk(string id)
|
|
|
+ {
|
|
|
+ var trunk = await _trunkIvrManagerRepository.GetAsync(id, HttpContext.RequestAborted);
|
|
|
+ if (trunk is null)
|
|
|
+ throw UserFriendlyException.SameMessage("无效线路");
|
|
|
+ await _trunkIvrManagerRepository.RemoveAsync(id, false, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|