示例#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 "['权限不足']"
示例#2
0
def GetPageListLogByGeneral(request):
    page = None
    rows = None
    sort = None
    order = None
    filter = None
    try:
        page = request.POST['page']
    except:
        page = 1

    try:
        rows = request.POST['rows']
    except:
        rows = 50

    try:
        sort = request.POST['sort']
    except:
        sort = 'createon'

    try:
        order = request.POST['order']
    except:
        order = 'desc'

    try:
        filter = request.POST['filter']
    except:
        filter = ''

    response = HttpResponse()

    whereStatement = SearchFilter.TransfromFilterToSql(filter, False)

    if not whereStatement:
        whereStatement = ' 1 = 1'

    dtLogByGeneral = UserSerivce.GetDTByPage(
        CommonUtils.Current(response, request),
        SearchFilter.TransfromFilterToSql(filter, False), '', '', rows,
        sort + ' ' + order)

    recordCount = dtLogByGeneral.count
    pageValue = dtLogByGeneral.page(page)

    userTmp = ''
    for role in pageValue:
        userTmp = userTmp + ', ' + json.dumps(role, cls=DateEncoder)
        userTmp = userTmp.strip(',')
    returnValue = '{"total": ' + str(
        recordCount) + ', "rows":[' + userTmp + ']}'

    response.content = returnValue
    return response