Пример #1
0
def insert(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            if not args['data'].has_key('department_code') or not args[
                    'data'].has_key('department_name'):
                field_list = []
                if not args['data'].has_key('department_code'):
                    field_list.append("department_code")
                if not args['data'].has_key('department_name'):
                    field_list.append("department_name")
                lock.release()
                return {"error": {"fields": field_list, "code": "missing"}}

            data = set_dict_data(args)
            ret = models.HCSSYS_Departments().insert(data)
            lock.release()
            return ret

        lock.release()
        return dict(error="request parameter is not exist")
    except Exception as ex:
        lock.release()
        raise (ex)
Пример #2
0
def get_list(args):
    items = models.HCSSYS_Departments().aggregate().project(
        department_code = 1,
        department_name = 1,
        parent_code = 1
        )
    
    return items.get_list()
Пример #3
0
def delete(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            ret = models.HCSSYS_Departments().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)
Пример #4
0
def update(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            data = set_dict_data(args)
            ret = models.HCSSYS_Departments().update(data,
                                                     "_id == @id",
                                                     id=ObjectId(
                                                         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)