Пример #1
0
def del_page_data(data: SavePageDataRequest):
    """
    删除页面数据
    :param data:
    :return:
    """
    version = service.find_version_by_id(data.version_id)
    if version is None:
        return make_error_response("版本错误")

    page_info = service.find_pages_info(version)
    node = find_node_by_key(page_info, data.node_key)

    if node is None:
        return make_error_response("没有找到该节点信息")
    pending_del_id = [item for item in map(lambda item: item.id, data.data)]

    new_data = [
        item for item in filter(lambda item: item.id not in pending_del_id,
                                node.data)
    ]
    node.data = new_data
    if service.save_pages_info(version, page_info):
        return make_no_data_response("删除成功")
    else:
        return make_no_data_response("删除失败")
Пример #2
0
def save_page_data(data: SavePageDataRequest):
    """
    保存页面的数据
    :param data:
    :return:
    """
    names = [item for item in map(lambda item: item.name, data.data)]

    set_name = set(names)
    if len(set_name) != len(names):
        return make_error_response("不可以重复添加变量名")

    version = service.find_version_by_id(data.version_id)
    if version is None:
        return make_error_response("版本错误")

    page_info = service.find_pages_info(version)
    node = find_node_by_key(page_info, data.node_key)

    if node is None:
        return make_error_response("没有找到该节点信息")

    node.data = data.data
    service.save_pages_info(version, page_info)
    return make_no_data_response()
Пример #3
0
def get_plan_version_pages():
    """
    获取版本计划列表 包括删除的
    :return:
    """
    versions = service.find_all_version_pages(include_del=True)
    pages = []
    for item in versions:
        pages.append({
            'version_id': item.version_id,
            "name": item.version_name,
            "path": item.path,
            "pages": service.find_pages_info(item)
        })
    return make_response(pages)
Пример #4
0
def copy_version(data: VersionHandleRequest):
    """
    复制一个版本
    :param data:
    :return:
    """
    version = VersionModel.create(data.version_name, data.path)
    pages_data = []
    try:
        pages_data = dir_modules(version.path)
    except:
        pass

    if len(pages_data) == 0:
        return make_error_response("添加失败,请检查你的代码路径(path)")

    old_pages_data = service.find_pages_info(data)
    replace_pages_data(old_pages_data, pages_data)
    service.save_pages_info(version, pages_data)
    service.update_pages_version_info(version)
    return make_no_data_response("添加成功")