public IActionResult GetAllMenu()
        {
            var result = new TResultModel <List <MenuVModel> >(1);

            return(this.Wrapper(ref result, () =>
            {
                result.TModel = _subMenuRepository.GetAll <MenuVModel>();
            }, true));
        }
        public IActionResult GetByEmail([FromBody] EmailVModel model)
        {
            var result = new TResultModel <List <MenuVModel> >(1);

            return(this.Wrapper(ref result, () =>
            {
                var user = _userRepository.GetByEmail(model.email);
                if (user == null)
                {
                    result.ResultNo = -2;
                    result.Message = "非管理账号";
                    return;
                }
                if (user.Status == 2)
                {
                    result.ResultNo = -3;
                    result.Message = $"账号已冻结,如有疑问,可以发邮件给管理员";
                    return;
                }
                var role = _roleRepository.GetByUserId(user.Id);
                if (role == null)
                {
                    result.ResultNo = -1;
                    result.Message = "账号未设置角色,请联系管理员";
                    return;
                }
                var allMenus = _subMenuRepository.GetAll <MenuVModel>();
                if (role.Type == 1)
                {
                    result.TModel = allMenus;
                }
                else
                {
                    var thirdMenus = _subMenuRepository.GetByRoleId <MenuVModel>(role.Id);
                    if (thirdMenus?.Any() ?? false)
                    {
                        var secondMenus = allMenus.FindAll(x => thirdMenus.Exists(y => x.id == y.parentId) && !thirdMenus.Exists(y => x.id == y.id));
                        if (secondMenus?.Any() ?? false)
                        {
                            thirdMenus.AddRange(secondMenus);
                            var firstMenus = allMenus.FindAll(x => secondMenus.Exists(y => x.id == y.parentId) && !secondMenus.Exists(y => x.id == y.id));
                            if (firstMenus?.Any() ?? false)
                            {
                                thirdMenus.AddRange(firstMenus);
                            }
                        }
                    }

                    result.TModel = thirdMenus?.Distinct( )?.ToList();
                }
            }, true));
        }
        public IActionResult GetAll()
        {
            var result = new TResultModel <List <TagVModel> >(1);

            return(this.Wrapper(ref result, () => {
                var tags = _tagRepository.GetList(50);
                result.TModel = new List <TagVModel>();
                tags?.ForEach(ea => {
                    result.TModel.Add(new TagVModel()
                    {
                        tagId = ea.Id,
                        tagName = ea.Name
                    });
                });
            }, true));
        }
        public IActionResult GetAll()
        {
            var result = new TResultModel <List <RoleVModel> >(1);

            return(this.Wrapper(ref result, () =>
            {
                result.TModel = new List <RoleVModel>();
                _roleRepository.GetList(100)?.ForEach(ea =>
                {
                    result.TModel.Add(new RoleVModel()
                    {
                        id = ea.Id,
                        name = ea.Name,
                        remark = ea.Remark,
                        type = ea.Type
                    });
                });
            }, true));
        }
        public IActionResult GetAll()
        {
            var result = new TResultModel <List <CategroyVModel> >(1);

            return(this.Wrapper(ref result, () =>
            {
                result.TModel = new List <CategroyVModel>();
                var categorys = _categoryRepository.GetInUse();
                categorys?.ForEach(ea =>
                {
                    result.TModel.Add(new CategroyVModel()
                    {
                        id = ea.Id,
                        isDel = ea.IsDel,
                        name = ea.Name,
                        remark = ea.Remark
                    });
                });
            }, false));
        }
Example #6
0
        public IActionResult AddImage([FromForm] ImageFileVModel imageFileVModel)
        {
            var result = new TResultModel <FileNameVModel>(1);

            return(this.Wrapper(ref result, () =>
            {
                var file = imageFileVModel.file;
                var userId = _claimEntity.userId;
                var suffix = Path.GetExtension(file.FileName);//提取上传的文件文件后缀
                //if (this._pictureOptions.FileTypes.IndexOf(suffix) >= 0)//检查文件格式
                //{
                var fileName = $@"{Guid.NewGuid()}{suffix}";
                var baseUrl = _configuration["ImageUrl"];
                var imageUrl = Path.Combine(baseUrl, userId.ToString(), fileName);

                var path = Path.Combine($@"D:\Image", userId.ToString());
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                var fullpath = Path.Combine(path, fileName);
                using (FileStream fs = System.IO.File.Create(fullpath)) //注意路径里面最好不要有中文
                {
                    file.CopyTo(fs);                                    //将上传的文件文件流,复制到fs中
                    fs.Flush();                                         //清空文件流
                }
                _photoRepository.Add(new HeyTom.Resources.Model.Photo()
                {
                    AlbumId = imageFileVModel.albumId,
                    CreateDate = DateTime.Now,
                    Name = file.FileName,
                    Path = imageUrl,
                    UserId = userId
                });

                result.TModel = new FileNameVModel()
                {
                    fileName = imageUrl
                };
            }, true));
        }
Example #7
0
        public IActionResult GetUserInfo()
        {
            var result = new TResultModel <UserInfo>(1);

            return(Wrapper(ref result, () => {
                var token = HttpContext.Request.Headers["Authorization"];
                var payload = JwtHelper.SerializeJwt(token);
                var userInfo = new UserInfo();

                payload.TryGetValue(ClaimTypes.Role, out var role);
                payload.TryGetValue("Name", out var name);
                payload.TryGetValue("Id", out object Id);

                result.TModel = new UserInfo()
                {
                    Name = name.ToString(),
                    Role = role.ToString(),
                    Id = int.Parse(Id.ToString())
                };
            }, false));
        }
Example #8
0
        public IActionResult GetUserInfo()
        {
            var result = new TResultModel <UserInfoVModel>(1);

            return(this.Wrapper(ref result, () =>
            {
                var userId = this._claimEntity.userId;
                var user = _userRepository.GetById(userId);
                if (user == null)
                {
                    result.ResultNo = -1;
                    result.Message = "用户信息有误";
                    return;
                }
                result.TModel = new UserInfoVModel()
                {
                    email = user.Email,
                    id = user.Id,
                    name = user.Name,
                    remark = user.Remark
                };
            }, true));
        }