Exemplo n.º 1
0
        public async Task <List <IPrivilege> > QueryUserPrivilegeList(string appCode, string userId, int type)
        {
            string sql = @"SELECT DISTINCT A.privilege_code as PrivilegeCode,A.privilege_name as PrivilegeName,A.privilege_type as PrivilegeType,A.parent_code as ParentCode,A.mark as Mark,A.resource as Resource,A.sequence as Sequence FROM privilege A
                            INNER JOIN role_privilege_relation B on A.privilege_code = B.privilege_code 
                            INNER JOIN role_user_relation C on B.role_code = C.role_code
                           WHERE  A.app_code = @AppCode";


            if (type > 0)
            {
                sql += " and A.privilege_type=" + type;
            }

            sql += " ORDER BY A.sequence ASC";
            var param = new
            {
                AppCode          = appCode,
                UserUID          = userId,
                EveryoneRoleCode = RuleHelper.GetAppEveryoneRuleCode(appCode)
            };
            var list = await base.QueryAsync <Privilege>(sql, param);

            return(list.ToList <IPrivilege>());
        }