def change_log(log_id): id_ = unquote(log_id) api_param = request.get_json() api_param = api_param if api_param != None else {} db_value = search_data('log', {'id': id_}) keys = db_value.keys() if isinstance(db_value, dict) else [] for key in keys: if key in api_param.keys(): db_value[key] = api_param[key] update_data('log', db_value, {'id': id_}) return api_factory({'msg': '修改成功'})
def add_log(list_id): token = request.headers.get('token') user_id = user_id_by_token(token) id_ = unquote(list_id) api_param = request.get_json() item = { 'list_id': id_, 'id': rand_string(), 'status': False, 'user_id': user_id, 'collection': False, 'content': api_param['text'] } insert_data('log', item) return api_factory(True)
def get_log(list_id): id_ = unquote(list_id) data = search_data('log', {'list_id': id_}, True) result = data if isinstance(data, list) else [] return api_factory(result)
def del_log(log_id): id_ = unquote(log_id) del_data('log', {'id': id_}) return api_factory({'msg': '删除成功'})
def del_list(list_id): id_ = unquote(list_id) del_data('list', {'id': id_}) del_data('log', {'list_id': id_}) return api_factory(True)