Beispiel #1
0
        public ActionResult AdminUserDetail(long id)
        {
            #region 用户信息

            UserViewModel user = null;
            if (id > 0)
            {
                AdminUserFilterDto filter = new AdminUserFilterDto()
                {
                    SysNos = new List <long>()
                    {
                        id
                    },
                };
                user = userService.GetUser(filter).MapTo <UserViewModel>();
            }
            if (user == null || !(user is AdminUserViewModel))
            {
                return(Content("没有找到用户信息"));
            }
            var adminUser = user as AdminUserViewModel;

            #endregion

            return(View(adminUser));
        }
Beispiel #2
0
 public ActionResult EditUser(EditUserViewModel user)
 {
     if (IsPost)
     {
         user.UserType = UserType.管理账户;
         AdminUserCmdDto adminUser = user.MapTo <AdminUserCmdDto>();
         SaveUserCmdDto  saveInfo  = new SaveUserCmdDto()
         {
             User = adminUser
         };
         var result = userService.SaveUser(saveInfo);
         return(Json(result));
     }
     else if (user.SysNo > 0)
     {
         AdminUserFilterDto filter = new AdminUserFilterDto()
         {
             SysNos = new List <long>()
             {
                 user.SysNo
             }
         };
         user = userService.GetUser(filter).MapTo <EditUserViewModel>();
     }
     return(View(user));
 }
        /// <summary>
        /// 管理用户查询对象
        /// </summary>
        /// <param name="adminUserFilter">管理用户筛选对象</param>
        /// <returns></returns>
        public IQuery CreateAdminQueryObject(AdminUserFilterDto adminUserFilter)
        {
            if (adminUserFilter == null)
            {
                return(null);
            }
            IQuery userQuery = CreateQueryObject(adminUserFilter, true) ?? QueryFactory.Create <UserQuery>();

            #region 角色筛选

            if (adminUserFilter.RoleFilter != null)
            {
                IQuery roleQuery = this.Instance <IRoleBusiness>().CreateQueryObject(adminUserFilter.RoleFilter);
                if (roleQuery != null && roleQuery.Criterias.Count > 0)
                {
                    roleQuery.AddQueryFields <RoleQuery>(c => c.SysNo);
                    IQuery userRoleQuery = QueryFactory.Create <UserRoleQuery>();
                    userRoleQuery.And <UserRoleQuery>(u => u.RoleSysNo, CriteriaOperator.In, roleQuery);
                    userRoleQuery.AddQueryFields <UserRoleQuery>(u => u.UserSysNo);
                    userQuery.And <UserQuery>(c => c.SysNo, CriteriaOperator.In, userRoleQuery);
                }
            }

            #endregion

            return(userQuery);
        }
Beispiel #4
0
        public Result List(AdminUserFilterDto dto, int loggedInUserId)
        {
            var result =
                new AdminUserActionFactory(_adminUserRepository, _unitOfWork).ExecuteAction(dto, loggedInUserId);

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

            var query = _adminUserRepository.AsNoTracking;

            query = new AdminUserFilter(query, dto).FilteredQuery();
            query = new AdminUserListOrder(query, dto).OrderByQuery();
            result.SetPaging(dto?.Page ?? 1, dto?.Size ?? 10, query.Count());

            result.Data = query.Select(s => new
            {
                s.Id,
                s.Name,
                s.Email,
                s.IsActive,
                s.LastLoginAt,
                s.CreatedAt,
                AdminRoles = s.Roles.Select(x => new { x.Name }).ToList()
            })
                          .ToPaged(result.Paging.Page, result.Paging.Size)
                          .ToList();

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// 管理用户查询对象
        /// </summary>
        /// <param name="adminUserFilter">管理用户筛选对象</param>
        /// <returns></returns>
        public IQuery CreateAdminQueryObject(AdminUserFilterDto adminUserFilter)
        {
            if (adminUserFilter == null)
            {
                return(null);
            }
            IQuery userQuery = CreateQueryObject(adminUserFilter, true) ?? QueryFactory.Create <UserQuery>();

            #region 角色筛选

            if (adminUserFilter.RoleFilter != null)
            {
                IQuery roleQuery = this.Instance <IRoleBusiness>().CreateQueryObject(adminUserFilter.RoleFilter);
                if (roleQuery != null && roleQuery.Criterias.Count > 0)
                {
                    roleQuery.AddQueryFields <RoleQuery>(c => c.SysNo);
                    IQuery userRoleQuery = QueryFactory.Create <UserRoleQuery>();
                    userRoleQuery.And <UserRoleQuery>(u => u.RoleSysNo, CriteriaOperator.In, roleQuery);
                    userRoleQuery.AddQueryFields <UserRoleQuery>(u => u.UserSysNo);
                    userQuery.And <UserQuery>(c => c.SysNo, CriteriaOperator.In, userRoleQuery);
                }
            }
            if (!adminUserFilter.WithoutRoles.IsNullOrEmpty())
            {
                IQuery withRoleQuery = QueryFactory.Create <UserRoleQuery>();
                withRoleQuery.In <UserRoleQuery>(r => r.RoleSysNo, adminUserFilter.WithoutRoles);
                withRoleQuery.AddQueryFields <UserRoleQuery>(r => r.UserSysNo);
                userQuery.And <UserQuery>(u => u.SysNo, CriteriaOperator.NotIn, withRoleQuery);
            }

            #endregion

            #region 加载数据

            if (adminUserFilter.LoadRole)
            {
                userQuery.SetLoadPropertys <AdminUser>(true, c => c.Roles);
            }

            #endregion

            return(userQuery);
        }
Beispiel #6
0
 public IHttpActionResult Get([FromUri] AdminUserFilterDto dto)
 {
     return(Result(_adminUserService.List(dto, UserAuth.AdminUser.UserId)));
 }