|
@@ -7,7 +7,8 @@ using System.Linq;
|
|
|
using System.Collections.Generic;
|
|
|
using GxPress.Request.Navigation;
|
|
|
using AutoMapper;
|
|
|
-
|
|
|
+using GxPress.Result.MiddleLable;
|
|
|
+using GxPress.Repository.Interface.SystemLabel;
|
|
|
namespace GxPress.Service.Implement.Navigation
|
|
|
{
|
|
|
public class MiddleLableService : IMiddleLableService
|
|
@@ -15,11 +16,13 @@ namespace GxPress.Service.Implement.Navigation
|
|
|
private readonly IMiddleLableRepository middleLableRepository;
|
|
|
private readonly IMiddleLableNexusRepository middleLableNexusRepository;
|
|
|
private readonly IMapper _mapper;
|
|
|
- public MiddleLableService(IMiddleLableRepository middleLableRepository, IMiddleLableNexusRepository middleLableNexusRepository, IMapper mapper)
|
|
|
+ private readonly ISystemLabelRepository systemLabelRepository;
|
|
|
+ public MiddleLableService(IMiddleLableRepository middleLableRepository, IMiddleLableNexusRepository middleLableNexusRepository, IMapper mapper, ISystemLabelRepository systemLabelRepository)
|
|
|
{
|
|
|
this.middleLableRepository = middleLableRepository;
|
|
|
this.middleLableNexusRepository = middleLableNexusRepository;
|
|
|
_mapper = mapper;
|
|
|
+ this.systemLabelRepository = systemLabelRepository;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 添加中间件页面
|
|
@@ -34,11 +37,9 @@ namespace GxPress.Service.Implement.Navigation
|
|
|
{
|
|
|
var model = _mapper.Map<Entity.Navigations.MiddleLable>(request);
|
|
|
var middleLableId = await middleLableRepository.InsertAsync(model);
|
|
|
- var ids = StringUtils.StringCollectionToStringList(request.LabelId);
|
|
|
- var idInts = new List<int>();
|
|
|
- foreach (var item in ids)
|
|
|
- idInts.Add(int.Parse(item));
|
|
|
- await middleLableNexusRepository.InsertAsync(middleLableId, idInts);
|
|
|
+ foreach (var item in request.MiddleLableNexusUpRequests)
|
|
|
+ item.MiddleLableId = middleLableId;
|
|
|
+ await middleLableNexusRepository.InsertAsync(request.MiddleLableNexusUpRequests);
|
|
|
transactionScope.Complete();
|
|
|
}
|
|
|
}
|
|
@@ -73,14 +74,12 @@ namespace GxPress.Service.Implement.Navigation
|
|
|
|
|
|
public async Task<bool> UpdateAsync(MiddleLableUpRequest request)
|
|
|
{
|
|
|
-
|
|
|
try
|
|
|
{
|
|
|
using (var transactionScope = new System.Transactions.TransactionScope())
|
|
|
{
|
|
|
await middleLableRepository.UpdateAsync(request);
|
|
|
- if (!string.IsNullOrEmpty(request.LabelId))
|
|
|
- await middleLableNexusRepository.UpdateAsync(request.Id, request.LabelId);
|
|
|
+ await middleLableNexusRepository.UpdateAsync(request.Id, request.MiddleLableNexusUpRequests);
|
|
|
transactionScope.Complete();
|
|
|
}
|
|
|
}
|
|
@@ -90,5 +89,38 @@ namespace GxPress.Service.Implement.Navigation
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="middleLableId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<MiddleLableResult> GetMiddleLableResultAsync(int middleLableId)
|
|
|
+ {
|
|
|
+ var middleLable = await middleLableRepository.GetAsync(middleLableId);
|
|
|
+ var middleLableResult = _mapper.Map<MiddleLableResult>(middleLable);
|
|
|
+ middleLableResult.MiddleLableNexusResults = new List<MiddleLableNexusResult>();
|
|
|
+ var middleLableNexusList = await middleLableNexusRepository.GetAllTaskAsync(middleLableId);
|
|
|
+ var systemLabels = await systemLabelRepository.GetAllAsync(middleLableNexusList.Select(n => n.LableId).ToList());
|
|
|
+ foreach (var item in systemLabels)
|
|
|
+ {
|
|
|
+ foreach (var middleLableNexus in middleLableNexusList)
|
|
|
+ {
|
|
|
+ if (middleLableNexus.LableId == item.Id)
|
|
|
+ {
|
|
|
+ var middleLableNexusResult = new MiddleLableNexusResult()
|
|
|
+ {
|
|
|
+ Id = middleLableNexus.Id,
|
|
|
+ LableId = item.Id,
|
|
|
+ MiddleLableId = middleLableId,
|
|
|
+ MiddleLableName = item.LabelName,
|
|
|
+ Sort = middleLableNexus.Sort
|
|
|
+ };
|
|
|
+ middleLableResult.MiddleLableNexusResults.Add(middleLableNexusResult);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return middleLableResult;
|
|
|
+ }
|
|
|
}
|
|
|
}
|