def home_select_articleList(self): """ 前台文章列表查询 不需要权限 :return: """ page = self.get_argument("page", 1) pageSize = self.get_argument("pageSize", 6) if pageSize.isdigit() and int(pageSize) == 6: cache_article_list = yield self.cache_manager.get( key=redis_cache_keys['cache_article_pages_key'].format( int(page))) if DEBUG: print("============分页缓存结果=============") print(cache_article_list) print("============分页缓存结果 END=============") if cache_article_list is None: pager = Pager(self) articleList = yield self.async_do( ArticleService.home_article_list, self.db, pager) if DEBUG: print("============分页查询结果=============") print(articleList) print("============分页查询结果 END=============") if articleList['list'] is not None: ### 缓存 3 天 yield self.cache_manager.set( key=redis_cache_keys['cache_article_pages_key'].format( int(page)), value=json.dumps(self.to_dict(articleList)), expire_time=3600 * 24 * 3) else: articleList = json.loads(cache_article_list) if articleList['list'] is not None: for item in articleList['list']: item['post_markdown'] = item['post_markdown'][ 0:270] + '......' self.json_return({'code': 0, 'data': self.to_dict(articleList)}) else: pager = Pager(self) articleList = yield self.async_do(ArticleService.home_article_list, self.db, pager) if DEBUG: print("============分页查询结果【pageSize != 6】=============") print(articleList) print("============分页查询结果【pageSize != 6】 END=============") if articleList['list'] is not None: for item in articleList['list']: item['post_markdown'] = item['post_markdown'][ 0:270] + '......' self.json_return({'code': 0, 'data': self.to_dict(articleList)})
def page_get(self): pager = Pager(self) comment_search_params = CommentSearchParams(self) comment_search_params.show_article_id_title = True comment_search_params.order_mode = CommentSearchParams.ORDER_MODE_CREATE_TIME_DESC comments_pager = yield self.async_do(CommentService.page_comments, self.db, pager, comment_search_params) self.render("admin/manage_comments.html", pager=comments_pager)
def page_get(self): pager = Pager(self) article_search_params = ArticleSearchParams(self) article_types = yield self.async_do(ArticleTypeService.list_simple, self.db) pager = yield self.async_do(ArticleService.page_articles, self.db, pager, article_search_params) self.render("admin/manage_articles.html", article_types=article_types, pager=pager, article_search_params=article_search_params)
def get(self): pager = Pager(self) base_url = self.reverse_url('index') order_search_params = OrderSearchParams(self) self.render("index.html", base_url=base_url, pager=pager, order_search_params=order_search_params)
async def page_get(self): pager = Pager(self) comment_search_params = CommentSearchParams(self) comment_search_params.show_article_id_title = True comment_search_params.order_mode = CommentSearchParams.ORDER_MODE_CREATE_TIME_DESC comments_pager = await self.loop_current.run_in_executor( self.thread_executor, CommentService.page_comments, self.db, pager, comment_search_params) self.render("admin/manage_comments.html", pager=comments_pager)
def page_get(self): pager = Pager(self) search_param = ArticleTypeSearchParams(self) search_param.show_setting = True search_param.show_articles_count = True pager = yield self.async_do(ArticleTypeService.page_article_types, self.db, pager, search_param) menus = yield self.async_do(MenuService.list_menus, self.db) self.render("admin/manage_articleTypes.html", pager=pager, menus=menus)
def get(self): pager = Pager(self) base_url = self.reverse_url('index') order_search_params = OrderSearchParams(self) pager = yield self.async_do(HomeService.page_order, self.db, pager, order_search_params) self.render("index.html", base_url=base_url, pager=pager, order_search_params=order_search_params)
def get(self, *args, **kwargs): """ 获取列表 :param args: :param kwargs: :return: """ pager = Pager(self) result = yield self.async_do(MovieService.movie_list, self.db, pager) self.json_return({'code': 0, 'data': self.to_dict(result)})
def get(self, article_id): article = yield self.async_do(ArticleService.get_article_all, self.db, article_id, True, add_view_count=1) if article: comments_pager = Pager(self) comment_search_params = CommentSearchParams(self) comment_search_params.article_id = article_id comments_pager = yield self.async_do(CommentService.page_comments, self.db, comments_pager, comment_search_params) self.render("article_detials.html", article=article, comments_pager=comments_pager) else: self.write_error(404)
def get(self): pager = Pager(self) article_search_params = ArticleSearchParams(self) article_search_params.show_article_type = True article_search_params.show_source = True article_search_params.show_summary = True article_search_params.show_comments_count = True pager = yield self.async_do(ArticleService.page_articles, self.db, pager, article_search_params) self.render("index.html", base_url=self.reverse_url('index'), pager=pager, article_search_params=article_search_params)
def admin_select_articleList(self): """ 后台文章列表查询 加权限 :return: """ pager = Pager(self) articleList = yield self.async_do( ArticleService.article_list, self.db, pager, None, self.get_argument('post_status', 'publish')) self.json_return({'code': 0, 'data': self.to_dict(articleList)})
def index_get(self): # 实例化 pager = Pager(self) # 插件搜索参数 plugin_search_params = PluginSearchParams(self) # 插件列表和记录条数 future = self.async_do(PluginService.page_plugins, self.db, pager, plugin_search_params) plugin_data = future.result() # print(plugin_data) self.render("admin/custom_blog_plugin.html", pager=plugin_data)
def get(self): pager = Pager(self) base_url = self.reverse_url('productList') product_search_params = ProductSearchParams(self) pager = yield self.async_do(HomeService.page_product, self.db, pager, product_search_params) self.render("productList.html", base_url=base_url, pager=pager, order_search_params=product_search_params)
def get(self, *args, **kwargs): """ 查询日志 自动分页 :param args: :param kwargs: :return: """ pager = Pager(self) logList = yield self.async_do(LogService.log_list, self.db, pager) self.json_return({ 'code':0, 'data': logList })
def page_get(self): pager = Pager(self) article_search_params = ArticleSearchParams(self) # article_types = await IOLoop.current().run_in_executor(self.thread_executor, ArticleTypeService.list_simple, self.db) future1 = self.async_do(ArticleTypeService.list_simple, self.db) article_types = future1.result() future2 = self.async_do(ArticleService.page_articles, self.db, pager, article_search_params) pager = future2.result() self.render("admin/manage_articles.html", article_types=article_types, pager=pager, article_search_params=article_search_params)
def get(self, *args, **kwargs): """ 查询Tag :param args: :param kwargs: :return: """ pager = Pager(self) count = self.db.query(Attributes).filter( Attributes.type == 'tag').count() tagList = yield self.async_do(TagService.tag_list, self.db, pager, count) self.json_return({'code': 0, 'data': tagList})
def home_select_articleListByCategory(self): """ 根据分类查询文章列表 :return: """ pager = Pager(self) where = self.get_argument('category', None) articleList = yield self.async_do(ArticleService.home_article_list, self.db, pager, where) if articleList['list'] is not None: for item in articleList['list']: item['post_markdown'] = item['post_markdown'][0:270] + '......' self.json_return({'code': 0, 'data': self.to_dict(articleList)})
def get(self, link_id=None, **kwargs): if link_id is None: pager = Pager(self) result = yield self.async_do(FuncService.query_link,self.db, pager=pager) self.json_return({ 'code':0, 'data': to_dict(result) }) else: result = yield self.async_do(FuncService.query_link, self.db, link_id=link_id) self.json_return({ 'code':0, 'data': to_dict(result) })
async def get(self, type_id): pager = Pager(self) article_search_params = ArticleSearchParams(self) article_search_params.show_article_type = True article_search_params.show_source = True article_search_params.show_summary = True article_search_params.show_comments_count = True article_search_params.articleType_id = type_id pager = await self.loop_current.run_in_executor( self.thread_executor, ArticleService.page_articles, self.db, pager, article_search_params) self.render("index.html", base_url=self.reverse_url('articleType', type_id), pager=pager, article_search_params=article_search_params)
def get(self): # 分页 pager = Pager(self) article_search_params = ArticleSearchParams(self) article_search_params.show_article_type = True article_search_params.show_source = True article_search_params.show_summary = True article_search_params.show_comments_count = True future = self.async_do(ArticleService.page_articles, self.db, pager, article_search_params) # future.result() 会阻塞调用 pager = future.result() # self.render("base.html", base_url=self.reverse_url('index'), pager=pager, article_search_params=article_search_params) self.render("index.html", base_url=self.reverse_url('index'), pager=pager, article_search_params=article_search_params)
def get(self): pager = Pager(self) article_search_params = ArticleSearchParams(self) article_search_params.show_article_type = True article_search_params.show_source = True article_search_params.show_summary = True article_search_params.show_comments_count = True # logging.info('jjj') # logging.info(article_search_params )# 起码不是空的字典, 至少是个object 对象 pager = yield self.async_do(ArticleService.page_articles, self.db, pager, article_search_params) logging.info(pager) # {'totalCount': 0L, 'totalPage': 1, 'pageSize': 10, 'pageNo': 1, 'result': []} self.render("index.html", base_url=self.reverse_url('index'), pager=pager, article_search_params=article_search_params)
async def get(self, article_id): # 获取文章详情 article = await self.loop_current.run_in_executor( self.thread_executor, ArticleService.get_article_all, self.db, article_id, True, 1) if article: comments_pager = Pager(self) comment_search_params = CommentSearchParams(self) comment_search_params.article_id = article_id # 获取文章对应的评论 comments_pager = await self.loop_current.run_in_executor( self.thread_executor, CommentService.page_comments, self.db, comments_pager, comment_search_params) self.render("article_detials.html", article=article, comments_pager=comments_pager) else: self.write_error(404)
def get(self, arg=None, **kwargs): """ 查询分类 :param categoryId: 分类ID 为空则查询分类列表 :param kwargs: :return: """ if arg is None: pager = Pager(self) count = self.db.query(Attributes).filter( Attributes.type == 'category').count() cateList = yield self.async_do(CategoryService.category_list, self.db, pager, count) self.json_return({'code': 0, 'data': cateList}) else: result = yield self.async_do(CategoryService.category, self.db, arg) self.json_return({'code': 0, 'data': self.to_dict(result)})
def get(self): pager = Pager(self) base_url = self.reverse_url('productListByOrder') product_search_params = ProductSearchParams(self) orderid = self.get_argument('id') ret = {'result': 'OK'} productList = [] order = yield self.async_do(HomeService.get_order_by_id, self.db, orderid) if order is not None: # userMark = unicode(order.userMark_.encode("utf-8"), "gbk") userMark = order.userMark_ classNameList__real = [] otherNameList__real = [] productNameList__real = [] if (userMark.find(')') > 0): # 先区分有多少类型 最后一个【米尊】保留着 classNameList = userMark.split(')') for className in classNameList: if (className.find('(') > 0): className_real = className.split('(')[0] # 排除第二个类型第一个字符是+ if (className_real.find('+') == 0): className_real = className_real[1:] print '类别:' + className_real productNameAll = className.split('(')[1] productName_real = productNameAll # 内有多个产品 if (productNameAll.find('+') > 0): productNameList = productNameAll.split('+') for productName in productNameList: productName_real = productName otherName_real = '' productNumber = 1 # 产品是否有别名? if (productName_real.find('【') > 0): otherName_real = productName_real.split( '【')[1][:-1] productName_real = productName_real.split( '【')[0] # 检查是否有个数 if (productName_real.find('个') > 0): productNumber = int( productName_real.split('个')[0]) productName_real = productName_real.split( '个')[1] # print otherName_real # print '产品Real:'+productName_real # print productNumber product_search_params.className = className_real product_search_params.otherName = otherName_real product_search_params.productName = productName_real product = yield self.async_do( HomeService.page_product_byorder, self.db, product_search_params) if product is not None: productItem = dict( id=product.id, status_=product.status_, picture_=product.picture_, className_=product.className_, productName_=product.productName_, otherName_=product.otherName_, price_=product.price_, productNumber_=productNumber, # createDate_ = product.createDate_, ) productList.append(productItem) # 只有一个产品 else: otherName_real = '' productNumber = 1 # 产品是否有别名? if (productName_real.find('【') > 0): otherName = productName_real.split('【')[1][:-1] productName_real = productName_real.split( '【')[0] # 检查是否有个数 if (productName_real.find('个') > 0): productNumber = int( productName_real.split('个')[0]) productName_real = productName_real.split( '个')[1] # print otherName # print '产品Real:'+productName_real # print productNumber product_search_params.className = className_real product_search_params.otherName = otherName_real product_search_params.productName = productName_real product = yield self.async_do( HomeService.page_product_byorder, self.db, product_search_params) if product is not None: productItem = dict( id=product.id, status_=product.status_, picture_=product.picture_, className_=product.className_, productName_=product.productName_, otherName_=product.otherName_, price_=product.price_, productNumber_=productNumber, # createDate_ = product.createDate_, ) productList.append(productItem) ret['status'] = 'true' else: ret['status'] = 'false' ret['productList'] = productList respon_json = tornado.escape.json_encode(ret) self.write_json(respon_json)
def index_get(self): pager = Pager(self) plugin_search_params = PluginSearchParams(self) pager = yield self.async_do(PluginService.page_plugins, self.db, pager, plugin_search_params) self.render("admin/custom_blog_plugin.html", pager=pager)
def page_get(self): pager = Pager(self) menu_search_params = MenuSearchParams(self) pager = yield self.async_do(MenuService.page_menus, self.db, pager, menu_search_params) self.render("admin/manage_articleTypes_nav.html", pager=pager)