Ejemplo n.º 1
0
def all():
    latlngs = Latlng.query.all()  #字典
    # dict = {"lists": latlngs,
    #         "code": Success().code,
    #         "msg": Success().msg,
    #         "error_code": Success().error_code}
    return SuccessViewModel.redict(latlngs)
Ejemplo n.º 2
0
def search():
    form = LatlngSearchForm().validate_for_api()
    pname = '%' + form.pname.data + '%'
    # 获取传入的pname
    # pname <class 'str'>
    latlngs = Latlng.query.filter(Latlng.project_name.like(pname)).all()
    return SuccessViewModel.redict(latlngs)
Ejemplo n.º 3
0
def landsearch():
    keyword_completes = []
    form = LandSearchForm().validate_for_api()
    land_search = '%' + form.land_search._value().replace(" ", "") + '%'
    keyword_completes_plotnum = Land.query.filter(
        Land.plotnum.like(land_search)).all()
    for keyword_complete in keyword_completes_plotnum:
        keyword_completes.append(
            LandViewModel.landsearch(keyword_complete, "plotnum"))

    keyword_completes_block_location = Land.query.filter(
        Land.block_location.like(land_search)).all()
    for keyword_complete in keyword_completes_block_location:
        keyword_completes.append(
            LandViewModel.landsearch(keyword_complete, "block_location"))

    keyword_completes_competitive_unit = Land.query.filter(
        Land.competitive_unit.like(land_search)).all()
    for keyword_complete in keyword_completes_competitive_unit:
        keyword_completes.append(
            LandViewModel.landsearch(keyword_complete, "competitive_unit"))

    keyword_completes_deal_date = Land.query.filter(
        Land.deal_date.like(land_search)).all()
    for keyword_complete in keyword_completes_deal_date:
        keyword_completes.append(
            LandViewModel.landsearch(keyword_complete, "deal_date"))

    keyword_completes = list(set(keyword_completes))
    return SuccessViewModel.redict(keyword_completes)
Ejemplo n.º 4
0
def search_latlng():
    form = LandFilterFormId().validate_for_api()
    lat, lng = Land.query.with_entities(
        Land.lat, Land.lng).filter(Land.id == form.id.data).first()
    lands = Land.query.filter(and_(Land.lat == lat, Land.lng == lng)).all()
    lands = [LandViewModel.landsearchbylatlng(land) for land in lands]
    return SuccessViewModel.redict(lands)
Ejemplo n.º 5
0
def get_latlng(id):
    latlngs = Latlng.query.filter_by(id=id).first_or_404()
    # if status == '':
    #     status = 1
    # latlngs = Latlng.query.filter(
    #     Latlng.status == status
    # ).all()
    return SuccessViewModel.redict(latlngs)
Ejemplo n.º 6
0
def all():
    histsups = Histsup.query.all()
    histsups = [dict(histsup) for histsup in histsups]
    # 显示状态码
    for histsup in histsups:
        histsup["display_code"] = 0
    histsups[0]["display_code"] = 1
    return SuccessViewModel.redict(histsups)
Ejemplo n.º 7
0
def feedback():
    form = UserFeedbackForm().validate_for_api()
    uid = g.user.uid
    create_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    title = form.title.data
    text = form.text.data
    Feedback.feedback(uid=uid, create_time=create_time, title=title, text=text)
    return SuccessViewModel.redict(dicts=[])
Ejemplo n.º 8
0
def all():
    lands = Land.query.all()
    lands = [LandViewModel.landviewmodel(land) for land in lands]
    # 显示状态码
    for land in lands:
        land["display_code"] = 0
    lands[0]["display_code"] = 1

    return SuccessViewModel.redict(lands)
Ejemplo n.º 9
0
def land_histsup():
    form = FilterFormLand().validate_for_api()
    plotnum = form.plotnum.data
    histsups = Histsup.query.filter(Histsup.plotnum == plotnum).first()
    if histsups is not None:
        histsups = HistsupViewModel.histsearchbylandid(histsups)
    else:
        histsups = []

    return SuccessViewModel.redict(histsups)
Ejemplo n.º 10
0
def search_latlng():
    form = FilterFormId().validate_for_api()
    lat, lng = Histsup.query.with_entities(
        Histsup.lat, Histsup.lng).filter(Histsup.id == form.id.data).first()
    histsups = Histsup.query.filter(
        and_(Histsup.lat == lat,
             Histsup.lng == lng)).order_by(Histsup.opening_date.desc()).all()
    histsups = [
        HistsupViewModel.histsearchbylatlng(histsup) for histsup in histsups
    ]
    return SuccessViewModel.redict(histsups)
Ejemplo n.º 11
0
def get_token():
    form = ClientForm().validate_for_api()
    promise = {ClientTypeEnum.USER_EMAIL: User.verify}
    identity = promise[ClientTypeEnum(form.type.data)](form.account.data,
                                                       form.secret.data)
    # Token
    expiration = current_app.config['TOKEN_EXPIRATION']
    token = generate_auth_token(identity['uid'], form.type.data,
                                identity['scope'], expiration)
    t = {'token': token.decode('ascii')}  # 转化字符串类型
    # return jsonify(t), 201
    return SuccessViewModel.redict(t)
Ejemplo n.º 12
0
def histsearch():
    keyword_completes = []
    form = HistSearchForm().validate_for_api()
    building_search = '%' + form.building_search._value().replace(" ",
                                                                  "") + '%'
    # for attri in HIST_SEARCH_ATTRI:
    #     keyword_completes_building_promotion_name = Histsup.query.filter(
    #         or_(
    #             Histsup.building_promotion_name.like(building_search),
    #             Histsup.building_name.like(building_search),
    #             Histsup.presale_license_number.like(building_search),
    #             Histsup.building_address.like(building_search)
    #         )
    #     ).all()
    #     for keyword_complete in keyword_completes_building_promotion_name:
    #         keyword_completes.append(
    #             HistsupViewModel.histsearch(keyword_complete, attri)
    #         )

    keyword_completes_building_promotion_name = Histsup.query.filter(
        Histsup.building_promotion_name.like(building_search)).all()
    for keyword_complete in keyword_completes_building_promotion_name:
        keyword_completes.append(
            HistsupViewModel.histsearch(keyword_complete,
                                        "building_promotion_name"))

    keyword_completes_building_name = Histsup.query.filter(
        Histsup.building_name.like(building_search)).all()
    for keyword_complete in keyword_completes_building_name:
        keyword_completes.append(
            HistsupViewModel.histsearch(keyword_complete, "building_name"))

    keyword_completes_presale_license_number = Histsup.query.filter(
        Histsup.presale_license_number.like(building_search)).all()
    for keyword_complete in keyword_completes_presale_license_number:
        keyword_completes.append(
            HistsupViewModel.histsearch(keyword_complete,
                                        "presale_license_number"))

    keyword_completes_building_address = Histsup.query.filter(
        Histsup.building_address.like(building_search)).all()
    for keyword_complete in keyword_completes_building_address:
        keyword_completes.append(
            HistsupViewModel.histsearch(keyword_complete, "building_address"))

    keyword_completes = list(set(keyword_completes))
    return SuccessViewModel.redict(keyword_completes)
Ejemplo n.º 13
0
def prelic():
    form = SechandhouseFilterForm().validate_for_api()

    prelic = form.presale_license_number.data
    sechandhouses = Sechandhouse.query.filter(
        Sechandhouse.presale_license_number == prelic)
    total = len(sechandhouses.all())
    # 分页
    page = form.page.data
    per_page = form.per_page.data
    sechandhouses = PageChoose.PageChoose(page=page,
                                          per_page=per_page,
                                          data=sechandhouses)

    sechandhouses = \
        [SechandhouseViewModel.secviewmodel(sechandhouse) for sechandhouse in sechandhouses]

    return SuccessViewModel.redict_page(dicts=sechandhouses,
                                        page=page,
                                        total=total)
Ejemplo n.º 14
0
def prelic():
    form = SingleroomFilterForm().validate_for_api()
    ad = form.order_ad.data
    present = form.order_basis.data

    prelic = form.presale_license_number.data
    singlerooms = Singleroom.query.filter(
        Singleroom.presale_license_number == prelic
        # ,
        # Singleroom.state != '非销售房产'
    ).order_by(singleroom_order_ad.Singleroom_Order_Ad(ad=ad, present=present))

    total = len(singlerooms.all())
    # 分页
    page = form.page.data
    per_page = form.per_page.data
    singlerooms = PageChoose.PageChoose(page=page, per_page=per_page, data=singlerooms)

    singlerooms = [SingleroomViewModel.singleroomviewmodel(singleroom) for singleroom in singlerooms]
    # 总价无法计算是因为对象返回时list,未通过其他视图层转化成字典对象
    return SuccessViewModel.redict_page(dicts=singlerooms, page=page, total=total)
Ejemplo n.º 15
0
def all():
    sechandhouse = Sechandhouse.query.all()
    return SuccessViewModel.redict(sechandhouse)
Ejemplo n.º 16
0
def filter():
    form = FilterForm().validate_for_api()
    ad = form.order_ad.data
    present = form.order_basis.data
    # 多条件筛选
    building_search = '%' + form.building_search._value().replace(" ",
                                                                  "") + '%'
    #区域多选
    region_choose = \
        MultiSelect.MultiSelect(string=form.hist_region_choose.data, dic=HIST_REGION)

    histsups = Histsup.query.filter(
        and_(
            Histsup.opening_date >= DateIsEmpty.dateisempty(
                form.opening_date_min),
            Histsup.opening_date <= isempty.IsEmpty(form.opening_date_max),
            Histsup.huxing_area >= isempty.IsEmpty(form.huxing_area_min),
            Histsup.huxing_area <= isempty.IsEmpty(form.huxing_area_max),
            Histsup.houses_average >= isempty.IsEmpty(form.houses_average_min),
            Histsup.houses_average <= isempty.IsEmpty(form.houses_average_max),
            Histsup.commercial_average >= isempty.IsEmpty(
                form.commercial_average_min), Histsup.commercial_average <=
            isempty.IsEmpty(form.commercial_average_max),
            or_(Histsup.building_promotion_name.like(building_search),
                Histsup.building_name.like(building_search),
                Histsup.presale_license_number.like(building_search),
                Histsup.building_address.like(building_search)),
            or_(*[Histsup.region.like(r) for r in region_choose]))).order_by(
                histsup_order_ad.Histsup_Order_Ad(ad=ad, present=present))

    total = len(histsups.all())
    # 如果有page传入则分页,其他不分页
    page = form.page.data
    per_page = form.per_page.data
    histsups = PageChoose.PageChoose(page=page,
                                     per_page=per_page,
                                     data=histsups)

    # 视图层转化
    histsups = [
        HistsupViewModel.re_data(histsup,
                                 VIEW_TYPE[form.view_type_choose.data])
        for histsup in histsups
    ]

    # 添加levels字段
    hisrange = [
        histsup[VIEW_TYPE[form.view_type_choose.data]] for histsup in histsups
    ]
    level = form.data_level.data
    for histsup in histsups:
        for i in range(level):
            if histsup[VIEW_TYPE[form.view_type_choose.data]] <= \
                    DataLayer.DataLayer(lists=hisrange, degree=i+1, level=level):
                histsup['levels'] = i + 1
                break
    # 显示状态码
    if len(histsups) > 0:
        for histsup in histsups:
            histsup["display_code"] = 0
        histsups[0]["display_code"] = 1

    return SuccessViewModel.redict_page(histsups, page=page, total=total)
Ejemplo n.º 17
0
def filter():
    form = LandFilterForm().validate_for_api()
    ad = form.order_ad.data
    present = form.order_basis.data
    land_search = '%' + form.land_search._value().replace(" ", "") + '%'

    # 区域,土地用途,地块状态多选
    region_choose = \
        MultiSelect.MultiSelect(string=form.land_region_choose.data, dic=LAND_REGION)
    land_usage_choose = \
        MultiSelect.MultiSelect(string=form.land_usage_type_choose.data, dic=LAND_USAGE_TYPE)
    block_status_choose = \
        MultiSelect.MultiSelect(string=form.land_block_status_choose.data, dic=LAND_BLOCK_STATUS)

    lands = Land.query.filter(
        and_(
            Land.listing_start_date >= DateIsEmpty.dateisempty(
                form.listing_start_date_min), Land.listing_start_date <=
            isempty.IsEmpty(form.listing_start_date_max),
            Land.total_land_area >= isempty.IsEmpty(form.total_land_area_min),
            Land.total_land_area <= isempty.IsEmpty(form.total_land_area_max),
            Land.price >= isempty.IsEmpty(form.price_min),
            Land.price <= isempty.IsEmpty(form.price_max),
            Land.deal_date > isempty.IsEmpty(form.deal_date_min)
            if form.land_view_type_choose.data == '2' else
            Land.deal_date >= isempty.IsEmpty(form.deal_date_min),
            Land.deal_date <= isempty.IsEmpty(form.deal_date_max),
            Land.deal_price >= isempty.IsEmpty(form.deal_price_min),
            Land.deal_price <= isempty.IsEmpty(form.deal_price_max),
            or_(Land.plotnum.like(land_search),
                Land.block_name.like(land_search),
                Land.block_location.like(land_search),
                Land.competitive_unit.like(land_search),
                Land.deal_date.like(land_search)),
            or_(*[Land.region.like(r) for r in region_choose]),
            or_(*[Land.land_usage.like(l) for l in land_usage_choose]),
            or_(*[Land.block_status.like(b)
                  for b in block_status_choose]))).order_by(
                      land_order_ad.Land_Order_Ad(ad=ad, present=present))

    total = len(lands.all())
    # 如果有page传入则分页,其他不分页
    page = form.page.data
    per_page = form.per_page.data
    lands = PageChoose.PageChoose(page=page, per_page=per_page, data=lands)

    # 视图层转化
    lands = [
        LandViewModel.landviewmodel(
            land, LAND_VIEW_TYPE[form.land_view_type_choose.data])
        for land in lands
    ]

    # 添加levels字段
    landrange = [
        land[LAND_VIEW_TYPE[form.land_view_type_choose.data]] for land in lands
    ]
    level = int(form.data_level.data)
    for land in lands:
        for i in range(level):
            if land[LAND_VIEW_TYPE[form.land_view_type_choose.data]] <= \
                    DataLayer.DataLayer(lists=landrange, degree=i + 1, level=level):
                land['levels'] = i + 1
                break
    # 显示状态码
    if len(lands) > 0:
        for land in lands:
            land["display_code"] = 0
        lands[0]["display_code"] = 1

    return SuccessViewModel.redict_page(dicts=lands, page=page, total=total)
Ejemplo n.º 18
0
def search_id():
    form = LandFilterFormId().validate_for_api()
    idents = Land.query.filter(Land.id == form.id.data).first()
    idents = LandViewModel.landsearchbyid(idents)
    return SuccessViewModel.redict(idents)
Ejemplo n.º 19
0
def search_id():
    form = FilterFormId().validate_for_api()
    idents = Histsup.query.filter(Histsup.id == form.id.data).first()
    idents = HistsupViewModel.histsearchbyid(idents)
    return SuccessViewModel.redict(idents)
Ejemplo n.º 20
0
def logout():
    t = {'token': ''}
    session.clear()

    return SuccessViewModel.redict(t)
Ejemplo n.º 21
0
def all():
    singleroom = Singleroom.query.all()
    return SuccessViewModel.redict(singleroom)