Exemple #1
0
        public async Task <ResultList <PermissionMenuInfoDetailsResponseDto> > Export([FromBody] PermissionMenuExportRequestDto dto)
        {
            // 验证请求数据合法性
            var result = dto.Valid();

            if (!result.Success)
            {
                return(ResultList <PermissionMenuInfoDetailsResponseDto> .ReFailure(result));
            }
            if (dto.List != null && dto.List.Count > 0)
            {
                List <PermissionMenuInfoDetailsResponseDto> res = new List <PermissionMenuInfoDetailsResponseDto>();

                foreach (var item in dto.List)
                {
                    res.Add(item);
                    var children = await this._permissionRepository.GetActionListByParentId(item.Id);

                    var child = Mapper.Map <List <PermissionMenuInfoDetailsResponseDto> >(children);
                    if (child != null && child.Count > 0)
                    {
                        foreach (var chi in child)
                        {
                            res.Add(chi);
                        }
                    }
                }
                return(ResultList <PermissionMenuInfoDetailsResponseDto> .ReSuccess(res));
            }
            else
            {
                return(ResultList <PermissionMenuInfoDetailsResponseDto> .ReFailure("没有菜单", 200));
            }
        }
Exemple #2
0
        public virtual async Task <Result> Import(PermissionMenuExportRequestDto dto)
        {
            //验证请求数据合法性
            var result = dto.Valid();

            if (!result.Success)
            {
                return(result);
            }

            if (dto.List != null && dto.List.Count > 0)
            {
                foreach (var item in dto.List)
                {
                    var model = await this._permissionRepository.GetAsync(item.Id);

                    if (model != null)
                    {
                        //修改
                        var entity = item.To();
                        await _permissionRepository.ModifyAsync(entity);
                    }
                    else
                    {
                        //添加
                        var entity = item.To();
                        await _permissionRepository.AddAsync(entity);
                    }
                }
            }
            return(Result.ReSuccess());
        }