| | |
| | | using FlexJobApi.Core; |
| | | using Furion.DatabaseAccessor; |
| | | using Mapster; |
| | | using MediatR; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | public Task<Guid> Handle(SaveDictionaryDataCommand request, CancellationToken cancellationToken) |
| | | { |
| | | return request.SaveData<DictionaryData, SaveDictionaryDataCommand>( |
| | | (q, e, r) => q.Any(it => |
| | | it => |
| | | it.CategoryId == request.CategoryId |
| | | && it.ParentId == request.ParentId |
| | | && it.Code == request.Code |
| | | && it.Content == request.Content), cancellationToken); |
| | | && it.Content == request.Content |
| | | && it.Id != request.Id, |
| | | (entity) => |
| | | { |
| | | entity.Path = DbUtils.GetTreeDataPath<DictionaryData>(request.ParentId, cancellationToken).Result; |
| | | if (request.Id.HasValue) |
| | | { |
| | | DbUtils.UpdateTreeDataChildrenPath<DictionaryData>( |
| | | $"{entity.Path}/{entity.Code}/", |
| | | $"{entity.Path}/{request.Code}/", |
| | | cancellationToken).Wait(); |
| | | } |
| | | request.Adapt(entity); |
| | | }, |
| | | cancellationToken); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public Task<int> Handle(SetDictionaryDataIsDisabledCommand request, CancellationToken cancellationToken) |
| | | { |
| | | return request.SetIsDisable<DictionaryData>(cancellationToken: cancellationToken); |
| | | return request.SetIsDisabled<DictionaryData>(cancellationToken: cancellationToken); |
| | | } |
| | | } |
| | | } |