Beispiel #1
0
    def GetUserListByPage(ctx,
                          userInfo,
                          page=1,
                          rows=50,
                          sort='sortcode',
                          order='asc',
                          filter=''):

        try:
            user = SecretHelper.AESDecrypt(userInfo)
            user = json.loads(user, object_hook=UserInfo.json_2_obj)
        except:
            yield "['认证失败']"

        if PublicController.ApiIsAuthorized(
                user, "UserManagement.GetUserListByPage"):

            dtUser = UserSerivce.GetDTByPage(
                user, SearchFilter.TransfromFilterToSql(filter, False), '', '',
                rows, sort + ' ' + order)
            recordCount = dtUser.count
            pageValue = dtUser.page(page)

            userTmp = ''
            for role in pageValue:
                userTmp = userTmp + ', ' + json.dumps(role, cls=DateEncoder)
                userTmp = userTmp.strip(',')
            returnValue = '{"total": ' + str(
                recordCount) + ', "rows":[' + userTmp + ']}'
            yield returnValue
        else:
            yield "['权限不足']"
Beispiel #2
0
    def GetUserPageDTByDepartmentId(ctx, userInfo, organizeId, searchValue,
                                    page, rows):
        try:
            user = SecretHelper.AESDecrypt(userInfo)
            user = json.loads(user, object_hook=UserInfo.json_2_obj)
        except:
            yield "['认证失败']"

        if PublicController.ApiIsAuthorized(
                user, "UserManagement.GetUserPageDTByDepartmentId"):

            searchValue = searchValue if searchValue else ''

            jsons = "[]"
            returnValue = ''

            if organizeId:
                recordCount = 0
                recordCount, dtUser = UserOrganizeService.GetUserPageDTByDepartment(
                    None, user, 'Resource.ManagePermission', searchValue, None,
                    '', None, True, True, page, rows, 'sortcode', organizeId)
                userTmp = ''
                for user in dtUser:
                    userTmp = userTmp + ', ' + json.dumps(user,
                                                          cls=DateEncoder)
                userTmp = userTmp.strip(',')
                returnValue = '{"total": ' + str(
                    recordCount) + ', "rows":[' + userTmp + ']}'

                yield returnValue
            else:
                yield jsons
        else:
            yield "['权限不足']"