From bc6813b74e9a390eae2181d460c647445b7cb25a Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期三, 06 八月 2025 11:22:18 +0800 Subject: [PATCH] feat:数据字典开发 --- FlexJobApi.User.Application/Menus/Commands/SaveMenuButtonCommandHandler.cs | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/FlexJobApi.User.Application/Menus/Commands/SaveMenuButtonCommandHandler.cs b/FlexJobApi.User.Application/Menus/Commands/SaveMenuButtonCommandHandler.cs index 21d9a7e..342236e 100644 --- a/FlexJobApi.User.Application/Menus/Commands/SaveMenuButtonCommandHandler.cs +++ b/FlexJobApi.User.Application/Menus/Commands/SaveMenuButtonCommandHandler.cs @@ -24,20 +24,26 @@ /// <inheritdoc/> public async Task<Guid> Handle(SaveMenuButtonCommand request, CancellationToken cancellationToken) { + var parent = await rep.FirstOrDefaultAsync(it => it.Id == request.ParentId); + if (parent == null) throw Oops.Oh(EnumErrorCodeType.s404, "涓婄骇鑿滃崟"); if (request.Id.HasValue) { - var entity = await rep.FirstOrDefaultAsync(it => it.Id == it.Id); + var entity = await rep.FirstOrDefaultAsync(it => it.Id == request.Id); + if (entity == null) throw Oops.Oh(EnumErrorCodeType.s404, "璇ヨ彍鍗�"); if (entity.ParentId != request.ParentId) throw Oops.Oh(EnumErrorCodeType.s410, "涓婄骇Id"); request.Adapt(entity); - if (await CheckExist(entity)) throw Oops.Oh(EnumErrorCodeType.s405, "鑿滃崟缂栧彿"); + if (await CheckExist(entity)) throw Oops.Oh(EnumErrorCodeType.s406, "鑿滃崟缂栧彿"); await rep.UpdateAsync(entity); return entity.Id; } else { var entity = new Menu(); + entity.Path = $"{parent.Path}{parent.Code}/"; + entity.Type = EnumMenuType.Button; + entity.VisitLevel = parent.VisitLevel; request.Adapt(entity); - if (await CheckExist(entity)) throw Oops.Oh(EnumErrorCodeType.s405, "鑿滃崟缂栧彿"); + if (await CheckExist(entity)) throw Oops.Oh(EnumErrorCodeType.s406, "鑿滃崟缂栧彿"); await rep.InsertAsync(entity); return entity.Id; } @@ -53,6 +59,7 @@ return await rep.AsQueryable().AsNoTracking() .AnyAsync(it => it.ParentId == entity.ParentId + && it.Type == entity.Type && it.Group == entity.Group && it.Location == entity.Location && it.Code == entity.Code -- Gitblit v1.9.1