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)
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)
def all(): latlngs = Latlng.query.all() #字典 # dict = {"lists": latlngs, # "code": Success().code, # "msg": Success().msg, # "error_code": Success().error_code} return SuccessViewModel.redict(latlngs)
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)
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=[])
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)
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)
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)
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)
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)
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)
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)
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)
def all(): sechandhouse = Sechandhouse.query.all() return SuccessViewModel.redict(sechandhouse)
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)
def logout(): t = {'token': ''} session.clear() return SuccessViewModel.redict(t)
def all(): singleroom = Singleroom.query.all() return SuccessViewModel.redict(singleroom)