本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_announcement方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_announcement方法的具体用法?Python QueryHelper.get_announcement怎么用?Python QueryHelper.get_announcement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.queryhelper.QueryHelper
的用法示例。
在下文中一共展示了QueryHelper.get_announcement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_announcement [as 别名]
def post(self):
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
page_size = int(data.get('pagesize', UWEB.LIMIT.PAGE_SIZE))
page_number = int(data.pagenum)
page_count = int(data.pagecnt)
start_time = data.start_time
end_time = data.end_time
logging.info("[UWEB] announcement request: %s, uid: %s",
data, self.current_user.uid)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
logging.info("[UWEB] Invalid data format: %s, Exception: %s",
data, e.args)
self.write_ret(status)
return
try:
if page_count == -1:
res = QueryHelper.get_announcement(
self.current_user.cid, start_time, end_time, self.db)
d, m = divmod(res.count, page_size)
page_count = (d + 1) if m else d
res = QueryHelper.get_announcement_paged(
self.current_user.cid, start_time, end_time, page_number * page_size, page_size, self.db)
self.write_ret(status=status,
dict_=DotDict(res=res,
pagecnt=page_count))
except Exception as e:
logging.exception("[UWEB] Get announcement list failed.")
status = ErrorCode.SUCCESS
self.write_ret(status=status)