예제 #1
0
파일: rst.py 프로젝트: liuzelei/walis
 def mget_last_record(cls, bankcard_ids):
     session = Session()
     subquery = session.query(cls)\
         .order_by(cls.created_at.desc()).subquery()
     query = session.query(cls, subquery).group_by(subquery.c.rst_id)\
         .filter(subquery.c.id.in_(bankcard_ids))
     return query.all()
예제 #2
0
파일: rst.py 프로젝트: liuzelei/walis
 def query(cls, rst_id, bankcard_id, limit=DEFAULT_RECORD_LIMIT):
     query = Session().query(cls)
     query = query.filter(cls.bankcard_id == bankcard_id)\
         .filter(cls.rst_id == rst_id)\
         .order_by(cls.created_at.desc())
     query = query.limit(limit)
     return query.all()
예제 #3
0
 def query(cls, rst_id, bankcard_id, limit=DEFAULT_RECORD_LIMIT):
     query = Session().query(cls)
     query = query.filter(cls.bankcard_id == bankcard_id)\
         .filter(cls.rst_id == rst_id)\
         .order_by(cls.created_at.desc())
     query = query.limit(limit)
     return query.all()
예제 #4
0
 def mget_last_record(cls, bankcard_ids):
     session = Session()
     subquery = session.query(cls)\
         .order_by(cls.created_at.desc()).subquery()
     query = session.query(cls, subquery).group_by(subquery.c.rst_id)\
         .filter(subquery.c.id.in_(bankcard_ids))
     return query.all()
예제 #5
0
def query_trs_query_cfg(city_id=None,
                        offset=DEFALUT_CITY_TRS_CFG_OFFSET,
                        limit=DEFALUT_CITY_TRS_CFG_LIMIT):
    if city_id is not None:
        return get_trs_query_cfg_by_city(city_id)
    q = DBSession().query(CityTransactionQueryConfig)
    q = q.offset(offset).limit(limit)
    return q.all()
예제 #6
0
파일: __init__.py 프로젝트: liuzelei/walis
def query_trs_query_cfg(city_id=None,
                        offset=DEFALUT_CITY_TRS_CFG_OFFSET,
                        limit=DEFALUT_CITY_TRS_CFG_LIMIT):
    if city_id is not None:
        return get_trs_query_cfg_by_city(city_id)
    q = DBSession().query(CityTransactionQueryConfig)
    q = q.offset(offset).limit(limit)
    return q.all()
예제 #7
0
def put():
    recruit_ids = [int(_id) for _id in json.loads(request.data).get("id_list")]
    status_to = int(json.loads(request.data).get("status"))
    session = DBSession()
    recruits = session.query(RestaurantRecruitment).filter(
        RestaurantRecruitment.id.in_(recruit_ids)).all()
    for recruit in recruits:
        recruit.status = status_to
    return ''
예제 #8
0
def query_bankcard_by_rst_ids(rst_ids, status=None):
    query = DBSession().query(RstBankCard)

    query = query.filter(RstBankCard.rst_id.in_(rst_ids))

    if status is not None:
        query = query.filter(RstBankCard.status == status)

    return query.all()
예제 #9
0
    def count(cls, rst_ids=None, status=None, type_code=None):
        query = Session().query(cls)

        if rst_ids is not None:
            query = query.filter(cls.rst_id.in_(rst_ids))
        if status is not None:
            query = query.filter(cls.status == status)
        if type_code is not None:
            query = query.filter(cls.type_code == type_code)
        return query.count()
예제 #10
0
파일: recruit.py 프로젝트: liuzelei/walis
def put():
    recruit_ids = [int(_id) for _id in
                   json.loads(request.data).get("id_list")]
    status_to = int(json.loads(request.data).get("status"))
    session = DBSession()
    recruits = session.query(RestaurantRecruitment).filter(
        RestaurantRecruitment.id.in_(recruit_ids)).all()
    for recruit in recruits:
        recruit.status = status_to
    return ''
예제 #11
0
파일: rst.py 프로젝트: liuzelei/walis
    def count(cls, rst_ids=None, status=None, type_code=None):
        query = Session().query(cls)

        if rst_ids is not None:
            query = query.filter(cls.rst_id.in_(rst_ids))
        if status is not None:
            query = query.filter(cls.status == status)
        if type_code is not None:
            query = query.filter(cls.type_code == type_code)
        return query.count()
예제 #12
0
파일: voicecall.py 프로젝트: liuzelei/walis
 def add(cls, restaurant_id=None, call_status=None,
         created_at=datetime.now(), phone=None, flush=False):
     session = DBSession()
     voice_call = cls(restaurant_id=restaurant_id,
                      call_status=call_status,
                      created_at=created_at,
                      phone=phone)
     session.add(voice_call)
     if flush:
         session.flush()
     return voice_call
예제 #13
0
파일: voicecall.py 프로젝트: liuzelei/walis
    def add(cls, restaurant_id, ban_type, flush=False):
        session = DBSession()
        exist_ban = cls.get_by_restaurant(restaurant_id)

        if not exist_ban:
            ban = cls(restaurant_id=restaurant_id,
                      ban_type=ban_type)
            session.add(ban)
            if flush:
                session.flush()
            return ban

        return None
예제 #14
0
파일: region.py 프로젝트: liuzelei/walis
    def query(cls, city_id=None, offset=None, limit=DEFAULT_QUERY_LIMIT):
        rb = DBSession().query(cls)

        if city_id is not None:
            rb = rb.filter(cls.city_id == city_id)

        if offset is not None:
            rb = rb.offset(offset)

        if limit is not None:
            rb = rb.limit(min(limit, MAX_QUERY_LIMIT))

        return rb.all()
예제 #15
0
def add_trs_query_cfg(city_id, date_from, date_end):
    city_trs_query_cfg = CityTransactionQueryConfig(city_id=city_id,
                                                    date_from=date_from,
                                                    date_end=date_end)

    DBSession().add(city_trs_query_cfg)
    return city_trs_query_cfg
예제 #16
0
def patch_update_restaurant_recruitment(data):
    obj_json = json.loads(data)
    _id = obj_json['id']
    obj = DBSession().query(RestaurantRecruitment).get(_id)
    for k, v in obj_json.iteritems():
        setattr(obj, k, v)
    return True
예제 #17
0
 def save(cls, name, type_code, city_id, area):
     DBSession().add(
         cls(
             name=name,
             type_code=type_code,
             city_id=city_id,
             area=area,
         ))
예제 #18
0
def query_events(status=None, category_l1=None, user_type=None, priority=None,
                 source=None, not_handler_id=None, handler_id=None,
                 is_to_compensate=None, begin_date=None, end_date=None, phone=None,
                 limit=None, offset=None):
    q = DBSession().query(CSEvent).order_by(CSEvent.updated_at.desc())

    if begin_date is not None:
        q = q.filter(CSEvent.created_at >= datestr2datetime(begin_date))

    if end_date is not None:
        q = q.filter(CSEvent.created_at <= datestr2datetime(end_date))

    if not_handler_id is not None:
        q = q.filter(CSEvent.handler_id != not_handler_id)

    if is_to_compensate is not None:
        if is_to_compensate:
            q = q.filter(CSEvent.compensation > 0)
        else:
            q = q.filter(CSEvent.compensation == 0)

    return make_query(q, CSEvent,
                      {'phone': phone, 'handler_id': handler_id, 'status': status,
                       'category_l1': category_l1, 'user_type': user_type,
                       'priority': priority, 'source': source, 'limit': limit,
                       'offset': offset})
예제 #19
0
def query_restaurant_recruitment(q):
    s = DBSession()
    search_params = json.loads(q)
    result = make_search_query(s, RestaurantRecruitment, search_params)
    is_single = search_params.get('single', False)
    if is_single:
        result = [result.serialize()]
    else:
        result = [obj.serialize() for obj in result]
    return result
예제 #20
0
def _diff_bankcard(walis_bankcard_dict, zeus_bankcard_dict, user_dict,
                   user_profile_dict):
    add_num = 0
    change_num = 0
    same_num = 0
    not_admin_num = 0
    session = DBSession()
    for zb_rst_id, zb in zeus_bankcard_dict.iteritems():
        wb = walis_bankcard_dict.get(zb_rst_id)
        rst_admin = user_profile_dict.get(zb.user_id)
        if rst_admin is None:
            not_admin_num += 1
            continue
        if wb is not None:
            if zb.card_id.strip() == wb.card_id.strip():
                same_num += 1
                continue
            else:
                change_num += 1
                print('walis_bankcard({}) is not same with zeus({}):{}=>{}'.
                      format(wb.id, zb.id, model2dict(wb), ttype2dict(zb)))
                _current_to_history(wb)
                session.add(wb)
                new_wb = _force_add_rst_bankcard(
                    rst_id=zb_rst_id,
                    username=user_dict[zb.user_id]['username'],
                    cardholder_name=zb.cardholder_name,
                    card_id=zb.card_id,
                    bank_id=zb.bank_id,
                    mobile=rst_admin.mobile,
                    status=RstBankCard.STATUS_VALID)
                session.add(new_wb)
        else:
            add_num += 1
            print('zeus_bankcard({}) does not exist in walis:{}'.format(
                zb.id, ttype2dict(zb)))
            new_wb = _force_add_rst_bankcard(
                rst_id=zb_rst_id,
                username=user_dict[zb.user_id]['username'],
                cardholder_name=zb.cardholder_name,
                card_id=zb.card_id,
                bank_id=zb.bank_id,
                mobile=rst_admin.mobile,
                status=RstBankCard.STATUS_VALID)
            session.add(new_wb)

    print(
        '(add_num:{add_num}, change_num:{change_num}, same_num:{same_num}, not_admin_num:{not_admin_num})'
        .format(add_num=add_num,
                change_num=change_num,
                same_num=same_num,
                not_admin_num=not_admin_num))
예제 #21
0
파일: rst.py 프로젝트: liuzelei/walis
    def update(cls, id, **bankcard_dict):
        query = Session().query(cls)
        query = query.filter(cls.id == id)
        rst_bankcard = query.first()
        if not rst_bankcard:
            return ''

        status = bankcard_dict.get('status')
        if status == cls.STATUS_VALID \
                and rst_bankcard.status == cls.STATUS_VALID:
            raise_user_exc(BANKCARD_UPDATE_ERR)

        if rst_bankcard.status == cls.STATUS_HISTORY:
            raise_user_exc(BANKCARD_STATUS_INVALID)

        for k, v in bankcard_dict.iteritems():
            if hasattr(rst_bankcard, k):
                setattr(rst_bankcard, k, v)

        Session().add(rst_bankcard)
예제 #22
0
    def update(cls, id, **bankcard_dict):
        query = Session().query(cls)
        query = query.filter(cls.id == id)
        rst_bankcard = query.first()
        if not rst_bankcard:
            return ''

        status = bankcard_dict.get('status')
        if status == cls.STATUS_VALID \
                and rst_bankcard.status == cls.STATUS_VALID:
            raise_user_exc(BANKCARD_UPDATE_ERR)

        if rst_bankcard.status == cls.STATUS_HISTORY:
            raise_user_exc(BANKCARD_STATUS_INVALID)

        for k, v in bankcard_dict.iteritems():
            if hasattr(rst_bankcard, k):
                setattr(rst_bankcard, k, v)

        Session().add(rst_bankcard)
예제 #23
0
파일: rst.py 프로젝트: liuzelei/walis
 def query_by_status(cls, rst_ids=None, status=None, type_code=None, offset=0, limit=None,):
     query = Session().query(cls)
     if rst_ids is not None:
         query = query.filter(cls.rst_id.in_(rst_ids))
     if status is not None:
         query = query.filter(cls.status == status)
     if type_code is not None:
         query = query.filter(cls.type_code == type_code)
     query = query.order_by(cls.created_at.desc(), cls.rst_id)
     if offset:
         query = query.offset(offset)
     if limit:
         query = query.limit(limit)
     return query.all()
예제 #24
0
def add_restaurant_recruitment(data):
    s = DBSession()
    obj = RestaurantRecruitment.from_tobj(data)
    s.add(obj)
    s.flush()
    obj_id = obj.id
    return obj_id
예제 #25
0
파일: rst.py 프로젝트: liuzelei/walis
 def query_by_rst(cls, rst_id, status=None, offset=0, limit=None):
     query = Session().query(cls)
     query = query.filter(cls.rst_id == rst_id)
     if status is not None:
         query = query.filter(cls.status == status)
     query = query.order_by(cls.updated_at.desc()).order_by(cls.status.desc())
     if offset:
         query = query.offset(offset)
     if limit:
         query = query.limit(limit)
     return query.all()
예제 #26
0
 def query_by_rst(cls, rst_id, status=None, offset=0, limit=None):
     query = Session().query(cls)
     query = query.filter(cls.rst_id == rst_id)
     if status is not None:
         query = query.filter(cls.status == status)
     query = query.order_by(cls.updated_at.desc()).order_by(
         cls.status.desc())
     if offset:
         query = query.offset(offset)
     if limit:
         query = query.limit(limit)
     return query.all()
예제 #27
0
파일: recruit.py 프로젝트: liuzelei/walis
def count_by_uid(user_id, status=None):
    q = DBSession().query(func.count(RestaurantRecruitment.id)).\
        filter(RestaurantRecruitment.restaurant_id > 0)

    if status is not None:
        q = q.filter(RestaurantRecruitment.status == status)

    # if super admin
    if current_user.is_super_admin():
        return q.scalar()

    with thrift_client('ers') as ers:
        user_struct = ers.get_direct_struct(user_id)

    # if city.admin
    if user_struct.city_ids:
        return q.filter(
            RestaurantRecruitment.city_id.in_(user_struct.city_ids)).all().scalar()

    region_ids = []
    # if region_group.admin
    if user_struct.region_group_ids:
        with thrift_client('ers') as ers:
            regions = ers.get_regions_by_region_group_ids(
                user_struct.region_group_ids)
        region_ids = [region.id for region in regions]

    # if region.admin
    if user_struct.region_ids:
        region_ids.extend(user_struct.region_ids)
        region_ids = list(set(region_ids))

    with thrift_client('ers') as ers:
        restaurant_ids = ers.mget_restaurant_in_region(region_ids, True)

    return q.filter(RestaurantRecruitment.restaurant_id.in_(restaurant_ids)).scalar()
예제 #28
0
 def add(cls,
         order_id=None,
         sequence_number=None,
         status_code=None,
         key_pressed=None,
         created_at=datetime.now(),
         call_id=None):
     voice_order = cls(order_id=order_id,
                       sequence_number=sequence_number,
                       status_code=status_code,
                       key_pressed=key_pressed,
                       created_at=created_at,
                       call_id=call_id)
     DBSession().add(voice_order)
     return voice_order
예제 #29
0
def add_change_record(user_id, from_type, to_type):
    session = DBSession()
    new_record = CSProcessTypeChangeRecord(
        user_id=user_id,
        from_type=from_type,
        to_type=to_type
    )

    session.add(new_record)
    session.flush()
    return new_record.id
예제 #30
0
    def add(cls, restaurant_id, ban_type, flush=False):
        session = DBSession()
        exist_ban = cls.get_by_restaurant(restaurant_id)

        if not exist_ban:
            ban = cls(restaurant_id=restaurant_id, ban_type=ban_type)
            session.add(ban)
            if flush:
                session.flush()
            return ban

        return None
예제 #31
0
    def query(cls, city_id=None, offset=None, limit=DEFAULT_QUERY_LIMIT):
        rb = DBSession().query(cls)

        if city_id is not None:
            rb = rb.filter(cls.city_id == city_id)

        if offset is not None:
            rb = rb.offset(offset)

        if limit is not None:
            rb = rb.limit(min(limit, MAX_QUERY_LIMIT))

        return rb.all()
예제 #32
0
 def query_by_status(
     cls,
     rst_ids=None,
     status=None,
     type_code=None,
     offset=0,
     limit=None,
 ):
     query = Session().query(cls)
     if rst_ids is not None:
         query = query.filter(cls.rst_id.in_(rst_ids))
     if status is not None:
         query = query.filter(cls.status == status)
     if type_code is not None:
         query = query.filter(cls.type_code == type_code)
     query = query.order_by(cls.created_at.desc(), cls.rst_id)
     if offset:
         query = query.offset(offset)
     if limit:
         query = query.limit(limit)
     return query.all()
예제 #33
0
    def add(cls, record_id, phone, restaurant_id, restaurant_name,
            activity_name, first_date, last_date, amount, total_subsidy,
            process_date, card_num_tail, sms_task_id, status):

        DBSession().add(
            cls(
                record_id=record_id,
                phone=phone,
                restaurant_id=restaurant_id,
                restaurant_name=restaurant_name,
                activity_name=activity_name,
                first_date=first_date,
                last_date=last_date,
                amount=amount,
                total_subsidy=total_subsidy,
                process_date=process_date,
                card_num_tail=card_num_tail,
                sms_task_id=sms_task_id,
                status=status,
            ))
예제 #34
0
 def add(cls,
         restaurant_id=None,
         call_status=None,
         created_at=datetime.now(),
         phone=None,
         flush=False):
     session = DBSession()
     voice_call = cls(restaurant_id=restaurant_id,
                      call_status=call_status,
                      created_at=created_at,
                      phone=phone)
     session.add(voice_call)
     if flush:
         session.flush()
     return voice_call
예제 #35
0
def get_by_uid(user_id, status=None, offset=None, limit=None):
    q = DBSession().query(RestaurantRecruitment).\
        filter(RestaurantRecruitment.restaurant_id > 0)

    if status is not None:
        q = q.filter(RestaurantRecruitment.status == status)

    if offset is not None:
        q = q.offset(offset)

    if limit is not None:
        q = q.limit(min(limit, MAX_QUERY_LIST_SIZE))

    # if super admin
    if current_user.is_super_admin():
        return q

    with thrift_client('ers') as ers:
        user_struct = ers.get_direct_struct(user_id)

    # if city.admin
    if user_struct.city_ids:
        return q.filter(RestaurantRecruitment.city_id.in_(
            user_struct.city_ids)).all()

    region_ids = []
    # if region_group.admin
    if user_struct.region_group_ids:
        with thrift_client('ers') as ers:
            regions = ers.get_regions_by_region_group_ids(
                user_struct.region_group_ids)
        region_ids = [region.id for region in regions]

    # if region.admin
    if user_struct.region_ids:
        region_ids.extend(user_struct.region_ids)
        region_ids = list(set(region_ids))

    with thrift_client('ers') as ers:
        restaurant_ids = ers.mget_restaurant_in_region(region_ids, True)

    return q.filter(RestaurantRecruitment.restaurant_id.in_(restaurant_ids))
예제 #36
0
def _diff_bankcard(walis_bankcard_dict, zeus_bankcard_dict, user_dict, user_profile_dict):
    add_num = 0
    change_num = 0
    same_num = 0
    not_admin_num = 0
    session = DBSession()
    for zb_rst_id, zb in zeus_bankcard_dict.iteritems():
        wb = walis_bankcard_dict.get(zb_rst_id)
        rst_admin = user_profile_dict.get(zb.user_id)
        if rst_admin is None:
            not_admin_num += 1
            continue
        if wb is not None:
            if zb.card_id.strip() == wb.card_id.strip():
                same_num += 1
                continue
            else:
                change_num += 1
                print('walis_bankcard({}) is not same with zeus({}):{}=>{}'
                      .format(wb.id, zb.id, model2dict(wb), ttype2dict(zb)))
                _current_to_history(wb)
                session.add(wb)
                new_wb = _force_add_rst_bankcard(rst_id=zb_rst_id, username=user_dict[zb.user_id]['username'],
                                                 cardholder_name=zb.cardholder_name, card_id=zb.card_id,
                                                 bank_id=zb.bank_id, mobile=rst_admin.mobile,
                                                 status=RstBankCard.STATUS_VALID)
                session.add(new_wb)
        else:
            add_num += 1
            print('zeus_bankcard({}) does not exist in walis:{}'.format(zb.id, ttype2dict(zb)))
            new_wb = _force_add_rst_bankcard(rst_id=zb_rst_id, username=user_dict[zb.user_id]['username'],
                                             cardholder_name=zb.cardholder_name, card_id=zb.card_id,
                                             bank_id=zb.bank_id, mobile=rst_admin.mobile,
                                             status=RstBankCard.STATUS_VALID)
            session.add(new_wb)

    print('(add_num:{add_num}, change_num:{change_num}, same_num:{same_num}, not_admin_num:{not_admin_num})'
          .format(add_num=add_num, change_num=change_num, same_num=same_num, not_admin_num=not_admin_num))
예제 #37
0
파일: recruit.py 프로젝트: liuzelei/walis
def get_by_uid(user_id, status=None, offset=None, limit=None):
    q = DBSession().query(RestaurantRecruitment).\
        filter(RestaurantRecruitment.restaurant_id > 0)

    if status is not None:
        q = q.filter(RestaurantRecruitment.status == status)

    if offset is not None:
        q = q.offset(offset)

    if limit is not None:
        q = q.limit(min(limit, MAX_QUERY_LIST_SIZE))

    # if super admin
    if current_user.is_super_admin():
        return q

    with thrift_client('ers') as ers:
        user_struct = ers.get_direct_struct(user_id)

    # if city.admin
    if user_struct.city_ids:
        return q.filter(
            RestaurantRecruitment.city_id.in_(user_struct.city_ids)).all()

    region_ids = []
    # if region_group.admin
    if user_struct.region_group_ids:
        with thrift_client('ers') as ers:
            regions = ers.get_regions_by_region_group_ids(
                user_struct.region_group_ids)
        region_ids = [region.id for region in regions]

    # if region.admin
    if user_struct.region_ids:
        region_ids.extend(user_struct.region_ids)
        region_ids = list(set(region_ids))

    with thrift_client('ers') as ers:
        restaurant_ids = ers.mget_restaurant_in_region(region_ids, True)

    return q.filter(RestaurantRecruitment.restaurant_id.in_(restaurant_ids))
예제 #38
0
def count_events(status=None, category_l1=None, user_type=None, priority=None,
                 source=None, not_handler_id=None, handler_id=None,
                 is_to_compensate=None, begin_date=None, end_date=None, phone=None):
    q = DBSession().query(func.count(CSEvent.id))

    if begin_date is not None:
        q = q.filter(CSEvent.created_at >= datestr2datetime(begin_date))

    if end_date is not None:
        q = q.filter(CSEvent.created_at <= datestr2datetime(end_date))

    if not_handler_id is not None:
        q = q.filter(CSEvent.handler_id != not_handler_id)

    if is_to_compensate is not None:
        if is_to_compensate:
            q = q.filter(CSEvent.compensation > 0)
        else:
            q = q.filter(CSEvent.compensation == 0)

    return make_query(q, CSEvent,
                      {'phone': phone, 'handler_id': handler_id, 'status': status,
                       'category_l1': category_l1, 'user_type': user_type,
                       'priority': priority, 'source': source}).scalar()
예제 #39
0
def count_by_uid(user_id, status=None):
    q = DBSession().query(func.count(RestaurantRecruitment.id)).\
        filter(RestaurantRecruitment.restaurant_id > 0)

    if status is not None:
        q = q.filter(RestaurantRecruitment.status == status)

    # if super admin
    if current_user.is_super_admin():
        return q.scalar()

    with thrift_client('ers') as ers:
        user_struct = ers.get_direct_struct(user_id)

    # if city.admin
    if user_struct.city_ids:
        return q.filter(RestaurantRecruitment.city_id.in_(
            user_struct.city_ids)).all().scalar()

    region_ids = []
    # if region_group.admin
    if user_struct.region_group_ids:
        with thrift_client('ers') as ers:
            regions = ers.get_regions_by_region_group_ids(
                user_struct.region_group_ids)
        region_ids = [region.id for region in regions]

    # if region.admin
    if user_struct.region_ids:
        region_ids.extend(user_struct.region_ids)
        region_ids = list(set(region_ids))

    with thrift_client('ers') as ers:
        restaurant_ids = ers.mget_restaurant_in_region(region_ids, True)

    return q.filter(
        RestaurantRecruitment.restaurant_id.in_(restaurant_ids)).scalar()
예제 #40
0
파일: rst.py 프로젝트: liuzelei/walis
 def get_next(cls, id, status=STATUS_PENDING):
     query = Session().query(cls)
     query = query.filter(cls.status == status)\
         .filter(cls.id < id).order_by(cls.id.desc())
     return query.first()
예제 #41
0
def get_voice_order(order_id):
    voice_order = DBSession.query(VoiceOrder).filter(
        VoiceOrder.order_id == order_id).first()
    return voice_order.serialize()
예제 #42
0
def mget_voice_order(order_ids):
    voice_orders = DBSession.query(VoiceOrder).filter(
        VoiceOrder.order_id.in_(order_ids)).all()
    return {v_order.order_id: v_order.serialize() for v_order in voice_orders}
예제 #43
0
 def get_by_status(cls, call_status):
     return DBSession().query(cls).filter(
         cls.call_status == call_status).all()
예제 #44
0
 def get(cls, call_id):
     return DBSession().query(cls).get(call_id)
예제 #45
0
def get_restaurant_recruitment(_id):
    obj = DBSession.query(RestaurantRecruitment).get(_id)
    return obj.serialize()
예제 #46
0
 def get_by_call_id(cls, call_id):
     return DBSession().query(cls).filter(cls.call_id == call_id).all()
예제 #47
0
def update_restaurant_recruitment(data):
    s = DBSession()
    obj = RestaurantRecruitment.from_tobj(data)
    # todo 检查data中id是否存在,数据库中对应id是否存在
    s.merge(obj)
    return True
예제 #48
0
def delete_restaurant_recruitment(_id):
    s = DBSession()
    obj = s.query(RestaurantRecruitment).get(_id)
    s.delete(obj)
    s.commit()
    return True
예제 #49
0
파일: activity.py 프로젝트: liuzelei/walis
 def get(cls, reply_id):
     return DBSession.query(cls).get(reply_id)
예제 #50
0
파일: __init__.py 프로젝트: liuzelei/walis
def get_trs_query_cfg_by_city(city_id):
    q = DBSession().query(CityTransactionQueryConfig)
    q = q.filter(CityTransactionQueryConfig.city_id == city_id)
    return q.first()
예제 #51
0
파일: rst.py 프로젝트: liuzelei/walis
 def get(cls, rst_id, id):
     query = Session().query(cls)
     query = query.filter(cls.id == id).filter(cls.rst_id == rst_id)
     return query.first()
예제 #52
0
파일: rst.py 프로젝트: liuzelei/walis
 def get_pre(cls, id, status=STATUS_PENDING):
     query = Session().query(cls)
     query = query.filter(cls.status == status)\
         .filter(cls.id > id).order_by(cls.id)
     return query.first()