def update(board_user_id: str, ver: str): session.rollback() data = deepcopy(request.data) data.update({"updated_by_id": request.user["id"]}) old_data = query_helper.find_by_params(session, BoardUser, [{ "id": { "$eq": board_user_id } }, { "ver": { "$eq": ver } }], json_result=True) result = query_helper.update_by_params(session, BoardUser, [{ "id": { "$eq": board_user_id } }, { "ver": { "$eq": ver } }], data, json_result=True) log_helper.log_update(session, BoardUser, request.user["id"], result, old_data) session.commit() return json_dumps(model_helper.insert_field_objects(session, result))
def delete(user_id: str, ver: str): session.rollback() old_data = query_helper.find_by_params(session, User, [{ "id": { "$eq": user_id } }, { "ver": { "$eq": ver } }], json_result=True) result = query_helper.delete_by_params( session, User, [{ "id": { "$eq": user_id } }, { "ver": { "$eq": ver } }], {'deleted_by_id': request.user['id']}, json_result=True) log_helper.log_update(session, User, request.user["id"], result, old_data) session.commit() return json_dumps(model_helper.insert_field_objects(session, result))
def delete(card_id: str, ver: str): session.rollback() data = deepcopy(request.data) data.update({"deleted_by_id": request.user["id"]}) old_data = query_helper.find_by_params( session, Card, [{"id": {"$eq": card_id}}, {"ver": {"$eq": ver}}], json_result=True ) result = query_helper.delete_by_params( session, Card, [{"id": {"$eq": card_id}}, {"ver": {"$eq": ver}}], data=data, json_result=True ) log_helper.log_update(session, Card, request.user["id"], result, old_data) session.commit() return json_dumps(result)
def update(user_id: str, ver: str): session.rollback() data = deepcopy(request.data) data.update({ "updated_by_id": request.user["id"], "updated_at": datetime.now() }) if 'password' in data: del data['password'] old_data = query_helper.find_by_params(session, User, [{ "id": { "$eq": user_id } }, { "ver": { "$eq": ver } }], json_result=True) result = query_helper.update_by_params(session, User, [{ "id": { "$eq": user_id } }, { "ver": { "$eq": ver } }], data, json_result=True) log_helper.log_update(session, User, request.user["id"], result, old_data) session.commit() return json_dumps(model_helper.insert_field_objects(session, result))