コード例 #1
0
 public async Task ModifyMemberIconAsync(Int32 userId, Int32 memberId, String newIcon)
 {
     Check.IfNullOrZero(userId);
     Check.IfNullOrZero(memberId);
     Check.IfNullOrZero(newIcon);
     await Task.Run(() =>
     {
         using var mapper = EntityMapper.CreateMapper();
         {
             try
             {
                 var member = new Member();
                 member.ModifyIconUrl(newIcon);
                 var result = mapper.Update(member, mem => mem.Id == memberId && mem.UserId == userId);
                 if (!result)
                 {
                     throw new BusinessException("修改桌面应用图片失败");
                 }
             }
             catch (System.Exception)
             {
                 throw;
             }
         }
     });
 }
コード例 #2
0
        public async Task <Role> GetRoleAsync(Int32 roleId)
        {
            Check.IfNullOrZero(roleId);

            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        return mapper.Query <Role>()
                        .Where(a => a.Id == roleId)
                        .Select(a => new
                        {
                            a.Id,
                            a.Name,
                            a.RoleIdentity
                        }).FirstOrDefault();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
コード例 #3
0
 public async Task ModifyAppTypeAsync(String appTypeName, Boolean isSystem, Int32 appTypeId)
 {
     Check.IfNullOrZero(appTypeName);
     Check.IfNullOrZero(appTypeId);
     await Task.Run(() =>
     {
         using var mapper = EntityMapper.CreateMapper();
         try
         {
             #region 更新应用分类
             {
                 var appType = new AppType();
                 appType.ModifyName(appTypeName);
                 if (isSystem)
                 {
                     appType.System();
                 }
                 else
                 {
                     appType.NotSystem();
                 }
                 var result = mapper.Update(appType, type => type.Id == appTypeId);
                 if (!result)
                 {
                     throw new BusinessException("更新应用分类");
                 }
             }
             #endregion
         }
         catch (System.Exception)
         {
             throw;
         }
     });
 }
コード例 #4
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task ModifyMemberDirectionToYAsync(Int32 userId)
        {
            Check.IfNullOrZero(userId);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var config = new Config();
                        config.DirectionToY();
                        var result = mapper.Update(config, conf => conf.UserId == userId);
                        if (!result)
                        {
                            throw new BusinessException("修改桌面应用为Y轴失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #5
0
        public async Task ModifyRoleAsync(Role role)
        {
            Check.IfNullOrZero(role);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        #region 修改角色
                        {
                            role.ModifyRoleName(role.Name);
                            var result = mapper.Update(role, r => r.Id == role.Id);
                            if (!result)
                            {
                                throw new BusinessException("修改角色失败");
                            }
                        }
                        #endregion
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #6
0
        public async Task <App> ReleaseAppAsync(Int32 appId)
        {
            Check.IfNullOrZero(appId);
            return(await Task.Run <App>(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                try
                {
                    #region 发布应用
                    {
                        var app = new App().AppRelease().Pass();
                        var result = mapper.Update(app, a => a.Id == appId);
                        if (!result)
                        {
                            throw new BusinessException("发布应用失败");
                        }
                    }
                    #endregion

                    #region 获取应用名称
                    {
                        return mapper.Query <App>().Where(a => a.Id == appId).Select(a => new { a.Name, a.UserId }).FirstOrDefault();
                    }
                    #endregion
                }
                catch (System.Exception)
                {
                    throw;
                }
            }));
        }
コード例 #7
0
        public async Task CreateNewAppTypeAsync(AppType appType)
        {
            Check.IfNullOrZero(appType);
            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                try
                {
                    #region 前置条件验证
                    {
                        var result = mapper.Query <AppType>().Where(a => a.Name == appType.Name).Count();
                        if (result > 0)
                        {
                            throw new BusinessException($@"分类:{appType.Name},已存在");
                        }
                    }
                    #endregion

                    #region 添加应用分类
                    {
                        var result = mapper.Add(appType);
                        if (result.Id <= 0)
                        {
                            throw new BusinessException("添加应用分类失败");
                        }
                    }
                    #endregion
                }
                catch (System.Exception)
                {
                    throw;
                }
            });
        }
コード例 #8
0
        public async Task <List <Wallpaper> > GetUploadWallpaperAsync(Int32 userId)
        {
            Check.IfNullOrZero(userId);

            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        return mapper.Query <Wallpaper>()
                        .Where(a => a.UserId == userId && a.Source != WallpaperSource.System)
                        .Select(a => new
                        {
                            a.UserId,
                            a.Height,
                            a.Id,
                            a.Md5,
                            a.ShortUrl,
                            a.Source,
                            a.Title,
                            a.Url,
                            a.Width
                        }).ToList();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
コード例 #9
0
        public async Task ModifyAppStarAsync(Int32 userId, Int32 appId, Int32 starCount)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(appId);
            Check.IfNullOrZero(starCount);
            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                try
                {
                    #region 前置条件判断
                    {
                        var result = mapper.Query <AppStar>().Where(a => a.UserId == userId && a.AppId == appId).Count();
                        if (result > 0)
                        {
                            throw new BusinessException("您已为这个应用打分");
                        }
                    }
                    #endregion

                    #region sql
                    {
                        var appStar = new AppStar(userId, appId, starCount);
                        mapper.Add(appStar);
                    }
                    #endregion
                }
                catch (System.Exception)
                {
                    throw;
                }
            });
        }
コード例 #10
0
        public async Task ModifyWallpaperAsync(Int32 userId, Int32 newWallpaperId)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(newWallpaperId);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var config = new Config();
                        config.NotFromBing().ModifyWallpaperId(newWallpaperId);
                        var result = mapper.Update(config, conf => conf.UserId == userId);
                        if (!result)
                        {
                            throw new BusinessException("修改壁纸失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #11
0
        public async Task <Wallpaper> GetUploadWallpaperAsync(String md5)
        {
            Check.IfNullOrZero(md5);

            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        return mapper.Query <Wallpaper>()
                        .Where(a => a.Md5 == md5)
                        .Select(a => new
                        {
                            a.UserId,
                            a.Height,
                            a.Id,
                            a.Md5,
                            a.ShortUrl,
                            a.Source,
                            a.Title,
                            a.Url,
                            a.Width
                        }).FirstOrDefault();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
コード例 #12
0
        public async Task ModifyWallpaperModeAsync(Int32 userId, String newMode)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(newMode);

            await Task.Run(() =>
            {
                if (Enum.TryParse(newMode, true, out WallpaperMode wallpaperMode))
                {
                    using var mapper = EntityMapper.CreateMapper();
                    {
                        try
                        {
                            var config = new Config();
                            config.ModeTo(wallpaperMode);
                            var result = mapper.Update(config, conf => conf.UserId == userId);
                            if (!result)
                            {
                                throw new BusinessException("修改壁纸显示失败");
                            }
                        }
                        catch (System.Exception)
                        {
                            throw;
                        }
                    }
                }
                else
                {
                    throw new BusinessException($"无法识别的壁纸显示模式:{newMode}");
                }
            });
        }
コード例 #13
0
        public async Task <(Int32 wapperId, String url)> AddWallpaperAsync(Wallpaper wallpaper)
        {
            Check.IfNullOrZero(wallpaper);
            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        #region 前置条件验证
                        {
                            var result = mapper.Query <Wallpaper>().Where(w => w.UserId == wallpaper.UserId).Count();
                            if (result > 6)
                            {
                                throw new BusinessException("最多只能上传6张图片");
                            }
                        }
                        #endregion

                        #region 插入壁纸
                        {
                            wallpaper = mapper.Add(wallpaper);
                            return (wallpaper.Id, wallpaper.Url);
                        }
                        #endregion
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
コード例 #14
0
 public async Task <List <Wallpaper> > GetWallpapersAsync()
 {
     return(await Task.Run(() =>
     {
         using var mapper = EntityMapper.CreateMapper();
         {
             try
             {
                 return mapper.Query <Wallpaper>()
                 .Where(a => a.Source == WallpaperSource.System)
                 .Select(a => new
                 {
                     a.UserId,
                     a.Height,
                     a.Id,
                     a.Md5,
                     a.ShortUrl,
                     a.Source,
                     a.Title,
                     a.Url,
                     a.Width
                 }).ToList();
             }
             catch (System.Exception)
             {
                 throw;
             }
         }
     }));
 }
コード例 #15
0
ファイル: UserContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task <Wallpaper> GetWallpaperAsync(Int32 wallPaperId)
        {
            Check.IfNullOrZero(wallPaperId);

            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        return mapper.Query <Wallpaper>()
                        .Where(w => w.Id == wallPaperId)
                        .Select(a => new
                        {
                            a.Url,
                            a.Width,
                            a.Height,
                            a.Source
                        }).FirstOrDefault();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
コード例 #16
0
ファイル: UserContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task <User> GetUserAsync(Int32 userId)
        {
            Check.IfNullOrZero(userId);

            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        return mapper.Query <User>()
                        .InnerJoin <Config>((a, b) => a.Id == b.UserId)
                        .Where(w => !w.IsDeleted)
                        .Select <User, Config>((a, b) => new
                        {
                            b.UserFace,
                            a.Id,
                            a.IsAdmin,
                            a.IsDisable,
                            a.IsOnline,
                            a.Name,
                            a.LockScreenPassword,
                            a.LoginPassword,
                            a.LastLoginTime,
                            a.AddTime,
                            b.IsModifyUserFace
                        }).FirstOrDefault();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
コード例 #17
0
        public async Task <Boolean> CheckPermissionsAsync(Int32 accessAppId, params Int32[] roleIds)
        {
            Check.IfNullOrZero(accessAppId);
            Check.IfNullOrZero(roleIds);

            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        #region 检查app是否为系统app
                        {
                            var result = mapper.Query <App>().Where(a => a.Id == accessAppId && a.IsSystem).Select().Count();
                            if (result <= 0)
                            {
                                return true;
                            }
                        }
                        #endregion
                        {
                            var result = mapper.Query <RolePower>().Where(a => roleIds.Contains(a.RoleId)).Select(a => new { a.AppId }).ToList();
                            return result.Any(a => a.AppId == accessAppId);
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
コード例 #18
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task ModifySkinAsync(Int32 userId, String newSkin)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(newSkin);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var config = new Config();
                        config.ModifySkin(newSkin);
                        var result = mapper.Update(config, conf => conf.UserId == userId);
                        if (!result)
                        {
                            throw new BusinessException("修改皮肤失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #19
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
 public async Task ModifyWallpaperSourceAsync(String source, Int32 userId)
 {
     Check.IfNullOrZero(source);
     Check.IfNullOrZero(userId);
     await Task.Run(() =>
     {
         using var mapper = EntityMapper.CreateMapper();
         {
             try
             {
                 var config = new Config();
                 if (source.ToLower() == WallpaperSource.Bing.ToString().ToLower())
                 {
                     config.FromBing();
                 }
                 else
                 {
                     config.NotFromBing();
                 }
                 var result = mapper.Update(config, conf => conf.UserId == userId);
                 if (!result)
                 {
                     throw new BusinessException("修改壁纸来源失败");
                 }
             }
             catch (System.Exception)
             {
                 throw;
             }
         }
     });
 }
コード例 #20
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
        public IList <Notify> CheckUnreadNotifyCount(Int32 userId, Int32 pageIndex, Int32 pageSize, out Int32 totalCount)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(pageIndex);
            Check.IfNullOrZero(pageSize);
            using var mapper = EntityMapper.CreateMapper();
            {
                try
                {
                    totalCount = mapper.Query <Notify>().Where(w => w.ToUserId == userId).Count();

                    return(mapper.Query <Notify>().Where(w => w.ToUserId == userId)
                           .Select(a => new
                    {
                        a.Id,
                        a.Title,
                        a.Content,
                        a.IsRead,
                        a.ToUserId
                    }).Page(pageIndex, pageSize).ToList());
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
        }
コード例 #21
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task ModifyDockPositionAsync(Int32 userId, Int32 defaultDeskNumber, String position)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(defaultDeskNumber);
            Check.IfNullOrZero(position);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var config      = new Config();
                        var newPosition = EnumExtensions.ToEnum <DockPosition>(position);
                        config.PositionTo(newPosition);
                        var result = mapper.Update(config, conf => conf.UserId == userId && conf.DefaultDeskNumber == defaultDeskNumber);
                        if (!result)
                        {
                            throw new BusinessException("修改应用码头位置失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #22
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task DockToOtherDeskAsync(Int32 userId, Int32 memberId, Int32 deskId)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(memberId);
            Check.IfNullOrZero(deskId);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var member = new Member();
                        member.OutDock().ModifyDeskIndex(deskId);
                        var result = mapper.Update(member, mem => mem.Id == memberId && mem.UserId == userId);
                        if (!result)
                        {
                            throw new BusinessException("桌面应用从应用码头移动到另一桌面时失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #23
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task MemberInDockAsync(Int32 userId, Int32 memberId)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(memberId);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var member = new Member();
                        member.OnDock();
                        var result = mapper.Update(member, mem => mem.Id == memberId && mem.UserId == userId);
                        if (!result)
                        {
                            throw new BusinessException("将桌面应用移动到应用码头失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #24
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task FolderToOtherFolderAsync(Int32 userId, Int32 memberId, Int32 folderId)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(memberId);
            Check.IfNullOrZero(folderId);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var member = new Member();
                        member.ModifyFolderId(folderId);
                        var result = mapper.Update(member, mem => mem.Id == memberId && mem.UserId == userId);
                        if (!result)
                        {
                            throw new BusinessException("桌面应用从文件夹移动到另一个文件夹中失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #25
0
ファイル: DeskContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task ModifyMemberVerticalSpacingAsync(Int32 userId, Int32 newSize)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(newSize);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var config = new Config();
                        config.ModifyAppHorizontalSpacing(newSize);
                        var result = mapper.Update(config, conf => conf.UserId == userId);
                        if (!result)
                        {
                            throw new BusinessException("修改桌面应用垂直间距失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #26
0
ファイル: UserContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task ModifyLockScreenPasswordAsync(Int32 userId, String newScreenPassword)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(newScreenPassword);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var user   = new User().ModifyLockScreenPassword(newScreenPassword);
                        var result = mapper.Update(user, acc => acc.Id == userId && !acc.IsDisable);
                        if (!result)
                        {
                            throw new BusinessException("修改锁屏密码失败");
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #27
0
ファイル: UserContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task DisableAsync(Int32 userId)
        {
            Check.IfNullOrZero(userId);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        #region 前置条件验证
                        {
                            var result = mapper.Query <Role>().InnerJoin <UserRole>((a, b) => a.Id == b.RoleId).Where <UserRole>((a, b) => a.IsAllowDisable && b.UserId == userId).Count();
                            if (result > 0)
                            {
                                throw new BusinessException("当前用户拥有管理员角色,因此不能禁用或删除");
                            }
                        }
                        #endregion
                        {
                            var user   = new User().Disable();
                            var result = mapper.Update(user, acc => acc.Id == userId);
                            if (!result)
                            {
                                throw new BusinessException("用户启用失败");
                            }
                        }
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            });
        }
コード例 #28
0
ファイル: UserContext.cs プロジェクト: haoxiaofan/newcrmcore
        public async Task <List <Role> > GetRolesAsync(Int32 userId)
        {
            Check.IfNullOrZero(userId);

            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        return mapper.Query <Role>()
                        .InnerJoin <UserRole>((a, b) => a.Id == b.RoleId)
                        .Where <UserRole>(a => a.UserId == userId)
                        .Select(a => new
                        {
                            a.Id,
                            a.Name,
                            a.RoleIdentity
                        })
                        .ThenByDesc <DateTime>(a => a.AddTime)
                        .ToList();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
コード例 #29
0
        public List <Log> GetLogs(String userName, Int32 logLevel, Int32 pageIndex, Int32 pageSize, out Int32 totalCount)
        {
            Check.IfNullOrZero(userName, true);
            Check.IfNullOrZero(logLevel);

            try
            {
                using var mapper = EntityMapper.CreateMapper();
                try
                {
                    var level    = EnumExtensions.ToEnum <LogLevel>(logLevel);
                    var logWhere = FilterFactory.Create <Log>(w => w.LogLevelEnum == level);

                    var userWhere = FilterFactory.Create <User>();
                    if (!String.IsNullOrEmpty(userName))
                    {
                        userWhere.And(w => w.Name.Contains(userName));
                    }

                    var filter = logWhere.Append(userWhere);

                    #region totalCount
                    {
                        totalCount = mapper.Query <Log>()
                                     .LeftJoin <User>((a, b) => a.UserId == b.Id)
                                     .Where <User>(filter).Count();
                    }
                    #endregion

                    #region sql
                    {
                        return(mapper.Query <Log>().LeftJoin <User>((a, b) => a.UserId == b.Id)
                               .Where <User>(filter)
                               .Select(a => new
                        {
                            a.LogLevelEnum,
                            a.Controller,
                            a.Action,
                            a.ExceptionMessage,
                            a.UserId,
                            a.AddTime
                        })
                               .Page(pageIndex, pageSize)
                               .ThenByDesc <DateTime>(a => a.AddTime)
                               .ToList());
                    }
                    #endregion
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #30
0
        public async Task <Member> GetMemberAsync(Int32 userId, Int32 memberId, Boolean isFolder)
        {
            Check.IfNullOrZero(userId);
            Check.IfNullOrZero(memberId);

            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        var where = new StringBuilder();
                        var parameters = new List <MapperParameter>();
                        if (isFolder)
                        {
                            parameters.Add(new MapperParameter("Id", memberId));
                            parameters.Add(new MapperParameter("MemberType", MemberType.Folder.ToValue <Int32>()));
                            where.Append($@" AND a.Id=@Id AND a.MemberType=@MemberType");
                        }
                        else
                        {
                            parameters.Add(new MapperParameter("Id", memberId));
                            where.Append($@" AND a.Id=@Id OR a.AppId=@Id");
                        }

                        var sql = $@"SELECT 
								a.MemberType,
								a.AppId,
								a.AppUrl,
								a.DeskIndex,
								a.FolderId,
								a.Height,
								a.IconUrl,
								a.Id,
								a.IsFlash,
								a.IsOnDock,
								a.IsOpenMax,
								a.IsResize,
								a.IsSetbar,
								a.Name,
								a.Width,
								a.UserId,
								a.IsIconByUpload,
								IFNULL((
									SELECT AVG(stars.StartNum) FROM newcrm_app_star AS stars WHERE stars.AppId=a.AppId AND stars.IsDeleted=0 GROUP BY stars.AppId
								),0) AS StarCount
								FROM newcrm_user_member AS a WHERE a.UserId=@UserId {where} AND a.IsDeleted=0"                                ;
                        parameters.Add(new MapperParameter("UserId", userId));
                        return mapper.SqlQuery(sql, parameters.ToArray()).FirstOrDefault <Member>();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }