sunpengfei
2025-08-05 356c47fb0ea1a642784e85c82833141d065bc4bc
FlexJobApi.User.Application/Menus/Commands/SaveMenuFieldCommandHandler.cs
@@ -24,9 +24,12 @@
        /// <inheritdoc/>
        public async Task<Guid> Handle(SaveMenuFieldCommand 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);
                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, "菜单编号");
@@ -36,6 +39,9 @@
            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, "菜单编号");
                await rep.InsertAsync(entity);