def search_case_by_case_id(case_id, character='player'): cond = [('id', '=', case_id)] if character != 'admin': cond.append(('is_show', '=', 1)), cond.append(('is_verified', '=', 1)), line = Data.find('case_info', cond) if line == None: return info_line = { 'case_id': line['id'], 'content': common_tools.decode_base64(line['content']), 'c_time': common_tools.time_to_str(line['c_time']).split()[0], 'title': common_tools.decode_base64(line['title']), 'uploader_info': http_tools.get_uploader_info(line['user_id']), 'post_items': http_tools.get_post_items(line['id']), } result = info_line return result
def kill_md(): all_info = Data.select('case_info', [('id', '!=', 0)]) for line in all_info: res = common.decode_base64(line['title']) # print(res) case_title_list = res.split('.') if len(case_title_list) >= 2: if case_title_list[1] == 'md': print(case_title_list[0]) new_title = common.get_base64( case_title_list[0].encode('utf-8')) Data.update('case_info', [('id', '=', line['id'])], {'title': new_title})
def post(self): data = self.get_post_data() keyword_list = data['keyword_list'] if self.get_user_base(Relay.admin) != None: cond = [] else: cond = [('is_show','=',status_can_show ),('is_verified','=',status_verified)] if keyword_list == []: self.send_faild(error.ERROR_PARAM) return case_id_list = [] for keyword in keyword_list: keyword_md5 = common.get_md5(keyword) res = Data.select('case_search_index',[('keyword_md5','=',keyword_md5)]) if res == None: continue else: for case in res: case_id_list.append(case['case_id']) continue case_id_list = list(set(case_id_list)) print(case_id_list) title_list = [] for case_id in case_id_list: res = Data.find('case_info',[('id','=',case_id)]+cond) # 需要能显示的才可以看 if res == None: continue else: case_info = { 'case_id':res['id'], 'title':common.decode_base64(res['title']) } title_list.append(case_info) continue title_list = list(reversed(title_list)) result = { 'keyword_list':keyword_list, 'result':title_list } # 关键词搜索 self.send_ok(result) return
def get_case_list_by_cond(cond): result_list = [] res = Data.select('case_info', cond) if res == None: return # 没有结果就返回none for line in res: info_line = { 'c_time': common_tools.time_to_str(line['c_time']).split()[0], 'title': common_tools.decode_base64(line['title']), 'case_id': line['id'] } result_list.append(info_line) result_list = list(reversed(result_list)) return result_list
def post(self): data = self.get_post_data() if self.get_user_base('admin') != None: cond = [] else: cond = [('is_show', '=', 1), ('is_verified', '=', 1)] search_time = data['limit_year_time'] if search_time != '': search_time_stamp_start = common.str_to_time( str(search_time) + '-01-01 00:00:00') search_time_stamp_end = common.str_to_time( str(search_time) + '-12-31 23:59:59') else: search_time_stamp_start = 0 search_time_stamp_end = 999999999 condition = [ ('event_time', '>', search_time_stamp_start), ('event_time', '<', search_time_stamp_end), ] + cond res = Data.select('case_info', condition) result_list = [] if res == None: self.send_faild(error.ERROR_NO_RESULT) return for line in res: info_line = { 'c_time': common.time_to_str(line['c_time']).split()[0], 'title': common.decode_base64(line['title']), 'case_id': line['id'] } result_list.append(info_line) result_list = list(reversed(result_list)) result = {'result_list': result_list} # print(result) self.send_ok(result) return
def get_content_by_case_id(case_id): line = Data.find('case_content', [('case_id', '=', case_id)]) if line is None: return return common_tools.decode_base64(line['content'])