Beispiel #1
0
def get_datail_with_searchtext(args):
    searchText = args['data'].get('search', '')
    pageSize = args['data'].get('pageSize', 0)
    pageIndex = args['data'].get('pageIndex', 20)
    sort = args['data'].get('sort', 20)
    where = args['data'].get('where', None)

    pageIndex = (lambda pIndex: pIndex if pIndex != None else 0)(pageIndex)
    pageSize = (lambda pSize: pSize if pSize != None else 20)(pageSize)
    ret = models.HCSSYS_ExcelTemplate().aggregate().project(
            function_id = 1,
            detail = 1
            )

    if where != None:
        ret.match("function_id == @func_id",func_id=where['function_id'])

    if(searchText != None):
        ret.match("contains(template_name, @name)",name=searchText)

    if(sort != None):
        ret.sort(sort)
        
    rs = ret.get_page(pageIndex, pageSize)

    if len(rs['items']) > 0:
        return {
                'total_items': rs['total_items'], 
                'items': rs['items'][0]['detail'], 
                'page_index': rs['page_index'], 
                'page_size': rs['page_size']
            }
    return rs
Beispiel #2
0
def get_list_with_searchtext(args):
    searchText = args['data'].get('search', '')
    pageSize = args['data'].get('pageSize', 0)
    pageIndex = args['data'].get('pageIndex', 20)
    sort = args['data'].get('sort', 20)
    where = args['data'].get('where', None)

    pageIndex = (lambda pIndex: pIndex if pIndex != None else 0)(pageIndex)
    pageSize = (lambda pSize: pSize if pSize != None else 20)(pageSize)
    ret = models.HCSSYS_ExcelTemplate().aggregate().project(
            function_id = 1,
            template_code = 1,
            template_name = 1,
            is_default = 1,
            view_name = 1
            )

    if where != None:
        ret.match("function_id == @func_id",func_id=where['function_id'])

    if(searchText != None):
        ret.match("contains(template_name, @name)",name=searchText)

    if(sort != None):
        ret.sort(sort)
        
    return ret.get_page(pageIndex, pageSize)
Beispiel #3
0
def delete(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            ret  =  models.HCSSYS_ExcelTemplate().delete("_id in {0}",[ObjectId(x["_id"])for x in args['data']])
            lock.release()
            return ret

        lock.release()
        return dict(
            error = "request parameter is not exist"
        )
    except Exception as ex:
        lock.release()
        raise(ex)
Beispiel #4
0
def update(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            data =  set_dict_update_data(args)
            ret  =  models.HCSSYS_ExcelTemplate().update(data, "_id == {0}", _id = args['data']['_id'])
            lock.release()
            return ret

        lock.release()
        return dict(
            error = "request parameter is not exist"
        )
    except Exception as ex:
        lock.release()
        raise(ex)
Beispiel #5
0
def insert(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            data =  set_dict_insert_data(args)
            ret  =  models.HCSSYS_ExcelTemplate().insert(data)
            lock.release()
            return ret

        lock.release()
        return dict(
            error = "request parameter is not exist"
        )
    except Exception as ex:
        lock.release()
        raise(ex)
Beispiel #6
0
def remove_detail(args):
    try:
        lock.acquire()
        ret = {}
        id = ""
        if args['data'] != None:
            filter_value=helpers.filter("detail.field_name == {0}", args['data']['detail'][0]['field_name']).get_filter()
            ret  =  models.HCSSYS_ExcelTemplate().update({
                    "$pull": filter_value
                },"_id == {0}",id)
            lock.release()
            return ret

        lock.release()
        return dict(
            error = "request parameter is not exist"
        )
    except Exception as ex:
        lock.release()
        raise(ex)