def _get_verify_list(status=None): page_index, page_size = get_page_info() join = 'as a left join %s as b on a.newWriterId = b.id' % ( NewWriterPool.__table__, ) args = [ctx.request.user.uid] where = '%s where a.uid = ? and a.status != 1' % (join, ) count_where = 'where uid = ? and status != 1' if status is not None: args.append(status) where = '%s and a.status = ?' % (where, ) count_where = '%s and status = ?' % (count_where, ) total = NewWriterVerifyRecord.count_by(count_where, *args) page = Page(total, page_index, page_size) where = '%s order by a.updateAt DESC limit ?,?' % (where, ) args.append(page.offset) args.append(page.limit) lists = NewWriterVerifyRecord.select_by(where, args, [ 'a.*', 'b.phone', 'b.ippreId', 'b.uid as userId', 'b.verifyType', 'b.verifyResult' ]) IPPool.join_by(lists, 'ippreId', 'ippreId') User.join_by(lists, 'userId', 'id') return lists, page.to_dict()
def _get_list_by_page(list_type='0', status='-1', final_state='-1', title=None, boutique='-1'): page_index, page_size = get_page_info() args = [list_type] where = 'where type = ?' if title: global IPPRE query = IPPRE.query query_res = query.contains('title', title).find() id_list = [] for info in query_res: id_list.append(info.id) args = [] where = "where ippreId in ('%s')" % ("','".join(id_list), ) else: if status != '-1': args.append(status) where = '%s and status = ?' % (where, ) if final_state != '-1': args.append(final_state) where = '%s and finalState = ?' % (where, ) if boutique == '1': where = '%s and ((verifyType = 3 or verifyType = 4) and verifyResult = 1)' % ( where, ) if boutique == '2': where = '%s and ((verifyType = 3 or verifyType = 4) and verifyResult = 2)' % ( where, ) if boutique == '3': where = '%s and ((verifyType = 1 and verifyResult = 1) or ((verifyType = 3 or verifyType = 4) and verifyResult = 0))' % ( where, ) if boutique == '4': where = '%s and verifyType = 1 and verifyResult = 2' % (where, ) total = NewWriterPool.count_by(where, *args) page = Page(total, page_index, page_size) where = '%s order by id DESC limit ?,?' % (where, ) args.append(page.offset) args.append(page.limit) lists = NewWriterPool.find_by(where, *args) IPPool.join_by(lists, 'ippreId', 'ippreId') User.join_by(lists, 'uid', 'id') return lists, page.to_dict()