コード例 #1
0
ファイル: RoleManager.cs プロジェクト: dovanduy/CountryTrain
        /// <summary>
        ///     获取指定角色下的用户
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public SysUser[] FindUserInRole(int roleId)
        {
            string sql = @"SELECT Sys_Users.* FROM Sys_Users LEFT JOIN Sys_RoleUser
ON Sys_Users.UserId=Sys_RoleUser.UserId
 WHERE  Sys_Users.Status=0 AND Sys_RoleUser.RoleId=" + roleId;

            return(_dataAccess.GetListBySql <SysUser>(sql).ToArray());
        }
コード例 #2
0
        public List<vTenantFunction> GetPermissionsByUserId(int userId)
        {
            string sql = @"SELECT distinct m.* FROM vTenantFunction m
LEFT JOIN Sys_RolePermission rm ON m.PermissionId=rm.PermissionId
LEFT JOIN Sys_RoleUser ru ON ru.RoleId=rm.RoleId
LEFT JOIN Sys_Roles r ON ru.RoleId=r.RoleId OR r.IsDefault=1
LEFT JOIN Sys_Users u ON u.UserId=ru.UserId AND m.TenantId=u.TenantId
WHERE r.Freezed = 0 and r.Status = 0 and u.UserId=" + userId
+ " ORDER BY m.Sort";
            return _dataAccess.GetListBySql<vTenantFunction>(sql).ToList();
        }
コード例 #3
0
        public bool FreezeUser(int[] userId)
        {
            if (userId.Length == 0)
            {
                return(false);
            }
            var users = _dataAccess.GetListBySql <SysUser>("select Freezed,UserId from Sys_Users where UserId in (" + userId.GetString() + ") and Status = 0");
            var tmp1  = users.Where(p => p.Freezed).Select(p => p.UserId);
            var tmp2  = users.Where(p => !p.Freezed).Select(p => p.UserId);
            List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >();

            list.Add(new KeyValuePair <string, string>("Freezed", "0"));
            list.Add(new KeyValuePair <string, string>("LoginFailure", "0"));
            _dataAccess.UpdateFields("Sys_Users", list, "UserId in (" + tmp1.GetString() + ")");
            _dataAccess.UpdateField("Sys_Users", "Freezed", "1", "UserId in (" + tmp2.GetString() + ")");
            return(true);
        }
コード例 #4
0
        /// <summary>
        /// 获取指定用户关注的所有人
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public IEnumerable <int> GetAttentions(int userId)
        {
            var sql = "SELECT UserId2 FROM Int_Relationship WHERE UserId=" + userId;

            return(_dataAccess.GetListBySql <int>(sql));
        }